moved code to crossFade()
Calling crossFade() with the chunk objects is easier than unrolling all the chunk properties manually, and decodeParent() can really use more of these simplifications. git-svn-id: https://svn.musicpd.org/mpd/trunk@7271 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
committed by
Eric Wong
parent
bc20b64302
commit
9760325ee6
31
src/decode.c
31
src/decode.c
@@ -359,6 +359,21 @@ static void advanceOutputBufferTo(OutputBuffer * cb, int to)
|
|||||||
cb->begin = to;
|
cb->begin = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void crossFade(OutputBufferChunk * a, OutputBufferChunk * b,
|
||||||
|
AudioFormat * format,
|
||||||
|
int fadePosition, int crossFadeChunks)
|
||||||
|
{
|
||||||
|
pcm_mix(a->data,
|
||||||
|
b->data,
|
||||||
|
a->chunkSize,
|
||||||
|
b->chunkSize,
|
||||||
|
format,
|
||||||
|
((float)fadePosition) /
|
||||||
|
crossFadeChunks);
|
||||||
|
if (b->chunkSize > a->chunkSize)
|
||||||
|
a->chunkSize = b->chunkSize;
|
||||||
|
}
|
||||||
|
|
||||||
static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb)
|
static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb)
|
||||||
{
|
{
|
||||||
int pause = 0;
|
int pause = 0;
|
||||||
@@ -508,21 +523,11 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
|
|||||||
}
|
}
|
||||||
nextChunk = outputBufferAbsolute(cb, crossFadeChunks);
|
nextChunk = outputBufferAbsolute(cb, crossFadeChunks);
|
||||||
if (nextChunk >= 0) {
|
if (nextChunk >= 0) {
|
||||||
OutputBufferChunk *fadeChunk =
|
crossFade(beginChunk,
|
||||||
outputBufferGetChunk(cb, nextChunk);
|
outputBufferGetChunk(cb, nextChunk),
|
||||||
pcm_mix(beginChunk->data,
|
|
||||||
fadeChunk->data,
|
|
||||||
beginChunk->chunkSize,
|
|
||||||
fadeChunk->chunkSize,
|
|
||||||
&(cb->audioFormat),
|
&(cb->audioFormat),
|
||||||
((float)fadePosition) /
|
fadePosition,
|
||||||
crossFadeChunks);
|
crossFadeChunks);
|
||||||
if (fadeChunk->chunkSize >
|
|
||||||
beginChunk->chunkSize
|
|
||||||
) {
|
|
||||||
beginChunk->chunkSize
|
|
||||||
= fadeChunk->chunkSize;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* there are not enough
|
/* there are not enough
|
||||||
decoded chunks yet */
|
decoded chunks yet */
|
||||||
|
|||||||
Reference in New Issue
Block a user