From 2e2f09be009dffc604a480ea3dfd3fa7adfb9b94 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Sun, 5 Nov 2017 13:49:06 -0800 Subject: [PATCH] Fix frame drops when stopping the stream --- app/src/main/java/com/limelight/Game.java | 12 +++++++++++- moonlight-common | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index a286e12b..cfc9c92c 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -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(); } } diff --git a/moonlight-common b/moonlight-common index 83423959..a5a40298 160000 --- a/moonlight-common +++ b/moonlight-common @@ -1 +1 @@ -Subproject commit 83423959a1b69440e68d6640bf810d82d45c139e +Subproject commit a5a402981fc2524b0a6a71971b7cdf9f123ff457