From 723faa5dee2915086c3b07fd1bfb6d541680b042 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Sat, 15 Jan 2022 22:17:38 +0100 Subject: [PATCH] Remember Device parameters This will allow to reuse them to recreate a ScreenInfo instance in order to change the maxSize value on MediaCodec error. PR #2947 --- .../src/main/java/com/genymobile/scrcpy/Device.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/Device.java b/server/src/main/java/com/genymobile/scrcpy/Device.java index 419e996e..591460b6 100644 --- a/server/src/main/java/com/genymobile/scrcpy/Device.java +++ b/server/src/main/java/com/genymobile/scrcpy/Device.java @@ -42,6 +42,11 @@ public final class Device { void onClipboardTextChanged(String text); } + private final Size deviceSize; + private final Rect crop; + private final int maxSize; + private final int lockVideoOrientation; + private ScreenInfo screenInfo; private RotationListener rotationListener; private ClipboardListener clipboardListener; @@ -69,8 +74,12 @@ public final class Device { int displayInfoFlags = displayInfo.getFlags(); - screenInfo = ScreenInfo.computeScreenInfo(displayInfo.getRotation(), displayInfo.getSize(), options.getCrop(), options.getMaxSize(), - options.getLockVideoOrientation()); + deviceSize = displayInfo.getSize(); + crop = options.getCrop(); + maxSize = options.getMaxSize(); + lockVideoOrientation = options.getLockVideoOrientation(); + + screenInfo = ScreenInfo.computeScreenInfo(displayInfo.getRotation(), deviceSize, crop, maxSize, lockVideoOrientation); layerStack = displayInfo.getLayerStack(); SERVICE_MANAGER.getWindowManager().registerRotationWatcher(new IRotationWatcher.Stub() {