Skip to content

Commit

Permalink
Configure init and cleanup asynchronously
Browse files Browse the repository at this point in the history
Accessing the settings (like --show-touches) on start should not delay
screen mirroring.

PR #2802 <#2802>
  • Loading branch information
rom1v committed Nov 18, 2021
1 parent c29a0bf commit ee93d2a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion server/src/main/java/com/genymobile/scrcpy/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static void scrcpy(Options options) throws IOException {
final Device device = new Device(options);
List<CodecOption> codecOptions = CodecOption.parse(options.getCodecOptions());

initAndCleanUp(options);
Thread initThread = startInitThread(options);

boolean tunnelForward = options.isTunnelForward();

Expand Down Expand Up @@ -95,6 +95,7 @@ public void onClipboardTextChanged(String text) {
// this is expected on close
Ln.d("Screen streaming stopped");
} finally {
initThread.interrupt();
if (controllerThread != null) {
controllerThread.interrupt();
}
Expand All @@ -105,6 +106,17 @@ public void onClipboardTextChanged(String text) {
}
}

private static Thread startInitThread(final Options options) {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
initAndCleanUp(options);
}
});
thread.start();
return thread;
}

private static Thread startController(final Controller controller) {
Thread thread = new Thread(new Runnable() {
@Override
Expand Down

0 comments on commit ee93d2a

Please sign in to comment.