Things updated

This commit is contained in:
Nekotekina 2015-01-17 21:33:39 +03:00
parent a6754e29a6
commit 011362bf1c
5 changed files with 44 additions and 16 deletions

View file

@ -2356,14 +2356,8 @@ void RSXThread::Task()
m_vblank_count = 0; 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) if (get_system_time() - start_time > m_vblank_count * 1000000 / 60)
{ {
m_vblank_count++; m_vblank_count++;
@ -2383,7 +2377,6 @@ void RSXThread::Task()
is_vblank_stopped = true; is_vblank_stopped = true;
}); });
vblank.detach();
while (!TestDestroy()) try while (!TestDestroy()) try
{ {

View file

@ -475,7 +475,6 @@ u32 adecOpen(AudioDecoder* adec_ptr)
} }
adec.is_finished = true; adec.is_finished = true;
if (Emu.IsStopped()) cellAdec->Warning("AudioDecoder thread aborted");
}); });
return adec_id; return adec_id;

View file

@ -2,6 +2,7 @@
#include "Emu/Memory/Memory.h" #include "Emu/Memory/Memory.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Emu/SysCalls/Modules.h" #include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/Callback.h"
#include "Emu/Memory/atomic_type.h" #include "Emu/Memory/atomic_type.h"
#include "rpcs3/Ini.h" #include "rpcs3/Ini.h"
@ -130,27 +131,64 @@ s32 cellAudioInit()
Emu.GetAudioManager().GetAudioOut().Quit(); 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()) 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(); const u64 stamp0 = get_system_time();
// TODO: send beforemix event (in ~2,6 ms before mixing) // TODO: send beforemix event (in ~2,6 ms before mixing)
// precise time of sleeping: 5,(3) ms (or 256/48000 sec) // 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)); std::this_thread::sleep_for(std::chrono::milliseconds(1));
continue; 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++; g_audio.counter++;
const u32 out_pos = g_audio.counter % BUFFER_NUM; const u32 out_pos = g_audio.counter % BUFFER_NUM;
if (Emu.IsPaused()) //if (Emu.IsPaused())
{ //{
continue; // continue;
} //}
bool first_mix = true; bool first_mix = true;

View file

@ -759,7 +759,6 @@ u32 dmuxOpen(Demuxer* dmux_ptr)
} }
dmux.is_finished = true; dmux.is_finished = true;
if (Emu.IsStopped()) cellDmux->Warning("Demuxer thread aborted");
}); });
return dmux_id; return dmux_id;

View file

@ -551,7 +551,6 @@ u32 vdecOpen(VideoDecoder* vdec_ptr)
} }
vdec.is_finished = true; vdec.is_finished = true;
if (Emu.IsStopped()) cellVdec->Warning("VideoDecoder thread aborted");
}); });
return vdec_id; return vdec_id;