twilio / audioswitch

An Android audio management library for real-time communication apps.
Apache License 2.0
163 stars 50 forks source link

AudioSwitch selected bluetooth headset but sound is still from phone speaker #66

Closed brian-chung-dragon closed 4 years ago

brian-chung-dragon commented 4 years ago

Before filing an issue please check that the issue is not already addressed by the following:

Please ensure that you are not sharing any Personally Identifiable Information(PII) or sensitive account information (API keys, credentials, etc.) when reporting an issue.

Describe the bug I implemented a logic to change the audio channel automatically once the audio device is connected to the phone. e.g. Earpiece -> Connect to a Bluetooth headset -> Audio switch will select BluetoothHeadset automatically Disconnect from Bluetooth headset -> Audio switch will switch the channel back to Earpiece

and there is an issue that audio switch library selected BluetoothHeadset, but the sound still come from phone speaker.

This issue only happens sometimes, but I can reproduce it with the steps below. audioSwitchLog.txt

To Reproduce Steps to reproduce the behavior:

  1. Make call without connecting to Bluetooth earphone.
  2. Hear voice from phone speaker
  3. Connect to Bluetooth earphone after 2-3 secs (connected to my Airpods)
  4. Audio switch can detect Airpods and able to select it
  5. No sound from Airpods, and can still hear the sound from phone speaker

Expected behavior Expected the sound should play on my Airpods

Actual behavior Sound still play on phone speaker

Screenshots I don't have screenshot, but I have a sample code to reproduce the issue.

Android Device (please complete the following information):

Version

aaalaniz commented 4 years ago

Hey @brian-chung-dragon

What version of AudioSwitch are you using?

Thank you for filing the issue!

brian-chung-dragon commented 4 years ago

@aaalaniz I am using AudioSwitch v1.0

Alton09 commented 4 years ago

Hi @brian-chung-dragon. Thanks for providing all of the info about this bug. Can you please also share some code snippets of how you are interacting with AudioSwitch?

brian-chung-dragon commented 4 years ago

I changed the voice quick start sample code a bit to reproduce the issue. And listed out all my findings into the README.txt sample.zip

brian-chung-dragon commented 4 years ago

hi @Alton09 , are you able to reproduce the issue? Do I need to provide more information? Thanks.

Alton09 commented 4 years ago

Hi @brian-chung-dragon . Sorry for the delay. I am investigating this issue and will report my findings soon. Thanks!

Alton09 commented 4 years ago

@brian-chung-dragon Can you please give this version, 1.0.1-SNAPSHOT, a try? We believe the issue may be fixed in this release. Note that this is not an official release, we want to verify if this resolves the issue first before cutting an official release. Thanks!

brian-chung-dragon commented 4 years ago

Thanks @Alton09 , will get back to you on Friday or next week Monday.

brian-chung-dragon commented 4 years ago

Hi @Alton09 , after I updated the config in gradle to use 1.0.1-SNAPSHOT. And the project couldn't find the Kotlin module. Do you know how to solve this?

image

Alton09 commented 4 years ago

@brian-chung-dragon Ah yeah that's because the voice quickstart doesn't use Kotlin. Try adding the following dependency to the app/build.gradle file: implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.0"

brian-chung-dragon commented 4 years ago

Hi @Alton09 , I can still reproduce the problem using 1.0.1-SNAPSHOT

Alton09 commented 4 years ago

Hi @brian-chung-dragon . Thank you for verifying. Our QA team was able to reproduce this issue on Huawei P10 and P20 devices. We will continue to investigate this issue and update on you on our findings. Thanks!

Alton09 commented 4 years ago

@brian-chung-dragon We have found that this issue occurs less frequently on Huawei devices with the latest version of the library, 1.0.1. Please give it a try and let us know if it helps. We are still investigating this issue in the meantime. Thanks!

brian-chung-dragon commented 4 years ago

Thanks @Alton09 will have a try this week, do you know is this issue happens more frequently on Huawei devices only?

Alton09 commented 4 years ago

@brian-chung-dragon Out of the devices that we have tested the library on, this issue only occurs on Huawei devices.

brian-chung-dragon commented 4 years ago

Thanks @Alton09 , I just did a quick test on release 1.0.1. The bluetooth issue seems improved but like what you said, the issue is still occurs in Huawei devices.

Alton09 commented 4 years ago

Hi @brian-chung-dragon . We have spent quite a bit of time on this issue and decided to close it and label it as won't fix. After running various test scenarios on a Huawei P30, 1.0.1 has proven to consistently connect audio on a bluetooth headset while on a call. We ran these tests on the Twilio Video App. Thanks for reaching out and please feel free to open any other issues related to this library if needed. Thanks!

Monika-Paliwal commented 4 years ago

Hey @Alton09 I am using the below-mentioned code but I am not getting the Bluetooth headset in the audio devices list. it's sometimes showing only earpiece or speaker. please let me know, why it's not working. I also called the audioSwitch.activate() and audioSwitch.Deactivate(). I am using a Samsung device. AudioSwitch audioSwitch = new AudioSwitch(getApplicationContext()); audioSwitch.start((audioDevices, audioDevice) -> { List availableAudioDevices = audioSwitch.getAvailableAudioDevices(); int selectedDeviceIndex = availableAudioDevices.indexOf(new AudioDevice.BluetoothHeadset("")); if (selectedDeviceIndex < -1) { audioSwitch.selectDevice(availableAudioDevices.get(selectedDeviceIndex)); } return Unit.INSTANCE; });

ataballyyeva commented 5 months ago

I have that issue too with latest version @Monika-Paliwal