Skip to content

Display and control your Android device

Downsize on error only before the first frame

Romain Vimont2eb6fe7d81c1
diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
index 10ba9fac..06f06a9d 100644
--- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
+++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
@@ -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) {