From 188ce55d4d5bf94b5fc5491c08d15519ce3bfd2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Fri, 8 Apr 2022 17:44:46 -0400 Subject: [PATCH 1/6] Fix auto restart video stream to ensure hmi level is streamable --- .../managers/video/VideoStreamManager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) 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..d78520dbae 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,13 +154,17 @@ 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); } } From c67fd747a5d69ec434732529f17f9631925dbd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Mon, 11 Apr 2022 14:50:31 -0400 Subject: [PATCH 2/6] Changed a log error to a log info, This appears to not be an error. --- .../main/java/com/android/grafika/gles/Texture2dProgram.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java b/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java index 1faed67768..3c2606dad0 100644 --- a/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java +++ b/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java @@ -162,7 +162,7 @@ public Texture2dProgram(ProgramType programType) { if (mProgramHandle == 0) { throw new RuntimeException("Unable to create program"); } - Log.e(TAG,"Created program " + mProgramHandle + " (" + programType + ")"); + Log.i(TAG,"Created program " + mProgramHandle + " (" + programType + ")"); // get locations of attributes and uniforms From 3260eac4c73b4e55e5b1b49a051ca8d34fe0dba3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Mon, 11 Apr 2022 14:52:17 -0400 Subject: [PATCH 3/6] Kept getting a error message form core "WARNING: EglCore was not explicitly released -- state may be leaked", So I modified logic to release it if we have already created EglCore object and are creating a new one --- .../com/smartdevicelink/encoder/VirtualDisplayEncoder.java | 3 +++ 1 file changed, 3 insertions(+) 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..03586598e4 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 @@ -262,6 +262,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). From 4081f836662250bd971beab4df567e76412c2d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Mon, 11 Apr 2022 15:07:12 -0400 Subject: [PATCH 4/6] Add behavior that video streaming will start back up if the app went form an HMI state that was not streamable to one that is. --- .../smartdevicelink/managers/video/VideoStreamManager.java | 4 ++++ 1 file changed, 4 insertions(+) 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 d78520dbae..17fd2ba4ed 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 @@ -202,6 +202,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); + } } } }; From eabf5cc9138663e5af3055c0beebaefcebea3b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Mon, 11 Apr 2022 15:15:05 -0400 Subject: [PATCH 5/6] Remove added space --- .../com/smartdevicelink/managers/video/VideoStreamManager.java | 1 - 1 file changed, 1 deletion(-) 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 17fd2ba4ed..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 @@ -164,7 +164,6 @@ public void onServiceEnded(SdlSession session, SessionType type) { transitionToState(SETTING_UP); if (withPendingRestart && isHMIStateVideoStreamCapable(currentOnHMIStatus)) { VideoStreamManager manager = VideoStreamManager.this; - manager.internalInterface.startVideoService(manager.getLastCachedStreamingParameters(), manager.isEncrypted, withPendingRestart); } } From eea49e9854cefde3c4c2a8f95055410f6867640f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9CJKAST=E2=80=9D?= Date: Mon, 11 Apr 2022 16:00:27 -0400 Subject: [PATCH 6/6] Add mEglCore release and set it to null in shutdown of VDE. And revert change in Texture2dProgram --- .../main/java/com/android/grafika/gles/Texture2dProgram.java | 2 +- .../com/smartdevicelink/encoder/VirtualDisplayEncoder.java | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java b/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java index 3c2606dad0..1faed67768 100644 --- a/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java +++ b/android/sdl_android/src/main/java/com/android/grafika/gles/Texture2dProgram.java @@ -162,7 +162,7 @@ public Texture2dProgram(ProgramType programType) { if (mProgramHandle == 0) { throw new RuntimeException("Unable to create program"); } - Log.i(TAG,"Created program " + mProgramHandle + " (" + programType + ")"); + Log.e(TAG,"Created program " + mProgramHandle + " (" + programType + ")"); // get locations of attributes and uniforms 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 03586598e4..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"); }