Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 207afaab authored by kunleiz's avatar kunleiz Committed by Gerrit - the friendly Code Review server
Browse files

hal: limit AFE sample rate at 48Khz for non-44.1-support devices

After VoIP is closed, Music playback will resume. After
this behavior, DUT will crash after a period.

When VOIP entered standby, the VoIP use case is left to
mantain active state, then Music only can select VoIP
device. If VoIP device is handset, and sample rate of
playback is 44.1Khz, then AFE Sample Rate is configured
as 44.1Khz for handset. While COPP is set to 48Khz for
handset. This would cause sampling rate mismatch.

Limit AFE Sample Rate at 48Khz for non-44.1-support devices.

CRs-Fixed: 1038106
Change-Id: I07f7a12f07f6fedfd65e1d456e7c57e9ed819d3e
parent cee2c712
Loading
Loading
Loading
Loading
+14 −5
Original line number Diff line number Diff line
@@ -2421,6 +2421,17 @@ int check_hdset_combo_device(snd_device_t snd_device)
    return ret;
}

int check_44100_support_device(audio_devices_t out_device)
{
    int ret = true;

    if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
        out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET ||
        out_device & AUDIO_DEVICE_OUT_LINE)
        ret = false;

    return ret;
}

static int platform_get_backend_index(snd_device_t snd_device)
{
@@ -4218,14 +4229,12 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev,
    }

    /*
     * hifi playback not supported on spkr devices, limit the Sample Rate
     * hifi playback not supported on non-44.1-support devices, limit the Sample Rate
     * to 48 khz.
     */
    if (SND_DEVICE_OUT_SPEAKER == snd_device ||
        SND_DEVICE_OUT_SPEAKER_WSA == snd_device ||
        SND_DEVICE_OUT_SPEAKER_VBAT == snd_device) {
    if (check_44100_support_device(usecase->devices)) {
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
        ALOGD("%s:becf: afe: playback on speaker device Configure afe to "
        ALOGD("%s:becf: afe: playback on non-44.1-support device Configure afe to "
            "default Sample Rate(48k)", __func__);
    }

+16 −5
Original line number Diff line number Diff line
@@ -2209,6 +2209,19 @@ int check_hdset_combo_device(snd_device_t snd_device)

    return ret;
}

int check_44100_support_device(audio_devices_t out_device)
{
    int ret = true;

    if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
        out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET ||
        out_device & AUDIO_DEVICE_OUT_LINE)
        ret = false;

    return ret;
}

static int platform_get_backend_index(snd_device_t snd_device)
{
    int32_t port = DEFAULT_CODEC_BACKEND;
@@ -4184,14 +4197,12 @@ static bool platform_check_codec_backend_cfg(struct audio_device* adev,
    }

    /*
     * hifi playback not supported on spkr devices, limit the Sample Rate
     * hifi playback not supported on non-44.1-support devices, limit the Sample Rate
     * to 48 khz.
     */
    if (SND_DEVICE_OUT_SPEAKER == snd_device ||
        SND_DEVICE_OUT_SPEAKER_WSA == snd_device ||
        SND_DEVICE_OUT_SPEAKER_VBAT == snd_device) {
    if (check_44100_support_device(usecase->devices)) {
        sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
        ALOGD("%s:becf: afe: playback on speaker device Configure afe to "
        ALOGD("%s:becf: afe: playback on non-44.1-support device Configure afe to "
            "default Sample Rate(48k)", __func__);
    }