Merge branch 'fix-gme-length' into 'master'

Fix GME not reporting song length most of the time

See merge request KartKrew/Kart!1123
This commit is contained in:
Oni 2023-03-31 09:40:08 +00:00
commit fd5186bfea
2 changed files with 6 additions and 3 deletions

View file

@ -72,7 +72,7 @@ void Gme::seek(int sample)
gme_seek_samples(instance_, sample);
}
std::optional<float> Gme::duration_seconds() const
float Gme::duration_seconds() const
{
SRB2_ASSERT(instance_ != nullptr);
@ -83,7 +83,10 @@ std::optional<float> Gme::duration_seconds() const
auto info_finally = srb2::finally([&info] { gme_free_info(info); });
if (info->length == -1)
return std::nullopt;
{
// these two fields added together also make the length of the song
return static_cast<float>(info->intro_length + info->loop_length) / 1000.f;
}
// info lengths are in ms
return static_cast<float>(info->length) / 1000.f;

View file

@ -56,7 +56,7 @@ public:
std::size_t get_samples(tcb::span<short> buffer);
void seek(int sample);
std::optional<float> duration_seconds() const;
float duration_seconds() const;
std::optional<float> loop_point_seconds() const;
float position_seconds() const;