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

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

hal: Use cached value of bt encoder format for encoder latency

Fixes device switch from A2dp to speaker taking 10+ seconds.
Communication from audio hal to bt ipc lib results in multiple
socket failures with host as BT is disconnecting. Use cached
encoder format rather than querying again, this will avoid adding
additional latency due to encoder latency checks.

CRs-Fixed: 2028982
Change-Id: I91bd8060660efa0ab163c70112eae59b9a594377
parent 862b39ab
Loading
Loading
Loading
Loading
+1 −13
Original line number Diff line number Diff line
@@ -827,23 +827,11 @@ void audio_extn_a2dp_init (void *adev)

uint32_t audio_extn_a2dp_get_encoder_latency()
{
    void *codec_info = NULL;
    uint8_t multi_cast = 0, num_dev = 1;
    audio_format_t codec_type = AUDIO_FORMAT_INVALID;
    uint32_t latency = 0;
    int avsync_runtime_prop = 0;
    int sbc_offset = 0, aptx_offset = 0, aptxhd_offset = 0, aac_offset = 0;
    char value[PROPERTY_VALUE_MAX];

    if (!a2dp.audio_get_codec_config) {
        ALOGE(" a2dp handle is not identified");
        return latency;
    }

    if (a2dp.a2dp_started)
        codec_info = a2dp.audio_get_codec_config(&multi_cast, &num_dev,
                               &codec_type);

    memset(value, '\0', sizeof(char)*PROPERTY_VALUE_MAX);
    avsync_runtime_prop = property_get("audio.a2dp.codec.latency", value, NULL);
    if (avsync_runtime_prop > 0) {
@@ -854,7 +842,7 @@ uint32_t audio_extn_a2dp_get_encoder_latency()
        }
    }

    switch(codec_type) {
    switch(a2dp.bt_encoder_format) {
        case AUDIO_FORMAT_SBC:
            latency = (avsync_runtime_prop > 0) ? sbc_offset : 150;
            break;