mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-12-27 21:46:44 +00:00
android: jni: native: Tighten up emulation start/stop signaling.
This commit is contained in:
parent
1e94d16dad
commit
9ba67eab4f
|
@ -61,7 +61,7 @@ public:
|
|||
}
|
||||
|
||||
bool IsRunning() const {
|
||||
return system.IsPoweredOn();
|
||||
return is_running.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
const Core::PerfStatsResults& PerfStats() const {
|
||||
|
@ -95,7 +95,8 @@ public:
|
|||
system.GetFileSystemController().CreateFactories(*system.GetFilesystem());
|
||||
|
||||
// Load the ROM.
|
||||
const Core::SystemResultStatus load_result{system.Load(EmulationSession::GetInstance().Window(), filepath)};
|
||||
const Core::SystemResultStatus load_result{
|
||||
system.Load(EmulationSession::GetInstance().Window(), filepath)};
|
||||
if (load_result != Core::SystemResultStatus::Success) {
|
||||
return load_result;
|
||||
}
|
||||
|
@ -124,19 +125,23 @@ public:
|
|||
}
|
||||
|
||||
void HaltEmulation() {
|
||||
is_running.store(false, std::memory_order_relaxed);
|
||||
cv.notify_one();
|
||||
}
|
||||
|
||||
void RunEmulation() {
|
||||
std::unique_lock lock(mutex);
|
||||
|
||||
is_running.store(true, std::memory_order_relaxed);
|
||||
|
||||
void(system.Run());
|
||||
|
||||
if (system.DebuggerEnabled()) {
|
||||
system.InitializeDebugger();
|
||||
}
|
||||
|
||||
while (cv.wait_for(lock, std::chrono::seconds (1)) == std::cv_status::timeout) {
|
||||
while (!cv.wait_for(lock, std::chrono::seconds(1),
|
||||
[&]() { return !is_running.load(std::memory_order_relaxed); })) {
|
||||
std::scoped_lock perf_stats_lock(perf_stats_mutex);
|
||||
perf_stats = system.GetAndResetPerfStats();
|
||||
}
|
||||
|
@ -157,6 +162,7 @@ private:
|
|||
std::unique_ptr<EmuWindow_Android> window;
|
||||
std::mutex mutex;
|
||||
std::condition_variable_any cv;
|
||||
std::atomic_bool is_running{};
|
||||
};
|
||||
|
||||
/*static*/ EmulationSession EmulationSession::s_instance;
|
||||
|
@ -231,8 +237,8 @@ void Java_org_yuzu_yuzu_1emu_NativeLibrary_NotifyOrientationChange(JNIEnv* env,
|
|||
jint layout_option,
|
||||
jint rotation) {}
|
||||
|
||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_SetUserDirectory(
|
||||
[[maybe_unused]] JNIEnv* env, [[maybe_unused]] jclass clazz,
|
||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_SetUserDirectory([[maybe_unused]] JNIEnv* env,
|
||||
[[maybe_unused]] jclass clazz,
|
||||
[[maybe_unused]] jstring j_directory) {}
|
||||
|
||||
void Java_org_yuzu_yuzu_1emu_NativeLibrary_UnPauseEmulation([[maybe_unused]] JNIEnv* env,
|
||||
|
@ -291,11 +297,11 @@ jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_onGamePadAxisEvent([[maybe_unused
|
|||
}
|
||||
|
||||
jboolean Java_org_yuzu_yuzu_1emu_NativeLibrary_onTouchEvent([[maybe_unused]] JNIEnv* env,
|
||||
[[maybe_unused]] jclass clazz,
|
||||
jfloat x, jfloat y,
|
||||
jboolean pressed) {
|
||||
[[maybe_unused]] jclass clazz, jfloat x,
|
||||
jfloat y, jboolean pressed) {
|
||||
if (EmulationSession::GetInstance().IsRunning()) {
|
||||
return static_cast<jboolean>(EmulationSession::GetInstance().Window().OnTouchEvent(x, y, pressed));
|
||||
return static_cast<jboolean>(
|
||||
EmulationSession::GetInstance().Window().OnTouchEvent(x, y, pressed));
|
||||
}
|
||||
return static_cast<jboolean>(false);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue