通话如何影响Android音频路由



我正在将AOSP(Android 10(移植到一个新设备上。音频正在工作。呼叫音频不工作。

我的audio_policy_configuration.xml当前为:

<audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude">
<globalConfiguration speaker_drc_enabled="true"/>
<modules>
<module name="primary" halVersion="2.0">
<attachedDevices>
<item>Speaker</item>    
<item>Built-In Mic</item>
<item>Telephony Rx</item>
<item>Telephony Tx</item>
</attachedDevices>
<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"/>
</mixPort>
<mixPort name="hdmi output" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="32000,44100,48000,88200,96000,176400,192000" channelMasks="AUDIO_CHANNEL_NONE"/>
</mixPort>
<mixPort name="esai output" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_HW_AV_SYNC">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000,96000,192000,384000,768000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
<profile name="" format="AUDIO_FORMAT_PCM_FLOAT"
samplingRates="48000,96000,192000,384000,768000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
</mixPort>
<mixPort name="dsd output" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD">
<profile name="" format="AUDIO_FORMAT_DSD"
samplingRates="2822400,5644800,11289600,22579200" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="primary input" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000,11025,16000,22050,24000,32000,44100,48000"
channelMasks="AUDIO_CHANNEL_IN_MONO,AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
<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="Speaker" type="AUDIO_DEVICE_OUT_SPEAKER" role="sink" >
</devicePort>
<devicePort tagName="Wired Headphones" type="AUDIO_DEVICE_OUT_WIRED_HEADPHONE" role="sink">
</devicePort>
<devicePort tagName="HDMI Out" type="AUDIO_DEVICE_OUT_AUX_DIGITAL" role="sink">
</devicePort>
<devicePort tagName="Line-Out" type="AUDIO_DEVICE_OUT_LINE" role="sink">
</devicePort>
<devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
</devicePort>
<devicePort tagName="Line-In" type="AUDIO_DEVICE_IN_AUX_DIGITAL" role="source">
</devicePort>
<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="Speaker"
sources="primary output"/>
<route type="mix" sink="Wired Headphones"
sources="dsd output,esai output,primary output"/>
<route type="mix" sink="HDMI Out"
sources="hdmi output,primary output"/>
<route type="mix" sink="Line-Out"
sources="dsd output,esai output,primary output"/>
<route type="mix" sink="primary input"
sources="Built-In Mic,Line-In"/>
<route type="mix" sink="Telephony Tx"
sources="voice_tx"/>
<route type="mix" sink="voice_rx"
sources="Telephony Rx"/>       
</routes>
</module>
<!-- A2dp Audio HAL -->
<xi:include href="a2dp_audio_policy_configuration.xml"/>
<!-- Usb Audio HAL -->
<xi:include href="usb_audio_policy_configuration.xml"/>
<!-- Remote Submix Audio HAL -->
<xi:include href="r_submix_audio_policy_configuration.xml"/>
</modules>
<!-- Volume section -->
<xi:include href="audio_policy_volumes.xml"/>
<xi:include href="default_volume_tables.xml"/>
</audioPolicyConfiguration>

(我添加了Telephone Tx/RxattachedDevicesdevicePortsvoice_tx/rxmixPorts以及Telephony Txvoice_rxroutes。(

logcat | grep audio的输出为:

<DIAL>
03-29 10:09:36.495  3504  3661 I audio_hw_primary: adev_set_mode mode 2
03-29 10:09:36.495  3504  3661 W audio_hw_primary: Entering IN_CALL state, in_call=0
03-29 10:09:36.495  3504  3661 W audio_hw_primary: no standby
03-29 10:09:36.495  3504  3661 I audio_hw_primary: select_output_device(), headphone 0 ,headset 0 ,speaker 0, earpiece 1,
03-29 10:09:36.591  3504  3661 D audio_hw_primary: out_set_parameters: enter: kvpairs: routing=2
03-29 10:09:36.591  3504  3661 D audio_hw_primary: out_set_parameters: exit: code(0)
03-29 10:09:36.594  3504  3661 D audio_hw_primary: out_set_parameters: enter: kvpairs: routing=2
03-29 10:09:36.594  3504  3661 D audio_hw_primary: out_set_parameters: exit: code(0)
03-29 10:09:36.643  4425  4425 I Dialer  : ProximitySensor.updateProximitySensorMode - screenOnImmediately: false, dialPadVisible: false, offHook: false, horizontal: false, uiShowing: false, audioRoute: EARPIECE
03-29 10:09:36.908  4425  4425 I Dialer  : ProximitySensor.updateProximitySensorMode - screenOnImmediately: false, dialPadVisible: false, offHook: true, horizontal: false, uiShowing: false, audioRoute: EARPIECE
03-29 10:09:36.910  4425  4425 I Dialer  : ProximitySensor.updateProximitySensorMode - screenOnImmediately: false, dialPadVisible: false, offHook: true, horizontal: false, uiShowing: true, audioRoute: EARPIECE
03-29 10:09:37.054  3737  4093 I Telecom : InCallController: Calling onAudioStateChanged, audioState: [AudioState isMuted: false, route: WIRED_HEADSET, supportedRouteMask: WIRED_HEADSET, SPEAKER, activeBluetoothDevice: [null], supportedBluetoothDevices: []] -> [AudioState isMuted: false, route: WIRED_HEADSET, supportedRouteMask: WIRED_HEADSET, SPEAKER, activeBluetoothDevice: [null], supportedBluetoothDevices: []]: (...->CS.crCo->H.CS.crCo->H.CS.crCo.pICR)->CSW.hCCC->CARSM.pM_UPDATE_SYSTEM_AUDIO_ROUTE@E-E-AGA
03-29 10:09:37.246  4425  4425 I Dialer  : ProximitySensor.updateProximitySensorMode - screenOnImmediately: true, dialPadVisible: false, offHook: true, horizontal: false, uiShowing: true, audioRoute: WIRED_HEADSET
03-29 10:09:37.296  4425  4425 I Dialer  : InCallFragment.setAudioState - audioState: [AudioState isMuted: false, route: WIRED_HEADSET, supportedRouteMask: WIRED_HEADSET, SPEAKER, activeBluetoothDevice: [null], supportedBluetoothDevices: []]
<ANSWER>
<HUP>
03-29 10:09:59.189  3737  4093 I Telecom : InCallController: Calling onAudioStateChanged, audioState: [AudioState isMuted: false, route: WIRED_HEADSET, supportedRouteMask: WIRED_HEADSET, SPEAKER, activeBluetoothDevice: [null], supportedBluetoothDevices: []] -> [AudioState isMuted: false, route: WIRED_HEADSET, supportedRouteMask: WIRED_HEADSET, SPEAKER, activeBluetoothDevice: [null], supportedBluetoothDevices: []]: CSW.sDc->CARSM.pM_UPDATE_SYSTEM_AUDIO_ROUTE@AO0
03-29 10:09:59.243  4425  4425 I Dialer  : ProximitySensor.updateProximitySensorMode - screenOnImmediately: true, dialPadVisible: false, offHook: false, horizontal: false, uiShowing: true, audioRoute: WIRED_HEADSET
03-29 10:09:59.343  3504  5123 I audio_hw_primary: start_output_stream_primary... 0xeb651000, device 2, address , mode 2
03-29 10:09:59.343  3504  5123 I audio_hw_primary: get_card_for_device adev: 0xeb62d000, device: 2, flag: 0, card_index: 0xeb651158
03-29 10:09:59.353  3504  5123 W audio_hw_primary: card 0, port 0 device 0x2
03-29 10:09:59.353  3504  5123 W audio_hw_primary: rate 48000, channel 2 period_size 0xc0
03-29 10:10:00.607  3737  4094 I Telecom : CallAudioModeStateMachine: Abandoning audio focus: now UNFOCUSED: CSW.sDc->ICTP.r->ICTP.cUTP->CAMSM.pM_3002@AO0
03-29 10:10:00.608  3504  3661 I audio_hw_primary: adev_set_mode mode 0
03-29 10:10:00.608  3504  3661 W audio_hw_primary: Leaving IN_CALL state, in_call=1, mode=0
03-29 10:10:00.609  3504  3661 W audio_hw_primary: do_out_standby... 0xeb651000
03-29 10:10:00.609  3504  3661 I audio_hw_primary: select_output_device(), headphone 0 ,headset 0 ,speaker 0, earpiece 1,
03-29 10:10:00.615  3504  5123 I audio_hw_primary: start_output_stream_primary... 0xeb651000, device 2, address , mode 0
03-29 10:10:00.615  3504  5123 I audio_hw_primary: select_output_device(), headphone 0 ,headset 0 ,speaker 0, earpiece 1,
03-29 10:10:00.618  3504  5123 I audio_hw_primary: get_card_for_device adev: 0xeb62d000, device: 2, flag: 0, card_index: 0xeb651158
03-29 10:10:00.623  3504  5123 W audio_hw_primary: card 0, port 0 device 0x2
03-29 10:10:00.623  3504  5123 W audio_hw_primary: rate 48000, channel 2 period_size 0xc0
03-29 10:10:01.776  4425  4425 I Dialer  : ProximitySensor.updateProximitySensorMode - screenOnImmediately: true, dialPadVisible: false, offHook: false, horizontal: false, uiShowing: false, audioRoute: WIRED_HEADSET
03-29 10:10:03.607  3504  3661 W audio_hw_primary: do_out_standby... 0xeb651000
^C

我在这里看不到任何错误。

我也看不到任何迹象表明新路线正在使用。(通话中还没有音频。(

我如何让Android注意到audio_policy_configuration.xml的添加,并让它在通话中使用路由的Telephony Txvoice_rx

当查看这个也有Telephony TxTelephony Rx端口的示例时,与您的配置相比的一个区别是,它还定义了从Telephony Rx到大多数接收器以及从所有麦克风到Telephony Tx:的路由

<route type="mix" sink="Speaker"
sources="primary output,deep_buffer,compressed_offload,BT SCO Headset Mic,Telephony Rx"/>
<route type="mix" sink="Wired Headset"
sources="primary output,deep_buffer,compressed_offload,BT SCO Headset Mic,Telephony Rx"/>
<route type="mix" sink="Wired Headphones"
sources="primary output,deep_buffer,compressed_offload,BT SCO Headset Mic,Telephony Rx"/>
<route type="mix" sink="Telephony Tx" 
sources="Built-In Mic,Built-In Back Mic,Wired Headset Mic,BT SCO Headset Mic"/>

这可能是您的配置中缺少的部分内容,以便路由正常工作。

由于某些原因,Telephony Rx没有被添加为Earpiece信宿的源。我不知道为什么。也许是疏忽(?(。

如果您使用的是Agora Android视频SDK,那么您可以使用setDefaultAudioRoutetoSpeakerphone方法

最新更新