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

Commit 8426d1f9 authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Gerrit - the friendly Code Review server
Browse files

hal: Fix VoIP Rx no sound after openOutput if setVolume is not received

HAL sets cached stream volume for VoIP with start output
or device switches. When an output is opened, all stream
members are initialized to 0. After opening an output
if we receive a write before setVolume is called, HAL
sets VoIP stream volume, which is 0 in this case.
Hence Rx is muted. Certain apps do not call setVolume
as frequently as they should leading to the call being
muted until app sends a volume change.

Fix this behavior by not setting VoIP volume as 0 from HAL
until a valid volume is set by client. Let default volume
get applied in lower layers for such scenarios.

Bug: 133829194
Change-Id: I281916295d9458b62a1c6b4b82b6a80116fbbcb9
parent f81da24f
Loading
Loading
Loading
Loading
+14 −0
Original line number Original line Diff line number Diff line
@@ -93,6 +93,7 @@
#define MMAP_PLAYBACK_VOLUME_MAX 0x2000
#define MMAP_PLAYBACK_VOLUME_MAX 0x2000
#define PCM_PLAYBACK_VOLUME_MAX 0x2000
#define PCM_PLAYBACK_VOLUME_MAX 0x2000
#define DSD_VOLUME_MIN_DB (-110)
#define DSD_VOLUME_MIN_DB (-110)
#define INVALID_OUT_VOLUME -1


#define RECORD_GAIN_MIN 0.0f
#define RECORD_GAIN_MIN 0.0f
#define RECORD_GAIN_MAX 1.0f
#define RECORD_GAIN_MAX 1.0f
@@ -779,6 +780,11 @@ static inline bool is_mmap_usecase(audio_usecase_t uc_id)
           (uc_id == USECASE_AUDIO_PLAYBACK_AFE_PROXY);
           (uc_id == USECASE_AUDIO_PLAYBACK_AFE_PROXY);
}
}


static inline bool is_valid_volume(float left, float right)
{
    return ((left >= 0.0f && right >= 0.0f) ? true : false);
}

static int enable_audio_route_for_voice_usecases(struct audio_device *adev,
static int enable_audio_route_for_voice_usecases(struct audio_device *adev,
                                                 struct audio_usecase *uc_info)
                                                 struct audio_usecase *uc_info)
{
{
@@ -4820,6 +4826,12 @@ static int out_set_voip_volume(struct audio_stream_out *stream, float left,
    struct mixer_ctl *ctl;
    struct mixer_ctl *ctl;
    long set_values[4];
    long set_values[4];


    if (!is_valid_volume(left, right)) {
        ALOGE("%s: Invalid stream volume for left=%f, right=%f",
                   __func__, left, right);
        return -EINVAL;
    }

    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
    ctl = mixer_get_ctl_by_name(adev->mixer, mixer_ctl_name);
    if (!ctl) {
    if (!ctl) {
        ALOGE("%s: Could not get ctl for mixer cmd - %s",
        ALOGE("%s: Could not get ctl for mixer cmd - %s",
@@ -6980,6 +6992,8 @@ int adev_open_output_stream(struct audio_hw_device *dev,
                                        AUDIO_CHANNEL_OUT_MONO : AUDIO_CHANNEL_OUT_STEREO;
                                        AUDIO_CHANNEL_OUT_MONO : AUDIO_CHANNEL_OUT_STEREO;
                out->usecase = USECASE_AUDIO_PLAYBACK_VOIP;
                out->usecase = USECASE_AUDIO_PLAYBACK_VOIP;
                out->format = AUDIO_FORMAT_PCM_16_BIT;
                out->format = AUDIO_FORMAT_PCM_16_BIT;
                out->volume_l = INVALID_OUT_VOLUME;
                out->volume_r = INVALID_OUT_VOLUME;


                out->config = default_pcm_config_voip_copp;
                out->config = default_pcm_config_voip_copp;
                out->config.period_size = VOIP_IO_BUF_SIZE(out->sample_rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
                out->config.period_size = VOIP_IO_BUF_SIZE(out->sample_rate, DEFAULT_VOIP_BUF_DURATION_MS, DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;