Now AIFF samples play correctly.
authorDavid Griffith <dave@661.org>
Sun, 12 Apr 2015 07:58:25 +0000 (00:58 -0700)
committerDavid Griffith <dave@661.org>
Sun, 12 Apr 2015 07:58:25 +0000 (00:58 -0700)
src/curses/ux_audio.c

index 77a7a4be44105c598fbce95abb2e477a54eb554b..9946a12d46e1d7962e53c8ffdf0b6235e428d7cb 100644 (file)
@@ -76,7 +76,10 @@ static sem_t         audio_empty;
 int    bleep_playing = 0;
 
 float  *musicbuffer;
+
 float  *bleepbuffer;
+int    bleepchannels;
+int    bleeprate;
 
 int    musiccount;
 int    bleepcount;
@@ -257,8 +260,6 @@ static void *mixer(void *arg)
 
     format.byte_format = AO_FMT_NATIVE;
     format.bits = 16;
-    format.channels = 2;
-    format.rate = SAMPLERATE;
 
     device = NULL;
 
@@ -266,6 +267,8 @@ static void *mixer(void *arg)
         sem_wait(&audio_full);          /* Wait until output buffer is full */
         pthread_mutex_lock(&mutex);     /* Acquire mutex */
 
+       format.channels = bleepchannels;
+       format.rate = bleeprate;
        if (bleep_playing && device == NULL) {
            device = ao_open_live(default_driver, &format, NULL);
            if (device == NULL) {
@@ -381,6 +384,9 @@ static int playaiff(EFFECT myeffect)
     frames_read = 0;
     toread = sf_info.frames * sf_info.channels;
 
+    bleepchannels = sf_info.channels;
+    bleeprate = sf_info.samplerate;
+
     bleep_playing = TRUE;
     while (toread > 0) {
        sem_wait(&audio_empty);