aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:09 +0200
committerMax Kellermann <max@duempel.org>2008-08-26 08:27:09 +0200
commit0aedf7dd5a3f72a1c541085c513d2b85bc3bff58 (patch)
tree243c31214aaf1ec6f35d21c1babf0fc6eb66caed
parent0fc2422cd098223642f12eecfc3fcd93d9f495d2 (diff)
downloadmpd-0aedf7dd5a3f72a1c541085c513d2b85bc3bff58.tar.gz
mpd-0aedf7dd5a3f72a1c541085c513d2b85bc3bff58.tar.xz
mpd-0aedf7dd5a3f72a1c541085c513d2b85bc3bff58.zip
pass max_chunks to calculateCrossFadeChunks()
Make calculateCrossFadeChunks() more generic and portable by eliminating global variable access.
-rw-r--r--src/decode.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/decode.c b/src/decode.c
index 4f12d7a97..da649ecea 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -64,9 +64,10 @@ static void quitDecode(void)
wakeup_main_task();
}
-static unsigned calculateCrossFadeChunks(AudioFormat * af, float totalTime)
+static unsigned calculateCrossFadeChunks(AudioFormat * af,
+ float totalTime, unsigned max_chunks)
{
- unsigned int buffered_chunks, chunks;
+ unsigned int chunks;
if (pc.crossFade == 0 || pc.crossFade >= totalTime ||
!isCurrentAudioFormat(af))
@@ -80,10 +81,8 @@ static unsigned calculateCrossFadeChunks(AudioFormat * af, float totalTime)
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
chunks = (chunks * pc.crossFade + 0.5);
- buffered_chunks = ob.size;
- assert(buffered_chunks >= buffered_before_play);
- if (chunks > (buffered_chunks - buffered_before_play))
- chunks = buffered_chunks - buffered_before_play;
+ if (chunks > max_chunks)
+ chunks = max_chunks;
return chunks;
}
@@ -500,7 +499,9 @@ static void decodeParent(void)
for it */
crossFadeChunks =
calculateCrossFadeChunks(&(ob.audioFormat),
- dc.totalTime);
+ dc.totalTime,
+ ob.size -
+ buffered_before_play);
if (crossFadeChunks > 0) {
do_xfade = XFADE_ENABLED;
nextChunk = -1;