diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java index 322ce0f23b..0f6b6b02d2 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/encoder/VirtualDisplayEncoder.java @@ -251,6 +251,10 @@ public void shutDown() { inputSurface.release(); inputSurface = null; } + if (mEglCore != null) { + mEglCore.release(); + mEglCore = null; + } } catch (Exception ex) { DebugTool.logError(TAG, "shutDown() failed"); } @@ -262,6 +266,9 @@ public void shutDown() { * @param Height */ private void setupGLES(int Width, int Height) { + if (mEglCore != null) { + mEglCore.release(); + } mEglCore = new EglCore(null, 0); // This 1x1 offscreen is created just to get the texture name (mTextureId). diff --git a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java index dc91e65c2f..f8e4305292 100644 --- a/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java +++ b/android/sdl_android/src/main/java/com/smartdevicelink/managers/video/VideoStreamManager.java @@ -154,12 +154,15 @@ public void onServiceStarted(SdlSession session, SessionType type, boolean isEnc public void onServiceEnded(SdlSession session, SessionType type) { if (SessionType.NAV.equals(type)) { if (remoteDisplay != null) { - stopStreaming(withPendingRestart); + if (withPendingRestart && isHMIStateVideoStreamCapable(currentOnHMIStatus)) { + stopStreaming(withPendingRestart); + } else { + stopStreaming(); + } } stateMachine.transitionToState(StreamingStateMachine.NONE); transitionToState(SETTING_UP); - - if (withPendingRestart) { + if (withPendingRestart && isHMIStateVideoStreamCapable(currentOnHMIStatus)) { VideoStreamManager manager = VideoStreamManager.this; manager.internalInterface.startVideoService(manager.getLastCachedStreamingParameters(), manager.isEncrypted, withPendingRestart); } @@ -198,6 +201,10 @@ public void onNotified(RPCNotification notification) { if (hasStarted && (isHMIStateVideoStreamCapable(prevOnHMIStatus)) && (!isHMIStateVideoStreamCapable(currentOnHMIStatus))) { stopVideoStream(); } + if (withPendingRestart && hasStarted && (!isHMIStateVideoStreamCapable(prevOnHMIStatus)) && (isHMIStateVideoStreamCapable(currentOnHMIStatus))) { + VideoStreamManager manager = VideoStreamManager.this; + manager.internalInterface.startVideoService(manager.getLastCachedStreamingParameters(), manager.isEncrypted, withPendingRestart); + } } } };