aboutsummaryrefslogtreecommitdiffstats
path: root/src/outputBuffer.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-06 22:13:23 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-06 22:13:23 +0000
commit62f32ccb010070501ed2d518d31cb788e37f7b3d (patch)
tree213f3085001e6c7c878e657bac0f2ab098b96770 /src/outputBuffer.c
parent33f21b9374d3f57210e5e58881bf67662eaaec3f (diff)
downloadmpd-62f32ccb010070501ed2d518d31cb788e37f7b3d.tar.gz
mpd-62f32ccb010070501ed2d518d31cb788e37f7b3d.tar.xz
mpd-62f32ccb010070501ed2d518d31cb788e37f7b3d.zip
harden metadatabuffer
git-svn-id: https://svn.musicpd.org/mpd/trunk@1362 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/outputBuffer.c')
-rw-r--r--src/outputBuffer.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 660067c27..a62d97778 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -29,10 +29,25 @@ static mpd_sint16 currentChunk = -1;
static mpd_sint8 currentMetaChunk = -1;
static mpd_sint8 sendMetaChunk = 0;
+void clearAllMetaChunkSets(OutputBuffer * cb) {
+ int i;
+
+ for(i=0; i<BUFFERED_METACHUNKS; i++) {
+ cb->metaChunkSet[i] = 0;
+ }
+}
+
void clearOutputBuffer(OutputBuffer * cb) {
currentChunk = -1;
cb->end = cb->begin;
cb->wrap = 0;
+
+ if(cb->acceptMetadata) {
+ clearAllMetaChunkSets(cb);
+ if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
+ cb->metaChunkSet[currentChunk] = 1;
+ }
+ }
}
void flushOutputBuffer(OutputBuffer * cb) {
@@ -126,20 +141,28 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
}
int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) {
+ int nextChunk;
+
printf("copyMpdTagToOB called\n");
if(!cb->acceptMetadata || !tag) {
sendMetaChunk = 0;
- return -1;
+ return 0;
}
sendMetaChunk = 1;
- currentMetaChunk++;
- if(currentMetaChunk >= BUFFERED_METACHUNKS) currentMetaChunk = 0;
+ nextChunk = currentMetaChunk+1;
+ if(nextChunk >= BUFFERED_METACHUNKS) nextChunk = 0;
+
+ if(cb->metaChunkSet[nextChunk]) return -1;
+
+ currentMetaChunk = nextChunk;
printMpdTag(stdout, tag);
copyMpdTagToMetadataChunk(tag, &(cb->metadataChunks[currentMetaChunk]));
+ cb->metaChunkSet[nextChunk] = 1;
+
return 0;
}