diff --git a/core/emulator.cpp b/core/emulator.cpp index 4b09a5c88..161922fab 100644 --- a/core/emulator.cpp +++ b/core/emulator.cpp @@ -847,6 +847,7 @@ void Emulator::start() if (config::ThreadedRendering) { + const std::lock_guard lock(mutex); threadResult = std::async(std::launch::async, [this] { InitAudio(); @@ -881,6 +882,7 @@ void Emulator::start() bool Emulator::checkStatus() { try { + const std::lock_guard lock(mutex); if (threadResult.valid()) { auto result = threadResult.wait_for(std::chrono::seconds(0)); diff --git a/core/emulator.h b/core/emulator.h index 29f0fe3a5..e469fcb12 100644 --- a/core/emulator.h +++ b/core/emulator.h @@ -27,6 +27,7 @@ #include #include #include +#include void loadGameSpecificSettings(); void SaveSettings(); @@ -178,6 +179,7 @@ private: u32 stepRangeFrom = 0; u32 stepRangeTo = 0; bool stopRequested = false; + std::mutex mutex; }; extern Emulator emu;