Limit cached timestamp use if HW fails to provide them
On some devices, if the HDMI cable is disconnected during use,
cached timestamp info can become very old.
Bug: 29423451
Change-Id: Ieecf5e98bad14d00b4f5f14b032c2cf66ae94ceb
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index 546ef25..01f3939 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -482,8 +482,6 @@
} else {
// HAL reported that more frames were presented than were written
mNativeFramesWrittenButNotPresented = 0;
- mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL] = 0;
- mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] = -1;
status = INVALID_OPERATION;
}
}
@@ -494,6 +492,10 @@
// fetch server time if we can't get timestamp
mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_SERVER] =
systemTime(SYSTEM_TIME_MONOTONIC);
+ // clear out kernel cached position as this may get rapidly stale
+ // if we never get a new valid timestamp
+ mTimestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL] = 0;
+ mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] = -1;
}
}
}