From 09485e3a5b64b1609f0ccfbb043d309bb5b8868f Mon Sep 17 00:00:00 2001 From: David Griffith Date: Thu, 15 Oct 2015 22:00:25 -0700 Subject: [PATCH] No more segfaults when playing an AIFF when an OGG is already playing. Sound of any kind is distorted after this. --- src/curses/ux_audio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/curses/ux_audio.c b/src/curses/ux_audio.c index 3537d5d..3eb3766 100644 --- a/src/curses/ux_audio.c +++ b/src/curses/ux_audio.c @@ -538,8 +538,8 @@ void *playaiff(EFFECT *raw_effect) /* If that's all, terminate and signal that we're done. */ if (src_data.end_of_input && src_data.output_frames_gen == 0) { - pthread_mutex_unlock(&mutex); sem_post(&audio_full); + pthread_mutex_unlock(&mutex); break; } @@ -559,8 +559,10 @@ void *playaiff(EFFECT *raw_effect) */ bleep_playing = FALSE; + memset(bleepbuffer, 0, BUFFSIZE * sizeof(float) * 2); + pthread_mutex_unlock(&mutex); -// sem_post(&audio_empty); + sem_post(&audio_empty); fseek(myeffect.fp, filestart, SEEK_SET); sf_close(sndfile); @@ -649,7 +651,7 @@ static void *playmod(EFFECT *raw_effect) if (myeffect.vol > 8) myeffect.vol = 8; ModPlug_SetMasterVolume(mod, mypower(2, myeffect.vol)); - shortbuffer = malloc(BUFFSIZE * sizeof(char) * 2); + shortbuffer = malloc(BUFFSIZE * sizeof(short) * 2); music_playing = TRUE; -- 2.34.1