Commit dc55e13c authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

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
parent b009b2a4
......@@ -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;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment