Permalink
Browse files

Merge pull request #145 from choongng/master

Play silence while audio is paused.
  • Loading branch information...
2 parents 58a6ab8 + 5eee657 commit f1fd87fe69da3d9d2c64ca1d8aad68a584c85ca4 @albertz committed Jun 3, 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 f1fd87f

Please sign in to comment.