From dbd79a6b47d1cf09f3ccc8df5ef1a8e1dfedd853 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Sat, 19 Jun 2004 22:27:29 +0000 Subject: fix a few bugs in mp3_decode and minimize alsa underruns by playing silence when switch songs git-svn-id: https://svn.musicpd.org/mpd/trunk@1572 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/decode.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/decode.c') diff --git a/src/decode.c b/src/decode.c index b7ded74da..e81cddb76 100644 --- a/src/decode.c +++ b/src/decode.c @@ -98,6 +98,12 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) { return (int)chunks; } +#define playSilenceOrSleep() \ + if(isAudioDeviceOpen()) { \ + playAudio(silence, CHUNK_SIZE); \ + } \ + else my_usleep(10000); + #define handleDecodeStart() \ if(decodeWaitedOn) { \ if(dc->state!=DECODE_STATE_START && *decode_pid > 0 && \ @@ -128,7 +134,7 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) { return; \ } \ else { \ - my_usleep(10000); \ + my_usleep(10000); \ continue; \ } \ } @@ -462,9 +468,8 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) { dc->state!=DECODE_STATE_STOP) { processDecodeInput(); - handleDecodeStart(); if(quit) return; - my_usleep(10000); + playSilenceOrSleep(); } while(!quit) { -- cgit v1.2.3