aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:13:36 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:13:36 +0000
commit9760325ee6a716a526f1adde9b6f1d861f3f9101 (patch)
treeeeeca0a0391e479d0be16894a6363ec127594a90 /src
parentbc20b6430218b62da9e9146fc07940eb3191d6fd (diff)
downloadmpd-9760325ee6a716a526f1adde9b6f1d861f3f9101.tar.gz
mpd-9760325ee6a716a526f1adde9b6f1d861f3f9101.tar.xz
mpd-9760325ee6a716a526f1adde9b6f1d861f3f9101.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/decode.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/decode.c b/src/decode.c
index af0173fa5..84eeada3f 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -359,6 +359,21 @@ static void advanceOutputBufferTo(OutputBuffer * cb, int 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)
{
int pause = 0;
@@ -508,21 +523,11 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
}
nextChunk = outputBufferAbsolute(cb, crossFadeChunks);
if (nextChunk >= 0) {
- OutputBufferChunk *fadeChunk =
- outputBufferGetChunk(cb, nextChunk);
- pcm_mix(beginChunk->data,
- fadeChunk->data,
- beginChunk->chunkSize,
- fadeChunk->chunkSize,
- &(cb->audioFormat),
- ((float)fadePosition) /
- crossFadeChunks);
- if (fadeChunk->chunkSize >
- beginChunk->chunkSize
- ) {
- beginChunk->chunkSize
- = fadeChunk->chunkSize;
- }
+ crossFade(beginChunk,
+ outputBufferGetChunk(cb, nextChunk),
+ &(cb->audioFormat),
+ fadePosition,
+ crossFadeChunks);
} else {
/* there are not enough
decoded chunks yet */