Closed Bug 1170951 Opened 9 years ago Closed 6 years ago

[B2G] Support USB audio

Categories

(Firefox OS Graveyard :: AudioChannel, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: alwu, Unassigned)

References

Details

Attachments

(1 file)

To support USB audio in FxOS, output data to external sound DAC.
Assignee: nobody → alwu
This patch implements setting the USB output device.
However, the GonkSwitch can't send the state-changing event of the USB OTG, I can't test whether the USB audio works well.
Updating some status.

[Testing environment]
My test devices is the USB-OTG cable, the mini sound card and wired headset.

I use the USB-OTG cable and the mini sound card to connect with phone, then plug the headset into the mini sound card. In FxOS, I set the audio output to AUDIO_DEVICE_OUT_USB_DEVICE, and set the volume of that. (In AudioManager.cpp)

---

(1) Android version
In the beginning, I tested the USB audio on Flame KK. Because I saw that the usb audio was surpported from Android 4.1 (API level 16). However, It can't take affect.

After re-studying, in Android 4.1, it only supports "Accessory mode", that means the Android device serves as a data source to the host, for example a dock. The USB-OTG and the mini sound card can't act as the host, so I should work on Nexus5, instead of Flame.

---

(2) Hardware support
My testing devices can work on the Nexus5 with official Android 5.0 factory image, but can't work on the FxOS based on the Android 5.0. 

Therefore, the Android verison isn't the problem, I need to check other settings, such like..

- Android kernal configuration (CONFIG_SND_USB_AUDIO=y...)
- Framework flag (via android.hardware.usb.host.xml)
- device.mk (add the audio.usb.default)
- USB audio policy (audio_policy.conf)

And all of them looks fine. Maybe the problem is in another part?

---

(3) Software changeset
The first problem is the FxOS can't detect the USB-OTG, so I can't get the notification from the GonkSwitch.

Because of that, I decide to set the USB audio output in the ctor of AudioManager, to force the phone using the USB output. It's only the testing method to check whether the audio can be output correctly when the USB output is set.

In Flame, I can set the output. However, I can't set the AUDIO_DEVICE_OUT_USB_DEVICE correctly in Nexus5. It might be caused by the difference of the USB audio policy.

That is the config of the Flame,
> usb_device {
>   sampling_rates 44100
>   channel_masks AUDIO_CHANNEL_OUT_STEREO
>   formats AUDIO_FORMAT_PCM_16_BIT
>   devices AUDIO_DEVICE_OUT_USB_DEVICE
> }

However, the config of the Nexus5 is,
> usb_device {
>   sampling_rates dynamic
>   channel_masks dynamic
>   formats dynamic
>   devices AUDIO_DEVICE_OUT_USB_DEVICE
> }

The keyword "dynamic" resulted loading USB output device fail. The related code is in the "framework/ac/service/audiopolicy/AudioPolicyManager.cpp".

If I define the specific parameter in Nexus5's config (like the config of the Flame), then the USB output can be set correctly. However, It still can't work, even if the audio output and volume are all correct in AudioFlinger.

----

According to the above descriptions, I guess the problem may be that the Gonk layer doesn't handle the USB device well. Despite I set the audio output correctly, If the device can't be found by Gonk, the sound still can't be heard. I need some help from Gonk team guys to figure out whether my assumption is correct.
After discussion with Gonk guys, now Gecko doesn't support USB Host mode, so we can't implement it.
See Also: → 1204023
Assignee: alwu → nobody
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: