potential bugfixes for handling metadata in player/decoder
git-svn-id: https://svn.musicpd.org/mpd/trunk@1369 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
parent
0860334488
commit
ae44b7dae5
|
@ -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);
|
||||
|
|
57
src/decode.c
57
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,
|
||||
¤tChunkSent, ¤tMetadataChunk);
|
||||
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,
|
||||
¤tChunkSent,
|
||||
¤tMetadataChunk,
|
||||
nextChunk);
|
||||
}
|
||||
}
|
||||
while(pc->queueState==PLAYER_QUEUE_DECODE ||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,4 +155,3 @@ void playerCycleLogFiles();
|
|||
Song * playerCurrentDecodeSong();
|
||||
|
||||
#endif
|
||||
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|
||||
|
|
Loading…
Reference in New Issue