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>
This commit is contained in:
parent
3a0ba7d0a4
commit
2eb6fe7d81
1 changed files with 4 additions and 1 deletions
|
@ -41,6 +41,8 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
private final boolean downsizeOnError;
|
private final boolean downsizeOnError;
|
||||||
private long ptsOrigin;
|
private long ptsOrigin;
|
||||||
|
|
||||||
|
private boolean firstFrameSent;
|
||||||
|
|
||||||
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps, List<CodecOption> codecOptions, String encoderName,
|
public ScreenEncoder(boolean sendFrameMeta, int bitRate, int maxFps, List<CodecOption> codecOptions, String encoderName,
|
||||||
boolean downsizeOnError) {
|
boolean downsizeOnError) {
|
||||||
this.sendFrameMeta = sendFrameMeta;
|
this.sendFrameMeta = sendFrameMeta;
|
||||||
|
@ -99,7 +101,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
codec.stop();
|
codec.stop();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Ln.e("Encoding error: " + e.getClass().getName() + ": " + e.getMessage());
|
Ln.e("Encoding error: " + e.getClass().getName() + ": " + e.getMessage());
|
||||||
if (!downsizeOnError) {
|
if (!downsizeOnError || firstFrameSent) {
|
||||||
// Fail immediately
|
// Fail immediately
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +159,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
IO.writeFully(fd, codecBuffer);
|
IO.writeFully(fd, codecBuffer);
|
||||||
|
firstFrameSent = true;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
if (outputBufferId >= 0) {
|
if (outputBufferId >= 0) {
|
||||||
|
|
Loading…
Reference in a new issue