aaudio: improve accuracy of timestamps
Account for latency added by the AAudio service.
Fix input timestamps.
Bug: 37080396
Test: test_timestamps.cpp input_monitor.cpp
Change-Id: I1053cd21af722bb9b9371df4e5731bf4a0a57b0b
diff --git a/services/oboeservice/AAudioServiceStreamMMAP.h b/services/oboeservice/AAudioServiceStreamMMAP.h
index 533e5a8..e6f8fad 100644
--- a/services/oboeservice/AAudioServiceStreamMMAP.h
+++ b/services/oboeservice/AAudioServiceStreamMMAP.h
@@ -100,6 +100,8 @@
aaudio_result_t getDownDataDescription(AudioEndpointParcelable &parcelable) override;
aaudio_result_t getFreeRunningPosition(int64_t *positionFrames, int64_t *timeNanos) override;
+ virtual aaudio_result_t getHardwareTimestamp(int64_t *positionFrames,
+ int64_t *timeNanos) override;
private:
// This proxy class was needed to prevent a crash in AudioFlinger
@@ -132,6 +134,7 @@
MonotonicCounter mFramesRead;
int32_t mPreviousFrameCounter = 0; // from HAL
int mAudioDataFileDescriptor = -1;
+ int64_t mHardwareTimeOffsetNanos = 0; // TODO get from HAL
// Interface to the AudioFlinger MMAP support.
android::sp<android::MmapStreamInterface> mMmapStream;