Hi Alberado21,
I was unable replicate your bluetooth issue with the tests I carried out ( a seven call test) after setting the bluetooth device connection after the first call (see EstablishedCallFragment below)
Below is some debug output from the calls that you can also verify for yourself with logcat in Android Studio.
I connected the bluetooth using the onAudioStateChanged from our Android Reference application hosted on github (https://github.com/sinch/rtc-reference-applications/) as shown below.
Sinch Voice Reference App audio state manipulation
com.sinch.rtc.vvc.reference.app > features > calls > established > EstablishedCallFragment
private fun attachBindings() {
┊ binding.hangUpButton.setOnClickListener { onBackPressed() }
┊ binding.audioStateButton.onAudioStateChanged = { newState ->
┊ ┊ viewModel.onAudioStateChanged(newState)
┊ ┊ showModeMessage(newState)
┊ }
Can you verify that onAudioStateChanged toggles between devices when your call is connected?
In your application are you able to verify that on each call:
The Bluetooth device is still available? (checking the connectionState)
If it is still the TYPE_BLUETOOTH_SCO for the call (or whichever type your bluetooth device shows as when connected.)
Logcat verification in Android Studio
Device connection
Here are some example logs showing the bluetooth connection verification upon changing the audioState from the sample application:
2022-09-04 20:43:57.967 21760-21760/com.sinch.rtc.vvc.reference.app D/BluetoothManager: Connected bluetooth headset: name=<your bluetooth device will be here>, state=CONNECTED, SCO audio=false
2022-09-04 20:43:57.986 2466-843/? I/HeadsetService: isHaDeviceConnected : false
2022-09-04 20:43:58.016 1350-1538/? D/BluetoothController: updateConnected = 2mConnectionState = 2
2022-09-04 20:43:58.064 1350-1350/? I/PowerUI: mBootCompleted = true | mFullyConnected = true
2022-09-04 20:43:58.350 2466-723/? I/HeadsetStateMachine: AudioConnecting: currentDevice=305075_1, msg=processAudioEvent: audio connected
2022-09-04 20:43:58.409 1350-1538/? D/BluetoothController: updateConnected = 2mConnectionState = 2
2022-09-04 20:43:58.413 21760-21760/com.sinch.rtc.vvc.reference.app D/BluetoothManager: +++ Bluetooth audio SCO is now connected
2022-09-04 20:43:58.413 21760-21760/com.sinch.rtc.vvc.reference.app D/AudioManagerInternal: --- updateAudioDeviceState: wired headset=false, BT state=SCO_CONNECTED
2022-09-04 20:43:58.413 21760-21760/com.sinch.rtc.vvc.reference.app D/AudioManagerInternal: Need BT audio: start=false, stop=false, BT state=SCO_CONNECTED
2022-09-04 20:43:58.419 21760-21760/com.sinch.rtc.vvc.reference.app D/BluetoothManager: onReceive done: BT state=SCO_CONNECTED
Logcat showing the AudioDevice on each call
Logcat will shows the audio device on each received call. (The Sinch client was not stopped between tests)
2022-09-04 20:36:08.080 21760-3011/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=321 (321)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
2022-09-04 20:36:41.041 21760-3247/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=353 (353)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
2022-09-04 20:37:03.773 21760-3425/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=385 (385)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
2022-09-04 20:37:15.963 21760-3627/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=417 (417)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
2022-09-04 20:37:35.422 21760-3794/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=449 (449)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
2022-09-04 20:37:54.367 21760-3963/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=481 (481)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
2022-09-04 20:38:31.556 21760-4125/com.sinch.rtc.vvc.reference.app I/org.webrtc.Logging: WebRtcAudioRecordExternal: client audio source=VOICE_COMMUNICATION, client session id=513 (513)
┊ AudioDevice: type=TYPE_BLUETOOTH_SCO, id=28
I hope this gives you some insight into troubleshooting your bluetooth issue.
If you need us to look at any of your Android logcat output, please open a ticket with us.
... View more