Allow users to change max amount of queued frames

This commit is contained in:
Gliniak 2021-12-07 23:14:40 +01:00
parent 498dde6e1a
commit 07a1e77218
1 changed files with 7 additions and 3 deletions

View File

@ -33,6 +33,10 @@
// and let the normal AudioSystem handling take it, to prevent duplicate // and let the normal AudioSystem handling take it, to prevent duplicate
// implementations. They can be found in xboxkrnl_audio_xma.cc // implementations. They can be found in xboxkrnl_audio_xma.cc
DEFINE_uint32(
max_queued_frames, 64,
"Allows changing max buffered audio frames to reduce audio delay.", "APU");
namespace xe { namespace xe {
namespace apu { namespace apu {
@ -44,7 +48,7 @@ AudioSystem::AudioSystem(cpu::Processor* processor)
for (size_t i = 0; i < kMaximumClientCount; ++i) { for (size_t i = 0; i < kMaximumClientCount; ++i) {
client_semaphores_[i] = client_semaphores_[i] =
xe::threading::Semaphore::Create(0, kMaximumQueuedFrames); xe::threading::Semaphore::Create(0, cvars::max_queued_frames);
wait_handles_[i] = client_semaphores_[i].get(); wait_handles_[i] = client_semaphores_[i].get();
} }
shutdown_event_ = xe::threading::Event::CreateAutoResetEvent(false); shutdown_event_ = xe::threading::Event::CreateAutoResetEvent(false);
@ -172,7 +176,7 @@ X_STATUS AudioSystem::RegisterClient(uint32_t callback, uint32_t callback_arg,
assert_true(index >= 0); assert_true(index >= 0);
auto client_semaphore = client_semaphores_[index].get(); auto client_semaphore = client_semaphores_[index].get();
auto ret = client_semaphore->Release(kMaximumQueuedFrames, nullptr); auto ret = client_semaphore->Release(cvars::max_queued_frames, nullptr);
assert_true(ret); assert_true(ret);
AudioDriver* driver; AudioDriver* driver;
@ -275,7 +279,7 @@ bool AudioSystem::Restore(ByteStream* stream) {
client.in_use = true; client.in_use = true;
auto client_semaphore = client_semaphores_[id].get(); auto client_semaphore = client_semaphores_[id].get();
auto ret = client_semaphore->Release(kMaximumQueuedFrames, nullptr); auto ret = client_semaphore->Release(cvars::max_queued_frames, nullptr);
assert_true(ret); assert_true(ret);
AudioDriver* driver = nullptr; AudioDriver* driver = nullptr;