Skip to content

Commit 452a5d7

Browse files
author
Shi Su
committed
Guard video client stop with a mutex
1 parent 3e550b8 commit 452a5d7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

amazon-chime-sdk/src/main/java/com/amazonaws/services/chime/sdk/meetings/internal/video/DefaultVideoClientController.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ import com.xodee.client.video.VideoSubscriptionConfigurationInternal
3434
import java.security.InvalidParameterException
3535
import kotlinx.coroutines.GlobalScope
3636
import kotlinx.coroutines.launch
37+
import kotlinx.coroutines.sync.Mutex
38+
import kotlinx.coroutines.sync.withLock
3739

3840
class DefaultVideoClientController(
3941
private val context: Context,
@@ -64,7 +66,7 @@ class DefaultVideoClientController(
6466
private val cameraCaptureSource: DefaultCameraCaptureSource
6567
private var videoSourceAdapter = VideoSourceAdapter()
6668
private var isUsingInternalCaptureSource = false
67-
69+
private val videoClientStopMutex = Mutex()
6870
init {
6971
videoClientStateController.bindLifecycleHandler(this)
7072

@@ -102,10 +104,12 @@ class DefaultVideoClientController(
102104
// So it doesn't call it spuriously
103105
videoClientObserver.primaryMeetingPromotionObserver = null
104106

105-
videoClientStateController.stop()
107+
videoClientStopMutex.withLock {
108+
videoClientStateController.stop()
106109

107-
eglCore?.release()
108-
eglCore = null
110+
eglCore?.release()
111+
eglCore = null
112+
}
109113
}
110114
}
111115

0 commit comments

Comments
 (0)