mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 12:03:02 +00:00
Remove starting app stage from under the lock
This commit is contained in:
parent
636c20d67b
commit
8f3eecd980
@ -214,52 +214,48 @@ public class NvConnection {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void establishConnection() {
|
|
||||||
String appName = context.streamConfig.getApp().getAppName();
|
|
||||||
|
|
||||||
try {
|
|
||||||
context.serverAddress = InetAddress.getByName(host);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
context.connListener.connectionTerminated(-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
context.connListener.stageStarting(appName);
|
|
||||||
|
|
||||||
try {
|
|
||||||
startApp();
|
|
||||||
context.connListener.stageComplete(appName);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
context.connListener.displayMessage(e.getMessage());
|
|
||||||
context.connListener.stageFailed(appName, 0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ByteBuffer ib = ByteBuffer.allocate(16);
|
|
||||||
ib.putInt(context.riKeyId);
|
|
||||||
|
|
||||||
MoonBridge.startConnection(context.serverAddress.getHostAddress(),
|
|
||||||
context.serverAppVersion, context.serverGfeVersion,
|
|
||||||
context.negotiatedWidth, context.negotiatedHeight,
|
|
||||||
context.negotiatedFps, context.streamConfig.getBitrate(),
|
|
||||||
context.streamConfig.getRemote(), context.streamConfig.getAudioConfiguration(),
|
|
||||||
context.streamConfig.getHevcSupported(), context.riKey.getEncoded(), ib.array(),
|
|
||||||
context.videoCapabilities);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void start(final AudioRenderer audioRenderer, final VideoDecoderRenderer videoDecoderRenderer, final NvConnectionListener connectionListener)
|
public void start(final AudioRenderer audioRenderer, final VideoDecoderRenderer videoDecoderRenderer, final NvConnectionListener connectionListener)
|
||||||
{
|
{
|
||||||
new Thread(new Runnable() {
|
new Thread(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
|
context.connListener = connectionListener;
|
||||||
|
context.videoCapabilities = videoDecoderRenderer.getCapabilities();
|
||||||
|
|
||||||
|
String appName = context.streamConfig.getApp().getAppName();
|
||||||
|
|
||||||
|
try {
|
||||||
|
context.serverAddress = InetAddress.getByName(host);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
context.connListener.connectionTerminated(-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.connListener.stageStarting(appName);
|
||||||
|
|
||||||
|
try {
|
||||||
|
startApp();
|
||||||
|
context.connListener.stageComplete(appName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
context.connListener.displayMessage(e.getMessage());
|
||||||
|
context.connListener.stageFailed(appName, 0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuffer ib = ByteBuffer.allocate(16);
|
||||||
|
ib.putInt(context.riKeyId);
|
||||||
|
|
||||||
// Moonlight-core is not thread-safe with respect to connection start and stop, so
|
// Moonlight-core is not thread-safe with respect to connection start and stop, so
|
||||||
// we must not invoke that functionality in parallel.
|
// we must not invoke that functionality in parallel.
|
||||||
synchronized (MoonBridge.class) {
|
synchronized (MoonBridge.class) {
|
||||||
MoonBridge.setupBridge(videoDecoderRenderer, audioRenderer, connectionListener);
|
MoonBridge.setupBridge(videoDecoderRenderer, audioRenderer, connectionListener);
|
||||||
context.connListener = connectionListener;
|
MoonBridge.startConnection(context.serverAddress.getHostAddress(),
|
||||||
context.videoCapabilities = videoDecoderRenderer.getCapabilities();
|
context.serverAppVersion, context.serverGfeVersion,
|
||||||
|
context.negotiatedWidth, context.negotiatedHeight,
|
||||||
establishConnection();
|
context.negotiatedFps, context.streamConfig.getBitrate(),
|
||||||
|
context.streamConfig.getRemote(), context.streamConfig.getAudioConfiguration(),
|
||||||
|
context.streamConfig.getHevcSupported(), context.riKey.getEncoded(), ib.array(),
|
||||||
|
context.videoCapabilities);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user