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