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
1 changed files with 2 additions and 2 deletions
|
@ -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 a new issue