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:
@@ -191,6 +191,7 @@ int commandStatus(FILE * fp, unsigned int * permission, int argArrayLength,
|
|||||||
int updateJobId;
|
int updateJobId;
|
||||||
int song;
|
int song;
|
||||||
|
|
||||||
|
/*syncPlayerAndPlaylist();*/
|
||||||
playPlaylistIfPlayerStopped();
|
playPlaylistIfPlayerStopped();
|
||||||
switch(getPlayerState()) {
|
switch(getPlayerState()) {
|
||||||
case PLAYER_STATE_STOP:
|
case PLAYER_STATE_STOP:
|
||||||
|
57
src/decode.c
57
src/decode.c
@@ -399,26 +399,47 @@ int decoderInit(PlayerControl * pc, OutputBuffer * cb, DecoderControl * dc) {
|
|||||||
kill(getppid(), SIGUSR1); \
|
kill(getppid(), SIGUSR1); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleMetadata(OutputBuffer * cb, PlayerControl * pc) {
|
void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous,
|
||||||
static int previous = -1;
|
int * currentChunkSent, MetadataChunk * currentChunk)
|
||||||
|
{
|
||||||
if(cb->begin!=cb->end || cb->wrap) {
|
if(cb->begin!=cb->end || cb->wrap) {
|
||||||
int meta = cb->metaChunk[cb->begin];
|
int meta = cb->metaChunk[cb->begin];
|
||||||
if( meta != previous ) {
|
if( meta != *previous ) {
|
||||||
if( meta >= 0 && pc->metadataState ==
|
if( meta >= 0 && cb->metaChunkSet[meta]) {
|
||||||
PLAYER_METADATA_STATE_WRITE &&
|
|
||||||
cb->metaChunkSet[meta])
|
|
||||||
{
|
|
||||||
printf("METADATA!, copying it.\n");
|
printf("METADATA!, copying it.\n");
|
||||||
memcpy(&(pc->metadataChunk),
|
memcpy(currentChunk,
|
||||||
cb->metadataChunks+meta,
|
cb->metadataChunks+meta,
|
||||||
sizeof(MetadataChunk));
|
sizeof(MetadataChunk));
|
||||||
pc->metadataState =
|
*currentChunkSent = 0;
|
||||||
PLAYER_METADATA_STATE_READ;
|
|
||||||
cb->metaChunkSet[meta] = 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;
|
int decodeWaitedOn = 0;
|
||||||
char silence[CHUNK_SIZE];
|
char silence[CHUNK_SIZE];
|
||||||
double sizeToTime = 0.0;
|
double sizeToTime = 0.0;
|
||||||
|
int previousMetadataChunk = -1;
|
||||||
|
MetadataChunk currentMetadataChunk;
|
||||||
|
int currentChunkSent = 1;
|
||||||
|
|
||||||
memset(silence,0,CHUNK_SIZE);
|
memset(silence,0,CHUNK_SIZE);
|
||||||
|
|
||||||
@@ -454,7 +478,8 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
|
|||||||
while(!quit) {
|
while(!quit) {
|
||||||
processDecodeInput();
|
processDecodeInput();
|
||||||
handleDecodeStart();
|
handleDecodeStart();
|
||||||
handleMetadata(cb, pc);
|
handleMetadata(cb, pc, &previousMetadataChunk,
|
||||||
|
¤tChunkSent, ¤tMetadataChunk);
|
||||||
if(dc->state==DECODE_STATE_STOP &&
|
if(dc->state==DECODE_STATE_STOP &&
|
||||||
pc->queueState==PLAYER_QUEUE_FULL &&
|
pc->queueState==PLAYER_QUEUE_FULL &&
|
||||||
pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
|
pc->queueLockState==PLAYER_QUEUE_UNLOCKED)
|
||||||
@@ -558,7 +583,11 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
|
|||||||
{
|
{
|
||||||
nextChunk -= buffered_chunks;
|
nextChunk -= buffered_chunks;
|
||||||
}
|
}
|
||||||
cb->begin = nextChunk;
|
advanceOutputBufferTo(cb, pc,
|
||||||
|
&previousMetadataChunk,
|
||||||
|
¤tChunkSent,
|
||||||
|
¤tMetadataChunk,
|
||||||
|
nextChunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(pc->queueState==PLAYER_QUEUE_DECODE ||
|
while(pc->queueState==PLAYER_QUEUE_DECODE ||
|
||||||
|
@@ -38,15 +38,20 @@ void clearAllMetaChunkSets(OutputBuffer * cb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void clearOutputBuffer(OutputBuffer * cb) {
|
void clearOutputBuffer(OutputBuffer * cb) {
|
||||||
|
int currentSet = 1;
|
||||||
|
|
||||||
currentChunk = -1;
|
currentChunk = -1;
|
||||||
cb->end = cb->begin;
|
cb->end = cb->begin;
|
||||||
cb->wrap = 0;
|
cb->wrap = 0;
|
||||||
|
|
||||||
if(cb->acceptMetadata) {
|
/* 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);
|
clearAllMetaChunkSets(cb);
|
||||||
if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
|
if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
|
||||||
cb->metaChunkSet[currentChunk] = 1;
|
cb->metaChunkSet[currentChunk] = currentSet;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -155,4 +155,3 @@ void playerCycleLogFiles();
|
|||||||
Song * playerCurrentDecodeSong();
|
Song * playerCurrentDecodeSong();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
/* vim:set shiftwidth=4 tabstop=8 expandtab: */
|
|
||||||
|
Reference in New Issue
Block a user