diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/SidplayDecoderPlugin.cxx | 65 |
1 files changed, 36 insertions, 29 deletions
diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index d65ea8d4c..e1bb4ffbb 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -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); |