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 27, 2020
1 parent c0f428e commit ef56cc6
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 @@ -63,8 +63,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 ef56cc6

Please sign in to comment.