aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decode.c5
-rw-r--r--src/outputBuffer.c10
-rw-r--r--src/outputBuffer.h2
3 files changed, 13 insertions, 4 deletions
diff --git a/src/decode.c b/src/decode.c
index b3107cd1d..fb485a90a 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -557,10 +557,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
break;
pc->totalPlayTime +=
sizeToTime * beginChunk->chunkSize;
- if ((unsigned)cb->begin + 1 >= buffered_chunks) {
- cb->begin = 0;
- } else
- cb->begin++;
+ outputBufferShift(cb);
player_wakeup_decoder_nb();
} else if (!outputBufferEmpty(cb) && cb->begin == next) {
/* at the beginning of a new song */
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 48e9598f6..525f4af24 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -56,6 +56,16 @@ int outputBufferEmpty(const OutputBuffer * cb)
return cb->begin == cb->end;
}
+void outputBufferShift(OutputBuffer * cb)
+{
+ assert(cb->begin != cb->end);
+ assert(cb->begin < buffered_chunks);
+
+ ++cb->begin;
+ if (cb->begin >= buffered_chunks)
+ cb->begin = 0;
+}
+
unsigned int outputBufferRelative(const OutputBuffer * cb, unsigned i)
{
if (i >= cb->begin)
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index a99489968..8e797c324 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -65,6 +65,8 @@ void flushOutputBuffer(OutputBuffer * cb);
/** is the buffer empty? */
int outputBufferEmpty(const OutputBuffer * cb);
+void outputBufferShift(OutputBuffer * cb);
+
/**
* what is the position of the specified chunk number, relative to
* the first chunk in use?