Saturday, 3 April 2021

How does being in a call affect Android Audio routing?

I'm porting AOSP (Android 10) to a new device. Audio is working. Call audio is not working.

My audio_policy_configuration.xml is currently:

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

(I have added the Telephone Tx/Rx attachedDevices and devicePorts, the voice_tx/rx mixPorts and the Telephony Tx and voice_rx routes.)

The output of logcat | grep audio is:

<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

I cannot see any errors here.

Nor can I see any indication that the new routes are being used. (There is no audio in calls yet.)

How do I make Android notice the additions to the audio_policy_configuration.xmland make it use the Telephony Tx and voice_rx routed during a call?



from How does being in a call affect Android Audio routing?

No comments:

Post a Comment