aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:14:01 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:14:01 +0000
commitdc55e13ca1ac382770a80b7f1bf984fe7acb5066 (patch)
treebfac390d847d050197081ac37699f17adafc3fa1
parentb009b2a437bee5947f0fff109ad0ca632d01162f (diff)
downloadmpd-dc55e13ca1ac382770a80b7f1bf984fe7acb5066.tar.gz
mpd-dc55e13ca1ac382770a80b7f1bf984fe7acb5066.tar.xz
mpd-dc55e13ca1ac382770a80b7f1bf984fe7acb5066.zip
let calculateCrossFadeChunks() decide
Moved the decision whether to cross-fade the current song to calculateCrossFadeChunks(). This simplifies the function decoderParent() and eliminates one layer of indentation. git-svn-id: https://svn.musicpd.org/mpd/trunk@7276 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/decode.c b/src/decode.c
index a15778b64..066176116 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -76,11 +76,13 @@ static void quitDecode(PlayerControl * pc, DecoderControl * dc)
wakeup_main_task();
}
-static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af)
+static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af,
+ float totalTime)
{
long chunks;
- if (pc->crossFade <= 0)
+ if (pc->crossFade <= 0 || pc->crossFade >= totalTime ||
+ !isCurrentAudioFormat(af))
return 0;
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
@@ -499,21 +501,17 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
/* enable cross fading in this song? if yes,
calculate how many chunks will be required
for it */
- if (isCurrentAudioFormat(&(cb->audioFormat))) {
+ crossFadeChunks =
+ calculateCrossFadeChunks(pc,
+ &(cb->
+ audioFormat),
+ dc->totalTime);
+ if (crossFadeChunks > 0) {
doCrossFade = 1;
nextChunk = -1;
- crossFadeChunks =
- calculateCrossFadeChunks(pc,
- &(cb->
- audioFormat));
- if (!crossFadeChunks
- || pc->crossFade >= dc->totalTime) {
- /* cross fading is disabled or
- the next song is too
- short */
- doCrossFade = -1;
- }
} else
+ /* cross fading is disabled or the
+ next song is too short */
doCrossFade = -1;
}