diff options
author | Phil Burk <philburk@google.com> | 2019-09-02 15:58:27 -0700 |
---|---|---|
committer | Phil Burk <philburk@google.com> | 2019-09-02 15:58:27 -0700 |
commit | c230a4966aef824fe0c53c3200fb1d806e97d741 (patch) | |
tree | 7e17f39a73533fedf29216a4c3c21a4e07a21dad /include | |
parent | a769295bdb6ed8165e8b9895ab06665e5909aca6 (diff) | |
download | oboe-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.h | 17 |
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: /** |