mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2025-07-21 03:52:48 +00:00
Prevent racing connection start and stop
This commit is contained in:
parent
b3a1938c1d
commit
7651ce5e84
@ -63,9 +63,13 @@ public class NvConnection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void stop() {
|
public void stop() {
|
||||||
|
// Moonlight-core is not thread-safe with respect to connection start and stop, so
|
||||||
|
// we must not invoke that functionality in parallel.
|
||||||
|
synchronized (MoonBridge.class) {
|
||||||
MoonBridge.stopConnection();
|
MoonBridge.stopConnection();
|
||||||
MoonBridge.cleanupBridge();
|
MoonBridge.cleanupBridge();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean startApp() throws XmlPullParserException, IOException
|
private boolean startApp() throws XmlPullParserException, IOException
|
||||||
{
|
{
|
||||||
@ -210,6 +214,13 @@ public class NvConnection {
|
|||||||
private void establishConnection() {
|
private void establishConnection() {
|
||||||
String appName = context.streamConfig.getApp().getAppName();
|
String appName = context.streamConfig.getApp().getAppName();
|
||||||
|
|
||||||
|
try {
|
||||||
|
context.serverAddress = InetAddress.getByName(host);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
context.connListener.connectionTerminated(-1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
context.connListener.stageStarting(appName);
|
context.connListener.stageStarting(appName);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -234,23 +245,20 @@ public class NvConnection {
|
|||||||
context.videoCapabilities);
|
context.videoCapabilities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start(AudioRenderer audioRenderer, VideoDecoderRenderer videoDecoderRenderer, NvConnectionListener connectionListener)
|
public void start(final AudioRenderer audioRenderer, final VideoDecoderRenderer videoDecoderRenderer, final NvConnectionListener connectionListener)
|
||||||
{
|
{
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
public void run() {
|
||||||
|
// Moonlight-core is not thread-safe with respect to connection start and stop, so
|
||||||
|
// we must not invoke that functionality in parallel.
|
||||||
|
synchronized (MoonBridge.class) {
|
||||||
MoonBridge.setupBridge(videoDecoderRenderer, audioRenderer, connectionListener);
|
MoonBridge.setupBridge(videoDecoderRenderer, audioRenderer, connectionListener);
|
||||||
context.connListener = connectionListener;
|
context.connListener = connectionListener;
|
||||||
context.videoCapabilities = videoDecoderRenderer.getCapabilities();
|
context.videoCapabilities = videoDecoderRenderer.getCapabilities();
|
||||||
|
|
||||||
new Thread(new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
context.serverAddress = InetAddress.getByName(host);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
context.connListener.connectionTerminated(-1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
establishConnection();
|
establishConnection();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user