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

Commit 2e6f6244 authored by Nikhil Latukar's avatar Nikhil Latukar Committed by Garmond Leung
Browse files

audio: hal: Fix incorrect boundary check for intereactive audio

Fix incorrect boundary check for pan/scale/downmix controls.
Fix be_id being overridden because of incorrect indexing.

Change-Id: I96a2919a0a3df18a0cbaed48f27c1be43cdc68c8
CRs-fixed: 2091555
parent 6ceda20b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -424,7 +424,10 @@ bool audio_extn_passthru_is_direct_passthrough(struct stream_out *out)
        return false;
    }

    if ((out != NULL) && (out->compr_config.codec->compr_passthr == PASSTHROUGH || out->compr_config.codec->compr_passthr == PASSTHROUGH_IEC61937))
    if ((out != NULL) &&
        (out->compr_config.codec != NULL) &&
        (out->compr_config.codec->compr_passthr == PASSTHROUGH ||
         out->compr_config.codec->compr_passthr == PASSTHROUGH_IEC61937))
        return true;
    else
        return false;
+4 −2
Original line number Diff line number Diff line
@@ -2330,9 +2330,11 @@ int audio_extn_utils_set_downmix_params(

    out->downmix_params.has_mixer_coeffs = mm_params->has_mixer_coeffs;
    for (i = 0; i < mm_params->num_output_channels; i++)
        for (j = 0; j < mm_params->num_input_channels; j++)
        for (j = 0; j < mm_params->num_input_channels; j++) {
            //Convert the channel coefficient gains in Q14 format
            out->downmix_params.mixer_coeffs[i][j] =
                               mm_params->mixer_coeffs[i][j];
                               mm_params->mixer_coeffs[i][j] * (2 << 13);
    }

    ret = platform_set_stream_downmix_params(out->dev->platform,
                                             out->pcm_device_id,
+2 −2
Original line number Diff line number Diff line
@@ -5026,7 +5026,7 @@ int adev_open_output_stream(struct audio_hw_device *dev,
    }

    /* Init use case and pcm_config */
#ifndef COMPRESS_VOIP_ENABLED
#ifndef COMPRES_ENABLED
    if (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX) &&
        (out->sample_rate == 8000 || out->sample_rate == 16000 ||
         out->sample_rate == 32000 || out->sample_rate == 48000)) {
@@ -5039,7 +5039,7 @@ int adev_open_output_stream(struct audio_hw_device *dev,
        out->config.rate = out->sample_rate;

#else
    if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION || voice_extn_compress_voip_is_active(out->dev)) &&
    } else if ((out->dev->mode == AUDIO_MODE_IN_COMMUNICATION || voice_extn_compress_voip_is_active(out->dev)) &&
               (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT | AUDIO_OUTPUT_FLAG_VOIP_RX)) &&
               (voice_extn_compress_voip_is_config_supported(config))) {
        ret = voice_extn_compress_voip_open_output_stream(out);
+17 −15
Original line number Diff line number Diff line
@@ -6072,12 +6072,7 @@ int platform_set_stream_pan_scale_params(void *platform,
    int iter_i = 0;
    int iter_j = 0;
    int length = 0;
    int pan_scale_data[MAX_LENGTH_MIXER_CONTROL_IN_INT] = {0};

    if (sizeof(mm_params) > MAX_LENGTH_MIXER_CONTROL_IN_INT) {
        ret = -EINVAL;
        goto end;
    }
    int *pan_scale_data = NULL;

    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
                          "Audio Stream %d Pan Scale Control", snd_id);
@@ -6090,6 +6085,11 @@ int platform_set_stream_pan_scale_params(void *platform,
        ret = -EINVAL;
        goto end;
    }
    pan_scale_data = (int* ) calloc(1, sizeof(mm_params));
    if (!pan_scale_data) {
        ret = -ENOMEM;
        goto end;
    }
    pan_scale_data[length++] = mm_params.num_output_channels;
    pan_scale_data[length++] = mm_params.num_input_channels;

@@ -6123,6 +6123,8 @@ int platform_set_stream_pan_scale_params(void *platform,

    ret = mixer_ctl_set_array(ctl, pan_scale_data, length);
end:
    if (pan_scale_data)
        free(pan_scale_data);
    return ret;
}

@@ -6135,20 +6137,13 @@ int platform_set_stream_downmix_params(void *platform,
    struct audio_device *adev = my_data->adev;
    struct mixer_ctl *ctl;
    char mixer_ctl_name[MIXER_PATH_MAX_LENGTH] = {0};
    int downmix_param_data[MAX_LENGTH_MIXER_CONTROL_IN_INT] = {0};
    int *downmix_param_data = NULL;
    int ret = 0;
    int iter_i = 0;
    int iter_j = 0;
    int length = 0;
    int be_idx = 0;

    if ((sizeof(mm_params) +
         sizeof(be_idx)) >
        MAX_LENGTH_MIXER_CONTROL_IN_INT) {
        ret = -EINVAL;
        goto end;
    }

    snprintf(mixer_ctl_name, sizeof(mixer_ctl_name),
                          "Audio Device %d Downmix Control", snd_id);
    ALOGD("%s mixer_ctl_name:%s", __func__, mixer_ctl_name);
@@ -6160,8 +6155,13 @@ int platform_set_stream_downmix_params(void *platform,
        ret = -EINVAL;
    }

    downmix_param_data = (int* ) calloc(1, sizeof(mm_params) + sizeof(be_idx));
    if (!downmix_param_data) {
        ret = -ENOMEM;
        goto end;
    }
    be_idx = platform_get_snd_device_backend_index(snd_device);
    downmix_param_data[length]   = be_idx;
    downmix_param_data[length++] = be_idx;
    downmix_param_data[length++] = mm_params.num_output_channels;
    downmix_param_data[length++] = mm_params.num_input_channels;

@@ -6196,6 +6196,8 @@ int platform_set_stream_downmix_params(void *platform,

    ret = mixer_ctl_set_array(ctl, downmix_param_data, length);
end:
    if (downmix_param_data)
        free(downmix_param_data);
    return ret;
}