Configure init and cleanup asynchronously

Accessing the settings (like --show-touches) on start should not delay
screen mirroring.

PR #2802 <https://github.com/Genymobile/scrcpy/pull/2802>
This commit is contained in:
Romain Vimont 2021-11-17 10:29:41 +01:00
parent c29a0bf675
commit ee93d2aac1
1 changed files with 13 additions and 1 deletions

View File

@ -63,7 +63,7 @@ public final class Server {
final Device device = new Device(options);
List<CodecOption> codecOptions = CodecOption.parse(options.getCodecOptions());
initAndCleanUp(options);
Thread initThread = startInitThread(options);
boolean tunnelForward = options.isTunnelForward();
@ -95,6 +95,7 @@ public final class Server {
// this is expected on close
Ln.d("Screen streaming stopped");
} finally {
initThread.interrupt();
if (controllerThread != null) {
controllerThread.interrupt();
}
@ -105,6 +106,17 @@ public final class Server {
}
}
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