aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/plugins
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-09-24 22:44:58 +0200
committerMax Kellermann <max@duempel.org>2014-09-24 22:44:58 +0200
commit8a7ff6a6fd70d6a8e7611ffb0f794fb3eab2a462 (patch)
treeb3f616d3c8b4d38254256b8d8c7c38141da49e5e /src/decoder/plugins
parent6c48aa5fae5b6f6dda8011b72e646af3ed1d35cd (diff)
downloadmpd-8a7ff6a6fd70d6a8e7611ffb0f794fb3eab2a462.tar.gz
mpd-8a7ff6a6fd70d6a8e7611ffb0f794fb3eab2a462.tar.xz
mpd-8a7ff6a6fd70d6a8e7611ffb0f794fb3eab2a462.zip
decoder/flac: move code to tag/MixRamp.cxx
Diffstat (limited to 'src/decoder/plugins')
-rw-r--r--src/decoder/plugins/FlacMetadata.cxx45
1 files changed, 10 insertions, 35 deletions
diff --git a/src/decoder/plugins/FlacMetadata.cxx b/src/decoder/plugins/FlacMetadata.cxx
index 4628ad4a2..f917a8fcc 100644
--- a/src/decoder/plugins/FlacMetadata.cxx
+++ b/src/decoder/plugins/FlacMetadata.cxx
@@ -27,32 +27,11 @@
#include "tag/Tag.hxx"
#include "tag/VorbisComment.hxx"
#include "tag/ReplayGain.hxx"
+#include "tag/MixRamp.hxx"
#include "ReplayGainInfo.hxx"
#include "util/ASCII.hxx"
#include "util/SplitString.hxx"
-#include <string.h>
-
-static const char *
-vorbis_comment_value(const FLAC__StreamMetadata *block,
- const char *name)
-{
- int offset =
- FLAC__metadata_object_vorbiscomment_find_entry_from(block, 0,
- name);
- if (offset < 0)
- return nullptr;
-
- size_t name_length = strlen(name);
-
- const FLAC__StreamMetadata_VorbisComment_Entry &vc =
- block->data.vorbis_comment.comments[offset];
- const char *comment = (const char *)vc.entry;
-
- /* 1 is for '=' */
- return comment + name_length + 1;
-}
-
bool
flac_parse_replay_gain(ReplayGainInfo &rgi,
const FLAC__StreamMetadata_VorbisComment &vc)
@@ -70,23 +49,19 @@ flac_parse_replay_gain(ReplayGainInfo &rgi,
return found;
}
-gcc_pure
-static std::string
-flac_find_string_comment(const FLAC__StreamMetadata *block, const char *cmnt)
-{
- const char *value = vorbis_comment_value(block, cmnt);
- if (value == nullptr)
- return std::string();
-
- return std::string(value);
-}
-
MixRampInfo
flac_parse_mixramp(const FLAC__StreamMetadata *block)
{
+ const FLAC__StreamMetadata_VorbisComment &vc =
+ block->data.vorbis_comment;
+
MixRampInfo mix_ramp;
- mix_ramp.SetStart(flac_find_string_comment(block, "mixramp_start"));
- mix_ramp.SetEnd(flac_find_string_comment(block, "mixramp_end"));
+
+ const auto *comments = vc.comments;
+ for (FLAC__uint32 i = 0, n = vc.num_comments; i < n; ++i)
+ ParseMixRampVorbis(mix_ramp,
+ (const char *)comments[i].entry);
+
return mix_ramp;
}