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

Commit c49a3b50 authored by Weiyin Jiang's avatar Weiyin Jiang Committed by Gerrit - the friendly Code Review server
Browse files

audio: adjust latency for pcm offload stream

Choppy noise is heard when inserting usb headset during pcm offload
playback. That's because muteWaitMs calculated based on output latency
is inaccurate. COMPRESS_OFFLOAD_PLAYBACK_LATENCY a fixed estimation
value is used for both pcm and compress offload. But for pcm offload
use case, this value is not sufficient enough to ensure PCM buffer
completely presented before output/device change happens.

Fix is to introduce accurate latency for pcm offload. This number is
calculated based on real DSP path delay and buffer duration.

Change-Id: Id2b2b13b7aae06fa0ac3896b24fa693b8b1a6de5
CRs-Fixed: 2293194
parent e2ee1ed2
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 * Not a Contribution.
 *
 * Copyright (C) 2014 The Android Open Source Project
@@ -102,6 +102,9 @@

/* ToDo: Check and update a proper value in msec */
#define COMPRESS_OFFLOAD_PLAYBACK_LATENCY  50
#define PCM_OFFLOAD_PLAYBACK_DSP_PATHDELAY 62
#define PCM_OFFLOAD_PLAYBACK_LATENCY \
    (PCM_OFFLOAD_BUFFER_DURATION + PCM_OFFLOAD_PLAYBACK_DSP_PATHDELAY)

#ifndef MAX_CHANNELS_SUPPORTED
#define MAX_CHANNELS_SUPPORTED 8
@@ -1806,6 +1809,12 @@ int audio_extn_utils_compress_get_dsp_latency(struct stream_out *out)
    struct snd_compr_metadata metadata;
    int delay_ms = COMPRESS_OFFLOAD_PLAYBACK_LATENCY;

    /* override the latency for pcm offload use case */
    if ((out->flags & AUDIO_OUTPUT_FLAG_DIRECT) &&
        !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)) {
        delay_ms = PCM_OFFLOAD_PLAYBACK_LATENCY;
    }

    if (property_get_bool("vendor.audio.playback.dsp.pathdelay", false)) {
        ALOGD("%s:: Quering DSP delay %d",__func__, __LINE__);
        if (!(is_offload_usecase(out->usecase))) {