From a9b2697f3e3d43f329d43ee091516fbd4270b136 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Fri, 27 Jan 2023 22:42:37 +0100 Subject: [PATCH] Move local variables declarations This makes it clear that these local variables are only passed to setDisplaySurface(). --- .../java/com/genymobile/scrcpy/ScreenEncoder.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 023b676f..37467937 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -90,16 +90,17 @@ public class ScreenEncoder implements Device.RotationListener { format.setInteger(MediaFormat.KEY_WIDTH, videoRect.width()); format.setInteger(MediaFormat.KEY_HEIGHT, videoRect.height()); - // does not include the locked video orientation - Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect(); - int videoRotation = screenInfo.getVideoRotation(); - int layerStack = device.getLayerStack(); - Surface surface = null; try { codec.configure(format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE); surface = codec.createInputSurface(); + + // does not include the locked video orientation + Rect unlockedVideoRect = screenInfo.getUnlockedVideoSize().toRect(); + int videoRotation = screenInfo.getVideoRotation(); + int layerStack = device.getLayerStack(); setDisplaySurface(display, surface, videoRotation, contentRect, unlockedVideoRect, layerStack); + codec.start(); alive = encode(codec, fd);