aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-04-12 04:14:50 +0000
committerEric Wong <normalperson@yhbt.net>2008-04-12 04:14:50 +0000
commit079f13bc7df49fec505d757e1ee4a8d55bcd0da1 (patch)
tree5291c03c6fab90aefc1364b3ed913f25b4907176
parent4ee8396f417d15c161b425c6f8c15fe845242434 (diff)
downloadmpd-079f13bc7df49fec505d757e1ee4a8d55bcd0da1.tar.gz
mpd-079f13bc7df49fec505d757e1ee4a8d55bcd0da1.tar.xz
mpd-079f13bc7df49fec505d757e1ee4a8d55bcd0da1.zip
moved currentChunk into OutputBuffer
currentChunk is a global variable, which renders the whole output buffer code non-reentrant. Although this is not a real problem since there is only one global output buffer currently, we should move it to the OutputBuffer struct. git-svn-id: https://svn.musicpd.org/mpd/trunk@7284 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/outputBuffer.c19
-rw-r--r--src/outputBuffer.h2
2 files changed, 11 insertions, 10 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 525f4af24..9e97c3dff 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -26,28 +26,27 @@
#include "conf.h"
#include "os_compat.h"
-static mpd_sint16 currentChunk = -1;
-
void initOutputBuffer(OutputBuffer * cb, OutputBufferChunk * chunks)
{
memset(&cb->convState, 0, sizeof(ConvState));
cb->chunks = chunks;
+ cb->currentChunk = -1;
}
void clearOutputBuffer(OutputBuffer * cb)
{
cb->end = cb->begin;
- currentChunk = -1;
+ cb->currentChunk = -1;
}
void flushOutputBuffer(OutputBuffer * cb)
{
- if (currentChunk == cb->end) {
+ if (cb->currentChunk == cb->end) {
if (((unsigned)cb->end + 1) >= buffered_chunks) {
cb->end = 0;
}
else cb->end++;
- currentChunk = -1;
+ cb->currentChunk = -1;
}
}
@@ -119,8 +118,8 @@ static int tailChunk(OutputBuffer * cb, InputStream * inStream,
unsigned int next;
OutputBufferChunk *chunk;
- if (currentChunk == cb->end)
- return currentChunk;
+ if (cb->currentChunk == cb->end)
+ return cb->currentChunk;
next = cb->end + 1;
if (next >= buffered_chunks) {
@@ -144,13 +143,13 @@ static int tailChunk(OutputBuffer * cb, InputStream * inStream,
if (dc->stop)
return OUTPUT_BUFFER_DC_STOP;
- currentChunk = cb->end;
- chunk = outputBufferGetChunk(cb, currentChunk);
+ cb->currentChunk = cb->end;
+ chunk = outputBufferGetChunk(cb, cb->currentChunk);
chunk->chunkSize = 0;
chunk->bitRate = bitRate;
chunk->times = data_time;
- return currentChunk;
+ return cb->currentChunk;
}
int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index 8e797c324..21c375f96 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -52,6 +52,8 @@ typedef struct _OutputBuffer {
/** the index after the last decoded chunk */
mpd_uint16 volatile end;
+ mpd_sint16 currentChunk;
+
AudioFormat audioFormat;
ConvState convState;
} OutputBuffer;