From a7b19012d309ae0c32562a18e416ac2f961eea95 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Apr 2008 04:11:41 +0000 Subject: add method availableOutputBuffer() The method availableOutputBuffer() calculates how many chunks are in use. This simplifies code which needs this information, and it can run without knowing OutputBuffer internals. The function knows how to calculate this when begin>end; this might have been a bug in decodeParent(), which does not. git-svn-id: https://svn.musicpd.org/mpd/trunk@7250 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/outputBuffer.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/outputBuffer.c') diff --git a/src/outputBuffer.c b/src/outputBuffer.c index d15a947e3..f5a6dbf51 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -57,6 +57,14 @@ void flushOutputBuffer(OutputBuffer * cb) } } +unsigned availableOutputBuffer(const OutputBuffer * cb) +{ + if (cb->end >= cb->begin) + return cb->end - cb->begin; + else + return cb->end + buffered_chunks - cb->begin; +} + /** * 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