mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-07-02 06:35:18 +02:00
Audio: convert seconds to samples by rounding rather than flooring
This commit is contained in:
parent
c58d708faa
commit
6a3a0ddc86
2 changed files with 3 additions and 5 deletions
|
@ -153,9 +153,8 @@ struct SDLSoundSource : ALDataSource
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Unfortunately there is no easy API in SDL_sound for seeking with better precision than 1ms.
|
// Unfortunately there is no easy API in SDL_sound for seeking with better precision than 1ms.
|
||||||
// TODO: Work around this by manually consuming the remaining samples.
|
// TODO: Work around this by flooring instead of rounding, and then manually consuming the remaining samples.
|
||||||
// TODO: Also we're flooring here when we probably should be rounding.
|
Sound_Seek(sample, static_cast<uint32_t>(lround(seconds * 1000)));
|
||||||
Sound_Seek(sample, static_cast<uint32_t>(seconds * 1000));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -164,8 +164,7 @@ struct VorbisSource : ALDataSource
|
||||||
currentFrame = 0;
|
currentFrame = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: We're flooring here when we probably should be rounding.
|
currentFrame = lround(seconds * info.rate);
|
||||||
currentFrame = seconds * info.rate;
|
|
||||||
|
|
||||||
if (loop.valid && currentFrame > loop.end)
|
if (loop.valid && currentFrame > loop.end)
|
||||||
currentFrame = loop.start;
|
currentFrame = loop.start;
|
||||||
|
|
Loading…
Add table
Reference in a new issue