Enable FastTrack timestamps
Bug: 26413951
Change-Id: Id54c32cb0f0be83d443f6cf1007181ebc461c586
diff --git a/services/audioflinger/PlaybackTracks.h b/services/audioflinger/PlaybackTracks.h
index c81bbf9..fe3cc53 100644
--- a/services/audioflinger/PlaybackTracks.h
+++ b/services/audioflinger/PlaybackTracks.h
@@ -89,6 +89,7 @@
// ExtendedAudioBufferProvider interface
virtual size_t framesReady() const;
virtual size_t framesReleased() const;
+ virtual void onTimestamp(const AudioTimestamp ×tamp);
bool isPausing() const { return mState == PAUSING; }
bool isPaused() const { return mState == PAUSED; }
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index 5f70479..6f84af1 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -76,8 +76,6 @@
// be dropped and therefore not read by the application.
sp<SyncEvent> mSyncStartEvent;
- AudioRecordServerProxy *mAudioRecordServerProxy;
-
// number of captured frames to drop after the start sync event has been received.
// when < 0, maximum frames to drop before starting capture even if sync event is
// not received
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 5aff394..4807400 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -6157,7 +6157,7 @@
// update frame information and push timestamp out
activeTrack->updateTrackFrameInfo(
- activeTrack->mAudioRecordServerProxy->framesReleased(),
+ activeTrack->mServerProxy->framesReleased(),
mTimestamp.mPosition[ExtendedTimestamp::LOCATION_SERVER],
mSampleRate, mTimestamp);
}
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index b719046..536581c 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -596,6 +596,20 @@
return mAudioTrackServerProxy->framesReleased();
}
+void AudioFlinger::PlaybackThread::Track::onTimestamp(const AudioTimestamp ×tamp)
+{
+ // This call comes from a FastTrack and should be kept lockless.
+ // The server side frames are already translated to client frames.
+
+ ExtendedTimestamp ets;
+ ets.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] =
+ timestamp.mTime.tv_sec * 1000000000LL + timestamp.mTime.tv_nsec;
+ ets.mPosition[ExtendedTimestamp::LOCATION_KERNEL] = timestamp.mPosition;
+
+ // Caution, this doesn't set the timebase for BOOTTIME properly, but is ignored right now.
+ mAudioTrackServerProxy->setTimestamp(ets);
+}
+
// Don't call for fast tracks; the framesReady() could result in priority inversion
bool AudioFlinger::PlaybackThread::Track::isReady() const {
if (mFillingUpStatus != FS_FILLING || isStopped() || isPausing()) {
@@ -1438,9 +1452,8 @@
return;
}
- mAudioRecordServerProxy = new AudioRecordServerProxy(mCblk, mBuffer, frameCount,
+ mServerProxy = new AudioRecordServerProxy(mCblk, mBuffer, frameCount,
mFrameSize, !isExternalTrack());
- mServerProxy = mAudioRecordServerProxy;
mResamplerBufferProvider = new ResamplerBufferProvider(this);
@@ -1594,7 +1607,7 @@
local.mPosition[i] = relativeTrackFrames + trackFramesReleased;
}
}
- mAudioRecordServerProxy->setExtendedTimestamp(local);
+ mServerProxy->setTimestamp(local);
}
AudioFlinger::RecordThread::PatchRecord::PatchRecord(RecordThread *recordThread,