Monday 25 October 2021

How do Audio HALs tell Android that their inputs are AUDIO_SOURCE_VOICE_COMMUNICATION?

I'm porting Android to a custom iMX8 based system that uses a discreet LTE modem module.

The microphone and speakers work correctly and the LTE modem works as an ALSA device - i.e. I can use tinyplay to send .wav file audio during a phone call.

Normal call audio isn't working (though DTMF tones are).

This ALOG_ASSERT is triggered in frameworks/av/services/audiopolicy/managerdefault/AudioPolicyManager.cpp on call setup:

uint32_t AudioPolicyManager::updateCallRouting(const DeviceVector &rxDevices, uint32_t delayMs)
{
    bool createTxPatch = false;
    bool createRxPatch = false;
    uint32_t muteWaitMs = 0;

    if(!hasPrimaryOutput() || mPrimaryOutput->devices().types() == AUDIO_DEVICE_OUT_STUB) {
        return muteWaitMs;
    }
    ALOG_ASSERT(!rxDevices.isEmpty(), "updateCallRouting() no selected output device");

    audio_attributes_t attr = { .source = AUDIO_SOURCE_VOICE_COMMUNICATION };
    auto txSourceDevice = mEngine->getInputDeviceForAttributes(attr);
    ALOG_ASSERT(txSourceDevice != 0, "updateCallRouting() input selected device not available");
    ...

10-21 14:43:38.528  3794  3813 I Telecom : InCallController: Components updated: [ComponentInfo{com.android.dialer/com.android.incallui.InCallServiceImpl}]: CSW.pE@ASY
10-21 14:43:39.232  5284  5318 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 5318 (Binder:5284_1), pid 5284 (audioserver)
10-21 14:43:39.290  5334  5334 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-21 14:43:39.290  5334  5334 F DEBUG   : Build fingerprint: 'Android/smarc_mx8mq/smarc_mx8mq:10/QD1A.190821.014.C2/user.example.1:eng/dev-keys'
10-21 14:43:39.290  5334  5334 F DEBUG   : Revision: '0'
10-21 14:43:39.290  5334  5334 F DEBUG   : ABI: 'arm64'
10-21 14:43:39.291  5334  5334 F DEBUG   : Timestamp: 2021-10-21 14:43:39+0100
10-21 14:43:39.291  5334  5334 F DEBUG   : pid: 5284, tid: 5318, name: Binder:5284_1  >>> /system/bin/audioserver <<<
10-21 14:43:39.291  5334  5334 F DEBUG   : uid: 1041
10-21 14:43:39.291  5334  5334 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
10-21 14:43:39.291  5334  5334 F DEBUG   : Abort message: 'updateCallRouting() input selected device not available'
10-21 14:43:39.292  5334  5334 F DEBUG   :     x0  0000000000000000  x1  00000000000014c6  x2  0000000000000006  x3  0000f16738efbfa0
10-21 14:43:39.292  5334  5334 F DEBUG   :     x4  fefff0663a30bf47  x5  fefff0663a30bf47  x6  fefff0663a30bf47  x7  7f7fff7f7f7fff7f
10-21 14:43:39.292  5334  5334 F DEBUG   :     x8  00000000000000f0  x9  0000f1673ac804e0  x10 0000000000000000  x11 0000000000000001
...

I believe, possibly incorrectly, that the reason I get a crash is that my Primary Audio HAL's inputs are not flagged as AUDIO_SOURCE_VOICE_COMMUNICATION.

I have found AUDIO_SOURCE_VOICE_COMMUNICATION in only one HAL - I expected it to be in all phone Primary Audio HALs:

$ cgrep " = AUDIO_SOURCE_VOICE_COMMUNICATION"
./hardware/qcom/audio/hal/audio_hw.c:6244:                in.source = AUDIO_SOURCE_VOICE_COMMUNICATION;
./hardware/libhardware_legacy/include/hardware_legacy/AudioSystemLegacy.h:63:    AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_COMMUNICATION,
./frameworks/wilhelm/src/android/AudioRecorder_to_android.cpp:51:        newRecordSource = AUDIO_SOURCE_VOICE_COMMUNICATION;
./frameworks/av/services/audiopolicy/managerdefault/AudioPolicyManager.cpp:517:    audio_attributes_t attr = { .source = AUDIO_SOURCE_VOICE_COMMUNICATION };
./frameworks/av/services/audiopolicy/managerdefault/AudioPolicyManager.cpp:5424:        attributes.source = AUDIO_SOURCE_VOICE_COMMUNICATION;
./frameworks/av/services/audiopolicy/enginedefault/src/Engine.cpp:542:            inputSource = AUDIO_SOURCE_VOICE_COMMUNICATION;

How and where are a phone's Primary Audio HAL's inputs flagged as AUDIO_SOURCE_VOICE_COMMUNICATION?



from How do Audio HALs tell Android that their inputs are AUDIO_SOURCE_VOICE_COMMUNICATION?

No comments:

Post a Comment