Commit 50dc380f authored by Max Kellermann's avatar Max Kellermann Committed by Eric Wong

added outputBufferEmpty()

Another "don't use OutputBuffer internals" patch. This ignores the copied "end" value, but I do not think that has ever been a real issue. git-svn-id: https://svn.musicpd.org/mpd/trunk@7263 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent e626028b
...@@ -493,7 +493,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * ...@@ -493,7 +493,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
if (pause) if (pause)
player_sleep(); player_sleep();
else if (cb->begin != end && 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 && ((next > cb->begin &&
...@@ -562,7 +562,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * ...@@ -562,7 +562,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
} else } else
cb->begin++; cb->begin++;
player_wakeup_decoder_nb(); player_wakeup_decoder_nb();
} else if (cb->begin != end && cb->begin == next) { } else if (!outputBufferEmpty(cb) && cb->begin == next) {
/* at the beginning of a new song */ /* at the beginning of a new song */
if (doCrossFade == 1 && nextChunk >= 0) { if (doCrossFade == 1 && nextChunk >= 0) {
......
...@@ -57,6 +57,11 @@ void flushOutputBuffer(OutputBuffer * cb) ...@@ -57,6 +57,11 @@ void flushOutputBuffer(OutputBuffer * cb)
} }
} }
int outputBufferEmpty(const OutputBuffer * cb)
{
return cb->begin == cb->end;
}
unsigned availableOutputBuffer(const OutputBuffer * cb) unsigned availableOutputBuffer(const OutputBuffer * cb)
{ {
if (cb->end >= cb->begin) if (cb->end >= cb->begin)
......
...@@ -55,6 +55,9 @@ void clearOutputBuffer(OutputBuffer * cb); ...@@ -55,6 +55,9 @@ void clearOutputBuffer(OutputBuffer * cb);
void flushOutputBuffer(OutputBuffer * cb); void flushOutputBuffer(OutputBuffer * cb);
/** is the buffer empty? */
int outputBufferEmpty(const OutputBuffer * cb);
/** determine the number of decoded chunks */ /** determine the number of decoded chunks */
unsigned availableOutputBuffer(const OutputBuffer * cb); unsigned availableOutputBuffer(const OutputBuffer * cb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment