Android: Add HostThreadLock where necessary
This commit is contained in:
parent
3519a7070d
commit
03f2f57edf
|
@ -11,6 +11,7 @@
|
||||||
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
#include "Core/ConfigLoaders/GameConfigLoader.h"
|
||||||
#include "Core/ConfigLoaders/IsSettingSaveable.h"
|
#include "Core/ConfigLoaders/IsSettingSaveable.h"
|
||||||
#include "jni/AndroidCommon/AndroidCommon.h"
|
#include "jni/AndroidCommon/AndroidCommon.h"
|
||||||
|
#include "jni/Host.h"
|
||||||
|
|
||||||
constexpr jint LAYER_BASE_OR_CURRENT = 0;
|
constexpr jint LAYER_BASE_OR_CURRENT = 0;
|
||||||
constexpr jint LAYER_BASE = 1;
|
constexpr jint LAYER_BASE = 1;
|
||||||
|
@ -122,6 +123,7 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_loadGameInis
|
||||||
jstring jGameId,
|
jstring jGameId,
|
||||||
jint jRevision)
|
jint jRevision)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
const std::string game_id = GetJString(env, jGameId);
|
const std::string game_id = GetJString(env, jGameId);
|
||||||
const u16 revision = static_cast<u16>(jRevision);
|
const u16 revision = static_cast<u16>(jRevision);
|
||||||
Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision));
|
Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision));
|
||||||
|
@ -131,6 +133,7 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_loadGameInis
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_unloadGameInis(JNIEnv*, jclass)
|
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_unloadGameInis(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
Config::RemoveLayer(Config::LayerType::GlobalGame);
|
Config::RemoveLayer(Config::LayerType::GlobalGame);
|
||||||
Config::RemoveLayer(Config::LayerType::LocalGame);
|
Config::RemoveLayer(Config::LayerType::LocalGame);
|
||||||
}
|
}
|
||||||
|
@ -138,6 +141,7 @@ Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_unloadGameIn
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_save(
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_save(
|
||||||
JNIEnv*, jclass, jint layer)
|
JNIEnv*, jclass, jint layer)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
return GetLayer(layer, {})->Save();
|
return GetLayer(layer, {})->Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,6 +149,7 @@ JNIEXPORT void JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteAllKeys(JNIEnv*, jclass,
|
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteAllKeys(JNIEnv*, jclass,
|
||||||
jint layer)
|
jint layer)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
return GetLayer(layer, {})->DeleteAllKeys();
|
return GetLayer(layer, {})->DeleteAllKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,6 +166,7 @@ JNIEXPORT jboolean JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteKey(
|
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_deleteKey(
|
||||||
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key)
|
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
const Config::Location location = GetLocation(env, file, section, key);
|
const Config::Location location = GetLocation(env, file, section, key);
|
||||||
const bool had_value = GetLayer(layer, location)->DeleteKey(location);
|
const bool had_value = GetLayer(layer, location)->DeleteKey(location);
|
||||||
if (had_value)
|
if (had_value)
|
||||||
|
@ -214,6 +220,7 @@ JNIEXPORT void JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setString(
|
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setString(
|
||||||
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jstring value)
|
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jstring value)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
return Set(layer, GetLocation(env, file, section, key), GetJString(env, value));
|
return Set(layer, GetLocation(env, file, section, key), GetJString(env, value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,18 +228,21 @@ JNIEXPORT void JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setBoolean(
|
Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setBoolean(
|
||||||
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jboolean value)
|
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jboolean value)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
return Set(layer, GetLocation(env, file, section, key), static_cast<bool>(value));
|
return Set(layer, GetLocation(env, file, section, key), static_cast<bool>(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setInt(
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setInt(
|
||||||
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jint value)
|
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jint value)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
return Set(layer, GetLocation(env, file, section, key), value);
|
return Set(layer, GetLocation(env, file, section, key), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setFloat(
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_features_settings_model_NativeConfig_setFloat(
|
||||||
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jfloat value)
|
JNIEnv* env, jclass, jint layer, jstring file, jstring section, jstring key, jfloat value)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
return Set(layer, GetLocation(env, file, section, key), value);
|
return Set(layer, GetLocation(env, file, section, key), value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,12 +489,14 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RefreshWiimo
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadConfig(JNIEnv*, jclass)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ReloadConfig(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
SConfig::GetInstance().LoadSettings();
|
SConfig::GetInstance().LoadSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_NativeLibrary_UpdateGCAdapterScanThread(JNIEnv*, jclass)
|
Java_org_dolphinemu_dolphinemu_NativeLibrary_UpdateGCAdapterScanThread(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
if (GCAdapter::UseAdapter())
|
if (GCAdapter::UseAdapter())
|
||||||
{
|
{
|
||||||
GCAdapter::StartScanThread();
|
GCAdapter::StartScanThread();
|
||||||
|
@ -507,6 +509,9 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_UpdateGCAdapterScanThread(JNIEnv*,
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(JNIEnv*, jclass)
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Initialize(JNIEnv*, jclass)
|
||||||
{
|
{
|
||||||
|
// InitControllers ends up calling config code, and some config callbacks use RunAsCPUThread
|
||||||
|
HostThreadLock guard;
|
||||||
|
|
||||||
UICommon::CreateDirectories();
|
UICommon::CreateDirectories();
|
||||||
Common::RegisterMsgAlertHandler(&MsgAlert);
|
Common::RegisterMsgAlertHandler(&MsgAlert);
|
||||||
Common::AndroidSetReportHandler(&ReportSend);
|
Common::AndroidSetReportHandler(&ReportSend);
|
||||||
|
@ -621,6 +626,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RunSystemMen
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env, jclass,
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_ChangeDisc(JNIEnv* env, jclass,
|
||||||
jstring jFile)
|
jstring jFile)
|
||||||
{
|
{
|
||||||
|
HostThreadLock guard;
|
||||||
const std::string path = GetJString(env, jFile);
|
const std::string path = GetJString(env, jFile);
|
||||||
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Change Disc: %s", path.c_str());
|
__android_log_print(ANDROID_LOG_INFO, DOLPHIN_TAG, "Change Disc: %s", path.c_str());
|
||||||
Core::RunAsCPUThread([&path] { Core::System::GetInstance().GetDVDInterface().ChangeDisc(path); });
|
Core::RunAsCPUThread([&path] { Core::System::GetInstance().GetDVDInterface().ChangeDisc(path); });
|
||||||
|
|
Loading…
Reference in New Issue