From 6c48aa5fae5b6f6dda8011b72e646af3ed1d35cd Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Sep 2014 20:31:54 +0200 Subject: decoder/mad: move code to tag/MixRamp.cxx --- src/tag/MixRamp.cxx | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/tag/MixRamp.cxx (limited to 'src/tag/MixRamp.cxx') 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 + +template +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}); +} -- cgit v1.2.3