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

Commit 0b2e5dc8 authored by Zhou Song's avatar Zhou Song
Browse files

audio_hal: increase written frames size when HAL is in SSR

Written PCM frames count is not increased when HAL stays in SSR,
it can make mismatch with the written framecount in AudioFlinger,
so rendered frames count return from AudioFlinger is not correct.
Then A/V sync will be missed since the played audio duration is
calculated by rendered frames count.

Increase the written frames count even the frames are not written
to the PCM driver during SSR.

CRs-Fixed: 791738

Change-Id: I53cfeae9294ae1f5a6466a749da90d1f8ef297cb
parent 52f8653d
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2069,6 +2069,11 @@ static ssize_t out_write(struct audio_stream_out *stream, const void *buffer,
    pthread_mutex_lock(&out->lock);

    if (SND_CARD_STATE_OFFLINE == snd_scard_state) {
        // increase written size during SSR to avoid mismatch
        // with the written frames count in AF
        if (!is_offload_usecase(out->usecase))
            out->written += bytes / (out->config.channels * sizeof(short));

        if (out->pcm) {
            ALOGD(" %s: sound card is not active/SSR state", __func__);
            ret= -EIO;