From e626028b41a957d969b93f2d3cb39813eebaac2b Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Apr 2008 04:12:42 +0000 Subject: moved check to outputBufferAbsolute() decoderParent() uses a lot of OutputBuffer internals to see whether cross-fading should be started. Move these checks to outputBuffer.c, which also simplifies decoderParent(). git-svn-id: https://svn.musicpd.org/mpd/trunk@7262 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/outputBuffer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/outputBuffer.c') diff --git a/src/outputBuffer.c b/src/outputBuffer.c index f5a6dbf5..b5fddd98 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -65,6 +65,23 @@ unsigned availableOutputBuffer(const OutputBuffer * cb) return cb->end + buffered_chunks - cb->begin; } +int outputBufferAbsolute(const OutputBuffer * cb, unsigned relative) +{ + unsigned i, max; + + max = cb->end; + if (max < cb->begin) + max += buffered_chunks; + i = (unsigned)cb->begin + relative; + if (i >= max) + return -1; + + if (i >= buffered_chunks) + i -= buffered_chunks; + + return (int)i; +} + /** * Return the tail chunk has room for additional data. If there is no * room in the queue, this function blocks until the player thread has -- cgit v1.2.3