mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Things updated
This commit is contained in:
parent
a6754e29a6
commit
011362bf1c
5 changed files with 44 additions and 16 deletions
|
|
@ -2,6 +2,7 @@
|
|||
#include "Emu/Memory/Memory.h"
|
||||
#include "Emu/System.h"
|
||||
#include "Emu/SysCalls/Modules.h"
|
||||
#include "Emu/SysCalls/Callback.h"
|
||||
#include "Emu/Memory/atomic_type.h"
|
||||
|
||||
#include "rpcs3/Ini.h"
|
||||
|
|
@ -130,27 +131,64 @@ s32 cellAudioInit()
|
|||
Emu.GetAudioManager().GetAudioOut().Quit();
|
||||
});
|
||||
|
||||
u64 last_pause_time;
|
||||
std::atomic<u64> added_time(0);
|
||||
NamedThreadBase* audio_thread = GetCurrentNamedThread();
|
||||
|
||||
PauseCallbackRegisterer pcb(Emu.GetCallbackManager(), [&last_pause_time, &added_time, audio_thread](bool is_paused)
|
||||
{
|
||||
if (is_paused)
|
||||
{
|
||||
last_pause_time = get_system_time();
|
||||
}
|
||||
else
|
||||
{
|
||||
added_time += get_system_time() - last_pause_time;
|
||||
audio_thread->Notify();
|
||||
}
|
||||
});
|
||||
|
||||
while (g_audio.state.read_relaxed() == AUDIO_STATE_INITIALIZED && !Emu.IsStopped())
|
||||
{
|
||||
if (Emu.IsPaused())
|
||||
{
|
||||
GetCurrentNamedThread()->WaitForAnySignal();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (added_time)
|
||||
{
|
||||
g_audio.start_time += added_time.exchange(0);
|
||||
}
|
||||
|
||||
const u64 stamp0 = get_system_time();
|
||||
|
||||
// TODO: send beforemix event (in ~2,6 ms before mixing)
|
||||
|
||||
// precise time of sleeping: 5,(3) ms (or 256/48000 sec)
|
||||
if (g_audio.counter * AUDIO_SAMPLES * MHZ / 48000 >= stamp0 - g_audio.start_time)
|
||||
const u64 expected_time = g_audio.counter * AUDIO_SAMPLES * MHZ / 48000;
|
||||
if (expected_time >= stamp0 - g_audio.start_time)
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
continue;
|
||||
}
|
||||
|
||||
// crutch to hide giant lags caused by debugger
|
||||
const u64 missed_time = stamp0 - g_audio.start_time - expected_time;
|
||||
if (missed_time > AUDIO_SAMPLES * MHZ / 48000)
|
||||
{
|
||||
cellAudio->Notice("%f ms adjusted", (float)missed_time / 1000);
|
||||
g_audio.start_time += missed_time;
|
||||
}
|
||||
|
||||
g_audio.counter++;
|
||||
|
||||
const u32 out_pos = g_audio.counter % BUFFER_NUM;
|
||||
|
||||
if (Emu.IsPaused())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
//if (Emu.IsPaused())
|
||||
//{
|
||||
// continue;
|
||||
//}
|
||||
|
||||
bool first_mix = true;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue