AudioTrack: add setBufferSizeInFrames()
Also add getBufferCapacityInFrames().
These can be used to dynamically raise or lower latency.
Bug: 21019153
Signed-off-by: Phil Burk <philburk@google.com>
Change-Id: I02ca7f6f5cc4e089fcd81cc8a2b6ff234e0381a8
diff --git a/include/private/media/AudioTrackShared.h b/include/private/media/AudioTrackShared.h
index e458f3c..68d27bb 100644
--- a/include/private/media/AudioTrackShared.h
+++ b/include/private/media/AudioTrackShared.h
@@ -204,6 +204,8 @@
size_t mNonContig; // number of additional non-contiguous frames available
};
+ size_t frameCount() const { return mFrameCount; }
+
protected:
// These refer to shared memory, and are virtual addresses with respect to the current process.
// They may have different virtual addresses within the other process.
@@ -285,7 +287,7 @@
return mEpoch + mCblk->mServer;
}
- void setEpoch(const Modulo<uint32_t> &epoch) {
+ void setEpoch(const Modulo<uint32_t> &epoch) {
mEpoch = epoch;
}
@@ -305,6 +307,15 @@
return mEpoch;
}
+ size_t getBufferSizeInFrames() const { return mBufferSizeInFrames; }
+ // See documentation for AudioTrack.setBufferSizeInFrames()
+ size_t setBufferSizeInFrames(size_t requestedSize);
+
+protected:
+ // This is set by AudioTrack.setBufferSizeInFrames().
+ // A write will not fill the buffer above this limit.
+ size_t mBufferSizeInFrames; // effective size of the buffer
+
private:
Modulo<uint32_t> mEpoch;
};