Refactor to call getSize() only once

Avoid to call capture.getSize() (provided by the SurfaceCapture
implementation) twice.

PR #5370 <https://github.com/Genymobile/scrcpy/pull/5370>
This commit is contained in:
Romain Vimont 2024-10-12 09:23:31 +02:00
parent 5f0480c039
commit 68e54d9b0b

View File

@ -68,12 +68,16 @@ public class SurfaceEncoder implements AsyncProcessor {
capture.init();
try {
streamer.writeVideoHeader(capture.getSize());
boolean alive;
boolean headerWritten = false;
do {
Size size = capture.getSize();
if (!headerWritten) {
streamer.writeVideoHeader(size);
headerWritten = true;
}
format.setInteger(MediaFormat.KEY_WIDTH, size.getWidth());
format.setInteger(MediaFormat.KEY_HEIGHT, size.getHeight());