Skip to content

Commit

Permalink
Use correct CallControlScope for device selection
Browse files Browse the repository at this point in the history
  • Loading branch information
liviu-timar committed Aug 19, 2024
1 parent 79196a6 commit c71de51
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ internal class TelecomHandler private constructor(
private val telecomHandlerScope = CoroutineScope(
DispatcherProvider.Default + SupervisorJob() + exceptionHandler,
)
private var callControlScope: CallControlScope? = null

companion object {
@Volatile
Expand Down Expand Up @@ -279,11 +278,15 @@ internal class TelecomHandler private constructor(
calls[call.cid]?.deviceListener = listener
}

fun selectDevice(device: CallEndpointCompat) {
logger.d { "[selectDevice] device: $device" }

callControlScope?.let {
it.launch { it.requestEndpointChange(device) }
fun selectDevice(call: StreamCall, device: CallEndpointCompat) {
calls[call.cid]?.callControlScope?.let {
with(it) {
launch {
requestEndpointChange(device).let { result ->
logger.d { "[selectDevice] To device: ${device.name}, requestEndpointChange result: $result" }
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ internal object TelecomCompat {
override fun stop() {}

override fun selectDevice(audioDevice: StreamAudioDevice?) {
audioDevice?.telecomDevice?.let { telecomHandler.selectDevice(it) }
audioDevice?.telecomDevice?.let { telecomHandler.selectDevice(call, it) }
}
}
},
Expand Down

0 comments on commit c71de51

Please sign in to comment.