如何在主 HAL 和 USB 音频 HAL 之间配置呼叫音频?

问题描述

我有以下系统:

Call Audio Routing

支持 SGTL5000 的专有 NXP Primary Audio HAL 工作正常。我可以从 Android 播放和录制声音。

EM12-G 调制解调器显示为 USB 声卡。我可以使用 tinyplay 中的 adb shell 将 .wav 文件从调制解调器播放到远程电话(当呼叫已经建立时)。即 EM12-G 在 ALSA 层作为声卡正常工作,因为声音是在远程电话上出现的。

我的问题是当我替换认的usb_audio_policy_configuration.xml

<module name="usb" halVersion="2.0">
    <mixPorts>
        <mixPort name="usb_accessory output" role="source">
            <profile name="" format="AUdio_FORMAT_PCM_16_BIT"
                     samplingRates="44100" channelMasks="AUdio_CHANNEL_OUT_STEREO"/>
        </mixPort>
        <mixPort name="usb_device output" role="source"/>
        <mixPort name="usb_device input" role="sink"/>
    </mixPorts>
    <devicePorts>
        <devicePort tagName="USB Host Out" type="AUdio_DEVICE_OUT_USB_ACCESSORY" role="sink">
            <profile name="" format="AUdio_FORMAT_PCM_16_BIT"
                     samplingRates="44100" channelMasks="AUdio_CHANNEL_OUT_STEREO"/>
        </devicePort>
        <devicePort tagName="USB Device Out" type="AUdio_DEVICE_OUT_USB_DEVICE" role="sink"/>
        <devicePort tagName="USB Headset Out" type="AUdio_DEVICE_OUT_USB_HEADSET" role="sink"/>
        <devicePort tagName="USB Device In" type="AUdio_DEVICE_IN_USB_DEVICE" role="source"/>
        <devicePort tagName="USB Headset In" type="AUdio_DEVICE_IN_USB_HEADSET" role="source"/>
    </devicePorts>
    <routes>
        <route type="mix" sink="USB Host Out"
               sources="usb_accessory output"/>
        <route type="mix" sink="USB Device Out"
               sources="usb_device output"/>
        <route type="mix" sink="USB Headset Out"
               sources="usb_device output"/>
        <route type="mix" sink="usb_device input"
               sources="USB Device In,USB Headset In"/>
    </routes>
</module>

带有将 EM12-G USB 声卡视为调制解调器的自定义版本:

<module name="usb" halVersion="2.0">
    <attachedDevices>
        <item>Telephony Tx</item>
        <item>Telephony Rx</item>
    </attachedDevices>
    <mixPorts>
        <mixPort name="voice_tx" role="source">
            <profile name="" format="AUdio_FORMAT_PCM_16_BIT"
                        samplingRates="16000" channelMasks="AUdio_CHANNEL_OUT_MONO,AUdio_CHANNEL_OUT_STEREO"/>
        </mixPort>
        <mixPort name="voice_rx" role="sink">
            <profile name="" format="AUdio_FORMAT_PCM_16_BIT"
                        samplingRates="16000" channelMasks="AUdio_CHANNEL_IN_MONO,AUdio_CHANNEL_IN_STEREO"/>
        </mixPort>
    </mixPorts>
    <devicePorts>
        <devicePort tagName="Telephony Rx" type="AUdio_DEVICE_IN_TELEPHONY_RX" role="source">
        </devicePort>
        <devicePort tagName="Telephony Tx" type="AUdio_DEVICE_OUT_TELEPHONY_TX" role="sink">
        </devicePort>
    </devicePorts>
    <routes>
        <route type="mix" sink="Telephony Tx"
                sources="voice_tx"/>
        <route type="mix" sink="voice_rx"
                sources="Telephony Rx"/>       
    </routes>
</module>

我仍然没有收到通话音频。

对此进行调查,通过向许多 .c 和 .cpp 音频源文件添加调试,我看到:

I audioflinger: nextUniqueId()
I audioflinger: loadHwModule() Loaded usb audio interface,handle 18
I AudioPolicyClientImpl: openOutput(),address: ""
I audioflinger: openOutput(),address: ""
I audioflinger: openOutput() this 0xe8a10dbf1600,module 18 Device 0x10000,SamplingRate 16000,Format 0x000001,Channels 0x3,flags 0
I audioflinger: openOutput_l(),address: ""
I audioflinger: findSuitableHwDev_l()
I audioflinger: nextUniqueId()
I DeviceHAL: openOutputStream()
I DeviceHAL: openOutputStreamImpl()
I DeviceHAL: open_output_stream handle: 21 devices: 10000 flags: 0 srate: 16000 format 0x1 channels 3 address 
I modules.usbaudio.audio_hal: adev_open_output_stream()
I modules.usbaudio.audio_hal: adev_open_output_stream() handle:0x15,devicesspec:0x10000,flags:0x0,address:""
I modules.usbaudio.audio_hal: parse_card_device_params() 
I modules.usbaudio.audio_hal: parse_card_device_params() *card: -1,*device: -1
I modules.usbaudio.audio_hal: adev_open_output_stream() ret: 0
I DeviceHAL: open_output_stream status 0 stream 0xf2205540
I DeviceHAL: analyzeStatus()
I modules.usbaudio.audio_hal: out_get_sample_rate()

这里的主要问题是高层不给低层任何地址,导致*card = -1,*device = -1。下层需要知道EM12-G调制解调器声卡的卡号和设备号才能打开。

使用耳机配置时,我看到:

I modules.usbaudio.audio_hal: parse_card_device_params() "card=3;device=0"
I modules.usbaudio.audio_hal: parse_card_device_params() *card: 3,*device: 0

问题:

  • USB 音频 HAL 能否用于通话音频?
  • 如果是这样,我使用的配置有什么问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)