I am trying to get audio working on a board to which we're porting Android.
Currently, sounds played with usages such as USAGE_ALARM
(4) are audible, whereas sounds played with usages such as USAGE_MEDIA
(1) are silent.
For the audible usages, we can see calls to the Audio HAL:
...
D AudioFlinger: Client defaulted notificationFrames to 11025 for frameCount 22050
D AF::TrackHandle: OpPlayAudio: track:64 usage:4 not muted
D audio_hw_primary: out_set_parameters: enter: kvpairs: routing=2
D audio_hw_primary: out_set_parameters: exit: code(0)
I audio_hw_primary: start_output_stream_primary... 0xf3856000, device 2, address , mode 0
I audio_hw_primary: select_output_device(), headphone 0 ,headset 0 ,speaker 2, earpiece 0,
I audio_hw_primary: get_card_for_device adev: 0xf3828000, device: 2, flag: 0, card_index: 0xf3856158
W audio_hw_primary: card 0, port 0 device 0x2
W audio_hw_primary: rate 48000, channel 2 period_size 0xc0
W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
...
Whereas for silent usages, we see only:
...
D AudioFlinger: Client defaulted notificationFrames to 11025 for frameCount 22050
D AF::TrackHandle: OpPlayAudio: track:65 usage:1 not muted
W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
...
I thought that /vendor/etc/audio_policy_configuration.xml
might be important. I've paired it back to just having one output, but nothing has changed.
<attachedDevices>
<item>Speaker</item>
...
<defaultOutputDevice>Speaker</defaultOutputDevice>
<mixPorts>
<mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
...
<devicePorts>
<devicePort tagName="Speaker" type="AUDIO_DEVICE_OUT_SPEAKER" role="sink" >
</devicePort>
...
<routes>
<route type="mix" sink="Speaker"
sources="primary output"/>
What part of AOSP is responsible for the routing of different usages?
Why do some work and other are silent?