From 4832267307382f597de711d4e79c0b355d118c09 Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Fri, 4 Oct 2024 11:44:24 +0200 Subject: [PATCH] Fixes audio buffering on non-windows platforms --- rpcs3/Emu/Cell/Modules/cellAudio.cpp | 4 ++-- rpcs3/Emu/Cell/Modules/cellAudio.h | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.cpp b/rpcs3/Emu/Cell/Modules/cellAudio.cpp index db5dddeae4..8137e3b58f 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.cpp +++ b/rpcs3/Emu/Cell/Modules/cellAudio.cpp @@ -813,7 +813,7 @@ void cell_audio_thread::operator()() if (time_left > cfg.period_comparison_margin) { - thread_ctrl::wait_for(get_thread_wait_delay(time_left)); + thread_ctrl::wait_for(time_left - cfg.period_comparison_margin); continue; } } @@ -886,7 +886,7 @@ void cell_audio_thread::operator()() const s64 time_left = m_dynamic_period - time_since_last_period; if (time_left > cfg.period_comparison_margin) { - thread_ctrl::wait_for(get_thread_wait_delay(time_left)); + thread_ctrl::wait_for(time_left - cfg.period_comparison_margin); continue; } diff --git a/rpcs3/Emu/Cell/Modules/cellAudio.h b/rpcs3/Emu/Cell/Modules/cellAudio.h index 1e12a68c9e..cab56aeef7 100644 --- a/rpcs3/Emu/Cell/Modules/cellAudio.h +++ b/rpcs3/Emu/Cell/Modules/cellAudio.h @@ -251,7 +251,12 @@ struct cell_audio_config static constexpr f32 period_average_alpha = 0.02f; // alpha factor for the m_average_period rolling average - static constexpr s64 period_comparison_margin = 250; // when comparing the current period time with the desired period, if it is below this number of usecs we do not wait any longer + // when comparing the current period time with the desired period, if it is below this number of usecs we do not wait any longer(quantum dependent) +#ifdef _WIN32 + static constexpr s64 period_comparison_margin = 250; +#else + static constexpr s64 period_comparison_margin = 5; +#endif u64 fully_untouched_timeout = 0; // timeout if the game has not touched any audio buffer yet u64 partially_untouched_timeout = 0; // timeout if the game has not touched all audio buffers yet @@ -373,11 +378,6 @@ private: void mix(float* out_buffer, s32 offset = 0); void finish_port_volume_stepping(); - constexpr static u64 get_thread_wait_delay(u64 time_left) - { - return (time_left > 350) ? time_left - 250 : 100; - } - void update_config(bool backend_changed); void reset_counters();