Permalink
Browse files

Play silence while stream is paused to avoid audio glitches when used…

… with JACK.
  • Loading branch information...
1 parent 58a6ab8 commit 5eee657bac43c49ec21fd886194321f281d3c546 @choongng choongng committed Apr 15, 2012
Showing with 16 additions and 4 deletions.
  1. +16 −4 hairtunes.c
View
@@ -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<OUTFRAME_BYTES/2; i++) {
+ silence[i] = 0;
+ }
#ifdef FANCY_RESAMPLING
float *frame, *outframe;
@@ -770,9 +778,13 @@ static void *audio_thread_func(void *arg) {
#endif
while (1) {
- do {
- inbuf = buffer_get_frame();
- } while (!inbuf);
+ if (ab_buffering) {
+ inbuf = silence;
+ } else {
+ do {
+ inbuf = buffer_get_frame();
+ } while (!inbuf);
+ }
#ifdef FANCY_RESAMPLING
if (fancy_resampling) {

0 comments on commit 5eee657

Please sign in to comment.