fix some streaming metadata issues
git-svn-id: https://svn.musicpd.org/mpd/trunk@1416 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
@@ -393,7 +393,9 @@ void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous,
|
|||||||
if(cb->begin!=cb->end) {
|
if(cb->begin!=cb->end) {
|
||||||
int meta = cb->metaChunk[cb->begin];
|
int meta = cb->metaChunk[cb->begin];
|
||||||
if( meta != *previous ) {
|
if( meta != *previous ) {
|
||||||
|
DEBUG("player: metadata change\n");
|
||||||
if( meta >= 0 && cb->metaChunkSet[meta]) {
|
if( meta >= 0 && cb->metaChunkSet[meta]) {
|
||||||
|
DEBUG("player: new metadata from decoder!\n");
|
||||||
memcpy(currentChunk,
|
memcpy(currentChunk,
|
||||||
cb->metadataChunks+meta,
|
cb->metadataChunks+meta,
|
||||||
sizeof(MetadataChunk));
|
sizeof(MetadataChunk));
|
||||||
@@ -625,6 +627,7 @@ void decode() {
|
|||||||
|
|
||||||
cb = &(getPlayerData()->buffer);
|
cb = &(getPlayerData()->buffer);
|
||||||
|
|
||||||
|
clearAllMetaChunkSets(cb);
|
||||||
cb->begin = 0;
|
cb->begin = 0;
|
||||||
cb->end = 0;
|
cb->end = 0;
|
||||||
pc = &(getPlayerData()->playerControl);
|
pc = &(getPlayerData()->playerControl);
|
||||||
@@ -634,7 +637,6 @@ void decode() {
|
|||||||
dc->seek = 0;
|
dc->seek = 0;
|
||||||
dc->stop = 0;
|
dc->stop = 0;
|
||||||
dc->start = 1;
|
dc->start = 1;
|
||||||
clearAllMetaChunkSets(cb);
|
|
||||||
|
|
||||||
if(decode_pid==NULL || *decode_pid<=0) {
|
if(decode_pid==NULL || *decode_pid<=0) {
|
||||||
if(decoderInit(pc,cb,dc)<0) return;
|
if(decoderInit(pc,cb,dc)<0) return;
|
||||||
|
@@ -206,6 +206,9 @@ void putOggCommentsIntoOutputBuffer(OutputBuffer * cb, char * streamName,
|
|||||||
MpdTag * tag;
|
MpdTag * tag;
|
||||||
|
|
||||||
tag = oggCommentsParse(comments);
|
tag = oggCommentsParse(comments);
|
||||||
|
if(!tag && streamName) {
|
||||||
|
tag = newMpdTag();
|
||||||
|
}
|
||||||
if(!tag) return;
|
if(!tag) return;
|
||||||
|
|
||||||
/*if(tag->artist) printf("Artist: %s\n", tag->artist);
|
/*if(tag->artist) printf("Artist: %s\n", tag->artist);
|
||||||
|
@@ -21,6 +21,7 @@
|
|||||||
#include "pcm_utils.h"
|
#include "pcm_utils.h"
|
||||||
#include "playerData.h"
|
#include "playerData.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -154,10 +155,12 @@ int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) {
|
|||||||
sendMetaChunk = 0;
|
sendMetaChunk = 0;
|
||||||
if(last) free(last);
|
if(last) free(last);
|
||||||
last = NULL;
|
last = NULL;
|
||||||
|
DEBUG("copyMpdTagToOB: !acceptMetadata || !tag\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(last && mpdTagsAreEqual(last, tag)) {
|
if(last && mpdTagsAreEqual(last, tag)) {
|
||||||
|
DEBUG("copyMpdTagToOB: same as last\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +170,11 @@ int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) {
|
|||||||
nextChunk = currentMetaChunk+1;
|
nextChunk = currentMetaChunk+1;
|
||||||
if(nextChunk >= BUFFERED_METACHUNKS) nextChunk = 0;
|
if(nextChunk >= BUFFERED_METACHUNKS) nextChunk = 0;
|
||||||
|
|
||||||
if(cb->metaChunkSet[nextChunk]) return -1;
|
if(cb->metaChunkSet[nextChunk]) {
|
||||||
|
sendMetaChunk = 0;
|
||||||
|
DEBUG("copyMpdTagToOB: metachunk in use!\n");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
sendMetaChunk = 1;
|
sendMetaChunk = 1;
|
||||||
currentMetaChunk = nextChunk;
|
currentMetaChunk = nextChunk;
|
||||||
@@ -178,5 +185,7 @@ int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) {
|
|||||||
|
|
||||||
cb->metaChunkSet[nextChunk] = 1;
|
cb->metaChunkSet[nextChunk] = 1;
|
||||||
|
|
||||||
|
DEBUG("copyMpdTagToOB: copiedTag\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
10
src/player.c
10
src/player.c
@@ -473,11 +473,8 @@ Song * playerCurrentDecodeSong() {
|
|||||||
Song * ret = NULL;
|
Song * ret = NULL;
|
||||||
PlayerControl * pc = &(getPlayerData()->playerControl);
|
PlayerControl * pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
if(pc->metadataState == PLAYER_METADATA_STATE_READ &&
|
if(pc->metadataState == PLAYER_METADATA_STATE_READ) {
|
||||||
((!song || strcmp(song->utf8url, pc->currentUrl))
|
DEBUG("playerCurrentDecodeSong: caught new metadata!\n");
|
||||||
|| (!prev || memcmp(prev, &(pc->metadataChunk),
|
|
||||||
sizeof(MetadataChunk)))))
|
|
||||||
{
|
|
||||||
if(prev) free(prev);
|
if(prev) free(prev);
|
||||||
prev = malloc(sizeof(MetadataChunk));
|
prev = malloc(sizeof(MetadataChunk));
|
||||||
memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk));
|
memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk));
|
||||||
@@ -488,9 +485,8 @@ Song * playerCurrentDecodeSong() {
|
|||||||
song->tag = metadataChunkToMpdTagDup(prev);
|
song->tag = metadataChunkToMpdTagDup(prev);
|
||||||
validateUtf8Tag(song->tag);
|
validateUtf8Tag(song->tag);
|
||||||
ret = song;
|
ret = song;
|
||||||
}
|
|
||||||
|
|
||||||
resetPlayerMetadata();
|
resetPlayerMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user