Usb attached device with 2 audio ports
- By vladpetreaca
- Android Development
- 1 Replies
Thank you for your response.Yes, it is possible to get all audio ports from an USB attached device. You can use Android's AudioManager class to access each port and configure the routing of the audio accordingly. You can also use audio APIs such as OpenSL ES to access the audio ports. From there, you can use the Audio Routes API to route the audio to multiple destinations. Additionally, you should take a look at some 3rd party libraries that provide more options for audio routing, such as the Audio Jack library.
I used getDevice() method from AudioManager when my controller was connected to my Samsung Galaxy Tab S8 and it has 3 devices: first is Type 2(AudioDeviceInfo.TYPE_BUILTIN_SPEAKER), second is Type 11(AudioDeviceInfo.TYPE_USB_DEVICE) and the third Type 18(AudioDeviceInfo.TYPE_TELEPHONY). After connection, the selected device is Type 11 and the music is heard in the master port(automatically default selected by Android).
When I plugg in headphones in the headphones port, nothing changed in the AudioManager and I have the same 3 output devices.
I mention that I have tested the controller with a DJ software on PC and the headphones port worked fine.
I will try to use OpenSL ES API to get a solution., maybe it will work.
