summaryrefslogtreecommitdiff
path: root/src/common/android/id_cache.h
diff options
context:
space:
mode:
authorGravatar t8952024-02-05 06:07:29 -0500
committerGravatar t8952024-02-08 13:45:26 -0500
commite7c4c8b993ce27a50b7a56f90247056048d20f7d (patch)
treeb87c275f4ea92092f7c8b6cdcb0f50d32819490f /src/common/android/id_cache.h
parentMerge pull request #12892 from liamwhite/serialization-stuff (diff)
downloadyuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.gz
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.tar.xz
yuzu-e7c4c8b993ce27a50b7a56f90247056048d20f7d.zip
android: Move JNI setup and helpers to common
Diffstat (limited to '')
-rw-r--r--src/common/android/id_cache.h (renamed from src/android/app/src/main/jni/id_cache.h)26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/android/app/src/main/jni/id_cache.h b/src/common/android/id_cache.h
index 00e48afc0..47802f96c 100644
--- a/src/android/app/src/main/jni/id_cache.h
+++ b/src/common/android/id_cache.h
@@ -3,20 +3,40 @@
3 3
4#pragma once 4#pragma once
5 5
6#include <future>
6#include <jni.h> 7#include <jni.h>
7 8
8#include "video_core/rasterizer_interface.h" 9#include "video_core/rasterizer_interface.h"
9 10
10namespace IDCache { 11namespace Common::Android {
11 12
12JNIEnv* GetEnvForThread(); 13JNIEnv* GetEnvForThread();
14
15/**
16 * Starts a new thread to run JNI. Intended to be used when you must run JNI from a fiber.
17 * @tparam T Typename of the return value for the work param
18 * @param work Lambda that runs JNI code. This function will take care of attaching this thread to
19 * the JVM
20 * @return The result from the work lambda param
21 */
22template <typename T = void>
23T RunJNIOnFiber(const std::function<T(JNIEnv*)>& work) {
24 std::future<T> j_result = std::async(std::launch::async, [&] {
25 auto env = GetEnvForThread();
26 return work(env);
27 });
28 return j_result.get();
29}
30
13jclass GetNativeLibraryClass(); 31jclass GetNativeLibraryClass();
32
14jclass GetDiskCacheProgressClass(); 33jclass GetDiskCacheProgressClass();
15jclass GetDiskCacheLoadCallbackStageClass(); 34jclass GetDiskCacheLoadCallbackStageClass();
16jclass GetGameDirClass(); 35jclass GetGameDirClass();
17jmethodID GetGameDirConstructor(); 36jmethodID GetGameDirConstructor();
18jmethodID GetExitEmulationActivity();
19jmethodID GetDiskCacheLoadProgress(); 37jmethodID GetDiskCacheLoadProgress();
38
39jmethodID GetExitEmulationActivity();
20jmethodID GetOnEmulationStarted(); 40jmethodID GetOnEmulationStarted();
21jmethodID GetOnEmulationStopped(); 41jmethodID GetOnEmulationStopped();
22jmethodID GetOnProgramChanged(); 42jmethodID GetOnProgramChanged();
@@ -65,4 +85,4 @@ jclass GetBooleanClass();
65jmethodID GetBooleanConstructor(); 85jmethodID GetBooleanConstructor();
66jfieldID GetBooleanValueField(); 86jfieldID GetBooleanValueField();
67 87
68} // namespace IDCache 88} // namespace Common::Android