Wait for Bluetooth audio to start on Android

Viewed 29

We have a voice communications app that needs to play audio via bluetooth when a call starts.

We are using AudioManager.startBluetoothSco to start the bluetooth, and we are waiting for the ACTION_SCO_AUDIO_STATE_UPDATED broadcast intent to change to SCO_AUDIO_STATE_CONNECTED before playing audio.

However waiting for ACTION_SCO_AUDIO_STATE_UPDATED only delays our start by 150 ms and it takes about 2 seconds before audio starts playing, during this time any audio played just disappears it isn't played out on any device, it isn't delayed it's just gone.

Is there a way to wait for the bluetooth device to be ready to play audio, so that we don't lose the start of our audio?

We also tried using a self managed ConnectionService following the instructions here set the audio route to bluetooth and waited for the CallAudioState to change, but this had exactly the same problem.

0 Answers
Related