diff options
author | Max Kellermann <max@duempel.org> | 2014-12-04 21:58:09 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-07-29 14:56:05 +0200 |
commit | 071cacc9a4cdb0fb9997cfe5c44a79c89dbb242b (patch) | |
tree | bcd2c7b4b8f4d69649edcfa17a8c3d7ab315186a /src | |
parent | 33f33323affdf15315d7c71d57e265c5dd05c193 (diff) |
decoder/sidplay: pass SidTuneMod to get_song_length()
Eliminate duplicate SidTune construction.
Diffstat (limited to 'src')
-rw-r--r-- | src/decoder/plugins/SidplayDecoderPlugin.cxx | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 7bd355086..395945157 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -130,19 +130,12 @@ ParseContainerPath(Path path_fs) /* get the song length in seconds */ static SignedSongTime -get_song_length(const SidplayContainerPath &container) +get_song_length(SidTuneMod &tune) { - if (songlength_database == nullptr) - return SignedSongTime::Negative(); + assert(tune); - SidTuneMod tune(container.path.c_str()); - if(!tune) { - LogWarning(sidplay_domain, - "failed to load file for calculating md5 sum"); + if (songlength_database == nullptr) return SignedSongTime::Negative(); - } - - tune.selectSong(container.track); const auto length = songlength_database->length(tune); if (length < 0) @@ -159,7 +152,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs) /* load the tune */ const auto container = ParseContainerPath(path_fs); - SidTune tune(container.path.c_str(), nullptr, true); + SidTuneMod tune(container.path.c_str()); if (!tune) { LogWarning(sidplay_domain, "failed to load file"); return; @@ -168,7 +161,7 @@ sidplay_file_decode(Decoder &decoder, Path path_fs) const int song_num = container.track; tune.selectSong(song_num); - auto duration = get_song_length(container); + auto duration = get_song_length(tune); if (duration.IsNegative() && default_songlength > 0) duration = SongTime::FromS(default_songlength); @@ -298,10 +291,12 @@ sidplay_scan_file(Path path_fs, const auto container = ParseContainerPath(path_fs); const unsigned song_num = container.track; - SidTune tune(container.path.c_str(), nullptr, true); + SidTuneMod tune(container.path.c_str()); if (!tune) return false; + tune.selectSong(song_num); + const SidTuneInfo &info = tune.getInfo(); /* title */ @@ -332,7 +327,7 @@ sidplay_scan_file(Path path_fs, tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track); /* time */ - const auto duration = get_song_length(container); + const auto duration = get_song_length(tune); if (!duration.IsNegative()) tag_handler_invoke_duration(handler, handler_ctx, SongTime(duration)); |