Release boot session data during Netplay cleanup
Boot session data is already handled when the game is booted so this is just fallback in case the game launch fails in some weird way. Add missing @Keep annotations to functions called from C++
This commit is contained in:
+15
-2
@@ -27,8 +27,6 @@ import org.dolphinemu.dolphinemu.features.netplay.model.ConnectionType
|
|||||||
import org.dolphinemu.dolphinemu.features.netplay.model.NetplayMessage
|
import org.dolphinemu.dolphinemu.features.netplay.model.NetplayMessage
|
||||||
import org.dolphinemu.dolphinemu.features.netplay.model.Player
|
import org.dolphinemu.dolphinemu.features.netplay.model.Player
|
||||||
|
|
||||||
//TODO add other necessary @Keep annotations
|
|
||||||
//TODO clear boot session data at appropriate time
|
|
||||||
object Netplay {
|
object Netplay {
|
||||||
@Keep
|
@Keep
|
||||||
private var netPlayClientPointer: Long = 0
|
private var netPlayClientPointer: Long = 0
|
||||||
@@ -123,6 +121,11 @@ object Netplay {
|
|||||||
sessionScope?.cancel()
|
sessionScope?.cancel()
|
||||||
sessionScope = null
|
sessionScope = null
|
||||||
|
|
||||||
|
if (bootSessionDataPointer != 0L) {
|
||||||
|
ReleaseBootSessionData()
|
||||||
|
bootSessionDataPointer = 0
|
||||||
|
}
|
||||||
|
|
||||||
if (netPlayClientPointer != 0L) {
|
if (netPlayClientPointer != 0L) {
|
||||||
ReleaseNetplayClient()
|
ReleaseNetplayClient()
|
||||||
netPlayClientPointer = 0
|
netPlayClientPointer = 0
|
||||||
@@ -158,6 +161,9 @@ object Netplay {
|
|||||||
@JvmStatic
|
@JvmStatic
|
||||||
external fun adjustPadBufferSize(buffer: Int)
|
external fun adjustPadBufferSize(buffer: Int)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
private external fun ReleaseBootSessionData()
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
private external fun ReleaseNetplayClient()
|
private external fun ReleaseNetplayClient()
|
||||||
|
|
||||||
@@ -170,6 +176,7 @@ object Netplay {
|
|||||||
|
|
||||||
// NetPlayUI callbacks
|
// NetPlayUI callbacks
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onBootGame(gameFilePath: String, bootSessionDataPointer: Long) {
|
fun onBootGame(gameFilePath: String, bootSessionDataPointer: Long) {
|
||||||
this.bootSessionDataPointer = bootSessionDataPointer
|
this.bootSessionDataPointer = bootSessionDataPointer
|
||||||
@@ -189,31 +196,37 @@ object Netplay {
|
|||||||
_connectionLost.trySend(Unit)
|
_connectionLost.trySend(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onConnectionError(message: String) {
|
fun onConnectionError(message: String) {
|
||||||
_connectionErrors.trySend(message)
|
_connectionErrors.trySend(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onUpdate(players: Array<Player>) {
|
fun onUpdate(players: Array<Player>) {
|
||||||
_players.tryEmit(players.toList())
|
_players.tryEmit(players.toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onChatMessageReceived(message: String) {
|
fun onChatMessageReceived(message: String) {
|
||||||
_chatMessages.tryEmit(message)
|
_chatMessages.tryEmit(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onHostInputAuthorityChanged(enabled: Boolean) {
|
fun onHostInputAuthorityChanged(enabled: Boolean) {
|
||||||
_hostInputAuthorityEnabled.tryEmit(enabled)
|
_hostInputAuthorityEnabled.tryEmit(enabled)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onGameChanged(game: String) {
|
fun onGameChanged(game: String) {
|
||||||
_game.tryEmit(game)
|
_game.tryEmit(game)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Keep
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun onPadBufferChanged(buffer: Int) {
|
fun onPadBufferChanged(buffer: Int) {
|
||||||
// Only for remote pad buffer settings. Ignore local max buffer changes.
|
// Only for remote pad buffer settings. Ignore local max buffer changes.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
#include "Core/Boot/Boot.h"
|
||||||
#include "Core/Config/NetplaySettings.h"
|
#include "Core/Config/NetplaySettings.h"
|
||||||
#include "Core/NetPlayClient.h"
|
#include "Core/NetPlayClient.h"
|
||||||
#include "UICommon/GameFile.h"
|
#include "UICommon/GameFile.h"
|
||||||
@@ -166,6 +167,15 @@ Java_org_dolphinemu_dolphinemu_features_netplay_Netplay_Join(JNIEnv* env, jclass
|
|||||||
return reinterpret_cast<jlong>(client);
|
return reinterpret_cast<jlong>(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL
|
||||||
|
Java_org_dolphinemu_dolphinemu_features_netplay_Netplay_ReleaseBootSessionData(JNIEnv* env, jclass)
|
||||||
|
{
|
||||||
|
auto* data = reinterpret_cast<BootSessionData*>(
|
||||||
|
env->GetStaticLongField(IDCache::GetNetplayClass(), IDCache::GetNetplayBootSessionDataPointer()));
|
||||||
|
delete data;
|
||||||
|
env->SetStaticLongField(IDCache::GetNetplayClass(), IDCache::GetNetplayBootSessionDataPointer(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_dolphinemu_dolphinemu_features_netplay_Netplay_ReleaseNetplayClient(JNIEnv* env, jclass)
|
Java_org_dolphinemu_dolphinemu_features_netplay_Netplay_ReleaseNetplayClient(JNIEnv* env, jclass)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user