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 {
|
private void internalStreamScreen(Device device, FileDescriptor fd) throws IOException {
|
||||||
MediaFormat format = createFormat(bitRate, maxFps, codecOptions);
|
MediaFormat format = createFormat(bitRate, maxFps, codecOptions);
|
||||||
|
IBinder display = createDisplay();
|
||||||
device.setRotationListener(this);
|
device.setRotationListener(this);
|
||||||
boolean alive;
|
boolean alive;
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
MediaCodec codec = createCodec(encoderName);
|
MediaCodec codec = createCodec(encoderName);
|
||||||
IBinder display = createDisplay();
|
|
||||||
ScreenInfo screenInfo = device.getScreenInfo();
|
ScreenInfo screenInfo = device.getScreenInfo();
|
||||||
Rect contentRect = screenInfo.getContentRect();
|
Rect contentRect = screenInfo.getContentRect();
|
||||||
// include the locked video orientation
|
// include the locked video orientation
|
||||||
|
@ -120,7 +120,6 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
device.setMaxSize(newMaxSize);
|
device.setMaxSize(newMaxSize);
|
||||||
alive = true;
|
alive = true;
|
||||||
} finally {
|
} finally {
|
||||||
destroyDisplay(display);
|
|
||||||
codec.release();
|
codec.release();
|
||||||
if (surface != null) {
|
if (surface != null) {
|
||||||
surface.release();
|
surface.release();
|
||||||
|
@ -129,6 +128,7 @@ public class ScreenEncoder implements Device.RotationListener {
|
||||||
} while (alive);
|
} while (alive);
|
||||||
} finally {
|
} finally {
|
||||||
device.setRotationListener(null);
|
device.setRotationListener(null);
|
||||||
|
destroyDisplay(display);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue