mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-19 11:03:01 +00:00
Fix cleanup on stream connection failure
This commit is contained in:
parent
864bcadcb2
commit
63e2fd447d
@ -1,7 +1,7 @@
|
||||
package com.limelight.nvstream.av.audio;
|
||||
|
||||
public interface AudioRenderer {
|
||||
void setup(int audioConfiguration);
|
||||
int setup(int audioConfiguration);
|
||||
|
||||
void playDecodedAudio(byte[] audioData);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.limelight.nvstream.av.video;
|
||||
|
||||
public abstract class VideoDecoderRenderer {
|
||||
public abstract boolean setup(int format, int width, int height, int redrawRate);
|
||||
public abstract int setup(int format, int width, int height, int redrawRate);
|
||||
|
||||
public abstract int submitDecodeUnit(byte[] frameData);
|
||||
|
||||
|
@ -5,6 +5,8 @@ import com.limelight.nvstream.av.audio.AudioRenderer;
|
||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||
|
||||
public class MoonBridge {
|
||||
/* See documentation in Limelight.h for information about these functions and constants */
|
||||
|
||||
public static final int AUDIO_CONFIGURATION_STEREO = 0;
|
||||
public static final int AUDIO_CONFIGURATION_51_SURROUND = 1;
|
||||
|
||||
@ -31,9 +33,12 @@ public class MoonBridge {
|
||||
return slices << 24;
|
||||
}
|
||||
|
||||
public static void bridgeDrSetup(int videoFormat, int width, int height, int redrawRate) {
|
||||
public static int bridgeDrSetup(int videoFormat, int width, int height, int redrawRate) {
|
||||
if (videoRenderer != null) {
|
||||
videoRenderer.setup(videoFormat, width, height, redrawRate);
|
||||
return videoRenderer.setup(videoFormat, width, height, redrawRate);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,9 +57,12 @@ public class MoonBridge {
|
||||
}
|
||||
}
|
||||
|
||||
public static void bridgeArInit(int audioConfiguration) {
|
||||
public static int bridgeArInit(int audioConfiguration) {
|
||||
if (audioRenderer != null) {
|
||||
audioRenderer.setup(audioConfiguration);
|
||||
return audioRenderer.setup(audioConfiguration);
|
||||
}
|
||||
else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -69,10 +69,10 @@ JNIEXPORT void JNICALL
|
||||
Java_com_limelight_nvstream_jni_MoonBridge_init(JNIEnv *env, jobject class) {
|
||||
(*env)->GetJavaVM(env, &JVM);
|
||||
GlobalBridgeClass = (*env)->NewGlobalRef(env, (*env)->FindClass(env, "com/limelight/nvstream/jni/MoonBridge"));
|
||||
BridgeDrSetupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSetup", "(IIII)V");
|
||||
BridgeDrSetupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSetup", "(IIII)I");
|
||||
BridgeDrCleanupMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrCleanup", "()V");
|
||||
BridgeDrSubmitDecodeUnitMethod = (*env)->GetStaticMethodID(env, class, "bridgeDrSubmitDecodeUnit", "([B)I");
|
||||
BridgeArInitMethod = (*env)->GetStaticMethodID(env, class, "bridgeArInit", "(I)V");
|
||||
BridgeArInitMethod = (*env)->GetStaticMethodID(env, class, "bridgeArInit", "(I)I");
|
||||
BridgeArCleanupMethod = (*env)->GetStaticMethodID(env, class, "bridgeArCleanup", "()V");
|
||||
BridgeArPlaySampleMethod = (*env)->GetStaticMethodID(env, class, "bridgeArPlaySample", "([B)V");
|
||||
BridgeClStageStartingMethod = (*env)->GetStaticMethodID(env, class, "bridgeClStageStarting", "(I)V");
|
||||
@ -84,14 +84,20 @@ Java_com_limelight_nvstream_jni_MoonBridge_init(JNIEnv *env, jobject class) {
|
||||
BridgeClDisplayTransientMessageMethod = (*env)->GetStaticMethodID(env, class, "bridgeClDisplayTransientMessage", "(Ljava/lang/String;)V");
|
||||
}
|
||||
|
||||
void BridgeDrSetup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) {
|
||||
int BridgeDrSetup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags) {
|
||||
JNIEnv* env = GetThreadEnv();
|
||||
int err;
|
||||
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeDrSetupMethod, videoFormat, width, height, redrawRate);
|
||||
err = (*env)->CallStaticIntMethod(env, GlobalBridgeClass, BridgeDrSetupMethod, videoFormat, width, height, redrawRate);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
err = -1;
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
void BridgeDrCleanup(void) {
|
||||
@ -134,29 +140,42 @@ int BridgeDrSubmitDecodeUnit(PDECODE_UNIT decodeUnit) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
void BridgeArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||
int BridgeArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig) {
|
||||
JNIEnv* env = GetThreadEnv();
|
||||
int err;
|
||||
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(&OpusConfig, opusConfig, sizeof(*opusConfig));
|
||||
Decoder = opus_multistream_decoder_create(opusConfig->sampleRate,
|
||||
opusConfig->channelCount,
|
||||
opusConfig->streams,
|
||||
opusConfig->coupledStreams,
|
||||
opusConfig->mapping,
|
||||
&err);
|
||||
err = (*env)->CallStaticIntMethod(env, GlobalBridgeClass, BridgeArInitMethod, audioConfiguration);
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
err = -1;
|
||||
}
|
||||
if (err == 0) {
|
||||
memcpy(&OpusConfig, opusConfig, sizeof(*opusConfig));
|
||||
Decoder = opus_multistream_decoder_create(opusConfig->sampleRate,
|
||||
opusConfig->channelCount,
|
||||
opusConfig->streams,
|
||||
opusConfig->coupledStreams,
|
||||
opusConfig->mapping,
|
||||
&err);
|
||||
if (Decoder == NULL) {
|
||||
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeArCleanupMethod);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
(*env)->CallStaticVoidMethod(env, GlobalBridgeClass, BridgeArInitMethod, audioConfiguration);
|
||||
return err;
|
||||
}
|
||||
|
||||
void BridgeArCleanup() {
|
||||
JNIEnv* env = GetThreadEnv();
|
||||
|
||||
opus_multistream_decoder_destroy(Decoder);
|
||||
if (Decoder != NULL) {
|
||||
opus_multistream_decoder_destroy(Decoder);
|
||||
Decoder = NULL;
|
||||
}
|
||||
|
||||
if ((*env)->ExceptionCheck(env)) {
|
||||
return;
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit ec6c5691302a846100760536440c5e240a1783a8
|
||||
Subproject commit 2d7bf5be828492c2a18b4ea84b526fde60273520
|
Loading…
x
Reference in New Issue
Block a user