From 5eee657bac43c49ec21fd886194321f281d3c546 Mon Sep 17 00:00:00 2001 From: Choong Ng Date: Sat, 14 Apr 2012 23:46:42 -0700 Subject: [PATCH] Play silence while stream is paused to avoid audio glitches when used with JACK. --- hairtunes.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/hairtunes.c b/hairtunes.c index 8b815111..6859cffd 100644 --- a/hairtunes.c +++ b/hairtunes.c @@ -102,6 +102,8 @@ static double volume = 1.0; static int fix_volume = 0x10000; static pthread_mutex_t vol_mutex = PTHREAD_MUTEX_INITIALIZER; + + typedef struct audio_buffer_entry { // decoded audio packets int ready; signed short *data; @@ -750,8 +752,14 @@ static void *audio_thread_func(void *arg) { int play_samples; signed short buf_fill __attribute__((unused)); - signed short *inbuf, *outbuf; + signed short *inbuf, *outbuf, *silence; outbuf = malloc(OUTFRAME_BYTES); + silence = malloc(OUTFRAME_BYTES); + int i; + + for (i=0; i