Fixes audio buffering on non-windows platforms

This commit is contained in:
RipleyTom 2024-10-04 11:44:24 +02:00 committed by Elad
parent 6bb01066fb
commit 4832267307
2 changed files with 8 additions and 8 deletions

View File

@ -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;
}

View File

@ -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();