You need to sign in or sign up before continuing.
Commit a494bd73 authored by Warren Dukes's avatar Warren Dukes

try to fix metadata on initially playing (metadata being sent before device is open)

git-svn-id: https://svn.musicpd.org/mpd/trunk@2344 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent a2dbae48
...@@ -183,6 +183,6 @@ void closeAudioDevice() { ...@@ -183,6 +183,6 @@ void closeAudioDevice() {
closeAudioOutput(aoOutput); closeAudioOutput(aoOutput);
} }
void sendMetdataToAudioDevice(MpdTag * tag) { void sendMetadataToAudioDevice(MpdTag * tag) {
if(shoutOutput) sendMetadataToAudioOutput(shoutOutput, tag); if(shoutOutput) sendMetadataToAudioOutput(shoutOutput, tag);
} }
...@@ -58,6 +58,6 @@ int isAudioDeviceOpen(); ...@@ -58,6 +58,6 @@ int isAudioDeviceOpen();
int isCurrentAudioFormat(AudioFormat * audioFormat); int isCurrentAudioFormat(AudioFormat * audioFormat);
void sendMetdataToAudioDevice(MpdTag * tag); void sendMetadataToAudioDevice(MpdTag * tag);
#endif #endif
...@@ -119,6 +119,12 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) { ...@@ -119,6 +119,12 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
quitDecode(pc,dc); \ quitDecode(pc,dc); \
return; \ return; \
} \ } \
{ \
MpdTag * tag = metadataChunkToMpdTagDup( \
&fileMetadataChunk); \
sendMetadataToAudioDevice(tag); \
freeMpdTag(tag); \
} \
pc->totalTime = dc->totalTime; \ pc->totalTime = dc->totalTime; \
pc->sampleRate = dc->audioFormat.sampleRate; \ pc->sampleRate = dc->audioFormat.sampleRate; \
pc->bits = dc->audioFormat.bits; \ pc->bits = dc->audioFormat.bits; \
...@@ -141,11 +147,10 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) { ...@@ -141,11 +147,10 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
} }
int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
int * decodeWaitedOn) int * decodeWaitedOn, MetadataChunk * fileMetadataChunk)
{ {
strncpy(pc->currentUrl, pc->utf8url, MAXPATHLEN); strncpy(pc->currentUrl, pc->utf8url, MAXPATHLEN);
pc->currentUrl[MAXPATHLEN] = '\0'; pc->currentUrl[MAXPATHLEN] = '\0';
MpdTag * tag = NULL;
while(decode_pid && *decode_pid>0 && dc->start) my_usleep(10000); while(decode_pid && *decode_pid>0 && dc->start) my_usleep(10000);
...@@ -157,10 +162,8 @@ int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, ...@@ -157,10 +162,8 @@ int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
return -1; return -1;
} }
if((tag = metadataChunkToMpdTagDup(&(pc->fileMetadataChunk)))) { memcpy(fileMetadataChunk, &(pc->fileMetadataChunk),
sendMetdataToAudioDevice(tag); sizeof(MetadataChunk));
freeMpdTag(tag);
}
pc->totalTime = pc->fileTime; pc->totalTime = pc->fileTime;
pc->bitRate = 0; pc->bitRate = 0;
...@@ -173,7 +176,8 @@ int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, ...@@ -173,7 +176,8 @@ int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
} }
int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
int * decodeWaitedOn, int * next) int * decodeWaitedOn, int * next,
MetadataChunk * fileMetadataChunk)
{ {
int ret = -1; int ret = -1;
...@@ -187,7 +191,8 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, ...@@ -187,7 +191,8 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
cb->end = 0; cb->end = 0;
dc->error = 0; dc->error = 0;
dc->start = 1; dc->start = 1;
waitOnDecode(pc,dc,cb,decodeWaitedOn); waitOnDecode(pc,dc,cb,decodeWaitedOn,
fileMetadataChunk);
} }
if(*decode_pid>0 && dc->state!=DECODE_STATE_STOP && if(*decode_pid>0 && dc->state!=DECODE_STATE_STOP &&
dc->seekable) dc->seekable)
...@@ -244,7 +249,9 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, ...@@ -244,7 +249,9 @@ int decodeSeek(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
if(pause) closeAudioDevice(); \ if(pause) closeAudioDevice(); \
} \ } \
if(pc->seek) { \ if(pc->seek) { \
if(decodeSeek(pc,dc,cb,&decodeWaitedOn,&next) == 0) { \ if(decodeSeek(pc,dc,cb,&decodeWaitedOn,&next, \
&fileMetadataChunk) == 0) \
{ \
doCrossFade = 0; \ doCrossFade = 0; \
nextChunk = -1; \ nextChunk = -1; \
bbp = 0; \ bbp = 0; \
...@@ -431,7 +438,7 @@ void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous, ...@@ -431,7 +438,7 @@ void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int * previous,
*currentChunkSent = 1; *currentChunkSent = 1;
if((tag = metadataChunkToMpdTagDup(currentChunk))) { if((tag = metadataChunkToMpdTagDup(currentChunk))) {
sendMetdataToAudioDevice(tag); sendMetadataToAudioDevice(tag);
freeMpdTag(tag); freeMpdTag(tag);
} }
...@@ -470,13 +477,14 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) { ...@@ -470,13 +477,14 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
double sizeToTime = 0.0; double sizeToTime = 0.0;
int previousMetadataChunk = -1; int previousMetadataChunk = -1;
MetadataChunk currentMetadataChunk; MetadataChunk currentMetadataChunk;
MetadataChunk fileMetadataChunk;
int currentChunkSent = 1; int currentChunkSent = 1;
int end; int end;
int next = -1; int next = -1;
memset(silence,0,CHUNK_SIZE); memset(silence,0,CHUNK_SIZE);
if(waitOnDecode(pc,dc,cb,&decodeWaitedOn)<0) return; if(waitOnDecode(pc,dc,cb,&decodeWaitedOn,&fileMetadataChunk)<0) return;
pc->elapsedTime = 0; pc->elapsedTime = 0;
pc->state = PLAYER_STATE_PLAY; pc->state = PLAYER_STATE_PLAY;
...@@ -627,7 +635,9 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) { ...@@ -627,7 +635,9 @@ void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb) {
} }
else { else {
next = -1; next = -1;
if(waitOnDecode(pc,dc,cb,&decodeWaitedOn)<0) { if(waitOnDecode(pc,dc,cb,&decodeWaitedOn,
&fileMetadataChunk)<0)
{
return; return;
} }
nextChunk = -1; nextChunk = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment