aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder')
-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);