Implement server side playback timestamps with 64 bit accuracy
Provide server timestamps if the HAL doesn't provide it.
Provide monotonic - boottime translation.
Integrate record timestamps and playback timestamps together.
Bug: 17472992
Bug: 22871200
Bug: 26400089
Bug: 26682703
Change-Id: If1974f94232fcce7ba0bbcdf63d9e54ed51918ff
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index 7c92c1c..507f197 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -381,7 +381,7 @@
};
void acquireWakeLock(int uid = -1);
- void acquireWakeLock_l(int uid = -1);
+ virtual void acquireWakeLock_l(int uid = -1);
void releaseWakeLock();
void releaseWakeLock_l();
void updateWakeLockUids(const SortedVector<int> &uids);
@@ -460,6 +460,7 @@
sp<NBLog::Writer> mNBLogWriter;
bool mSystemReady;
bool mNotifiedBatteryStart;
+ ExtendedTimestamp mTimestamp;
};
// --- PlaybackThread ---
@@ -691,9 +692,7 @@
// 'volatile' means accessed via atomic operations and no lock.
volatile int32_t mSuspended;
- // FIXME overflows every 6+ hours at 44.1 kHz stereo 16-bit samples
- // mFramesWritten would be better, or 64-bit even better
- size_t mBytesWritten;
+ int64_t mBytesWritten;
private:
// mMasterMute is in both PlaybackThread and in AudioFlinger. When a
// PlaybackThread needs to find out if master-muted, it checks it's local
@@ -868,6 +867,14 @@
virtual uint32_t suspendSleepTimeUs() const;
virtual void cacheParameters_l();
+ virtual void acquireWakeLock_l(int uid = -1) {
+ PlaybackThread::acquireWakeLock_l(uid);
+ if (hasFastMixer()) {
+ mFastMixer->setBoottimeOffset(
+ mTimestamp.mTimebaseOffset[ExtendedTimestamp::TIMEBASE_BOOTTIME]);
+ }
+ }
+
// threadLoop snippets
virtual ssize_t threadLoop_write();
virtual void threadLoop_standby();
@@ -1311,8 +1318,6 @@
// rolling index that is never cleared
int32_t mRsmpInRear; // last filled frame + 1
- ExtendedTimestamp mTimestamp;
-
// For dumpsys
const sp<NBAIO_Sink> mTeeSink;