Fix frame drops when stopping the stream

This commit is contained in:
Cameron Gutman
2017-11-05 13:49:06 -08:00
parent c402103fe3
commit 2e2f09be00
2 changed files with 12 additions and 2 deletions

View File

@@ -969,7 +969,17 @@ public class Game extends Activity implements SurfaceHolder.Callback,
private void stopConnection() {
if (connecting || connected) {
connecting = connected = false;
conn.stop();
// Stop may take a few hundred ms to do some network I/O to tell
// the server we're going away and clean up. Let it run in a separate
// thread to keep things smooth for the UI. Inside moonlight-common,
// we prevent another thread from starting a connection before and
// during the process of stopping this one.
new Thread() {
public void run() {
conn.stop();
}
}.start();
}
}