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

Commit 59d296d8 authored by Ravi Kumar Alamanda's avatar Ravi Kumar Alamanda Committed by Iliyan Malchev
Browse files

hal: select speaker mic for voice communication



- Current implementation selects handset mic for voice
  communication in speaker mode
- Check if the primary output (rx path) is active on
  speaker and select speaker mic during input device
  selection
- If the tx path is started first, ensure that tx device
  is updated while starting the rx path.

Bug: 8325112
Change-Id: I1c556c0c9c92e599c8a1f68575b26ecdad155e7e
Signed-off-by: default avatarIliyan Malchev <malchev@google.com>
parent 73fb11d9
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -764,14 +764,27 @@ static int select_devices(struct audio_device *adev,
        if (usecase->type == PCM_PLAYBACK) {
            usecase->devices = usecase->stream.out->devices;
            in_snd_device = SND_DEVICE_NONE;
            if (out_snd_device == SND_DEVICE_NONE)
            if (out_snd_device == SND_DEVICE_NONE) {
                out_snd_device = get_output_snd_device(adev,
                                            usecase->stream.out->devices);
                if (usecase->stream.out == adev->primary_output &&
                        adev->active_input &&
                        adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
                    select_devices(adev, adev->active_input->usecase);
                }
            }
        } else if (usecase->type == PCM_CAPTURE) {
            usecase->devices = usecase->stream.in->device;
            out_snd_device = SND_DEVICE_NONE;
            if (in_snd_device == SND_DEVICE_NONE)
                in_snd_device = get_input_snd_device(adev, SND_DEVICE_NONE);
            if (in_snd_device == SND_DEVICE_NONE) {
                if (adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION &&
                        adev->primary_output && !adev->primary_output->standby) {
                    in_snd_device = get_input_snd_device(adev,
                                        adev->primary_output->devices);
                } else {
                    in_snd_device = get_input_snd_device(adev, AUDIO_DEVICE_NONE);
                }
            }
        }
    }

@@ -1402,13 +1415,14 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,

    pthread_mutex_lock(&out->lock);
    if (out->standby) {
        out->standby = false;
        pthread_mutex_lock(&adev->lock);
        ret = start_output_stream(out);
        pthread_mutex_unlock(&adev->lock);
        if (ret != 0) {
            out->standby = true;
            goto exit;
        }
        out->standby = false;
    }

    if (out->pcm) {