diff options
| author | JosJuice <josjuice@gmail.com> | 2019-11-04 17:15:13 +0100 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2019-11-05 09:28:40 +0100 |
| commit | c007dd1852896efe1671ade96fa50080a030a51b (patch) | |
| tree | 79e75e549ef6df4ca239987625d7ad9830e4fc1d /Source/Core | |
| parent | 0f4c971326ae9389b3ad55b0fefacb708d148f4d (diff) | |
Android: Replace emulation rotation crash workaround with proper fix
The workaround was added in 0446a58.
The underlying problem is that we must not destroy the surface
while the video backend is initializing, otherwise the video
backend may reference nullptr.
I've also cleaned up the logic for when to destroy the surface.
Note that the comment in EmulationFragment.java about only being
able to destroy the surface when emulation is running is not true
anymore (due to de632fc, it seems like).
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/Core/Core.cpp | 12 | ||||
| -rw-r--r-- | Source/Core/Core/Core.h | 1 |
2 files changed, 12 insertions, 1 deletions
diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 5908cc1347..4030ec9acc 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -94,6 +94,7 @@ static bool s_is_stopping = false; static bool s_hardware_initialized = false; static bool s_is_started = false; static Common::Flag s_is_booting; +static Common::Event s_done_booting; static std::thread s_emu_thread; static StateChangedCallbackFunc s_on_state_changed_callback; @@ -236,6 +237,8 @@ bool Init(std::unique_ptr<BootParameters> boot, const WindowSystemInfo& wsi) g_video_backend->PrepareWindow(wsi); // Start the emu thread + s_done_booting.Reset(); + s_is_booting.Set(); s_emu_thread = std::thread(EmuThread, std::move(boot), wsi); return true; } @@ -412,11 +415,11 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path, static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi) { 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_done_booting.Set(); s_is_started = false; s_is_stopping = false; s_wants_determinism = false; @@ -539,6 +542,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi // The hardware is initialized. s_hardware_initialized = true; s_is_booting.Clear(); + s_done_booting.Set(); // Set execution state to known values (CPU/FIFO/Audio Paused) CPU::Break(); @@ -662,6 +666,12 @@ State GetState() return State::Uninitialized; } +void WaitUntilDoneBooting() +{ + if (s_is_booting.IsSet() || !s_hardware_initialized) + s_done_booting.Wait(); +} + static std::string GenerateScreenshotFolderPath() { const std::string& gameId = SConfig::GetInstance().GetGameID(); diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h index 530079b8ab..4015b98e15 100644 --- a/Source/Core/Core/Core.h +++ b/Source/Core/Core/Core.h @@ -56,6 +56,7 @@ bool WantsDeterminism(); // [NOT THREADSAFE] For use by Host only void SetState(State state); State GetState(); +void WaitUntilDoneBooting(); void SaveScreenShot(bool wait_for_completion = false); void SaveScreenShot(std::string_view name, bool wait_for_completion = false); |
