aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-11 21:56:02 +0200
committerMax Kellermann <max@duempel.org>2014-07-11 21:56:02 +0200
commit8cfe901391044da6509b1dc5c58bccabcaf9e4b4 (patch)
tree96742d8254bbaae33e0542aa3b56bb9ca01b4042 /src/decoder
parent30f1ee7a1fba9b03404f0a4b1af83b708734d636 (diff)
downloadmpd-8cfe901391044da6509b1dc5c58bccabcaf9e4b4.tar.gz
mpd-8cfe901391044da6509b1dc5c58bccabcaf9e4b4.tar.xz
mpd-8cfe901391044da6509b1dc5c58bccabcaf9e4b4.zip
decoder/sndfile: move code to sndfile_handle_tag()
Diffstat (limited to '')
-rw-r--r--src/decoder/plugins/SndfileDecoderPlugin.cxx27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx
index 525cae267..8c9024201 100644
--- a/src/decoder/plugins/SndfileDecoderPlugin.cxx
+++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx
@@ -213,13 +213,21 @@ sndfile_stream_decode(Decoder &decoder, InputStream &is)
sf_close(sf);
}
+static void
+sndfile_handle_tag(SNDFILE *sf, int str, TagType tag,
+ const struct tag_handler *handler, void *handler_ctx)
+{
+ const char *value = sf_get_string(sf, str);
+ if (value != nullptr)
+ tag_handler_invoke_tag(handler, handler_ctx, tag, value);
+}
+
static bool
sndfile_scan_file(Path path_fs,
const struct tag_handler *handler, void *handler_ctx)
{
SNDFILE *sf;
SF_INFO info;
- const char *p;
info.format = 0;
@@ -237,20 +245,9 @@ sndfile_scan_file(Path path_fs,
tag_handler_invoke_duration(handler, handler_ctx,
info.frames / info.samplerate);
- p = sf_get_string(sf, SF_STR_TITLE);
- if (p != nullptr)
- tag_handler_invoke_tag(handler, handler_ctx,
- TAG_TITLE, p);
-
- p = sf_get_string(sf, SF_STR_ARTIST);
- if (p != nullptr)
- tag_handler_invoke_tag(handler, handler_ctx,
- TAG_ARTIST, p);
-
- p = sf_get_string(sf, SF_STR_DATE);
- if (p != nullptr)
- tag_handler_invoke_tag(handler, handler_ctx,
- TAG_DATE, p);
+ sndfile_handle_tag(sf, SF_STR_TITLE, TAG_TITLE, handler, handler_ctx);
+ sndfile_handle_tag(sf, SF_STR_ARTIST, TAG_ARTIST, handler, handler_ctx);
+ sndfile_handle_tag(sf, SF_STR_DATE, TAG_DATE, handler, handler_ctx);
sf_close(sf);