AudioFlinger: refine latency computation if track is drained
Use server timestamp if track has no actively presented frames
(i.e. drained). Sometimes track frames may not have reached the HAL.
Test: audioflinger dumpsys with BT audio
Bug: 80447764
Change-Id: Iffc52f4cfcbadd419c6b6ccfa278e0712f3af4af
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 27d3919..70fb2b9 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3265,6 +3265,7 @@
t->updateTrackFrameInfo(
t->mAudioTrackServerProxy->framesReleased(),
mFramesWritten,
+ mSampleRate,
mTimestamp);
}
}
@@ -5059,8 +5060,10 @@
dprintf(fd, " AudioMixer tracks: %s\n", mAudioMixer->trackNames().c_str());
dprintf(fd, " Master mono: %s\n", mMasterMono ? "on" : "off");
const double latencyMs = mTimestamp.getOutputServerLatencyMs(mSampleRate);
- if (latencyMs > 0.) {
+ if (latencyMs != 0.) {
dprintf(fd, " NormalMixer latency ms: %.2lf\n", latencyMs);
+ } else {
+ dprintf(fd, " NormalMixer latency ms: unavail\n");
}
if (hasFastMixer()) {