From a485c4856c29568ca938f561df6d1954ddd0e6c2 Mon Sep 17 00:00:00 2001 From: skidoo23 <18039569+skidoo23@users.noreply.github.com> Date: Wed, 29 Apr 2020 16:27:54 +0200 Subject: [PATCH] decoder/sidplay: support new song length format with libsidplayfp 2.0 --- src/decoder/plugins/SidplayDecoderPlugin.cxx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index d71e9bd63..7fa9af10f 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -219,11 +219,24 @@ get_song_length(T &tune) noexcept if (sidplay_global->songlength_database == nullptr) return SignedSongTime::Negative(); - const auto length = sidplay_global->songlength_database->length(tune); - if (length < 0) +#if LIBSIDPLAYFP_VERSION_MAJ >= 2 + const auto lengthms = + sidplay_global->songlength_database->lengthMs(tune); + /* check for new song length format since HVSC#68 or later */ + if (lengthms < 0) + { +#endif + /* old song lenghth format */ + const auto length = + sidplay_global->songlength_database->length(tune); + if (length >= 0) + return SignedSongTime::FromS(length); return SignedSongTime::Negative(); - return SignedSongTime::FromS(length); +#if LIBSIDPLAYFP_VERSION_MAJ >= 2 + } + return SignedSongTime::FromMS(lengthms); +#endif } static void