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
This commit is contained in:

committed by
Eric Wong

parent
b009b2a437
commit
dc55e13ca1
26
src/decode.c
26
src/decode.c
@ -76,11 +76,13 @@ static void quitDecode(PlayerControl * pc, DecoderControl * dc)
|
|||||||
wakeup_main_task();
|
wakeup_main_task();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af)
|
static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af,
|
||||||
|
float totalTime)
|
||||||
{
|
{
|
||||||
long chunks;
|
long chunks;
|
||||||
|
|
||||||
if (pc->crossFade <= 0)
|
if (pc->crossFade <= 0 || pc->crossFade >= totalTime ||
|
||||||
|
!isCurrentAudioFormat(af))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
chunks = (af->sampleRate * af->bits * af->channels / 8.0 / CHUNK_SIZE);
|
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,
|
/* enable cross fading in this song? if yes,
|
||||||
calculate how many chunks will be required
|
calculate how many chunks will be required
|
||||||
for it */
|
for it */
|
||||||
if (isCurrentAudioFormat(&(cb->audioFormat))) {
|
crossFadeChunks =
|
||||||
|
calculateCrossFadeChunks(pc,
|
||||||
|
&(cb->
|
||||||
|
audioFormat),
|
||||||
|
dc->totalTime);
|
||||||
|
if (crossFadeChunks > 0) {
|
||||||
doCrossFade = 1;
|
doCrossFade = 1;
|
||||||
nextChunk = -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
|
} else
|
||||||
|
/* cross fading is disabled or the
|
||||||
|
next song is too short */
|
||||||
doCrossFade = -1;
|
doCrossFade = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user