Hi,
I am trying to enable support for USB Audio on Android 6 using the tinyalsa HAL.
This is what I have done so far:
I have verified that the device exists in /proc/asound/devices:
9: [ 3- 0]: digital audio playback
10: [ 3- 0]: digital audio capture
In /proc/asound/devices/card3, I verified that the device supported playback. Here is the contents of stream0 to show this:
Creative Technology Ltd Sound Blaster Play! 3 at usb-ci_hdrc.1-1.2, full speed : USB Audio
Playback:
Status: Stop
Interface 1
Altset 1
Format: S16_LE
Channels: 2
Endpoint: 1 OUT (SYNC)
Rates: 44100, 48000
Interface 1
Altset 2
Format: S24_3LE
Channels: 2
Endpoint: 1 OUT (SYNC)
Rates: 44100, 48000
Interface 1
Altset 3
Format: S16_LE
Channels: 2
Endpoint: 1 OUT (SYNC)
Rates: 88200, 96000
Interface 1
Altset 4
Format: S24_3LE
Channels: 2
Endpoint: 1 OUT (SYNC)
Rates: 88200, 96000
I have added USB audio to my audio_policy.conf:
usb { outputs { usb_accessory { sampling_rates 44100 channel_masks AUDIO_CHANNEL_OUT_STEREO formats AUDIO_FORMAT_PCM_16_BIT devices AUDIO_DEVICE_OUT_USB_ACCESSORY } usb_device { sampling_rates 44100 channel_masks AUDIO_CHANNEL_OUT_STEREO formats AUDIO_FORMAT_PCM_16_BIT devices AUDIO_DEVICE_OUT_USB_DEVICE } } } With regard to the alsa setup, this was the existing config_usbaudio.h /* ALSA cards for IMX, these must be defined according different board / kernel config*/ static struct audio_card usbaudio_card = { .name = "USB Device", .driver_name = "USB-Audio", .supported_out_devices = AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET, .supported_in_devices = AUDIO_DEVICE_IN_USB_DEVICE|AUDIO_DEVICE_IN_DGTL_DOCK_HEADSET, .defaults = NULL, .bt_output = NULL, .speaker_output = NULL, .hs_output = NULL, .earpiece_output = NULL, .vx_hs_mic_input = NULL, .mm_main_mic_input = NULL, .vx_main_mic_input = NULL, .mm_hs_mic_input = NULL, .vx_bt_mic_input = NULL, .mm_bt_mic_input = NULL, .card = 0, .out_rate = 0, .out_channels = 0, .out_format = 0, .in_rate = 0, .in_channels = 0, .in_format = 0, }; I'm not sure if I have to change any of this and would appreciate some direction with what I must do with this file. In tinyalsa_hal.c I added the usbaudio_card above to the supported devices: /*"null_card" must be in the end of this array*/ struct audio_card *audio_card_list[] = { &wm8958_card, &wm8962_card, &hdmi_card, &spdif_card, &cs42888_card, &wm8960_card, &sii902x_card, &sgtl5000_card, &tc358743_card, &usbaudio_card, &null_card, }; Lastly, I ran tinyhal test.wav -D 3 -d 0 and did not have any errors but no sound came out. Note that I ran this before making all of the above changes. (It should not be affected by the audio policy but I will update if this ends up working once I compile the tinyhal additions) On android, the USB device is seen but does not use the alsa hal: 01-01 00:00:49.924 2359-2359/? I/AudioFlinger: loadHwModule() Loaded primary audio interface from Freescale i.MX Audio HW HAL (audio) handle 1 01-01 00:00:49.927 2359-2359/? I/AudioFlinger: loadHwModule() Loaded usb audio interface from USB audio HW HAL (audio) handle 2 01-01 00:00:49.927 2359-2359/? I/AudioFlinger: openOutput(), module 2 Device 4000, SamplingRate 0, Format 00000000, Channels 0, flags 0 01-01 00:00:49.927 2359-2359/? I/AudioFlinger: AudioStreamOut::open(), mHalFormatIsLinearPcm = 1 01-01 00:00:49.928 2359-2359/? I/AudioFlinger: HAL output buffer size 448 frames, normal sink buffer size 896 frames Even with this no sound comes out My questions are, what else must I do to get usb audio working on android? How do I enable the use of tinyhal on android? Am I doing anything wrong? Is there any documentation you could point me to because the android source documentation on audio almost leaves out android 6 completely. Thanks in advance for the help
Hello Michael,
Information below are from android design team:
-----------------------
usb audo HAL is AOSP code, no related to our audio HAL, so USB sound card can be used directly.
----------------------
In addition, The descriptions on USB Audio here should be helpful for your application:
USB Digital Audio | Android Open Source Project
Have a nice day!
B.R,
Weidong