harden metadatabuffer
git-svn-id: https://svn.musicpd.org/mpd/trunk@1362 09075e82-0dd4-0310-85a5-a0d7c8717e4f
This commit is contained in:
@@ -406,7 +406,8 @@ void handleMetadata(OutputBuffer * cb, PlayerControl * pc) {
|
|||||||
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 && pc->metadataState ==
|
||||||
PLAYER_METADATA_STATE_WRITE)
|
PLAYER_METADATA_STATE_WRITE &&
|
||||||
|
cb->metaChunkSet[meta])
|
||||||
{
|
{
|
||||||
printf("METADATA!, copying it.\n");
|
printf("METADATA!, copying it.\n");
|
||||||
memcpy(&(pc->metadataChunk),
|
memcpy(&(pc->metadataChunk),
|
||||||
@@ -414,6 +415,7 @@ void handleMetadata(OutputBuffer * cb, PlayerControl * pc) {
|
|||||||
sizeof(MetadataChunk));
|
sizeof(MetadataChunk));
|
||||||
pc->metadataState =
|
pc->metadataState =
|
||||||
PLAYER_METADATA_STATE_READ;
|
PLAYER_METADATA_STATE_READ;
|
||||||
|
cb->metaChunkSet[meta] = 0;
|
||||||
previous = meta;
|
previous = meta;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -621,6 +623,7 @@ 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;
|
||||||
|
@@ -29,10 +29,25 @@ static mpd_sint16 currentChunk = -1;
|
|||||||
static mpd_sint8 currentMetaChunk = -1;
|
static mpd_sint8 currentMetaChunk = -1;
|
||||||
static mpd_sint8 sendMetaChunk = 0;
|
static mpd_sint8 sendMetaChunk = 0;
|
||||||
|
|
||||||
|
void clearAllMetaChunkSets(OutputBuffer * cb) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i=0; i<BUFFERED_METACHUNKS; i++) {
|
||||||
|
cb->metaChunkSet[i] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void clearOutputBuffer(OutputBuffer * cb) {
|
void clearOutputBuffer(OutputBuffer * cb) {
|
||||||
currentChunk = -1;
|
currentChunk = -1;
|
||||||
cb->end = cb->begin;
|
cb->end = cb->begin;
|
||||||
cb->wrap = 0;
|
cb->wrap = 0;
|
||||||
|
|
||||||
|
if(cb->acceptMetadata) {
|
||||||
|
clearAllMetaChunkSets(cb);
|
||||||
|
if(sendMetaChunk == 0 && currentMetaChunk >= 0) {
|
||||||
|
cb->metaChunkSet[currentChunk] = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void flushOutputBuffer(OutputBuffer * cb) {
|
void flushOutputBuffer(OutputBuffer * cb) {
|
||||||
@@ -126,20 +141,28 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) {
|
int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) {
|
||||||
|
int nextChunk;
|
||||||
|
|
||||||
printf("copyMpdTagToOB called\n");
|
printf("copyMpdTagToOB called\n");
|
||||||
|
|
||||||
if(!cb->acceptMetadata || !tag) {
|
if(!cb->acceptMetadata || !tag) {
|
||||||
sendMetaChunk = 0;
|
sendMetaChunk = 0;
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMetaChunk = 1;
|
sendMetaChunk = 1;
|
||||||
currentMetaChunk++;
|
nextChunk = currentMetaChunk+1;
|
||||||
if(currentMetaChunk >= BUFFERED_METACHUNKS) currentMetaChunk = 0;
|
if(nextChunk >= BUFFERED_METACHUNKS) nextChunk = 0;
|
||||||
|
|
||||||
|
if(cb->metaChunkSet[nextChunk]) return -1;
|
||||||
|
|
||||||
|
currentMetaChunk = nextChunk;
|
||||||
|
|
||||||
printMpdTag(stdout, tag);
|
printMpdTag(stdout, tag);
|
||||||
|
|
||||||
copyMpdTagToMetadataChunk(tag, &(cb->metadataChunks[currentMetaChunk]));
|
copyMpdTagToMetadataChunk(tag, &(cb->metadataChunks[currentMetaChunk]));
|
||||||
|
|
||||||
|
cb->metaChunkSet[nextChunk] = 1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -41,7 +41,7 @@ typedef struct _OutputBuffer {
|
|||||||
mpd_sint8 volatile wrap;
|
mpd_sint8 volatile wrap;
|
||||||
AudioFormat audioFormat;
|
AudioFormat audioFormat;
|
||||||
MetadataChunk metadataChunks[BUFFERED_METACHUNKS];
|
MetadataChunk metadataChunks[BUFFERED_METACHUNKS];
|
||||||
mpd_sint8 metdataChunkSet[BUFFERED_METACHUNKS];
|
mpd_sint8 metaChunkSet[BUFFERED_METACHUNKS];
|
||||||
mpd_sint8 * volatile metaChunk;
|
mpd_sint8 * volatile metaChunk;
|
||||||
volatile mpd_sint8 acceptMetadata;
|
volatile mpd_sint8 acceptMetadata;
|
||||||
} OutputBuffer;
|
} OutputBuffer;
|
||||||
@@ -56,8 +56,8 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
|||||||
DecoderControl * dc, int seekable, char * data, long datalen,
|
DecoderControl * dc, int seekable, char * data, long datalen,
|
||||||
float time, mpd_uint16 bitRate);
|
float time, mpd_uint16 bitRate);
|
||||||
|
|
||||||
void copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag);
|
int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag);
|
||||||
|
|
||||||
void zeroMetadataChunkSets(OutputBuffer * cb, int begin, int end, int wrap);
|
void clearAllMetaChunkSets(OutputBuffer * cb);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user