From 97fe75a0bf4ce5a0769a7509f758eda3f52fd6b3 Mon Sep 17 00:00:00 2001 From: Warren Dukes Date: Mon, 31 May 2004 02:21:06 +0000 Subject: little cleanup of plugin stuff git-svn-id: https://svn.musicpd.org/mpd/trunk@1247 09075e82-0dd4-0310-85a5-a0d7c8717e4f --- src/inputPlugins/flac_plugin.c | 13 +++++-------- src/inputPlugins/mp3_plugin.c | 9 +++------ src/inputPlugins/ogg_plugin.c | 43 ++++++++++++++++++------------------------ 3 files changed, 26 insertions(+), 39 deletions(-) (limited to 'src/inputPlugins') diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 23e2bcfea..a90270850 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -27,7 +27,6 @@ #include "../outputBuffer.h" #include "../replayGain.h" #include "../audio.h" -#include "../path.h" #include #include @@ -438,7 +437,7 @@ FLAC__StreamDecoderWriteStatus flacWrite(const FLAC__SeekableStreamDecoder *dec, return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } -MpdTag * flacMetadataDup(char * utf8file, int * vorbisCommentFound) { +MpdTag * flacMetadataDup(char * file, int * vorbisCommentFound) { MpdTag * ret = NULL; FLAC__Metadata_SimpleIterator * it; FLAC__StreamMetadata * block = NULL; @@ -448,7 +447,7 @@ MpdTag * flacMetadataDup(char * utf8file, int * vorbisCommentFound) { *vorbisCommentFound = 0; it = FLAC__metadata_simple_iterator_new(); - if(!FLAC__metadata_simple_iterator_init(it,rmp2amp(utf8ToFsCharset(utf8file)),1,0)) { + if(!FLAC__metadata_simple_iterator_init(it, file ,1,0)) { FLAC__metadata_simple_iterator_delete(it); return ret; } @@ -530,14 +529,14 @@ MpdTag * flacMetadataDup(char * utf8file, int * vorbisCommentFound) { return ret; } -MpdTag * flacTagDup(char * utf8file) { +MpdTag * flacTagDup(char * file) { MpdTag * ret = NULL; int foundVorbisComment = 0; - ret = flacMetadataDup(utf8file,&foundVorbisComment); + ret = flacMetadataDup(file, &foundVorbisComment); if(!ret) return NULL; if(!foundVorbisComment) { - MpdTag * temp = id3Dup(utf8file); + MpdTag * temp = id3Dup(file); if(temp) { temp->time = ret->time; freeMpdTag(ret); @@ -545,8 +544,6 @@ MpdTag * flacTagDup(char * utf8file) { } } - if(ret) validateUtf8Tag(ret); - return ret; } diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 594f17876..de23b6c7b 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -36,7 +36,6 @@ #include "../log.h" #include "../utils.h" #include "../tag.h" -#include "../path.h" #include #include @@ -613,21 +612,19 @@ int mp3_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) { return 0; } -MpdTag * mp3_tagDup(char * utf8file) { +MpdTag * mp3_tagDup(char * file) { MpdTag * ret = NULL; int time; - ret = id3Dup(utf8file); + ret = id3Dup(file); - time = getMp3TotalTime(rmp2amp(utf8ToFsCharset(utf8file))); + time = getMp3TotalTime(file); if(time>=0) { if(!ret) ret = newMpdTag(); ret->time = time; } - if(ret) validateUtf8Tag(ret); - return ret; } diff --git a/src/inputPlugins/ogg_plugin.c b/src/inputPlugins/ogg_plugin.c index 4f44af4c2..4f49f286b 100644 --- a/src/inputPlugins/ogg_plugin.c +++ b/src/inputPlugins/ogg_plugin.c @@ -108,7 +108,9 @@ long ogg_tell_cb(void * vdata) { char * ogg_parseComment(char * comment, char * needle) { int len = strlen(needle); - if(strncasecmp(comment,needle,len)) return comment+len; + if(strncasecmp(comment, needle, len) == 0 && *(comment+len) == '=') { + return comment+len+1; + } return NULL; } @@ -274,16 +276,14 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc, InputStream * inStream) return 0; } -MpdTag * oggTagDup(char * utf8file) { +MpdTag * oggTagDup(char * file) { MpdTag * ret = NULL; FILE * fp; OggVorbis_File vf; char ** comments; char * temp; - char * s1; - char * s2; - fp = fopen(rmp2amp(utf8ToFsCharset(utf8file)),"r"); + fp = fopen(file,"r"); if(!fp) return NULL; if(ov_open(fp,&vf,NULL,0)<0) { fclose(fp); @@ -296,33 +296,28 @@ MpdTag * oggTagDup(char * utf8file) { comments = ov_comment(&vf,-1)->user_comments; while(*comments) { - temp = strdup(*comments); - ++comments; - if(!(s1 = strtok(temp,"="))) continue; - s2 = strtok(NULL,""); - if(!s1 || !s2); - else if(0==strcasecmp(s1,"artist")) { + if((temp = ogg_parseComment(*comments,"artist"))) { if(!ret->artist) { - stripReturnChar(s2); - ret->artist = strdup(s2); + ret->artist = strdup(temp); + stripReturnChar(ret->artist); } - } - else if(0==strcasecmp(s1,"title")) { + } + else if((temp = ogg_parseComment(*comments,"title"))) { if(!ret->title) { - stripReturnChar(s2); - ret->title = strdup(s2); + ret->title = strdup(temp); + stripReturnChar(ret->title); } } - else if(0==strcasecmp(s1,"album")) { + else if((temp = ogg_parseComment(*comments,"album"))) { if(!ret->album) { - stripReturnChar(s2); - ret->album = strdup(s2); + ret->album = strdup(temp); + stripReturnChar(ret->album); } } - else if(0==strcasecmp(s1,"tracknumber")) { + else if((temp = ogg_parseComment(*comments,"tracknumber"))) { if(!ret->track) { - stripReturnChar(s2); - ret->track = strdup(s2); + ret->track = strdup(temp); + stripReturnChar(ret->track); } } free(temp); @@ -330,8 +325,6 @@ MpdTag * oggTagDup(char * utf8file) { ov_clear(&vf); - if(ret) validateUtf8Tag(ret); - return ret; } -- cgit v1.2.3