From 8cfe901391044da6509b1dc5c58bccabcaf9e4b4 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 11 Jul 2014 21:56:02 +0200 Subject: decoder/sndfile: move code to sndfile_handle_tag() --- src/decoder/plugins/SndfileDecoderPlugin.cxx | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'src') 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); -- cgit v1.2.3