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

Commit 9467e2c5 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

release-request-2950741e-0b24-4d70-b748-67bb2b5435b5-for-git_oc-mr1-release-43...

release-request-2950741e-0b24-4d70-b748-67bb2b5435b5-for-git_oc-mr1-release-4357583 snap-temp-L55500000105655441

Change-Id: I5ce6362290e4adde036240bd18056c4e23045b82
parents 25e3ee8c f4520b0d
Loading
Loading
Loading
Loading
+31 −17
Original line number Diff line number Diff line
@@ -1164,6 +1164,8 @@ int select_devices(struct audio_device *adev,
    audio_usecase_t hfp_ucid;
    struct listnode *node;
    int status = 0;
    struct audio_usecase *voip_usecase = get_usecase_from_list(adev,
                                             USECASE_AUDIO_PLAYBACK_VOIP);

    usecase = get_usecase_from_list(adev, uc_id);
    if (usecase == NULL) {
@@ -1207,8 +1209,6 @@ int select_devices(struct audio_device *adev,
            in_snd_device = SND_DEVICE_NONE;
            if (out_snd_device == SND_DEVICE_NONE) {
                struct stream_out *voip_out = adev->primary_output;
                struct audio_usecase *voip_usecase = get_usecase_from_list(adev,
                                                         USECASE_AUDIO_PLAYBACK_VOIP);

                out_snd_device = platform_get_output_snd_device(adev->platform,
                                            usecase->stream.out->devices);
@@ -1360,6 +1360,12 @@ int select_devices(struct audio_device *adev,
            voice_set_sidetone(adev, out_snd_device, true);
    }

    if (usecase == voip_usecase) {
        struct stream_out *voip_out = voip_usecase->stream.out;
        audio_extn_utils_send_app_type_gain(adev,
                                            voip_out->app_type_cfg.app_type,
                                            &voip_out->app_type_cfg.gain[0]);
    }
    return status;
}

@@ -1946,9 +1952,6 @@ int start_output_stream(struct stream_out *out)
    register_out_stream(out);
    audio_extn_perf_lock_release();
    audio_extn_tfa_98xx_enable_speaker();
    audio_extn_utils_send_app_type_gain(out->dev,
                                        out->app_type_cfg.app_type,
                                        &out->app_type_cfg.gain[0]);

    // consider a scenario where on pause lower layers are tear down.
    // so on resume, swap mixer control need to be sent only when
@@ -2672,20 +2675,35 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
    } else {
        error_code = ERROR_CODE_WRITE;
        if (out->pcm) {
            size_t bytes_to_write = bytes;

            if (out->muted)
                memset((void *)buffer, 0, bytes);
            // FIXME: this can be removed once audio flinger mixer supports mono output
            if (out->usecase == USECASE_AUDIO_PLAYBACK_VOIP) {
                size_t channel_count = audio_channel_count_from_out_mask(out->channel_mask);
                int16_t *src = (int16_t *)buffer;
                int16_t *dst = (int16_t *)buffer;

                LOG_ALWAYS_FATAL_IF(out->config.channels != 1 || channel_count != 2 ||
                                    out->format != AUDIO_FORMAT_PCM_16_BIT,
                                    "out_write called for VOIP use case with wrong properties");

            ALOGVV("%s: writing buffer (%zu bytes) to pcm device", __func__, bytes);
                for (size_t i = 0; i < frames ; i++, dst++, src += 2) {
                    *dst = (int16_t)(((int32_t)src[0] + (int32_t)src[1]) >> 1);
                }
                bytes_to_write /= 2;
            }
            ALOGVV("%s: writing buffer (%zu bytes) to pcm device", __func__, bytes_to_write);

            long ns = pcm_bytes_to_frames(out->pcm, bytes)*1000000000LL/
                                                out->config.rate;
            long ns = (frames * NANOS_PER_SECOND) / out->config.rate;
            request_out_focus(out, ns);

            bool use_mmap = is_mmap_usecase(out->usecase) || out->realtime;
            if (use_mmap)
                ret = pcm_mmap_write(out->pcm, (void *)buffer, bytes);
                ret = pcm_mmap_write(out->pcm, (void *)buffer, bytes_to_write);
            else
                ret = pcm_write(out->pcm, (void *)buffer, bytes);
                ret = pcm_write(out->pcm, (void *)buffer, bytes_to_write);

            release_out_focus(out, ns);
        } else {
@@ -3803,17 +3821,13 @@ static int adev_open_output_stream(struct audio_hw_device *dev,
        out->usecase = USECASE_AUDIO_PLAYBACK_AFE_PROXY;
        out->config = pcm_config_afe_proxy_playback;
        adev->voice_tx_output = out;
    } else if (out->flags == (AUDIO_OUTPUT_FLAG_DIRECT |
                              AUDIO_OUTPUT_FLAG_VOIP_RX)) {
    } else if (out->flags == AUDIO_OUTPUT_FLAG_VOIP_RX) {
        //FIXME: add support for MONO stream configuration when audioflinger mixer supports it
        uint32_t buffer_size, frame_size;
        out->supported_channel_masks[0] = AUDIO_CHANNEL_OUT_MONO;
        out->channel_mask = AUDIO_CHANNEL_OUT_MONO;
        out->usecase = USECASE_AUDIO_PLAYBACK_VOIP;
        out->config = pcm_config_voip;
        out->config.format = pcm_format_from_audio_format(config->format);
        out->config.rate = config->sample_rate;
        out->config.channels =
                audio_channel_count_from_out_mask(config->channel_mask);
        buffer_size = get_stream_buffer_size(VOIP_PLAYBACK_PERIOD_DURATION_MSEC,
                                             config->sample_rate,
                                             config->format,