aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:12:31 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:12:31 +0000
commitb89b019723ae0a3df4a162a08574b6fe5982ccdd (patch)
treee563e550104da131fcfee83afc8ab6f926ac2414 /src/decode.c
parentaaebd9ef2b04e28876492be811d7eaea4709e479 (diff)
downloadmpd-b89b019723ae0a3df4a162a08574b6fe5982ccdd.tar.gz
mpd-b89b019723ae0a3df4a162a08574b6fe5982ccdd.tar.xz
mpd-b89b019723ae0a3df4a162a08574b6fe5982ccdd.zip
moved the initial buffering code into the big loop
Eliminating some duplicated and. This also decreases the number of lines calling processDecodeInput(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7260 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/decode.c')
-rw-r--r--src/decode.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/decode.c b/src/decode.c
index a5486e4e4..59419ed1b 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -365,6 +365,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
{
int pause = 0;
int quit = 0;
+ int buffering = 1;
unsigned int bbp = buffered_before_play;
/** cross fading enabled for the current song? 0=must check;
1=enabled; -1=disabled */
@@ -390,8 +391,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
pc->play = 0;
wakeup_main_task();
- while (availableOutputBuffer(cb) < bbp &&
- dc->state != DECODE_STATE_STOP) {
+ while (!quit) {
processDecodeInput(pc, dc, cb,
&pause, &bbp, &doCrossFade,
&nextChunk, &decodeWaitedOn, &next);
@@ -401,17 +401,14 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
return;
}
- player_sleep();
- }
-
- while (!quit) {
- processDecodeInput(pc, dc, cb,
- &pause, &bbp, &doCrossFade,
- &nextChunk, &decodeWaitedOn, &next);
- if (pc->stop) {
- dropBufferedAudio();
- quitDecode(pc,dc);
- return;
+ if (buffering) {
+ if (availableOutputBuffer(cb) < bbp) {
+ /* not enough decoded buffer space yet */
+ player_sleep();
+ continue;
+ } else
+ /* buffering is complete */
+ buffering = 0;
}
if (decodeWaitedOn) {