From fdbc9397a7cb93eeac29481effb71eacbb74d24b Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 9 Jun 2023 22:24:32 +0200 Subject: [PATCH] Name Java threads Give a user-friendly name to Java threads created by the server. --- .../src/main/java/com/genymobile/scrcpy/AudioEncoder.java | 8 ++++---- .../main/java/com/genymobile/scrcpy/AudioRawRecorder.java | 2 +- .../src/main/java/com/genymobile/scrcpy/Controller.java | 2 +- .../java/com/genymobile/scrcpy/DeviceMessageSender.java | 2 +- .../main/java/com/genymobile/scrcpy/ScreenEncoder.java | 2 +- server/src/main/java/com/genymobile/scrcpy/Server.java | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java b/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java index 108bbaa1..bec79b05 100644 --- a/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/AudioEncoder.java @@ -134,7 +134,7 @@ public final class AudioEncoder implements AsyncProcessor { Ln.d("Audio encoder stopped"); listener.onTerminated(fatalError); } - }); + }, "audio-encoder"); thread.start(); } @@ -183,7 +183,7 @@ public final class AudioEncoder implements AsyncProcessor { Codec codec = streamer.getCodec(); mediaCodec = createMediaCodec(codec, encoderName); - mediaCodecThread = new HandlerThread("AudioEncoder"); + mediaCodecThread = new HandlerThread("media-codec"); mediaCodecThread.start(); MediaFormat format = createFormat(codec.getMimeType(), bitRate, codecOptions); @@ -201,7 +201,7 @@ public final class AudioEncoder implements AsyncProcessor { } finally { end(); } - }); + }, "audio-in"); outputThread = new Thread(() -> { try { @@ -216,7 +216,7 @@ public final class AudioEncoder implements AsyncProcessor { } finally { end(); } - }); + }, "audio-out"); mediaCodec.start(); mediaCodecStarted = true; diff --git a/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java b/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java index 2fc8c887..7d2adade 100644 --- a/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java +++ b/server/src/main/java/com/genymobile/scrcpy/AudioRawRecorder.java @@ -69,7 +69,7 @@ public final class AudioRawRecorder implements AsyncProcessor { Ln.d("Audio recorder stopped"); listener.onTerminated(fatalError); } - }); + }, "audio-raw"); thread.start(); } diff --git a/server/src/main/java/com/genymobile/scrcpy/Controller.java b/server/src/main/java/com/genymobile/scrcpy/Controller.java index 9a4e275a..733a2032 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Controller.java +++ b/server/src/main/java/com/genymobile/scrcpy/Controller.java @@ -95,7 +95,7 @@ public class Controller implements AsyncProcessor { Ln.d("Controller stopped"); listener.onTerminated(true); } - }); + }, "control-recv"); thread.start(); sender.start(); } diff --git a/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java b/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java index 0ef2a9ee..628c1d3c 100644 --- a/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java +++ b/server/src/main/java/com/genymobile/scrcpy/DeviceMessageSender.java @@ -60,7 +60,7 @@ public final class DeviceMessageSender { } finally { Ln.d("Device message sender stopped"); } - }); + }, "control-send"); thread.start(); } diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index d56e5d27..ce7c2838 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -299,7 +299,7 @@ public class ScreenEncoder implements Device.RotationListener, Device.FoldListen Ln.d("Screen streaming stopped"); listener.onTerminated(true); } - }); + }, "video"); thread.start(); } diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index 214ac27d..91e6f40a 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -185,7 +185,7 @@ public final class Server { } private static Thread startInitThread(final Options options) { - Thread thread = new Thread(() -> initAndCleanUp(options)); + Thread thread = new Thread(() -> initAndCleanUp(options), "init-cleanup"); thread.start(); return thread; }