From bdbf1f4eb7dac0f00c5419a99f23cd9f05e39871 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 31 Jan 2023 22:54:34 +0100 Subject: [PATCH] Move Workarounds call Workarounds are not specific to the screen encoder. Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com> --- .../java/com/genymobile/scrcpy/ScreenEncoder.java | 11 ----------- .../src/main/java/com/genymobile/scrcpy/Server.java | 7 +++++++ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index f0384e2c..c7f886b4 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -67,17 +67,6 @@ public class ScreenEncoder implements Device.RotationListener { } public void streamScreen(Device device, FileDescriptor fd) throws IOException { - Workarounds.prepareMainLooper(); - if (Build.BRAND.equalsIgnoreCase("meizu")) { - // - // - Workarounds.fillAppInfo(); - } - - internalStreamScreen(device, fd); - } - - private void internalStreamScreen(Device device, FileDescriptor fd) throws IOException { MediaCodec codec = createCodec(encoderName); MediaFormat format = createFormat(bitRate, maxFps, codecOptions); IBinder display = createDisplay(); diff --git a/server/src/main/java/com/genymobile/scrcpy/Server.java b/server/src/main/java/com/genymobile/scrcpy/Server.java index dc14d7c9..06281223 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Server.java +++ b/server/src/main/java/com/genymobile/scrcpy/Server.java @@ -71,6 +71,13 @@ public final class Server { boolean control = options.getControl(); boolean sendDummyByte = options.getSendDummyByte(); + Workarounds.prepareMainLooper(); + if (Build.BRAND.equalsIgnoreCase("meizu")) { + // + // + Workarounds.fillAppInfo(); + } + try (DesktopConnection connection = DesktopConnection.open(uid, tunnelForward, control, sendDummyByte)) { if (options.getSendDeviceMeta()) { Size videoSize = device.getScreenInfo().getVideoSize();