aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPhil Burk <philburk@google.com>2019-09-02 15:58:27 -0700
committerPhil Burk <philburk@google.com>2019-09-02 15:58:27 -0700
commitc230a4966aef824fe0c53c3200fb1d806e97d741 (patch)
tree7e17f39a73533fedf29216a4c3c21a4e07a21dad /include
parenta769295bdb6ed8165e8b9895ab06665e5909aca6 (diff)
downloadoboe-c230a4966aef824fe0c53c3200fb1d806e97d741.tar.gz
oboe: add waitForAvailableFrames()
This can avoid glitches if the input buffer is too empty and the MMAP timing is unreliable.
Diffstat (limited to 'include')
-rw-r--r--include/oboe/AudioStream.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/include/oboe/AudioStream.h b/include/oboe/AudioStream.h
index 1f7954ed..d9b2046a 100644
--- a/include/oboe/AudioStream.h
+++ b/include/oboe/AudioStream.h
@@ -401,6 +401,23 @@ public:
return previousCallback;
}
+ /**
+ * @return number of frames of data currently in the buffer
+ */
+ ResultWithValue<int32_t> getAvailableFrames();
+
+ /**
+ * Wait until the stream has a minimum amount of data available in its buffer.
+ * This can be used with an EXCLUSIVE MMAP input stream to avoid reading data too close to
+ * the DSP write position, which may cause glitches.
+ *
+ * @param numFrames minimum frames available
+ * @param timeoutNanoseconds
+ * @return number of frames available, ErrorTimeout
+ */
+ ResultWithValue<int32_t> waitForAvailableFrames(int32_t numFrames,
+ int64_t timeoutNanoseconds);
+
protected:
/**