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

Commit c46d0fa9 authored by Nadav Bar's avatar Nadav Bar
Browse files

Mute RX device according to volume in set_voice_volume

Sends the "Rx Device Mute" mixer ctl  with parameter 1
in platform_set_voice_volume when volume index matches the mute state.
Sends the same ctl with parameter 0 in case RX stream should not be
muted.
Part of a change which enables apps with MODIFY_PHONE_STATE
permission to mute the (Voice Call) RX stream.

Bug: 71017264
Fixes: 71017264
Test: Tested manually
Change-Id: I3e0b7b0d72f5c3e7b37e8c109067818153c82947
parent f1aaf36b
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -2107,6 +2107,7 @@ int platform_set_voice_volume(void *platform, int volume)
    struct audio_device *adev = my_data->adev;
    struct mixer_ctl *ctl;
    const char *mixer_ctl_name = "Voice Rx Gain";
    const char *mute_mixer_ctl_name = "Voice Rx Device Mute";
    int vol_index = 0, ret = 0;
    uint32_t set_values[ ] = {0,
                              ALL_SESSION_VSID,
@@ -2127,6 +2128,24 @@ int platform_set_voice_volume(void *platform, int volume)
    ALOGV("Setting voice volume index: %d", set_values[0]);
    mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));

    // Send mute command in case volume index is max since indexes are inverted
    // for mixer controls.
    if (vol_index == my_data->max_vol_index) {
        set_values[0] = 1;
    }
    else {
        set_values[0] = 0;
    }

    ctl = mixer_get_ctl_by_name(adev->mixer, mute_mixer_ctl_name);
    if (!ctl) {
        ALOGE("%s: Could not get ctl for mixer cmd - %s",
              __func__, mute_mixer_ctl_name);
        return -EINVAL;
    }
    ALOGV("%s: Setting RX Device Mute to: %d", __func__, set_values[0]);
    mixer_ctl_set_array(ctl, set_values, ARRAY_SIZE(set_values));

    if (my_data->csd != NULL) {
        ret = my_data->csd->volume(ALL_SESSION_VSID, volume,
                                   DEFAULT_VOLUME_RAMP_DURATION_MS);