aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:13:24 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:13:24 +0000
commit74910df0f367143e73e460524b31bacead953b16 (patch)
tree571196ade2bc01216679b5181b72d7e754a1f48a /src/decode.c
parent68a625b5b819416dacf2e4def6e124413d5226c5 (diff)
downloadmpd-74910df0f367143e73e460524b31bacead953b16.tar.gz
mpd-74910df0f367143e73e460524b31bacead953b16.tar.xz
mpd-74910df0f367143e73e460524b31bacead953b16.zip
added struct OutputBufferChunk
To make access to OutputBuffer easier, move everything which belongs to a chunk into its own structure, namely OutputBufferChunk. git-svn-id: https://svn.musicpd.org/mpd/trunk@7269 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/decode.c b/src/decode.c
index 8650184c6..af0173fa5 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -491,6 +491,8 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
if (pause)
player_sleep();
else if (!outputBufferEmpty(cb) && cb->begin != next) {
+ OutputBufferChunk *beginChunk =
+ outputBufferGetChunk(cb, cb->begin);
unsigned int fadePosition;
if (doCrossFade == 1 && next >= 0 &&
(fadePosition = outputBufferRelative(cb, next))
@@ -506,18 +508,20 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
}
nextChunk = outputBufferAbsolute(cb, crossFadeChunks);
if (nextChunk >= 0) {
- pcm_mix(outputBufferChunkData(cb, cb->begin),
- outputBufferChunkData(cb, nextChunk),
- cb->chunkSize[cb->begin],
- cb->chunkSize[nextChunk],
+ OutputBufferChunk *fadeChunk =
+ outputBufferGetChunk(cb, nextChunk);
+ pcm_mix(beginChunk->data,
+ fadeChunk->data,
+ beginChunk->chunkSize,
+ fadeChunk->chunkSize,
&(cb->audioFormat),
((float)fadePosition) /
crossFadeChunks);
- if (cb->chunkSize[nextChunk] >
- cb->chunkSize[cb->begin]
+ if (fadeChunk->chunkSize >
+ beginChunk->chunkSize
) {
- cb->chunkSize[cb->begin]
- = cb->chunkSize[nextChunk];
+ beginChunk->chunkSize
+ = fadeChunk->chunkSize;
}
} else {
/* there are not enough
@@ -535,18 +539,17 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
}
/* play the current chunk */
- pc->elapsedTime = cb->times[cb->begin];
- pc->bitRate = cb->bitRate[cb->begin];
- pcm_volumeChange(cb->chunks + cb->begin *
- CHUNK_SIZE,
- cb->chunkSize[cb->begin],
+ pc->elapsedTime = beginChunk->times;
+ pc->bitRate = beginChunk->bitRate;
+ pcm_volumeChange(beginChunk->data,
+ beginChunk->chunkSize,
&(cb->audioFormat),
pc->softwareVolume);
- if (playAudio(cb->chunks + cb->begin * CHUNK_SIZE,
- cb->chunkSize[cb->begin]) < 0)
+ if (playAudio(beginChunk->data,
+ beginChunk->chunkSize) < 0)
break;
pc->totalPlayTime +=
- sizeToTime * cb->chunkSize[cb->begin];
+ sizeToTime * beginChunk->chunkSize;
if ((unsigned)cb->begin + 1 >= buffered_chunks) {
cb->begin = 0;
} else