mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 00:41:26 +12:00
Things updated
This commit is contained in:
parent
a6754e29a6
commit
011362bf1c
5 changed files with 44 additions and 16 deletions
|
@ -2356,14 +2356,8 @@ void RSXThread::Task()
|
|||
|
||||
m_vblank_count = 0;
|
||||
|
||||
while (!TestDestroy())
|
||||
while (!TestDestroy() && !Emu.IsStopped())
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
{
|
||||
LOG_WARNING(RSX, "VBlank thread aborted");
|
||||
return;
|
||||
}
|
||||
|
||||
if (get_system_time() - start_time > m_vblank_count * 1000000 / 60)
|
||||
{
|
||||
m_vblank_count++;
|
||||
|
@ -2383,7 +2377,6 @@ void RSXThread::Task()
|
|||
|
||||
is_vblank_stopped = true;
|
||||
});
|
||||
vblank.detach();
|
||||
|
||||
while (!TestDestroy()) try
|
||||
{
|
||||
|
|
|
@ -475,7 +475,6 @@ u32 adecOpen(AudioDecoder* adec_ptr)
|
|||
}
|
||||
|
||||
adec.is_finished = true;
|
||||
if (Emu.IsStopped()) cellAdec->Warning("AudioDecoder thread aborted");
|
||||
});
|
||||
|
||||
return adec_id;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -759,7 +759,6 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
|
|||
}
|
||||
|
||||
dmux.is_finished = true;
|
||||
if (Emu.IsStopped()) cellDmux->Warning("Demuxer thread aborted");
|
||||
});
|
||||
|
||||
return dmux_id;
|
||||
|
|
|
@ -551,7 +551,6 @@ u32 vdecOpen(VideoDecoder* vdec_ptr)
|
|||
}
|
||||
|
||||
vdec.is_finished = true;
|
||||
if (Emu.IsStopped()) cellVdec->Warning("VideoDecoder thread aborted");
|
||||
});
|
||||
|
||||
return vdec_id;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue