From 3eda38e5fc63f08eed408c39155b88e1bcefc341 Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Thu, 21 Mar 2019 18:45:29 +0100 Subject: [PATCH] Do not call codec.stop() on exception On exception, the codec is not in a state were .stop() can be called. --- server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java index 22eb6a54..71f5ab10 100644 --- a/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java +++ b/server/src/main/java/com/genymobile/scrcpy/ScreenEncoder.java @@ -71,8 +71,9 @@ public class ScreenEncoder implements Device.RotationListener { codec.start(); try { alive = encode(codec, fd); - } finally { + // do not call stop() on exception, it would trigger an IllegalStateException codec.stop(); + } finally { destroyDisplay(display); codec.release(); surface.release();