aboutsummaryrefslogtreecommitdiffstats
path: root/src/decode.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-07 12:11:57 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-07 12:11:57 +0000
commitae44b7dae5878a1484243b89d14317d2dab5fdde (patch)
treeb122ffcb1ad6dd3a9c5ea60e0570ea5884ca3b2f /src/decode.c
parent08603344884138660d750df2c473a7cf34aab782 (diff)
downloadmpd-ae44b7dae5878a1484243b89d14317d2dab5fdde.tar.gz
mpd-ae44b7dae5878a1484243b89d14317d2dab5fdde.tar.xz
mpd-ae44b7dae5878a1484243b89d14317d2dab5fdde.zip
potential bugfixes for handling metadata in player/decoder
git-svn-id: https://svn.musicpd.org/mpd/trunk@1369 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r--src/decode.c57
1 files changed, 43 insertions, 14 deletions
diff --git a/src/decode.c b/src/decode.c
index 202415934..51c951c51 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -399,26 +399,47 @@ int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
kill(getppid(), SIGUSR1); \
}
-void handleMetadata(OutputBuffer * cb, PlayerControl * pc) {
- static int previous = -1;
-
+void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous,
+ int * currentChunkSent, MetadataChunk * currentChunk)
+{
if(cb->begin!=cb->end || cb->wrap) {
int meta = cb->metaChunk[cb->begin];
- if( meta != previous ) {
- if( meta >= 0 && pc->metadataState ==
- PLAYER_METADATA_STATE_WRITE &&
- cb->metaChunkSet[meta])
- {
+ if( meta != *previous ) {
+ if( meta >= 0 && cb->metaChunkSet[meta]) {
printf("METADATA!, copying it.\n");
- memcpy(&(pc->metadataChunk),
+ memcpy(currentChunk,
cb->metadataChunks+meta,
sizeof(MetadataChunk));
- pc->metadataState =
- PLAYER_METADATA_STATE_READ;
+ *currentChunkSent = 0;
cb->metaChunkSet[meta] = 0;
- previous = meta;
}
}
+ *previous = meta;
+ }
+ if(!(*currentChunkSent) && pc->metadataState ==
+ PLAYER_METADATA_STATE_WRITE)
+ {
+ printf("copy metadata to player\n");
+ *currentChunkSent = 1;
+ memcpy(&(pc->metadataChunk), currentChunk,
+ sizeof(MetadataChunk));
+ pc->metadataState = PLAYER_METADATA_STATE_READ;
+ kill(getppid(), SIGUSR1);
+ }
+}
+
+void advanceOutputBufferTo(OutputBuffer * cb, PlayerControl * pc,
+ int * previous, int * currentChunkSent, MetadataChunk * currentChunk,
+ int to)
+{
+ while(cb->begin!=to) {
+ handleMetadata(cb, pc, previous, currentChunkSent,
+ currentChunk);
+ cb->begin++;
+ if(cb->begin>=buffered_chunks) {
+ cb->begin = 0;
+ cb->wrap = 0;
+ }
}
}
@@ -434,6 +455,9 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
int decodeWaitedOn = 0;
char silence[CHUNK_SIZE];
double sizeToTime = 0.0;
+ int previousMetadataChunk = -1;
+ MetadataChunk currentMetadataChunk;
+ int currentChunkSent = 1;
memset(silence,0,CHUNK_SIZE);
@@ -454,7 +478,8 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
while(!quit) {
processDecodeInput();
handleDecodeStart();
- handleMetadata(cb, pc);
+ handleMetadata(cb, pc, &previousMetadataChunk,
+ &currentChunkSent, &currentMetadataChunk);
if(dc->state==DECODE_STATE_STOP &&
pc->queueState==PLAYER_QUEUE_FULL &&
pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
@@ -558,7 +583,11 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
{
nextChunk -= buffered_chunks;
}
- cb->begin = nextChunk;
+ advanceOutputBufferTo(cb, pc,
+ &previousMetadataChunk,
+ &currentChunkSent,
+ &currentMetadataChunk,
+ nextChunk);
}
}
while(pc->queueState==PLAYER_QUEUE_DECODE ||