Commit ffb9874d authored by Max Kellermann's avatar Max Kellermann

decoder/sidplay: move code to ScanSidTuneInfo()

parent 228cdbe6
......@@ -410,31 +410,10 @@ GetInfoString(const SidTuneInfo &info, unsigned i)
#endif
}
static bool
sidplay_scan_file(Path path_fs,
const TagHandler &handler, void *handler_ctx)
static void
ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
const TagHandler &handler, void *handler_ctx)
{
const auto container = ParseContainerPath(path_fs);
const unsigned song_num = container.track;
#ifdef HAVE_SIDPLAYFP
SidTune tune(container.path.c_str());
#else
SidTuneMod tune(container.path.c_str());
#endif
if (!tune.getStatus())
return false;
tune.selectSong(song_num);
#ifdef HAVE_SIDPLAYFP
const SidTuneInfo &info = *tune.getInfo();
const unsigned n_tracks = info.songs();
#else
const SidTuneInfo &info = tune.getInfo();
const unsigned n_tracks = info.songs;
#endif
/* title */
const char *title = GetInfoString(info, 0);
if (title == nullptr)
......@@ -443,8 +422,8 @@ sidplay_scan_file(Path path_fs,
if (n_tracks > 1) {
char tag_title[1024];
snprintf(tag_title, sizeof(tag_title),
"%s (%d/%u)",
title, song_num, n_tracks);
"%s (%u/%u)",
title, track, n_tracks);
tag_handler_invoke_tag(handler, handler_ctx,
TAG_TITLE, tag_title);
} else
......@@ -463,9 +442,37 @@ sidplay_scan_file(Path path_fs,
date);
/* track */
char track[16];
sprintf(track, "%d", song_num);
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track);
char track_buffer[16];
sprintf(track_buffer, "%d", track);
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track_buffer);
}
static bool
sidplay_scan_file(Path path_fs,
const TagHandler &handler, void *handler_ctx)
{
const auto container = ParseContainerPath(path_fs);
const unsigned song_num = container.track;
#ifdef HAVE_SIDPLAYFP
SidTune tune(container.path.c_str());
#else
SidTuneMod tune(container.path.c_str());
#endif
if (!tune.getStatus())
return false;
tune.selectSong(song_num);
#ifdef HAVE_SIDPLAYFP
const SidTuneInfo &info = *tune.getInfo();
const unsigned n_tracks = info.songs();
#else
const SidTuneInfo &info = tune.getInfo();
const unsigned n_tracks = info.songs;
#endif
ScanSidTuneInfo(info, song_num, n_tracks, handler, handler_ctx);
/* time */
const auto duration = get_song_length(tune);
......
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