diff options
author | Max Kellermann <max@duempel.org> | 2014-09-24 20:56:25 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-09-24 21:50:42 +0200 |
commit | d1e31261fe7d58f9ea50c93b58ace9befd5ea0cc (patch) | |
tree | 82c6f314c238861a369735539683213d1a5be52c /src/decoder | |
parent | 05dd9acba8c7534c8e8f01bf15342ab7493d28fc (diff) | |
download | mpd-d1e31261fe7d58f9ea50c93b58ace9befd5ea0cc.tar.gz mpd-d1e31261fe7d58f9ea50c93b58ace9befd5ea0cc.tar.xz mpd-d1e31261fe7d58f9ea50c93b58ace9befd5ea0cc.zip |
decoder/{vorbis,flac}: move duplicate code to tag/VorbisComment.cxx
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/plugins/FlacMetadata.cxx | 13 | ||||
-rw-r--r-- | src/decoder/plugins/VorbisComments.cxx | 14 |
2 files changed, 3 insertions, 24 deletions
diff --git a/src/decoder/plugins/FlacMetadata.cxx b/src/decoder/plugins/FlacMetadata.cxx index 0ee6026dd..a36d1b2e9 100644 --- a/src/decoder/plugins/FlacMetadata.cxx +++ b/src/decoder/plugins/FlacMetadata.cxx @@ -25,6 +25,7 @@ #include "tag/TagTable.hxx" #include "tag/TagBuilder.hxx" #include "tag/Tag.hxx" +#include "tag/VorbisComment.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" #include "util/SplitString.hxx" @@ -114,17 +115,7 @@ static const char * flac_comment_value(const FLAC__StreamMetadata_VorbisComment_Entry *entry, const char *name) { - size_t name_length = strlen(name); - const char *comment = (const char*)entry->entry; - - if (!StringEqualsCaseASCII(comment, name, name_length)) - return nullptr; - - if (comment[name_length] == '=') { - return comment + name_length + 1; - } - - return nullptr; + return vorbis_comment_value((const char *)entry->entry, name); } /** diff --git a/src/decoder/plugins/VorbisComments.cxx b/src/decoder/plugins/VorbisComments.cxx index 2a0820ab5..f1dcdc1b0 100644 --- a/src/decoder/plugins/VorbisComments.cxx +++ b/src/decoder/plugins/VorbisComments.cxx @@ -23,26 +23,14 @@ #include "tag/TagTable.hxx" #include "tag/TagHandler.hxx" #include "tag/TagBuilder.hxx" +#include "tag/VorbisComment.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" #include "util/SplitString.hxx" #include <stddef.h> -#include <string.h> #include <stdlib.h> -static const char * -vorbis_comment_value(const char *comment, const char *needle) -{ - size_t len = strlen(needle); - - if (StringEqualsCaseASCII(comment, needle, len) && - comment[len] == '=') - return comment + len + 1; - - return nullptr; -} - bool vorbis_comments_to_replay_gain(ReplayGainInfo &rgi, char **comments) { |