Consider the screen still until proven otherwise
In order to avoid always forcing static mode after initialization or
recentering, consider the screen still by default.
This required adding a defaultValue option to the detector, to be used
during the initialization period.
Test: atest --host libheadtracking-test
Change-Id: I7f5a39a0fbca898c55f637e311ec1ea44a10d9f3
diff --git a/media/libheadtracking/StillnessDetector.cpp b/media/libheadtracking/StillnessDetector.cpp
index 5fa4e3a..8f9b53a 100644
--- a/media/libheadtracking/StillnessDetector.cpp
+++ b/media/libheadtracking/StillnessDetector.cpp
@@ -35,13 +35,13 @@
bool StillnessDetector::calculate(int64_t timestamp) {
discardOld(timestamp);
- // If the window has not been full, we don't consider ourselves still.
+ // If the window has not been full, return the default value.
if (!mWindowFull) {
- return false;
+ return mOptions.defaultValue;
}
- // An empty FIFO and window full is considered still (this will happen in the unlikely case when
- // the window duration is shorter than the gap between samples).
+ // An empty FIFO and window full is considered still (this will happen when the window duration
+ // is shorter than the gap between samples, including the window size being 0).
if (mFifo.empty()) {
return true;
}