summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhou Song <quic_zhous@quicinc.com>2022-06-29 10:53:14 +0800
committerGerrit - the friendly Code Review server <code-review@localhost>2022-07-28 04:45:14 -0700
commitd23bf389c25131a324ee30c6a18918d266ae905e (patch)
tree505fdad19e8775d5e95b055aa4e6737c03c77738
parentd7676cfd5087b9eb2eb7c2e1516f85e993c42d0f (diff)
ahal: fix invalid pcm offload position when SSR happens
When SSR happens, postion queried from DSP could be invalid, instead, frames written could be returned as current position. Also cache the current position as compensation, when sound card is online, return current DSP position plus the compensation. Change-Id: Iff1b1ae9e5217f384d6ae0460b3acee5f8881aa5
-rw-r--r--hal/AudioStream.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/hal/AudioStream.cpp b/hal/AudioStream.cpp
index bcfb3a78..d320f155 100644
--- a/hal/AudioStream.cpp
+++ b/hal/AudioStream.cpp
@@ -2806,6 +2806,19 @@ int StreamOutPrimary::GetFrames(uint64_t *frames)
*frames = 0;
return 0;
}
+ /*
+ * when ssr happens, dsp position for pcm offload could be 0,
+ * so return written frames instead
+ */
+ if ((PAL_STREAM_PCM_OFFLOAD == streamAttributes_.type) &&
+ (CARD_STATUS_OFFLINE == AudioDevice::sndCardState)) {
+ struct timespec ts;
+ *frames = GetFramesWritten(&ts);
+ mCachedPosition = *frames;
+ AHAL_DBG("card is offline, return written frames %lld", (long long) *frames);
+ goto exit;
+ }
+
ret = pal_get_timestamp(pal_stream_handle_, &tstamp);
if (ret != 0) {
AHAL_ERR("pal_get_timestamp failed %d", ret);