twilio / audioswitch

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

USB Headset audio always defaults or switches 5-10 seconds after requesting focus #150

Closed schuranator closed 8 months ago

schuranator commented 1 year ago

I'm noticing issues with the Samsung S7+ Android 12 and 13 along with the Pixel 7 Android 13.

I created a small Activity that would allow me to toggle which audio output to use. The toggle works initially but after 5-10 seconds I see the audio get switched back to the USB Headset Audio output.

Here is some logs: 2023-05-23 13:42:52.399 1061-1857 SoundAlive...384 arch64 audioserver I SoundAlive_SRC384: Instance 173 Init(outFs 8, InFs 5, chnum 1, outBW 3, inBW 3) 2023-05-23 13:42:52.399 1061-1857 Samsung_So...SRC arch64 audioserver I SRC384 version Samsung SoundAlive SRC ver320 arch64 2021.08.04 (Cppref for ARM64, ver.300.c 32bit 07_10_2016 based) 2023-05-23 13:42:52.594 1061-1857 SoundAlive...384 arch64 audioserver I ~SoundAlive_SRC384(): instance 173

cc600357-d91f-4171-8a37-b47ca6cd2b42

angeloraso commented 1 year ago

Hi!

Example code:

audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
             AudioDeviceInfo speakerphoneDevice = getAudioDevice(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER);
             if (speakerphoneDevice != null) {
                 success = audioManager.setCommunicationDevice(speakerphoneDevice);
                 if (success) {
                     audioManager.setMode(AudioManager.MODE_IN_COMMUNICATION);
                 } else {
                     Log.d(TAG, "Speaker error");
                 }
             }

I hope it helps you

schuranator commented 1 year ago

I tried this workflow but still have the cut out after a few seconds of playing. I have a better log not sure if this helps. AudioSwitchLog.txt

acalpitojr commented 1 year ago

I am experiencing the same issue. After switching to MODE_IN_COMMUNICATION, after about 5 seconds, the mode auto switches to MODE_NORMAL.

I tried @angeloraso example code and I still see the problem.

ocarevs commented 11 months ago

@schuranator I've been unable to reproduce the issue so far. Can you add a log file with AudioSwitch.loggingEnabled = true set where you encounter this issue?

afalls-twilio commented 8 months ago

Closing due to a lack of customer response.