From ca8d597cd34b87e21495bafc7d667b782e3192e0 Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Mon, 24 Sep 2007 16:42:23 +0100 Subject: [PATCH] less harsh dropping of near-empty buffers Organization: Straylight/Edgeware From: Richard Kettlewell --- clients/playrtp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/clients/playrtp.c b/clients/playrtp.c index 33623ab..d5668b7 100644 --- a/clients/playrtp.c +++ b/clients/playrtp.c @@ -757,7 +757,10 @@ static void play_rtp(void) { info("Playing..."); /* Keep playing until the buffer empties out, or ALSA tells us to get * lost */ - while(nsamples >= minbuffer && !escape) { + while((nsamples >= minbuffer + || (nsamples > 0 + && contains(pheap_first(&packets), next_timestamp))) + && !escape) { /* Wait for ALSA to ask us for more data */ pthread_mutex_unlock(&lock); wait_alsa(); @@ -828,7 +831,9 @@ static void play_rtp(void) { if(status) fatal(0, "AudioDeviceStart: %d", (int)status); /* Wait until the buffer empties out */ - while(nsamples >= minbuffer) + while(nsamples >= minbuffer + || (nsamples > 0 + && contains(pheap_first(&packets), next_timestamp))) pthread_cond_wait(&cond, &lock); /* Stop playing for a bit until the buffer re-fills */ status = AudioDeviceStop(adid, adioproc); -- [mdw]