24#include "oboe/Definitions.h"
25#include "oboe/ResultWithValue.h"
26#include "oboe/AudioStreamBuilder.h"
27#include "oboe/AudioStreamBase.h"
91 return Result::ErrorUnimplemented;
187 int64_t timeoutNanoseconds) = 0;
209 return Result::ErrorUnimplemented;
330 return Result::ErrorUnimplemented;
484 return mErrorCallbackResult;
488 int32_t getDelayBeforeCloseMillis()
const {
489 return mDelayBeforeCloseMillis;
534 mPerformanceHintEnabled =
enabled;
544 return mPerformanceHintEnabled;
559 return mErrorCallbackCalled.exchange(
true);
580 return DataCallbackResult::Stop;
597 return mDataCallbackEnabled;
605 mDataCallbackEnabled =
enabled;
618 if (mDelayBeforeCloseMillis > 0) {
619 usleep(mDelayBeforeCloseMillis * 1000);
643 void setWeakThis(std::shared_ptr<oboe::AudioStream> &
sharedStream) {
650 std::shared_ptr<oboe::AudioStream> lockWeakThis() {
651 return mWeakThis.lock();
654 std::weak_ptr<AudioStream> mWeakThis;
684 static constexpr int kMinDelayBeforeCloseMillis = 10;
685 int32_t mDelayBeforeCloseMillis = kMinDelayBeforeCloseMillis;
690 void checkScheduler();
691 int mPreviousScheduler = -1;
693 std::atomic<bool> mDataCallbackEnabled{
false};
694 std::atomic<bool> mErrorCallbackCalled{
false};
696 std::atomic<bool> mPerformanceHintEnabled{
false};
Definition AudioStreamBase.h:30
int32_t mChannelCount
Definition AudioStreamBase.h:250
AudioStreamDataCallback * mDataCallback
Definition AudioStreamBase.h:240
AudioStreamErrorCallback * mErrorCallback
Definition AudioStreamBase.h:244
Definition AudioStreamBuilder.h:34
Definition AudioStreamCallback.h:34
Definition AudioStreamCallback.h:102
Definition AudioStream.h:44
int32_t mFramesPerBurst
Definition AudioStream.h:680
virtual Result pause(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
std::atomic< int64_t > mFramesRead
Definition AudioStream.h:670
virtual Result waitForStateChange(StreamState inputState, StreamState *nextState, int64_t timeoutNanoseconds)=0
virtual DataCallbackResult onDefaultCallback(void *, int)
Definition AudioStream.h:579
void setDataCallbackEnabled(bool enabled)
Definition AudioStream.h:604
bool usesAAudio() const
Definition AudioStream.h:404
virtual AudioApi getAudioApi() const =0
int32_t getFramesPerBurst() const
Definition AudioStream.h:238
virtual Result flush(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
virtual Result requestStart()=0
virtual ResultWithValue< double > calculateLatencyMillis()
Definition AudioStream.h:302
virtual ResultWithValue< int32_t > read(void *, int32_t, int64_t)
Definition AudioStream.h:386
virtual bool isXRunCountSupported() const =0
int32_t getBytesPerSample() const
virtual ResultWithValue< int32_t > getXRunCount()
Definition AudioStream.h:224
virtual void updateFramesRead()=0
virtual StreamState getState()=0
virtual Result release()
Definition AudioStream.h:90
virtual void closePerformanceHint()
Definition AudioStream.h:637
int32_t getBytesPerFrame() const
Definition AudioStream.h:249
void sleepBeforeClose()
Definition AudioStream.h:617
virtual void updateFramesWritten()=0
virtual Result open()
Definition AudioStream.h:67
virtual void beginPerformanceHintInCallback()
Definition AudioStream.h:626
virtual Result requestFlush()=0
virtual void endPerformanceHintInCallback(int32_t)
Definition AudioStream.h:632
virtual Result requestPause()=0
virtual Result requestStop()=0
std::atomic< int64_t > mFramesWritten
Definition AudioStream.h:662
virtual Result waitForStateTransition(StreamState startingState, StreamState endingState, int64_t timeoutNanoseconds)
virtual void * getUnderlyingStream() const
Definition AudioStream.h:416
AudioStream(const AudioStreamBuilder &builder)
virtual oboe::Result getLastErrorCallbackResult() const
Definition AudioStream.h:483
bool isPerformanceHintEnabled()
Definition AudioStream.h:543
bool wasErrorCallbackCalled()
Definition AudioStream.h:558
ResultWithValue< int32_t > getAvailableFrames()
virtual ResultWithValue< int32_t > setBufferSizeInFrames(int32_t)
Definition AudioStream.h:208
virtual int64_t getFramesWritten()
DataCallbackResult fireDataCallback(void *audioData, int numFrames)
ResultWithValue< int32_t > waitForAvailableFrames(int32_t numFrames, int64_t timeoutNanoseconds)
virtual Result getTimestamp(clockid_t, int64_t *, int64_t *)
Definition AudioStream.h:327
virtual ResultWithValue< int32_t > write(const void *, int32_t, int64_t)
Definition AudioStream.h:368
void setPerformanceHintEnabled(bool enabled)
Definition AudioStream.h:533
bool isDataCallbackEnabled()
Definition AudioStream.h:596
virtual Result stop(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
virtual int64_t getFramesRead()
void calculateDefaultDelayBeforeCloseMillis()
virtual Result start(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
void setDelayBeforeCloseMillis(int32_t delayBeforeCloseMillis)
Definition AudioStream.h:506
virtual ResultWithValue< FrameTimestamp > getTimestamp(clockid_t)
Definition ResultWithValue.h:47
Definition AudioClock.h:24
Result
Definition Definitions.h:172
constexpr int64_t kNanosPerMillisecond
Definition Definitions.h:42
StreamState
Definition Definitions.h:57
AudioApi
Definition Definitions.h:254
constexpr int64_t kDefaultTimeoutNanos
Definition AudioStream.h:39
constexpr int32_t kUnspecified
Definition Definitions.h:31
DataCallbackResult
Definition Definitions.h:160
Definition AudioStream.h:703