diff options
author | Max Kellermann <max@duempel.org> | 2014-09-24 20:31:54 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-09-24 22:40:34 +0200 |
commit | 6c48aa5fae5b6f6dda8011b72e646af3ed1d35cd (patch) | |
tree | 9801e38c764433006114eac85d8a7af87a4b7eeb /src | |
parent | d82547acd3173316a741733c7f946eabf29b7bc6 (diff) | |
download | mpd-6c48aa5fae5b6f6dda8011b72e646af3ed1d35cd.tar.gz mpd-6c48aa5fae5b6f6dda8011b72e646af3ed1d35cd.tar.xz mpd-6c48aa5fae5b6f6dda8011b72e646af3ed1d35cd.zip |
decoder/mad: move code to tag/MixRamp.cxx
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/MadDecoderPlugin.cxx | 7 | ||||
-rw-r--r-- | src/tag/MixRamp.cxx | 63 | ||||
-rw-r--r-- | src/tag/MixRamp.hxx | 30 |
3 files changed, 95 insertions, 5 deletions
diff --git a/src/decoder/plugins/MadDecoderPlugin.cxx b/src/decoder/plugins/MadDecoderPlugin.cxx index 3cbc448f7..41efb593d 100644 --- a/src/decoder/plugins/MadDecoderPlugin.cxx +++ b/src/decoder/plugins/MadDecoderPlugin.cxx @@ -26,6 +26,7 @@ #include "tag/TagRva2.hxx" #include "tag/TagHandler.hxx" #include "tag/ReplayGain.hxx" +#include "tag/MixRamp.hxx" #include "CheckAudioFormat.hxx" #include "util/StringUtil.hxx" #include "util/ASCII.hxx" @@ -303,11 +304,7 @@ parse_id3_mixramp(struct id3_tag *tag) id3_ucs4_latin1duplicate(id3_field_getstring (&frame->fields[2])); - if (StringEqualsCaseASCII(key, "mixramp_start")) { - result.SetStart(value); - } else if (StringEqualsCaseASCII(key, "mixramp_end")) { - result.SetEnd(value); - } + ParseMixRampTag(result, key, value); free(key); free(value); diff --git a/src/tag/MixRamp.cxx b/src/tag/MixRamp.cxx new file mode 100644 index 000000000..36cf74c82 --- /dev/null +++ b/src/tag/MixRamp.cxx @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "config.h" +#include "MixRamp.hxx" +#include "MixRampInfo.hxx" +#include "util/ASCII.hxx" + +#include <assert.h> + +template<typename T> +static bool +ParseMixRampTagTemplate(MixRampInfo &info, const T t) +{ + const char *value; + + if ((value = t["mixramp_start"]) != nullptr) { + info.SetStart(value); + return true; + } else if ((value = t["mixramp_end"]) != nullptr) { + info.SetEnd(value); + return true; + } else + return false; + +} + +bool +ParseMixRampTag(MixRampInfo &info, const char *name, const char *value) +{ + assert(name != nullptr); + assert(value != nullptr); + + struct NameValue { + const char *name; + const char *value; + + gcc_pure + const char *operator[](const char *n) const { + return StringEqualsCaseASCII(name, n) + ? value + : nullptr; + } + }; + + return ParseMixRampTagTemplate(info, NameValue{name, value}); +} diff --git a/src/tag/MixRamp.hxx b/src/tag/MixRamp.hxx new file mode 100644 index 000000000..7f384153e --- /dev/null +++ b/src/tag/MixRamp.hxx @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2003-2014 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef MPD_TAG_MIXRAMP_HXX +#define MPD_TAG_MIXRAMP_HXX + +#include "check.h" + +class MixRampInfo; + +bool +ParseMixRampTag(MixRampInfo &info, const char *name, const char *value); + +#endif |