17 #ifndef OBOE_STREAM_H_ 18 #define OBOE_STREAM_H_ 24 #include "oboe/Definitions.h" 25 #include "oboe/ResultWithValue.h" 26 #include "oboe/AudioStreamBuilder.h" 27 #include "oboe/AudioStreamBase.h" 164 int64_t timeoutNanoseconds) = 0;
179 return Result::ErrorUnimplemented;
290 return Result::ErrorUnimplemented;
402 return previousCallback;
412 AudioStreamErrorCallback *swapErrorCallback(AudioStreamErrorCallback *errorCallback) {
415 return previousCallback;
433 int64_t timeoutNanoseconds);
439 return mErrorCallbackResult;
454 return mErrorCallbackCalled.exchange(
true);
465 int64_t timeoutNanoseconds);
475 return DataCallbackResult::Stop;
492 return mDataCallbackEnabled;
500 mDataCallbackEnabled = enabled;
507 void setWeakThis(std::shared_ptr<oboe::AudioStream> &sharedStream) {
508 mWeakThis = sharedStream;
514 std::shared_ptr<oboe::AudioStream> lockWeakThis() {
515 return mWeakThis.lock();
518 std::weak_ptr<AudioStream> mWeakThis;
543 void checkScheduler();
544 int mPreviousScheduler = -1;
546 std::atomic<bool> mDataCallbackEnabled{
false};
547 std::atomic<bool> mErrorCallbackCalled{
false};
558 audioStream->
close();
virtual DataCallbackResult onDefaultCallback(void *, int)
Definition: AudioStream.h:474
virtual Result stop(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
Definition: AudioStreamBuilder.h:33
ResultWithValue< int32_t > getAvailableFrames()
void setDataCallbackEnabled(bool enabled)
Definition: AudioStream.h:499
bool usesAAudio() const
Definition: AudioStream.h:359
virtual Result flush(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
AudioStreamDataCallback * mDataCallback
Definition: AudioStreamBase.h:182
int32_t getBytesPerFrame() const
Definition: AudioStream.h:217
virtual Result start(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
constexpr int64_t kDefaultTimeoutNanos
Definition: AudioStream.h:39
virtual ResultWithValue< int32_t > getXRunCount() const
Definition: AudioStream.h:194
std::atomic< int64_t > mFramesWritten
Definition: AudioStream.h:526
DataCallbackResult fireDataCallback(void *audioData, int numFrames)
virtual void * getUnderlyingStream() const
Definition: AudioStream.h:371
virtual void updateFramesWritten()=0
virtual int64_t getFramesWritten()
ResultWithValue< int32_t > waitForAvailableFrames(int32_t numFrames, int64_t timeoutNanoseconds)
Definition: AudioStreamCallback.h:34
int32_t mChannelCount
Definition: AudioStreamBase.h:190
DataCallbackResult
Definition: Definitions.h:119
AudioApi
Definition: Definitions.h:213
virtual Result waitForStateTransition(StreamState startingState, StreamState endingState, int64_t timeoutNanoseconds)
virtual int32_t getFramesPerBurst()=0
virtual ResultWithValue< int32_t > setBufferSizeInFrames(int32_t)
Definition: AudioStream.h:178
virtual ResultWithValue< double > calculateLatencyMillis()
Definition: AudioStream.h:266
virtual Result getTimestamp(clockid_t, int64_t *, int64_t *)
Definition: AudioStream.h:287
virtual Result open()
Definition: AudioStream.h:67
virtual int64_t getFramesRead()
Definition: AudioStream.h:44
bool isDataCallbackEnabled()
Definition: AudioStream.h:491
virtual ResultWithValue< int32_t > read(void *, int32_t, int64_t)
Definition: AudioStream.h:341
virtual Result requestPause()=0
virtual ResultWithValue< int32_t > write(const void *, int32_t, int64_t)
Definition: AudioStream.h:323
std::atomic< int64_t > mFramesRead
Definition: AudioStream.h:534
Definition: AudioStreamBase.h:29
constexpr int64_t kNanosPerMillisecond
Definition: Definitions.h:43
virtual Result requestStop()=0
virtual AudioApi getAudioApi() const =0
virtual Result waitForStateChange(StreamState inputState, StreamState *nextState, int64_t timeoutNanoseconds)=0
Result
Definition: Definitions.h:131
Definition: AudioStream.h:555
Definition: AudioStream.h:31
bool wasErrorCallbackCalled()
Definition: AudioStream.h:453
virtual bool isXRunCountSupported() const =0
virtual Result requestStart()=0
virtual oboe::Result getLastErrorCallbackResult() const
Definition: AudioStream.h:438
StreamState
Definition: Definitions.h:58
virtual StreamState getState() const =0
virtual Result pause(int64_t timeoutNanoseconds=kDefaultTimeoutNanos)
virtual Result requestFlush()=0
virtual void updateFramesRead()=0
AudioStreamErrorCallback * mErrorCallback
Definition: AudioStreamBase.h:185
int32_t getBytesPerSample() const
Definition: ResultWithValue.h:47