mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Element Call: add delay before selecting the default audio device (#4854)
This commit is contained in:
committed by
GitHub
parent
f224fe5c3b
commit
39aa7500de
+6
@@ -19,6 +19,7 @@ import androidx.annotation.RequiresApi
|
|||||||
import androidx.core.content.getSystemService
|
import androidx.core.content.getSystemService
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.serialization.Serializable
|
import kotlinx.serialization.Serializable
|
||||||
import kotlinx.serialization.Transient
|
import kotlinx.serialization.Transient
|
||||||
@@ -26,6 +27,7 @@ import kotlinx.serialization.json.Json
|
|||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import java.util.concurrent.Executors
|
import java.util.concurrent.Executors
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
|
import kotlin.time.Duration.Companion.milliseconds
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manages the audio devices for a WebView.
|
* This class manages the audio devices for a WebView.
|
||||||
@@ -221,6 +223,10 @@ class WebViewAudioManager(
|
|||||||
},
|
},
|
||||||
onAudioPlaybackStarted = {
|
onAudioPlaybackStarted = {
|
||||||
coroutineScope.launch(Dispatchers.Main) {
|
coroutineScope.launch(Dispatchers.Main) {
|
||||||
|
// Even with the callback, it seems like starting the audio takes a bit on the webview side,
|
||||||
|
// so we add an extra delay here to make sure it's ready
|
||||||
|
delay(500.milliseconds)
|
||||||
|
|
||||||
// Calling this ahead of time makes the default audio device to not use the right audio stream
|
// Calling this ahead of time makes the default audio device to not use the right audio stream
|
||||||
setAvailableAudioDevices()
|
setAvailableAudioDevices()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user