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
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 96f252c..097583b 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2069,6 +2069,11 @@
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;