Skip to content

Commit

Permalink
Use camera prepare() step
Browse files Browse the repository at this point in the history
For consistency with screen capture.

Refs b60e174
  • Loading branch information
rom1v committed Nov 15, 2024
1 parent 91373d9 commit df74cce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
23 changes: 12 additions & 11 deletions server/src/main/java/com/genymobile/scrcpy/video/CameraCapture.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,21 @@ protected void init() throws IOException {
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);
}
}
Expand Down Expand Up @@ -232,13 +239,7 @@ public boolean setMaxSize(int maxSize) {
}

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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public final void init(CaptureListener listener) throws ConfigurationException,
/**
* Called once before each capture starts, before {@link #getSize()}.
*/
public void prepare() throws ConfigurationException {
public void prepare() throws ConfigurationException, IOException {
// empty by default
}

Expand Down

0 comments on commit df74cce

Please sign in to comment.