Downsize on error only before the first frame

The purpose of automatic downscaling on error is to make mirroring work
by just starting scrcpy without an explicit -m value, even if the
encoder could not encode at the screen definition.

It is only useful when we detect an encoding failure before the first
frame. Downsizing later could be surprising, so disable it.

PR #2947 <https://github.com/Genymobile/scrcpy/pull/2947>
pull/2947/head
Romain Vimont 2 years ago
parent 3a0ba7d0a4
commit 2eb6fe7d81

@ -41,6 +41,8 @@ public class ScreenEncoder implements Device.RotationListener {
private final boolean downsizeOnError;
private long ptsOrigin;
private boolean firstFrameSent;
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps, List<CodecOption> codecOptions, String encoderName,
boolean downsizeOnError) {
this.sendFrameMeta = sendFrameMeta;
@ -99,7 +101,7 @@ public class ScreenEncoder implements Device.RotationListener {
codec.stop();
} catch (Exception e) {
Ln.e("Encoding error: " + e.getClass().getName() + ": " + e.getMessage());
if (!downsizeOnError) {
if (!downsizeOnError || firstFrameSent) {
// Fail immediately
throw e;
}
@ -157,6 +159,7 @@ public class ScreenEncoder implements Device.RotationListener {
}
IO.writeFully(fd, codecBuffer);
firstFrameSent = true;
}
} finally {
if (outputBufferId >= 0) {

Loading…
Cancel
Save