mirror of
https://github.com/Genymobile/scrcpy.git
synced 2026-04-21 01:33:36 +00:00
Move mediaCodec.stop() to finally block
This will allow to stop MediaCodec only after clean ups of other components which must be performed before stopping MediaCodec.
This commit is contained in:
parent
c0056637e9
commit
292af180c0
1 changed files with 5 additions and 3 deletions
|
|
@ -108,9 +108,6 @@ public class SurfaceEncoder implements AsyncProcessor {
|
|||
// The capture might have been closed internally (for example if the camera is disconnected)
|
||||
alive = !stopped.get() && !capture.isClosed();
|
||||
}
|
||||
|
||||
// do not call stop() on exception, it would trigger an IllegalStateException
|
||||
mediaCodec.stop();
|
||||
} catch (IllegalStateException | IllegalArgumentException e) {
|
||||
Ln.e("Encoding error: " + e.getClass().getName() + ": " + e.getMessage());
|
||||
if (!prepareRetry(size)) {
|
||||
|
|
@ -120,6 +117,11 @@ public class SurfaceEncoder implements AsyncProcessor {
|
|||
alive = true;
|
||||
} finally {
|
||||
reset.setRunningMediaCodec(null);
|
||||
try {
|
||||
mediaCodec.stop();
|
||||
} catch (IllegalStateException e) {
|
||||
// ignore
|
||||
}
|
||||
mediaCodec.reset();
|
||||
if (surface != null) {
|
||||
surface.release();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue