New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AudioDeviceChangeListener called with Earpiece after a switch to Bluetooth #47
Comments
Hi @alizeec . Thank you for filing this issue! I have found the root cause for this bug and will begin working on a fix. |
Hi @alizeec . I've only been able to reproduce this bug with the following steps in a test application:
However, this only works if the application does not call the AudioDeviceSelector's Also, you can find the code where I ran the reproduction steps here. |
Hi @Alton09 I confirm that audioDeviceSelector.stop() is called before the activity is finished.
|
Thanks for the information @alizeec . It appears that the library is unable to activate bluetooth SCO (i.e. audio) on the connected headset, and is reverting back to the earpiece after 5 seconds. This could be occurring because the AirPods are not "active" in the OS. In the Bluetooth settings app on that device, do the AirPods appear as "active"? Also, can you please run through the steps you mentioned above, open logcat and filter on "bluetooth" with verbose level filtering on your application enabled and share those logs? This will help us see what is going on with bluetooth as you run through the reproductions steps. Thanks! |
Hi @Alton09 I don't think AirPods are "not active" on Android. I use them every day, it's compatible. Currently in our app we handle the bluetooth manually and we don't have any problems. Moreover, in your previous version 0.1.4 it was working. You can find attached the logs.
Thanks |
Hi @alizeec . Thank you, this is very helpful information. Although, the logs appear to be from an older version of AudioSwitch, as the "Invoking bluetooth sco action" log is being displayed. In version 0.2.1, we introduced more detailed logging for starting and stopping bluetooth sco and better audio device fallback support. Do you mind running the same steps with logs on version 0.2.1? Thanks! |
Hi @Alton09 Thanks |
@Alton09 to give you more context, https://gist.github.com/alizeec/098295222a1bae1746477a80d39f0b05 you can see in this gist how I use the SDK, and where the "[AUDIOSDK] ..." logs are |
@alizeec Thanks for the logs from the most recent version and the code reference! From the behavior you are describing above and from what I'm seeing in your logs, it appears that bluetooth SCO is connected before your AudioService class invokes the The library should definitely guard against this by checking the SCO connection status before attempting to start a SCO connection. I will work to get that change in the upcoming release. As a workaround In the meantime, please ensure the following in your application:
|
Hi @alizeec . We believe we have provided a fix for this issue. Can you please validate by using this snapshot version of the library, |
Hi @Alton09 Thanks for the fix, it does solve the problem where the bluetooth fallback on earpiece 5 seconds later. Now the selected device returned is the one I'm suppose to have. But I still have a lot of problem with the device really selected . First test (my Airpods are already connected before the call):
When I stop the call and do another (audioDeviceSelector.stop() is called, it's another instance of the activity), with my bluetooth device connected, the selected device is earpiece while it should have been bluetooth. After that, I have the same behavior than above Thanks |
Hey @alizeec I have been investigating this bug and I do have some leads, but I wanted to get some more information before we try any more changes to the library.
We appreciate your patience as we work through this issue. If we cannot resolve over GitHub then we can schedule a live debug session to ensure we get this problem fixed. If you would like to setup a debug call with myself and @Alton09 you can reach out to me at aalaniz [at] twilio.com Thanks! |
Hey @alizeec I just wanted to check the status of this issue. We are pausing development of this issue fix until we clearly understand the steps to reproduce. Let us know if you have any updates. Thanks! |
Hi @aaalaniz, Great job with this library, thank you! I also have the an issue where after disconnecting a wired/bluetooth headsets, even if I apply the above code snippet (manually selecting the Speakerphone Audio Device) it still selects the Earpiece Audio Device. I've also ensured that there is only a single instance of AudioDeviceSelector where ever I use it. I am currently using version 0.2.1, the entire Twilio functionality is inside a Fragment that I start from an Activity where I initialize the AudioDeviceSelector that I then pass to a BroadcastReceiver and the respective Fragment. I start() the AudioDeviceSelector in the Activity but inside the Fragment, with the passed AudiosDeviceSelector, I cannot receive any devices and when I try to activate() it fails. If I also start() in the Fragment it will get the Audio Devices properly. The BroadcastReceiver I use it for detecting Audio Devices changes where I just do a findAvailableDevices and select one. Please let me know if you are still working on fixing this issue or if there are other workarounds that I can apply. Best regards, |
Hey @iorgad Can you open a separate issue with the scenario you described? What you are describing sounds slightly different than what @alizeec describes. In your scenario it looks like the library may be erroneously falling back to earpiece when you have selected speakerphone after a bluetooth disconnect. @alizeec seems to be describing a scenario where the app switches to speakerphone, but audio continues to flow out of the bluetooth device. I recommend upgrading to 0.3.0, enabling logging, and providing a log file when you are able to reproduce the issue. Thank you! |
hello @aaalaniz Sorry for the late response I was in holidays
So I guess you can close the issue for now, and I will re-open it with the sample later. Is it ok for you? Thanks |
Thanks for the response @alizeec ! Yes, that sounds like a good plan. Please create a new issue at your convenience later on. |
Hi @aaalaniz, Sorry for the late response. I've just updated the library to 0.3.0 and everything works properly now when switching from headsets to speaker. Thank you for your quick response and instructions. Great work on this library! Best regards, |
Hi @iorgad. Glad to hear that the upgrade solved your problem! We also just released our first stable release of the library, 1.0.0 which adds a couple enhancements. |
Hi @Alton09 I tried the version 1.0.0.
but I tried to remove the But now I have the initial issue again (it seems random) :
Should I open a new issue for that? Because it's still the same bug Thanks |
Hi @Alton09 |
Hi @Alton09 I am 100% sure that:
My use-case: Steps:
In logs I constantly see: My logs:
|
Hi @whiter13! Sorry for the late reply on this one. Can you please create a separate issue for this problem following the New Issue template? This appears to be a slightly different issue and it will help us track it better. Thanks! |
Hi @Alton09. If you connect BT headset & WiredHeadset, you will see 3 options: Speaker, Headset, Bluetooth (Or name of BT device). Maybe it's caused by my program configuration. Not sure. Please check how it behaves on Samsungs with Android 11 when BT headset & WiredHeadset connected to phone, how stable switching is. Also we experienced problems with Wearable SmartWatches. If device, after reboot saw only SmartWatches as connected BT device - there is also some problems with AudioOutput. Sadly can't provide more info, will be able to check behaviour with SmartWatch later. BR, Vitaliy. |
Thanks for reaching out @VitaliyHTC ! Do you mind creating a new issue following our new issue template with as much detail as possible? This will help us provide better support for your problem. Thanks! |
Describe the bug
After selecting a bluetooth device, the AudioDeviceChangeListener is called first with selectedAudioDevice = BluetoothHeadset (correct) and then with selectedAudioDevice = Earpiece 5 seconds later
To Reproduce
Steps to reproduce the behavior:
Expected behavior
I should see in log
Actual behavior
I see
But the audio is still routed to bluetooth
Android Device (please complete the following information):
Version
The text was updated successfully, but these errors were encountered: