Core: SetOnStoppedCallback -> SetOnStateChangedCallback

This commit is contained in:
Michael M
2017-09-04 10:57:42 -07:00
parent 22a9a08b24
commit 8e805dcbf4
5 changed files with 25 additions and 11 deletions

View File

@ -98,7 +98,7 @@ static Common::Flag s_is_booting;
static void* s_window_handle = nullptr;
static std::string s_state_filename;
static std::thread s_emu_thread;
static StoppedCallbackFunc s_on_stopped_callback;
static StateChangedCallbackFunc s_on_state_changed_callback;
static std::thread s_cpu_thread;
static bool s_request_refresh_info = false;
@ -455,14 +455,16 @@ static void EmuThread(std::unique_ptr<BootParameters> boot)
{
const SConfig& core_parameter = SConfig::GetInstance();
s_is_booting.Set();
if (s_on_state_changed_callback)
s_on_state_changed_callback(State::Starting);
Common::ScopeGuard flag_guard{[] {
s_is_booting.Clear();
s_is_started = false;
s_is_stopping = false;
s_wants_determinism = false;
if (s_on_stopped_callback)
s_on_stopped_callback();
if (s_on_state_changed_callback)
s_on_state_changed_callback(State::Uninitialized);
INFO_LOG(CONSOLE, "Stop\t\t---- Shutdown complete ----");
}};
@ -685,6 +687,9 @@ void SetState(State state)
PanicAlert("Invalid state");
break;
}
if (s_on_state_changed_callback)
s_on_state_changed_callback(GetState());
}
State GetState()
@ -869,6 +874,8 @@ void Callback_VideoCopiedToXFB(bool video_update)
{
s_frame_step = false;
CPU::Break();
if (s_on_state_changed_callback)
s_on_state_changed_callback(Core::GetState());
}
}
@ -962,9 +969,9 @@ void Shutdown()
HostDispatchJobs();
}
void SetOnStoppedCallback(StoppedCallbackFunc callback)
void SetOnStateChangedCallback(StateChangedCallbackFunc callback)
{
s_on_stopped_callback = std::move(callback);
s_on_state_changed_callback = std::move(callback);
}
void UpdateWantDeterminism(bool initial)