Commit d790d3ba authored by Max Kellermann's avatar Max Kellermann

decoder/sidplay: add GetInfoString()

parent c3dbc927
...@@ -281,6 +281,16 @@ sidplay_file_decode(Decoder &decoder, Path path_fs) ...@@ -281,6 +281,16 @@ sidplay_file_decode(Decoder &decoder, Path path_fs)
} while (cmd != DecoderCommand::STOP); } while (cmd != DecoderCommand::STOP);
} }
gcc_pure
static const char *
GetInfoString(const SidTuneInfo &info, unsigned i)
{
return info.numberOfInfoStrings > i
? info.infoString[i]
: nullptr;
}
static bool static bool
sidplay_scan_file(Path path_fs, sidplay_scan_file(Path path_fs,
const struct tag_handler *handler, void *handler_ctx) const struct tag_handler *handler, void *handler_ctx)
...@@ -297,11 +307,9 @@ sidplay_scan_file(Path path_fs, ...@@ -297,11 +307,9 @@ sidplay_scan_file(Path path_fs,
const SidTuneInfo &info = tune.getInfo(); const SidTuneInfo &info = tune.getInfo();
/* title */ /* title */
const char *title; const char *title = GetInfoString(info, 0);
if (info.numberOfInfoStrings > 0 && info.infoString[0] != nullptr) if (title == nullptr)
title=info.infoString[0]; title = "";
else
title="";
if(info.songs>1) { if(info.songs>1) {
char tag_title[1024]; char tag_title[1024];
...@@ -314,9 +322,10 @@ sidplay_scan_file(Path path_fs, ...@@ -314,9 +322,10 @@ sidplay_scan_file(Path path_fs,
tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title); tag_handler_invoke_tag(handler, handler_ctx, TAG_TITLE, title);
/* artist */ /* artist */
if (info.numberOfInfoStrings > 1 && info.infoString[1] != nullptr) const char *artist = GetInfoString(info, 1);
if (artist != nullptr)
tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST, tag_handler_invoke_tag(handler, handler_ctx, TAG_ARTIST,
info.infoString[1]); artist);
/* track */ /* track */
char track[16]; char track[16];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment