carlosrafaelgn / FPlayAndroid

Simple and straightforward Android music player, with equalizer and bass boost
BSD 2-Clause "Simplified" License
155 stars 64 forks source link

Support USB AUDIO in effects #18

Open dalb8 opened 7 years ago

dalb8 commented 7 years ago

The effects only support headset, headphones and loudspeaker but not audio via USB dongle.

carlosrafaelgn commented 7 years ago

Indeed! The problem is I do not own one of those dongles, so there is no way I could test it...

Moreover, the only references I could find regarding USB Audio were these (that work only on Android 23+ - Marshmallow+): https://developer.android.com/reference/android/media/AudioDeviceInfo.html https://developer.android.com/reference/android/media/AudioManager.html#getDevices(int)

Do you own one of those devices? If so, would you consider writing a code to detect usb audio, please? Then, I would merge your code into FPlay's code :)

dalb8 commented 7 years ago

I own one but I'm not able to write code. I may be able to get another soon, in which case I'd give one to you.

The AudioFX app in LineageOS as well as DSP Manager support USB audio.

On 26 February 2017 12:39:35 GMT+00:00, Carlos Rafael Gimenes das Neves notifications@github.com wrote:

Indeed! The problem is I do not own one of those dongles, so there is no way I could test it...

Moreover, the only references I could find regarding USB Audio were these (that work only on Android 23+ - Marshmallow+): https://developer.android.com/reference/android/media/AudioDeviceInfo.html https://developer.android.com/reference/android/media/AudioManager.html#getDevices(int)

Do you own one of those devices? If so, would you consider writing a code to detect usb audio, please? Then, I would merge your code into FPlay's code :)

james34602 commented 7 years ago

Android USB audio sometimes quite buggy, I have a highly modified DSP Manager in my repository, my experience show some device may have conflict when using USB audio output, the system always mix up with analog output. So USB DAC can be output as analog output. Whatever @carlosrafaelgn may experiment on USB audio :D

dalb8 commented 7 years ago

OK the Loudspeaker tab changes the USB output, on my phone at least. It opened on loudspeaker tab when I opened the app with dongle plugged in but I didn't realise it would work until I read James' comment.

carlosrafaelgn commented 7 years ago

Precise detection of audio output is kinda buggy on Android... Check out methods Player._checkAudioSinkViaRoute() and Player._checkAudioSink() (lines 3318 and 3369).

They are a massive workaround, sadly, because different devices behave differently :(

Reading through the code in AudioSystem.java, I came across two constants: public static final String DEVICE_OUT_USB_ACCESSORY_NAME = "usb_accessory"; public static final String DEVICE_OUT_USB_DEVICE_NAME = "usb_device";

Perhaps they could be used to try and detect whenever audio output is being done by the speaker or by an USB device???

james34602 commented 7 years ago

I don't even know is it work or not, have to do experiment on that. Carlos is right, different vendor may code audio framework differently...