17#ifndef OBOE_FULL_DUPLEX_STREAM_
18#define OBOE_FULL_DUPLEX_STREAM_
21#include "oboe/Definitions.h"
22#include "oboe/AudioStream.h"
23#include "oboe/AudioStreamCallback.h"
71 mSharedInputStream =
stream;
81 if (mSharedInputStream) {
82 return mSharedInputStream.get();
84 return mRawInputStream;
104 mSharedOutputStream =
stream;
114 if (mSharedOutputStream) {
115 return mSharedOutputStream.get();
117 return mRawOutputStream;
128 mCountCallbacksToDrain = kNumCallbacksToDrain;
129 mCountInputBurstsCushion = mNumInputBurstsCushion;
130 mCountCallbacksToDiscard = kNumCallbacksToDiscard;
136 mInputBuffer = std::make_unique<float[]>(
bufferSize);
141 if (
result != oboe::Result::OK) {
220 if (mCountCallbacksToDrain > 0) {
234 mCountCallbacksToDrain--;
237 }
else if (mCountInputBurstsCushion > 0) {
239 mCountInputBurstsCushion--;
241 }
else if (mCountCallbacksToDiscard > 0) {
242 mCountCallbacksToDiscard--;
304 return mNumInputBurstsCushion;
322 return mMinimumFramesBeforeRead;
328 static constexpr int32_t kNumCallbacksToDrain = 20;
329 static constexpr int32_t kNumCallbacksToDiscard = 30;
332 int32_t mNumInputBurstsCushion = 0;
333 int32_t mMinimumFramesBeforeRead = 0;
339 int32_t mCountCallbacksToDrain = kNumCallbacksToDrain;
341 int32_t mCountInputBurstsCushion = mNumInputBurstsCushion;
343 int32_t mCountCallbacksToDiscard = kNumCallbacksToDiscard;
347 std::shared_ptr<AudioStream> mSharedInputStream;
348 std::shared_ptr<AudioStream> mSharedOutputStream;
351 std::unique_ptr<float[]> mInputBuffer;
int32_t getChannelCount() const
Definition AudioStreamBase.h:53
virtual int32_t getBufferCapacityInFrames() const
Definition AudioStreamBase.h:91
Definition AudioStreamCallback.h:34
Definition AudioStream.h:42
virtual Result requestStart()=0
virtual ResultWithValue< int32_t > read(void *, int32_t, int64_t)
Definition AudioStream.h:384
int32_t getBytesPerFrame() const
Definition AudioStream.h:247
virtual Result requestStop()=0
ResultWithValue< int32_t > getAvailableFrames()
Definition FullDuplexStream.h:50
void setOutputStream(AudioStream *stream)
Definition FullDuplexStream.h:94
int32_t getMinimumFramesBeforeRead() const
Definition FullDuplexStream.h:321
virtual Result stop()
Definition FullDuplexStream.h:152
void setNumInputBurstsCushion(int32_t numBursts)
Definition FullDuplexStream.h:294
virtual ResultWithValue< int32_t > readInput(int32_t numFrames)
Definition FullDuplexStream.h:175
AudioStream * getOutputStream()
Definition FullDuplexStream.h:113
virtual DataCallbackResult onBothStreamsReady(const void *inputData, int numInputFrames, void *outputData, int numOutputFrames)=0
AudioStream * getInputStream()
Definition FullDuplexStream.h:80
DataCallbackResult onAudioReady(AudioStream *, void *audioData, int numFrames)
Definition FullDuplexStream.h:209
int32_t getNumInputBurstsCushion() const
Definition FullDuplexStream.h:303
void setInputStream(AudioStream *stream)
Definition FullDuplexStream.h:61
void setMinimumFramesBeforeRead(int32_t numFrames)
Definition FullDuplexStream.h:312
virtual Result start()
Definition FullDuplexStream.h:127
void setSharedOutputStream(std::shared_ptr< AudioStream > &stream)
Definition FullDuplexStream.h:103
void setSharedInputStream(std::shared_ptr< AudioStream > &stream)
Definition FullDuplexStream.h:70
Definition ResultWithValue.h:47
T value() const
Definition ResultWithValue.h:81