mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Add busy loop to audio thread.
This commit is contained in:
parent
8575c6dbe4
commit
a5e021a414
1 changed files with 6 additions and 1 deletions
|
|
@ -59,7 +59,12 @@ static void AudioThread()
|
||||||
auto now = std::chrono::steady_clock::now();
|
auto now = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
if ((next - now) < 1s)
|
if ((next - now) < 1s)
|
||||||
std::this_thread::sleep_until(next);
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::floor<std::chrono::milliseconds>(next - now));
|
||||||
|
|
||||||
|
while ((now = std::chrono::steady_clock::now()) < next)
|
||||||
|
std::this_thread::yield();
|
||||||
|
}
|
||||||
|
|
||||||
int64_t elapsed = std::chrono::nanoseconds(std::chrono::steady_clock::now() - start).count();
|
int64_t elapsed = std::chrono::nanoseconds(std::chrono::steady_clock::now() - start).count();
|
||||||
iteration = ((elapsed * XAUDIO_SAMPLES_HZ) / (XAUDIO_NUM_SAMPLES * 1000000000ll)) + 1;
|
iteration = ((elapsed * XAUDIO_SAMPLES_HZ) / (XAUDIO_NUM_SAMPLES * 1000000000ll)) + 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue