diff options
| author | JosJuice <josjuice@gmail.com> | 2024-06-02 16:45:30 +0200 |
|---|---|---|
| committer | JosJuice <josjuice@gmail.com> | 2024-06-21 20:52:55 +0200 |
| commit | 72cf2bdb87f09deff22e1085de3290126aa4ad05 (patch) | |
| tree | a3c399edfaa7ee17bf9b08cf95f2862a5d8edff9 /Source/Android/jni/MainAndroid.cpp | |
| parent | 962230f91e06a60b2395de6f0974fdd213854d4c (diff) | |
Audit uses of IsRunning and GetState
Some pieces of code are calling IsRunning because there's some
particular action that only makes sense when emulation is running, for
instance showing the state of the emulated CPU. IsRunning is appropriate
to use for this. Then there are pieces of code that are calling
IsRunning because there's some particular thing they must avoid doing
e.g. when the CPU thread is running or IOS is running. IsRunning isn't
quite appropriate for this. Such code should also be checking for the
states Starting and Stopping. Keep in mind that:
* When the state is Starting, the state can asynchronously change to
Running at any time.
* When we try to stop the core, the state gets set to Stopping before we
take any action to actually stop things.
This commit adds a new method Core::IsUninitialized, and changes all
callers of IsRunning and GetState that look to me like they should be
changed.
Diffstat (limited to 'Source/Android/jni/MainAndroid.cpp')
| -rw-r--r-- | Source/Android/jni/MainAndroid.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Source/Android/jni/MainAndroid.cpp b/Source/Android/jni/MainAndroid.cpp index 66a0694a94..8febc6f633 100644 --- a/Source/Android/jni/MainAndroid.cpp +++ b/Source/Android/jni/MainAndroid.cpp @@ -118,8 +118,7 @@ void Host_Message(HostMessageID id) } else if (id == HostMessageID::WMUserStop) { - if (Core::IsRunning(Core::System::GetInstance())) - Core::QueueHostJob(&Core::Stop); + Core::QueueHostJob(&Core::Stop); } } @@ -272,13 +271,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetIsBooting JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunning(JNIEnv*, jclass) { - return s_is_booting.IsSet() || - static_cast<jboolean>(Core::IsRunning(Core::System::GetInstance())); -} - -JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndStarted(JNIEnv*, - jclass) -{ return static_cast<jboolean>(Core::IsRunning(Core::System::GetInstance())); } @@ -288,6 +280,13 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_IsRunningAndUnpaused(JNIEnv*, jclas return static_cast<jboolean>(Core::GetState(Core::System::GetInstance()) == Core::State::Running); } +JNIEXPORT jboolean JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_IsUninitialized(JNIEnv*, + jclass) +{ + return static_cast<jboolean>(Core::IsUninitialized(Core::System::GetInstance()) && + !s_is_booting.IsSet()); +} + JNIEXPORT jstring JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_GetVersionString(JNIEnv* env, jclass) { |
