1

我试图让音频在我们正在移植 Android 的板上工作。

目前,使用诸如USAGE_ALARM(4) 的用法播放的声音是可听的,而使用诸如USAGE_MEDIA(1) 的用法播放的声音是无声的。

对于听得见的用法,我们可以看到对 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
...

而对于静默用法,我们只看到:

...
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
...

我认为这/vendor/etc/audio_policy_configuration.xml可能很重要。我已经将它重新配对为只有一个输出,但没有任何改变。

        <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"/>

AOSP 的哪一部分负责不同用途的路由?

为什么有的工作有的无声?

4

0 回答 0