aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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/command.c3
-rw-r--r--src/decode.c57
-rw-r--r--src/outputBuffer.c15
-rw-r--r--src/player.h1
4 files changed, 55 insertions, 21 deletions
diff --git a/src/command.c b/src/command.c
index 72742e993..1ab3b789a 100644
--- a/src/command.c
+++ b/src/command.c
@@ -191,7 +191,8 @@ int commandStatus(FILE * fp, unsigned int * permission, int argArrayLength,
int updateJobId;
int song;
- playPlaylistIfPlayerStopped();
+ /*syncPlayerAndPlaylist();*/
+ playPlaylistIfPlayerStopped();
switch(getPlayerState()) {
case PLAYER_STATE_STOP:
state = strdup(COMMAND_STOP);
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 ||
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index a62d97778..fd8d5b83f 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -38,15 +38,20 @@ void clearAllMetaChunkSets(OutputBuffer * cb) {
}
void clearOutputBuffer(OutputBuffer * cb) {
+ int currentSet = 1;
+
currentChunk = -1;
cb->end = cb->begin;
cb->wrap = 0;
- if(cb->acceptMetadata) {
- clearAllMetaChunkSets(cb);
- if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
- cb->metaChunkSet[currentChunk] = 1;
- }
+ /* be sure to reset metaChunkSets cause we are skipping over audio
+ * audio chunks, and thus skipping over metadata */
+ if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
+ currentSet = cb->metaChunkSet[currentChunk];
+ }
+ clearAllMetaChunkSets(cb);
+ if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
+ cb->metaChunkSet[currentChunk] = currentSet;
}
}
diff --git a/src/player.h b/src/player.h
index 6453bd372..e869d1fa9 100644
--- a/src/player.h
+++ b/src/player.h
@@ -155,4 +155,3 @@ void playerCycleLogFiles();
Song * playerCurrentDecodeSong();
#endif
-/* vim:set shiftwidth=4 tabstop=8 expandtab: */