mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 22:11:26 +12:00
Add timeout for untouched buffers
This commit is contained in:
parent
8f6043b568
commit
f17f984721
2 changed files with 18 additions and 7 deletions
|
@ -604,10 +604,7 @@ void cell_audio_thread::operator()()
|
||||||
|
|
||||||
// Wait until buffers have been touched
|
// Wait until buffers have been touched
|
||||||
//cellAudio.error("active=%u, in_progress=%u, untouched=%u, incomplete=%u", active_ports, in_progress, untouched, incomplete);
|
//cellAudio.error("active=%u, in_progress=%u, untouched=%u, incomplete=%u", active_ports, in_progress, untouched, incomplete);
|
||||||
if (
|
if (untouched > untouched_expected)
|
||||||
(untouched == active_ports) || // wait for at least one touched buffer
|
|
||||||
(untouched > (untouched_expected > 0 ? active_ports - untouched_expected : 0)) // with multiple audio ports, wait for the expected number of buffers to be touched
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!playing)
|
if (!playing)
|
||||||
{
|
{
|
||||||
|
@ -616,14 +613,26 @@ void cell_audio_thread::operator()()
|
||||||
cellAudio.trace("advancing time: untouched=%u/%u (expected=%u), enqueued_buffers=0", untouched, active_ports, untouched_expected);
|
cellAudio.trace("advancing time: untouched=%u/%u (expected=%u), enqueued_buffers=0", untouched, active_ports, untouched_expected);
|
||||||
untouched_expected = untouched;
|
untouched_expected = untouched;
|
||||||
advance(timestamp);
|
advance(timestamp);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
|
||||||
|
// We allow untouched buffers to go through after a timeout
|
||||||
|
// While we should always wait for in-progress buffers, games may sometimes "skip" audio periods entirely if they're falling behind
|
||||||
|
if(time_since_last_period < cfg.untouched_timeout)
|
||||||
{
|
{
|
||||||
cellAudio.trace("waiting: untouched=%u/%u (expected=%u), enqueued_buffers=%llu", untouched, active_ports, untouched_expected, enqueued_buffers);
|
cellAudio.trace("waiting: untouched=%u/%u (expected=%u), enqueued_buffers=%llu", untouched, active_ports, untouched_expected, enqueued_buffers);
|
||||||
thread_ctrl::wait_for(1000);
|
thread_ctrl::wait_for(1000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (untouched == active_ports)
|
||||||
|
{
|
||||||
|
// There's no audio in the buffers, simply advance time
|
||||||
|
cellAudio.trace("advancing time: untouched=%u/%u (expected=%u), enqueued_buffers=%llu", untouched, active_ports, untouched_expected, enqueued_buffers);
|
||||||
|
untouched_expected = untouched;
|
||||||
|
advance(timestamp);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for buffer(s) to be completely filled
|
// Wait for buffer(s) to be completely filled
|
||||||
|
|
|
@ -200,6 +200,8 @@ public:
|
||||||
|
|
||||||
const 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
|
const 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
|
||||||
|
|
||||||
|
const u64 untouched_timeout = 2 * audio_block_period;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Time Stretching
|
* Time Stretching
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue