mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Audio: fix GME not reporting song length most of the time
Now add the intro time and looping time together to get the length of the song, if the length field itself is not specified (it's usually not).
This commit is contained in:
parent
535fc17875
commit
fccdefb840
2 changed files with 6 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue