From 4c824e5309fe1a725c5d7759df7f779f521b0b14 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 10 Nov 2017 22:26:25 +0100 Subject: [PATCH] output/shout: simplify shout_tag_to_metadata() --- src/output/plugins/ShoutOutputPlugin.cxx | 25 +++++------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/output/plugins/ShoutOutputPlugin.cxx b/src/output/plugins/ShoutOutputPlugin.cxx index 6659c7c12..e9734293b 100644 --- a/src/output/plugins/ShoutOutputPlugin.cxx +++ b/src/output/plugins/ShoutOutputPlugin.cxx @@ -339,27 +339,12 @@ ShoutOutput::Pause() static void shout_tag_to_metadata(const Tag &tag, char *dest, size_t size) { - char artist[size]; - char title[size]; + const char *artist = tag.GetValue(TAG_ARTIST); + const char *title = tag.GetValue(TAG_TITLE); - artist[0] = 0; - title[0] = 0; - - for (const auto &item : tag) { - switch (item.type) { - case TAG_ARTIST: - strncpy(artist, item.value, size); - break; - case TAG_TITLE: - strncpy(title, item.value, size); - break; - - default: - break; - } - } - - snprintf(dest, size, "%s - %s", artist, title); + snprintf(dest, size, "%s - %s", + artist != nullptr ? artist : "", + title != nullptr ? title : ""); } void