added outputBufferRelative()
The cross-fade check is still very complicated whenever it uses OutputBuffer internals. Greatly simplify another check by introducing outputBufferRelative(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7264 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
50dc380f23
commit
4e60343e55
@ -496,12 +496,8 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
|
|||||||
else if (!outputBufferEmpty(cb) && cb->begin != next) {
|
else if (!outputBufferEmpty(cb) && cb->begin != next) {
|
||||||
unsigned int fadePosition;
|
unsigned int fadePosition;
|
||||||
if (doCrossFade == 1 && next >= 0 &&
|
if (doCrossFade == 1 && next >= 0 &&
|
||||||
((next > cb->begin &&
|
(fadePosition = outputBufferRelative(cb, next))
|
||||||
(fadePosition = next - cb->begin)
|
<= crossFadeChunks) {
|
||||||
<= crossFadeChunks) ||
|
|
||||||
(cb->begin > next &&
|
|
||||||
(fadePosition = next - cb->begin +
|
|
||||||
buffered_chunks) <= crossFadeChunks))) {
|
|
||||||
/* perform cross fade */
|
/* perform cross fade */
|
||||||
if (nextChunk < 0) {
|
if (nextChunk < 0) {
|
||||||
/* beginning of the cross fade
|
/* beginning of the cross fade
|
||||||
|
@ -62,12 +62,17 @@ int outputBufferEmpty(const OutputBuffer * cb)
|
|||||||
return cb->begin == cb->end;
|
return cb->begin == cb->end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned int outputBufferRelative(const OutputBuffer * cb, unsigned i)
|
||||||
|
{
|
||||||
|
if (i >= cb->begin)
|
||||||
|
return i - cb->begin;
|
||||||
|
else
|
||||||
|
return i + buffered_chunks - cb->begin;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned availableOutputBuffer(const OutputBuffer * cb)
|
unsigned availableOutputBuffer(const OutputBuffer * cb)
|
||||||
{
|
{
|
||||||
if (cb->end >= cb->begin)
|
return outputBufferRelative(cb, cb->end);
|
||||||
return cb->end - cb->begin;
|
|
||||||
else
|
|
||||||
return cb->end + buffered_chunks - cb->begin;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int outputBufferAbsolute(const OutputBuffer * cb, unsigned relative)
|
int outputBufferAbsolute(const OutputBuffer * cb, unsigned relative)
|
||||||
|
@ -58,6 +58,12 @@ void flushOutputBuffer(OutputBuffer * cb);
|
|||||||
/** is the buffer empty? */
|
/** is the buffer empty? */
|
||||||
int outputBufferEmpty(const OutputBuffer * cb);
|
int outputBufferEmpty(const OutputBuffer * cb);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* what is the position of the specified chunk number, relative to
|
||||||
|
* the first chunk in use?
|
||||||
|
*/
|
||||||
|
unsigned int outputBufferRelative(const OutputBuffer * cb, unsigned i);
|
||||||
|
|
||||||
/** determine the number of decoded chunks */
|
/** determine the number of decoded chunks */
|
||||||
unsigned availableOutputBuffer(const OutputBuffer * cb);
|
unsigned availableOutputBuffer(const OutputBuffer * cb);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user