mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 04:21:47 +00:00
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:
commit
fd5186bfea
2 changed files with 6 additions and 3 deletions
|
|
@ -72,7 +72,7 @@ void Gme::seek(int sample)
|
||||||
gme_seek_samples(instance_, sample);
|
gme_seek_samples(instance_, sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<float> Gme::duration_seconds() const
|
float Gme::duration_seconds() const
|
||||||
{
|
{
|
||||||
SRB2_ASSERT(instance_ != nullptr);
|
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); });
|
auto info_finally = srb2::finally([&info] { gme_free_info(info); });
|
||||||
|
|
||||||
if (info->length == -1)
|
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
|
// info lengths are in ms
|
||||||
return static_cast<float>(info->length) / 1000.f;
|
return static_cast<float>(info->length) / 1000.f;
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ public:
|
||||||
std::size_t get_samples(tcb::span<short> buffer);
|
std::size_t get_samples(tcb::span<short> buffer);
|
||||||
void seek(int sample);
|
void seek(int sample);
|
||||||
|
|
||||||
std::optional<float> duration_seconds() const;
|
float duration_seconds() const;
|
||||||
std::optional<float> loop_point_seconds() const;
|
std::optional<float> loop_point_seconds() const;
|
||||||
float position_seconds() const;
|
float position_seconds() const;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue