aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-06-01 11:18:25 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-06-01 11:18:25 +0000
commitfe0b751c8278ab07a350cd4d363743b734f4f830 (patch)
tree288ce38c0401ed60f416da239c94654df4413657 /src/inputPlugins
parent187eba5754ddc99f5105fe2edac9c817fd2f7561 (diff)
downloadmpd-fe0b751c8278ab07a350cd4d363743b734f4f830.tar.gz
mpd-fe0b751c8278ab07a350cd4d363743b734f4f830.tar.xz
mpd-fe0b751c8278ab07a350cd4d363743b734f4f830.zip
ogg voribs comment parsing on the fly in the decoder
git-svn-id: https://svn.musicpd.org/mpd/trunk@1279 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/ogg_plugin.c94
1 files changed, 60 insertions, 34 deletions
diff --git a/src/inputPlugins/ogg_plugin.c b/src/inputPlugins/ogg_plugin.c
index bb062dd10..8e42dec55 100644
--- a/src/inputPlugins/ogg_plugin.c
+++ b/src/inputPlugins/ogg_plugin.c
@@ -165,6 +165,61 @@ float ogg_getReplayGainScale(char ** comments) {
return 1.0;
}
+MpdTag * oggCommentsParse(char ** comments) {
+ MpdTag * ret = NULL;
+ char * temp;
+
+ while(*comments) {
+ if((temp = ogg_parseComment(*comments,"artist"))) {
+ if(!ret) ret = newMpdTag();
+ if(!ret->artist) {
+ ret->artist = strdup(temp);
+ stripReturnChar(ret->artist);
+ }
+ }
+ else if((temp = ogg_parseComment(*comments,"title"))) {
+ if(!ret) ret = newMpdTag();
+ if(!ret->title) {
+ ret->title = strdup(temp);
+ stripReturnChar(ret->title);
+ }
+ }
+ else if((temp = ogg_parseComment(*comments,"album"))) {
+ if(!ret) ret = newMpdTag();
+ if(!ret->album) {
+ ret->album = strdup(temp);
+ stripReturnChar(ret->album);
+ }
+ }
+ else if((temp = ogg_parseComment(*comments,"tracknumber"))) {
+ if(!ret) ret = newMpdTag();
+ if(!ret->track) {
+ ret->track = strdup(temp);
+ stripReturnChar(ret->track);
+ }
+ }
+
+ comments++;
+ }
+
+ return ret;
+}
+
+void putOggCommentsIntoDecoderControlMetadata(DecoderControl * dc,
+ char ** comments)
+{
+ MpdTag * tag;
+
+ if(dc->metadataSet) return;
+
+ tag = oggCommentsParse(comments);
+ if(!tag) return;
+
+ copyMpdTagToDecoderControlMetadata(dc, tag);
+
+ freeMpdTag(tag);
+}
+
int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
{
OggVorbis_File vf;
@@ -215,6 +270,8 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream)
comments = ov_comment(&vf, -1)->user_comments;
+ putOggCommentsIntoDecoderControlMetadata(dc, comments);
+
dc->state = DECODE_STATE_DECODE;
replayGainScale = ogg_getReplayGainScale(comments);
@@ -281,8 +338,6 @@ MpdTag * oggTagDup(char * file) {
MpdTag * ret = NULL;
FILE * fp;
OggVorbis_File vf;
- char ** comments;
- char * temp;
fp = fopen(file,"r");
if(!fp) return NULL;
@@ -291,39 +346,10 @@ MpdTag * oggTagDup(char * file) {
return NULL;
}
- ret = newMpdTag();
- ret->time = (int)(ov_time_total(&vf,-1)+0.5);
-
- comments = ov_comment(&vf,-1)->user_comments;
-
- while(*comments) {
- if((temp = ogg_parseComment(*comments,"artist"))) {
- if(!ret->artist) {
- ret->artist = strdup(temp);
- stripReturnChar(ret->artist);
- }
- }
- else if((temp = ogg_parseComment(*comments,"title"))) {
- if(!ret->title) {
- ret->title = strdup(temp);
- stripReturnChar(ret->title);
- }
- }
- else if((temp = ogg_parseComment(*comments,"album"))) {
- if(!ret->album) {
- ret->album = strdup(temp);
- stripReturnChar(ret->album);
- }
- }
- else if((temp = ogg_parseComment(*comments,"tracknumber"))) {
- if(!ret->track) {
- ret->track = strdup(temp);
- stripReturnChar(ret->track);
- }
- }
+ ret = oggCommentsParse(ov_comment(&vf,-1)->user_comments);
- comments++;
- }
+ if(!ret) ret = newMpdTag();
+ ret->time = (int)(ov_time_total(&vf,-1)+0.5);
ov_clear(&vf);