Permalink
Browse files

Only play sound when a program writes to KB.

  • Loading branch information...
1 parent 715d3e2 commit 333c3ad7c667f66222647bbd0ddcc0b67b925895 @pikhq committed Mar 24, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 mako.c
View
@@ -20,6 +20,7 @@ static int key_buf_r, key_buf_w;
static int snd_buf_r = 1, snd_buf_w = 0;
enum ring_buf { BUF_READ, BUF_WRITE };
static enum ring_buf key_buf_op = BUF_READ;
+static int sound_playing;
static void push(int32_t v)
{
@@ -70,6 +71,10 @@ static void stor(int32_t addr, int32_t val)
if(addr == CO)
putchar(val);
else if(addr == AU) {
+ if(!sound_playing) {
+ sound_playing = 1;
+ SDL_PauseAudio(0);
+ }
SDL_LockAudio();
while((snd_buf_w+1) % SND_BUF_SIZE == snd_buf_r) {
SDL_UnlockAudio();
@@ -353,8 +358,6 @@ int main(int argc, char **argv)
if(SDL_OpenAudio(&desired, NULL)) goto sdlerr;
- SDL_PauseAudio(0);
-
SDL_Surface *scr = NULL;

0 comments on commit 333c3ad

Please sign in to comment.