Display and control your Android device
Use camera prepare() step
Romain Vimontdf74cceb6fe1
diff --git a/server/src/main/java/com/genymobile/scrcpy/video/CameraCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/CameraCapture.javaindex 7385283e..0ec404eb 100644--- a/server/src/main/java/com/genymobile/scrcpy/video/CameraCapture.java+++ b/server/src/main/java/com/genymobile/scrcpy/video/CameraCapture.java@@ -80,14 +80,21 @@ public class CameraCapture extends SurfaceCapture {throw new IOException("No matching camera found");}+ Ln.i("Using camera '" + cameraId + "'");+ cameraDevice = openCamera(cameraId);+ } catch (CameraAccessException | InterruptedException e) {+ throw new IOException(e);+ }+ }++ @Override+ public void prepare() throws IOException {+ try {size = selectSize(cameraId, explicitSize, maxSize, aspectRatio, highSpeed);if (size == null) {throw new IOException("Could not select camera size");}-- Ln.i("Using camera '" + cameraId + "'");- cameraDevice = openCamera(cameraId);- } catch (CameraAccessException | InterruptedException e) {+ } catch (CameraAccessException e) {throw new IOException(e);}}@@ -232,13 +239,7 @@ public class CameraCapture extends SurfaceCapture {}this.maxSize = maxSize;- try {- size = selectSize(cameraId, null, maxSize, aspectRatio, highSpeed);- return size != null;- } catch (CameraAccessException e) {- Ln.w("Could not select camera size", e);- return false;- }+ return true;}@SuppressLint("MissingPermission")diff --git a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceCapture.java b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceCapture.javaindex de9e1b27..d0d93f54 100644--- a/server/src/main/java/com/genymobile/scrcpy/video/SurfaceCapture.java+++ b/server/src/main/java/com/genymobile/scrcpy/video/SurfaceCapture.java@@ -46,7 +46,7 @@ public abstract class SurfaceCapture {/*** Called once before each capture starts, before {@link #getSize()}.*/- public void prepare() throws ConfigurationException {+ public void prepare() throws ConfigurationException, IOException {// empty by default}