Audio HAL VTS: GetPresentationPosition may return 0 on stop stream
GetPresentationPosition returns the last time a sample was written to
the hardware.
Calling it on a stop stream should return 0 sample written, but the
timestamps of that measure is of little importance.
Thus allow this timestamp to be 0 indicating that the measure was never
actually made.
Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 36311550
Change-Id: I3c33b60f98e8cbea269a7739cc1889af932dcff5
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
index c31026f..9653886 100644
--- a/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
+++ b/audio/2.0/vts/functional/AudioPrimaryHidlHalTest.cpp
@@ -1297,6 +1297,13 @@
}
ASSERT_EQ(0U, frames);
+ if (mesureTS.tvNSec == 0 && mesureTS.tvSec == 0) {
+ // As the stream has never written a frame yet,
+ // the timestamp does not really have a meaning, allow to return 0
+ return;
+ }
+
+ // Make sure the return measure is not more than 1s old.
struct timespec currentTS;
ASSERT_EQ(0, clock_gettime(CLOCK_MONOTONIC, ¤tTS)) << errno;