From 441f9cc2ee1e62be0d5869c247aecff78c2ca3c6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Sep 2014 20:54:20 +0200 Subject: tag/ReplayGain: add VorbisComment parser Move code from the Vorbis and FLAC decoder plugins. --- src/tag/ReplayGain.cxx | 16 ++++++++++++++++ src/tag/ReplayGain.hxx | 3 +++ 2 files changed, 19 insertions(+) (limited to 'src/tag') diff --git a/src/tag/ReplayGain.cxx b/src/tag/ReplayGain.cxx index d2347dba5..83a48f243 100644 --- a/src/tag/ReplayGain.cxx +++ b/src/tag/ReplayGain.cxx @@ -19,6 +19,7 @@ #include "config.h" #include "ReplayGain.hxx" +#include "VorbisComment.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" @@ -68,3 +69,18 @@ ParseReplayGainTag(ReplayGainInfo &info, const char *name, const char *value) return ParseReplayGainTagTemplate(info, NameValue{name, value}); } + +bool +ParseReplayGainVorbis(ReplayGainInfo &info, const char *entry) +{ + struct VorbisCommentEntry { + const char *entry; + + gcc_pure + const char *operator[](const char *n) const { + return vorbis_comment_value(entry, n); + } + }; + + return ParseReplayGainTagTemplate(info, VorbisCommentEntry{entry}); +} diff --git a/src/tag/ReplayGain.hxx b/src/tag/ReplayGain.hxx index 2e6cf799e..2bf5e0db1 100644 --- a/src/tag/ReplayGain.hxx +++ b/src/tag/ReplayGain.hxx @@ -27,4 +27,7 @@ struct ReplayGainInfo; bool ParseReplayGainTag(ReplayGainInfo &info, const char *name, const char *value); +bool +ParseReplayGainVorbis(ReplayGainInfo &info, const char *entry); + #endif -- cgit v1.2.3