Skip to content

Commit 39aa750

Browse files
authored
Element Call: add delay before selecting the default audio device (#4854)
1 parent f224fe5 commit 39aa750

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

features/call/impl/src/main/kotlin/io/element/android/features/call/impl/utils/WebViewAudioManager.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ import androidx.annotation.RequiresApi
1919
import androidx.core.content.getSystemService
2020
import kotlinx.coroutines.CoroutineScope
2121
import kotlinx.coroutines.Dispatchers
22+
import kotlinx.coroutines.delay
2223
import kotlinx.coroutines.launch
2324
import kotlinx.serialization.Serializable
2425
import kotlinx.serialization.Transient
2526
import kotlinx.serialization.json.Json
2627
import timber.log.Timber
2728
import java.util.concurrent.Executors
2829
import java.util.concurrent.atomic.AtomicBoolean
30+
import kotlin.time.Duration.Companion.milliseconds
2931

3032
/**
3133
* This class manages the audio devices for a WebView.
@@ -221,6 +223,10 @@ class WebViewAudioManager(
221223
},
222224
onAudioPlaybackStarted = {
223225
coroutineScope.launch(Dispatchers.Main) {
226+
// Even with the callback, it seems like starting the audio takes a bit on the webview side,
227+
// so we add an extra delay here to make sure it's ready
228+
delay(500.milliseconds)
229+
224230
// Calling this ahead of time makes the default audio device to not use the right audio stream
225231
setAvailableAudioDevices()
226232

0 commit comments

Comments
 (0)