summaryrefslogtreecommitdiff
path: root/Source/Android
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2025-01-10 04:50:34 +0100
committerGitHub <noreply@github.com>2025-01-10 04:50:34 +0100
commit98a80239f1e9492f7d81a3634d0ba24c35591735 (patch)
treefe496d37508f1c9a017b746f42045dfbb95b79f2 /Source/Android
parent75abda6a3a1a9055e914d951a8c54b0423647b58 (diff)
parentdcf8ab01898eb71bcf4aca1fa527e6cd196367da (diff)
Merge pull request #13030 from JosJuice/android-wait-for-surface-in-run
Android: Wait for surface in Run
Diffstat (limited to 'Source/Android')
-rw-r--r--Source/Android/jni/MainAndroid.cpp26
1 files changed, 18 insertions, 8 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp
index b6468ed85c..00b1b5db61 100644
--- a/Source/Android/jni/MainAndroid.cpp
+++ b/Source/Android/jni/MainAndroid.cpp
@@ -1,13 +1,9 @@
// Copyright 2003 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
-#include <EGL/egl.h>
-#include <android/log.h>
-#include <android/native_window_jni.h>
+#include <condition_variable>
#include <cstdio>
#include <cstdlib>
-#include <fmt/format.h>
-#include <jni.h>
#include <memory>
#include <mutex>
#include <optional>
@@ -15,6 +11,12 @@
#include <thread>
#include <utility>
+#include <EGL/egl.h>
+#include <android/log.h>
+#include <android/native_window_jni.h>
+#include <fmt/format.h>
+#include <jni.h>
+
#include "Common/AndroidAnalytics.h"
#include "Common/Assert.h"
#include "Common/CPUDetect.h"
@@ -77,6 +79,8 @@ Common::Event s_update_main_frame_event;
// This exists to prevent surfaces from being destroyed during the boot process,
// as that can lead to the boot process dereferencing nullptr.
std::mutex s_surface_lock;
+std::condition_variable s_surface_cv;
+
bool s_need_nonblocking_alert_msg;
Common::Flag s_is_booting;
@@ -482,6 +486,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceChang
if (g_presenter)
g_presenter->ChangeSurface(s_surf);
+
+ s_surface_cv.notify_all();
}
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestroyed(JNIEnv*,
@@ -515,6 +521,8 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SurfaceDestr
ANativeWindow_release(s_surf);
s_surf = nullptr;
}
+
+ s_surface_cv.notify_all();
}
JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_HasSurface(JNIEnv*, jclass)
@@ -606,12 +614,14 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
volume.GetDiscNumber()));
}
- WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf, s_surf);
- wsi.render_surface_scale = GetRenderSurfaceScale(env);
-
s_need_nonblocking_alert_msg = true;
std::unique_lock<std::mutex> surface_guard(s_surface_lock);
+ s_surface_cv.wait(surface_guard, []() { return s_surf != nullptr; });
+
+ WindowSystemInfo wsi(WindowSystemType::Android, nullptr, s_surf, s_surf);
+ wsi.render_surface_scale = GetRenderSurfaceScale(env);
+
if (BootManager::BootCore(Core::System::GetInstance(), std::move(boot), wsi))
{
static constexpr int WAIT_STEP = 25;