From 8b7055f33ee69a758c324a087c00d3ee03eeec19 Mon Sep 17 00:00:00 2001 From: SachinVin Date: Fri, 9 Apr 2021 00:19:13 +0530 Subject: [PATCH] android: native.cpp: rename `is_running` to `stop_run` and invert uses --- src/android/app/src/main/jni/native.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index 931b704d8..6238d30f4 100644 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -47,7 +47,7 @@ ANativeWindow* s_surf; std::unique_ptr window; -std::atomic is_running{false}; +std::atomic stop_run{true}; std::atomic pause_emulation{false}; std::mutex paused_mutex; @@ -214,7 +214,7 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) { auto& telemetry_session = Core::System::GetInstance().TelemetrySession(); telemetry_session.AddField(Telemetry::FieldType::App, "Frontend", "SDL"); - is_running = true; + stop_run = false; pause_emulation = false; LoadDiskCacheProgress(VideoCore::LoadCallbackStage::Prepare, 0, 0); @@ -224,7 +224,7 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) { cpu_context->MakeCurrent(); } - system.Renderer().Rasterizer()->LoadDiskResources(!is_running, &LoadDiskCacheProgress); + system.Renderer().Rasterizer()->LoadDiskResources(stop_run, &LoadDiskCacheProgress); if (Settings::values.use_asynchronous_gpu_emulation) { cpu_context->DoneCurrent(); @@ -250,7 +250,7 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) { system.CoreTiming().ScheduleEvent(audio_stretching_ticks, audio_stretching_event); // Start running emulation - while (is_running) { + while (!stop_run) { if (!pause_emulation) { const auto result = system.RunLoop(); if (result == Core::System::ResultStatus::Success) { @@ -273,7 +273,7 @@ static Core::System::ResultStatus RunCitra(const std::string& filepath) { Settings::values.volume = 0; std::unique_lock pause_lock(paused_mutex); - running_cv.wait(pause_lock, [] { return !pause_emulation || !is_running; }); + running_cv.wait(pause_lock, [] { return !pause_emulation || stop_run; }); window->PollEvents(); } } @@ -305,7 +305,7 @@ void Java_org_citra_citra_1emu_NativeLibrary_SurfaceDestroyed(JNIEnv* env, } void Java_org_citra_citra_1emu_NativeLibrary_DoFrame(JNIEnv* env, [[maybe_unused]] jclass clazz) { - if (!is_running || pause_emulation) { + if (stop_run || pause_emulation) { return; } window->TryPresenting(); @@ -391,7 +391,7 @@ void Java_org_citra_citra_1emu_NativeLibrary_PauseEmulation(JNIEnv* env, void Java_org_citra_citra_1emu_NativeLibrary_StopEmulation(JNIEnv* env, [[maybe_unused]] jclass clazz) { - is_running = false; + stop_run = true; pause_emulation = false; window->StopPresenting(); running_cv.notify_all(); @@ -399,7 +399,7 @@ void Java_org_citra_citra_1emu_NativeLibrary_StopEmulation(JNIEnv* env, jboolean Java_org_citra_citra_1emu_NativeLibrary_IsRunning(JNIEnv* env, [[maybe_unused]] jclass clazz) { - return static_cast(is_running); + return static_cast(!stop_run); } jboolean Java_org_citra_citra_1emu_NativeLibrary_onGamePadEvent(JNIEnv* env, @@ -619,8 +619,8 @@ void Java_org_citra_citra_1emu_NativeLibrary_Run__Ljava_lang_String_2(JNIEnv* en jstring j_path) { const std::string path = GetJString(env, j_path); - if (is_running) { - is_running = false; + if (!stop_run) { + stop_run = true; running_cv.notify_all(); }