mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-08-12 04:09:36 -05:00
Make NetplaySession not a singleton
Create a new NetplaySession each time we try to join a netplay game. Hold onto it in NetplayManager so its available to the different activities that need to access it. Close the session when backing out of the netplay UI. Some guardrails in case things go out of sync: creating a session closes the old one if it is still around for some reason, finalizer in NetplaySession to release native resources if not closed explicitly for some reason. Profiling done to ensure all kotlin and native objects are successfully cleared / garbage collected.
This commit is contained in:
@@ -618,10 +618,10 @@ Java_org_dolphinemu_dolphinemu_NativeLibrary_Run___3Ljava_lang_String_2ZLjava_la
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RunNetPlay(
|
||||
JNIEnv* env, jclass, jobjectArray jPaths, jboolean jRiivolution)
|
||||
JNIEnv* env, jclass, jobjectArray jPaths, jboolean jRiivolution, jlong jBootSessionData)
|
||||
{
|
||||
auto boot_session_data = std::unique_ptr<BootSessionData>(reinterpret_cast<BootSessionData*>(
|
||||
env->GetStaticLongField(IDCache::GetNetplayClass(), IDCache::GetNetplayBootSessionDataPointer())));
|
||||
auto boot_session_data = std::unique_ptr<BootSessionData>(
|
||||
reinterpret_cast<BootSessionData*>(jBootSessionData));
|
||||
if (!boot_session_data)
|
||||
{
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetDisplayToastMsg(),
|
||||
@@ -629,7 +629,6 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_RunNetPlay(
|
||||
env->CallStaticVoidMethod(IDCache::GetNativeLibraryClass(), IDCache::GetFinishEmulationActivity());
|
||||
return;
|
||||
}
|
||||
env->SetStaticLongField(IDCache::GetNetplayClass(), IDCache::GetNetplayBootSessionDataPointer(), 0);
|
||||
Run(env, JStringArrayToVector(env, jPaths), jRiivolution, std::move(*boot_session_data));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user