summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-11-22 12:37:25 +0100
committerMax Kellermann <max@musicpd.org>2016-11-22 12:37:25 +0100
commitffb9874d84727d5375b342c7cc9c55ee3971d410 (patch)
tree36a6af29fa48085e1f56960d564713c5be7afd58 /src
parent228cdbe6afa927a423f6d40d3151d5d7af24fcda (diff)
decoder/sidplay: move code to ScanSidTuneInfo()
Diffstat (limited to 'src')
-rw-r--r--src/decoder/plugins/SidplayDecoderPlugin.cxx65
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);