Skip to content

Commit

Permalink
Retrieve screen info once
Browse files Browse the repository at this point in the history
The method getScreenInfo() is synchronized, and the result may change
between calls.

Call it once and store the result in a local variable.
  • Loading branch information
rom1v committed Feb 24, 2020
1 parent f903cd3 commit 12e269b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ public void streamScreen(Device device, FileDescriptor fd) throws IOException {
do {
MediaCodec codec = createCodec();
IBinder display = createDisplay();
Rect contentRect = device.getScreenInfo().getContentRect();
Rect videoRect = device.getScreenInfo().getVideoSize().toRect();
ScreenInfo screenInfo = device.getScreenInfo();
Rect contentRect = screenInfo.getContentRect();
Rect videoRect = screenInfo.getVideoSize().toRect();
setSize(format, videoRect.width(), videoRect.height());
configure(codec, format);
Surface surface = codec.createInputSurface();
Expand Down

0 comments on commit 12e269b

Please sign in to comment.