aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:13:56 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:13:56 +0000
commitb009b2a437bee5947f0fff109ad0ca632d01162f (patch)
treea35e4e03bb93ad3afb1472d6c88f9b7f6d8ff4e9
parent2e648b57f3f1c83f2694033900489a8290a55868 (diff)
downloadmpd-b009b2a437bee5947f0fff109ad0ca632d01162f.tar.gz
mpd-b009b2a437bee5947f0fff109ad0ca632d01162f.tar.xz
mpd-b009b2a437bee5947f0fff109ad0ca632d01162f.zip
moved code to playChunk()
Similar to the crossFade() patch: pass chunk objects to playChunk(), simplify decodeParent() by removing clutter. git-svn-id: https://svn.musicpd.org/mpd/trunk@7275 09075e82-0dd4-0310-85a5-a0d7c8717e4f
-rw-r--r--src/decode.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/decode.c b/src/decode.c
index fb485a90a..a15778b64 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -374,6 +374,24 @@ static void crossFade(OutputBufferChunk * a, OutputBufferChunk * b,
a->chunkSize = b->chunkSize;
}
+static int playChunk(PlayerControl * pc, OutputBufferChunk * chunk,
+ AudioFormat * format, double sizeToTime)
+{
+ pc->elapsedTime = chunk->times;
+ pc->bitRate = chunk->bitRate;
+
+ pcm_volumeChange(chunk->data, chunk->chunkSize,
+ format, pc->softwareVolume);
+
+ if (playAudio(chunk->data,
+ chunk->chunkSize) < 0)
+ return -1;
+
+ pc->totalPlayTime +=
+ sizeToTime * chunk->chunkSize;
+ return 0;
+}
+
static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb)
{
int pause = 0;
@@ -546,17 +564,9 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
}
/* play the current chunk */
- pc->elapsedTime = beginChunk->times;
- pc->bitRate = beginChunk->bitRate;
- pcm_volumeChange(beginChunk->data,
- beginChunk->chunkSize,
- &(cb->audioFormat),
- pc->softwareVolume);
- if (playAudio(beginChunk->data,
- beginChunk->chunkSize) < 0)
+ if (playChunk(pc, beginChunk, &(cb->audioFormat),
+ sizeToTime) < 0)
break;
- pc->totalPlayTime +=
- sizeToTime * beginChunk->chunkSize;
outputBufferShift(cb);
player_wakeup_decoder_nb();
} else if (!outputBufferEmpty(cb) && cb->begin == next) {