diff --git a/app/src/main/java/com/limelight/Game.java b/app/src/main/java/com/limelight/Game.java index c40d8f47..485f6cb5 100644 --- a/app/src/main/java/com/limelight/Game.java +++ b/app/src/main/java/com/limelight/Game.java @@ -971,6 +971,14 @@ public class Game extends Activity implements SurfaceHolder.Callback, @Override public void surfaceDestroyed(SurfaceHolder holder) { if (connected) { + // HACK: Android is supposed to let you return from this function + // before throwing a fit if you access the surface again. Unfortunately, + // MediaCodec often tries to access the destroyed surface and triggers + // an IllegalStateException. To workaround this, we will invoke + // the DecoderRenderer's stop function ourselves, so it will hopefully + // happen early enough to not trigger the bug + decoderRenderer.stop(); + stopConnection(); } } diff --git a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java index c2dfab45..b38b24c8 100644 --- a/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java +++ b/app/src/main/java/com/limelight/binding/video/MediaCodecDecoderRenderer.java @@ -475,8 +475,8 @@ public class MediaCodecDecoderRenderer extends EnhancedDecoderRenderer { } catch (InterruptedException ignored) { } } - // Stop the decoder - videoDecoder.stop(); + // We could stop the decoder here, but it seems to cause some problems + // so we'll just let release take care of it. } @Override