mirror of
https://github.com/Genymobile/scrcpy
synced 2024-12-25 00:22:19 +00:00
Keep the same display binder across sessions
Do not destroy/recreate the display when starting a new encoding session (on device rotation for example).
This commit is contained in:
parent
74d32e612d
commit
75d7c01a0c
@ -76,12 +76,12 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||
|
||||
private void internalStreamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||
MediaFormat format = createFormat(bitRate, maxFps, codecOptions);
|
||||
IBinder display = createDisplay();
|
||||
device.setRotationListener(this);
|
||||
boolean alive;
|
||||
try {
|
||||
do {
|
||||
MediaCodec codec = createCodec(encoderName);
|
||||
IBinder display = createDisplay();
|
||||
ScreenInfo screenInfo = device.getScreenInfo();
|
||||
Rect contentRect = screenInfo.getContentRect();
|
||||
// include the locked video orientation
|
||||
@ -120,7 +120,6 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||
device.setMaxSize(newMaxSize);
|
||||
alive = true;
|
||||
} finally {
|
||||
destroyDisplay(display);
|
||||
codec.release();
|
||||
if (surface != null) {
|
||||
surface.release();
|
||||
@ -129,6 +128,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||
} while (alive);
|
||||
} finally {
|
||||
device.setRotationListener(null);
|
||||
destroyDisplay(display);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user