diff options
-rw-r--r-- | src/decode.c | 4 | ||||
-rw-r--r-- | src/outputBuffer.c | 5 | ||||
-rw-r--r-- | src/outputBuffer.h | 3 |
3 files changed, 10 insertions, 2 deletions
diff --git a/src/decode.c b/src/decode.c index fd65dc5ae..688d78322 100644 --- a/src/decode.c +++ b/src/decode.c @@ -493,7 +493,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * if (pause) player_sleep(); - else if (cb->begin != end && cb->begin != next) { + else if (!outputBufferEmpty(cb) && cb->begin != next) { unsigned int fadePosition; if (doCrossFade == 1 && next >= 0 && ((next > cb->begin && @@ -562,7 +562,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * } else cb->begin++; 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 */ if (doCrossFade == 1 && nextChunk >= 0) { diff --git a/src/outputBuffer.c b/src/outputBuffer.c index b5fddd98d..f6fb38937 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -57,6 +57,11 @@ void flushOutputBuffer(OutputBuffer * cb) } } +int outputBufferEmpty(const OutputBuffer * cb) +{ + return cb->begin == cb->end; +} + unsigned availableOutputBuffer(const OutputBuffer * cb) { if (cb->end >= cb->begin) diff --git a/src/outputBuffer.h b/src/outputBuffer.h index 06ec60d19..252a0a905 100644 --- a/src/outputBuffer.h +++ b/src/outputBuffer.h @@ -55,6 +55,9 @@ void clearOutputBuffer(OutputBuffer * cb); void flushOutputBuffer(OutputBuffer * cb); +/** is the buffer empty? */ +int outputBufferEmpty(const OutputBuffer * cb); + /** determine the number of decoded chunks */ unsigned availableOutputBuffer(const OutputBuffer * cb); |