From 6423670eaec32eac829d0150fd7894b8287d5121 Mon Sep 17 00:00:00 2001 From: John Regan Date: Sun, 26 Apr 2020 09:24:34 -0400 Subject: [PATCH] gme: use song-reported fade-out time when available --- src/decoder/plugins/GmeDecoderPlugin.cxx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx index a8ab2dad7..1d253937d 100644 --- a/src/decoder/plugins/GmeDecoderPlugin.cxx +++ b/src/decoder/plugins/GmeDecoderPlugin.cxx @@ -173,10 +173,16 @@ gme_file_decode(DecoderClient &client, Path path_fs) } const int length = ti->play_length; +#if GME_VERSION >= 0x000700 + const int fade = ti->fade_length; +#else + const int fade = -1; +#endif gme_free_info(ti); const SignedSongTime song_len = length > 0 - ? SignedSongTime::FromMS(length + gme_default_fade) + ? SignedSongTime::FromMS(length + + (fade == -1 ? gme_default_fade : fade)) : SignedSongTime::Negative(); /* initialize the MPD decoder */ @@ -191,10 +197,10 @@ gme_file_decode(DecoderClient &client, Path path_fs) if (gme_err != nullptr) LogWarning(gme_domain, gme_err); - if (length > 0) + if (length > 0 && fade != 0) gme_set_fade(emu, length #if GME_VERSION >= 0x000700 - , gme_default_fade + , fade == -1 ? gme_default_fade : fade #endif ); @@ -229,7 +235,11 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count, TagHandler &handler) noexcept { if (info.play_length > 0) - handler.OnDuration(SongTime::FromMS(info.play_length + gme_default_fade)); + handler.OnDuration(SongTime::FromMS(info.play_length +#if GME_VERSION >= 0x000700 + + (info.fade_length == -1 ? gme_default_fade : info.fade_length) +#endif + )); if (track_count > 1) handler.OnTag(TAG_TRACK, StringFormat<16>("%u", song_num + 1).c_str());