Commit 547448ee authored by Warren Dukes's avatar Warren Dukes

lets try this soltuion to sending metadata, here we store metadata to send on the next shout_play

git-svn-id: https://svn.musicpd.org/mpd/trunk@2346 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 91c76213
......@@ -64,6 +64,8 @@ typedef struct _ShoutData {
int audioFormatConvert;
int opened;
MpdTag * tag;
} ShoutData;
static ShoutData * newShoutData() {
......@@ -73,12 +75,14 @@ static ShoutData * newShoutData() {
ret->convBuffer = NULL;
ret->convBufferLen = 0;
ret->opened = 0;
ret->tag = NULL;
return ret;
}
static void freeShoutData(ShoutData * sd) {
if(sd->shoutConn) shout_free(sd->shoutConn);
if(sd->tag) freeMpdTag(sd->tag);
free(sd);
}
......@@ -345,6 +349,45 @@ static void shout_convertAudioFormat(ShoutData * sd, char ** chunkArgPtr,
*chunkArgPtr = sd->convBuffer;
}
#define addTag(name, value) { \
if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
}
static void shout_sendMetadata(ShoutData * sd) {
ogg_int64_t granulepos = sd->vd.granulepos;
if(!sd->opened) return;
clearEncoder(sd);
if(initEncoder(sd) < 0) return;
sd->vd.granulepos = granulepos;
if(sd->tag) {
addTag("ARTIST", sd->tag->artist);
addTag("ALBUM", sd->tag->album);
addTag("TITLE", sd->tag->title);
}
vorbis_analysis_headerout(&(sd->vd), &(sd->vc), &(sd->header_main),
&(sd->header_comments), &(sd->header_codebooks));
ogg_stream_packetin(&(sd->os), &(sd->header_main));
ogg_stream_packetin(&(sd->os), &(sd->header_comments));
ogg_stream_packetin(&(sd->os), &(sd->header_codebooks));
/*vorbis_commentheader_out(&(sd->vc), &(sd->header_comments));
ogg_stream_packetin(&(sd->os), &(sd->header_comments));*/
while(ogg_stream_flush(&(sd->os), &(sd->og)))
{
if(write_page(sd) < 0) return;
}
freeMpdTag(sd->tag);
sd->tag = NULL;
}
static int shout_play(AudioOutput * audioOutput, char * playChunk, int size) {
int i,j;
ShoutData * sd = (ShoutData *)audioOutput->data;
......@@ -358,6 +401,8 @@ static int shout_play(AudioOutput * audioOutput, char * playChunk, int size) {
}
}
if(sd->tag) shout_sendMetadata(sd);
if(sd->audioFormatConvert) {
shout_convertAudioFormat(sd, &playChunk, &size);
}
......@@ -395,42 +440,15 @@ static int shout_play(AudioOutput * audioOutput, char * playChunk, int size) {
return 0;
}
#define addTag(name, value) { \
if(value) vorbis_comment_add_tag(&(sd->vc), name, value); \
}
static void shout_sendMetadata(AudioOutput * audioOutput, MpdTag * tag) {
static void shout_setTag(AudioOutput * audioOutput, MpdTag * tag) {
ShoutData * sd = (ShoutData *)audioOutput->data;
ogg_int64_t granulepos = sd->vd.granulepos;
if(!sd->opened) return;
clearEncoder(sd);
if(initEncoder(sd) < 0) return;
sd->vd.granulepos = granulepos;
if(tag) {
addTag("ARTIST", tag->artist);
addTag("ALBUM", tag->album);
addTag("TITLE", tag->title);
if(sd->tag) freeMpdTag(sd->tag);
sd->tag = NULL;
}
vorbis_analysis_headerout(&(sd->vd), &(sd->vc), &(sd->header_main),
&(sd->header_comments), &(sd->header_codebooks));
ogg_stream_packetin(&(sd->os), &(sd->header_main));
ogg_stream_packetin(&(sd->os), &(sd->header_comments));
ogg_stream_packetin(&(sd->os), &(sd->header_codebooks));
if(!tag) return;
/*vorbis_commentheader_out(&(sd->vc), &(sd->header_comments));
ogg_stream_packetin(&(sd->os), &(sd->header_comments));*/
while(ogg_stream_flush(&(sd->os), &(sd->og)))
{
if(write_page(sd) < 0) return;
}
sd->tag = mpdTagDup(tag);
}
AudioOutputPlugin shoutPlugin =
......@@ -441,7 +459,7 @@ AudioOutputPlugin shoutPlugin =
shout_openDevice,
shout_play,
shout_closeDevice,
shout_sendMetadata
shout_setTag
};
#else
......
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