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

Commit ff61315a authored by Aniket Kumar Lata's avatar Aniket Kumar Lata Committed by Shiv Maliyappanahalli
Browse files

hal: AV sync latency adjustment for non direct profiles

Presentation position calculation for signed_frames does not
account for encoder/sink device latencies. Adjust frames for
non direct profiles based on BT codec in use.

CRs-Fixed: 2078710
Change-Id: Ic3328326f941380b0ae48534ac5d7be22095da23
parent 761ce6cd
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -3254,7 +3254,7 @@ static uint32_t out_get_latency(const struct audio_stream_out *stream)
           (out->config.rate);
    }

    if ((AUDIO_DEVICE_OUT_BLUETOOTH_A2DP == out->devices) &&
    if ((AUDIO_DEVICE_OUT_ALL_A2DP & out->devices) &&
            !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD))
        latency += audio_extn_a2dp_get_encoder_latency();

@@ -3717,6 +3717,13 @@ static int out_get_presentation_position(const struct audio_stream_out *stream,
                signed_frames -=
                    (platform_render_latency(out->usecase) * out->sample_rate / 1000000LL);

                // Adjustment accounts for A2dp encoder latency with non offload usecases
                // Note: Encoder latency is returned in ms, while platform_render_latency in us.
                if (AUDIO_DEVICE_OUT_ALL_A2DP & out->devices) {
                    signed_frames -=
                        (audio_extn_a2dp_get_encoder_latency() * out->sample_rate / 1000);
                }

                // It would be unusual for this value to be negative, but check just in case ...
                if (signed_frames >= 0) {
                    *frames = signed_frames;