# Oboe: include/oboe/AudioStreamBase.h Source File

AudioStreamBase.h
/*
* Copyright 2015 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef OBOE_STREAM_BASE_H_
#define OBOE_STREAM_BASE_H_
#include <memory>
#include "oboe/AudioStreamCallback.h"
#include "oboe/Definitions.h"
namespace oboe {
class AudioStreamBase {
public:
AudioStreamBase() {}
virtual ~AudioStreamBase() = default;
// This class only contains primitives so we can use default constructor and copy methods.
AudioStreamBase(const AudioStreamBase&) = default;
AudioStreamBase& operator=(const AudioStreamBase&) = default;
int32_t getChannelCount() const { return mChannelCount; }
Direction getDirection() const { return mDirection; }
int32_t getSampleRate() const { return mSampleRate; }
int32_t getFramesPerCallback() const { return mFramesPerCallback; }
AudioFormat getFormat() const { return mFormat; }
virtual int32_t getBufferSizeInFrames() { return mBufferSizeInFrames; }
virtual int32_t getBufferCapacityInFrames() const { return mBufferCapacityInFrames; }
SharingMode getSharingMode() const { return mSharingMode; }
PerformanceMode getPerformanceMode() const { return mPerformanceMode; }
int32_t getDeviceId() const { return mDeviceId; }
AudioStreamCallback* getCallback() const {
return mStreamCallback;
}
Usage getUsage() const { return mUsage; }
ContentType getContentType() const { return mContentType; }
InputPreset getInputPreset() const { return mInputPreset; }
SessionId getSessionId() const { return mSessionId; }
bool isChannelConversionAllowed() const {
return mChannelConversionAllowed;
}
bool isFormatConversionAllowed() const {
return mFormatConversionAllowed;
}
SampleRateConversionQuality getSampleRateConversionQuality() const {
return mSampleRateConversionQuality;
}
protected:
AudioStreamCallback *mStreamCallback = nullptr;
int32_t mFramesPerCallback = kUnspecified;
int32_t mChannelCount = kUnspecified;
int32_t mSampleRate = kUnspecified;
int32_t mDeviceId = kUnspecified;
int32_t mBufferCapacityInFrames = kUnspecified;
int32_t mBufferSizeInFrames = kUnspecified;
int32_t mFramesPerBurst = kUnspecified;
SharingMode mSharingMode = SharingMode::Shared;
AudioFormat mFormat = AudioFormat::Unspecified;
Direction mDirection = Direction::Output;
PerformanceMode mPerformanceMode = PerformanceMode::None;
Usage mUsage = Usage::Media;
ContentType mContentType = ContentType::Music;
InputPreset mInputPreset = InputPreset::VoiceRecognition;
SessionId mSessionId = SessionId::None;
// Control whether Oboe can convert channel counts to achieve optimal results.
bool mChannelConversionAllowed = false;
// Control whether Oboe can convert data formats to achieve optimal results.
bool mFormatConversionAllowed = false;
// Control whether and how Oboe can convert sample rates to achieve optimal results.
SampleRateConversionQuality mSampleRateConversionQuality = SampleRateConversionQuality::None;
};
} // namespace oboe
#endif /* OBOE_STREAM_BASE_H_ */
oboe::AudioStreamBase::isChannelConversionAllowed
bool isChannelConversionAllowed() const
Definition: AudioStreamBase.h:131
oboe::AudioStreamBase::mBufferSizeInFrames
int32_t mBufferSizeInFrames
Definition: AudioStreamBase.h:164
oboe::Direction::Output
oboe::AudioStreamBase::mSessionId
SessionId mSessionId
Definition: AudioStreamBase.h:189
oboe::AudioStreamBase::mDirection
Direction mDirection
Definition: AudioStreamBase.h:176
oboe::AudioStreamBase::getDeviceId
int32_t getDeviceId() const
Definition: AudioStreamBase.h:99
oboe::AudioStreamBase::mFormat
AudioFormat mFormat
Definition: AudioStreamBase.h:174
oboe::AudioStreamBase::getFramesPerCallback
int32_t getFramesPerCallback() const
Definition: AudioStreamBase.h:66
oboe::AudioStreamBase::mContentType
ContentType mContentType
Definition: AudioStreamBase.h:183
oboe::PerformanceMode
PerformanceMode
Definition: Definitions.h:192
oboe::SessionId
SessionId
Definition: Definitions.h:414
oboe::SharingMode::Shared
oboe::AudioStreamBase::mPerformanceMode
PerformanceMode mPerformanceMode
Definition: AudioStreamBase.h:178
oboe::AudioStreamBase::getPerformanceMode
PerformanceMode getPerformanceMode() const
Definition: AudioStreamBase.h:94
oboe::AudioStreamBase::getChannelCount
int32_t getChannelCount() const
Definition: AudioStreamBase.h:51
oboe::AudioStreamBase::getSessionId
SessionId getSessionId() const
Definition: AudioStreamBase.h:126
oboe::AudioStreamCallback
Definition: AudioStreamCallback.h:33
oboe::AudioStreamBase::mSharingMode
SharingMode mSharingMode
Definition: AudioStreamBase.h:172
oboe::AudioStreamBase::mChannelCount
int32_t mChannelCount
Definition: AudioStreamBase.h:156
oboe::AudioStreamBase::isFormatConversionAllowed
bool isFormatConversionAllowed() const
Definition: AudioStreamBase.h:138
oboe::AudioStreamBase::getFormat
AudioFormat getFormat() const
Definition: AudioStreamBase.h:71
oboe::ContentType
ContentType
Definition: Definitions.h:339
oboe::AudioStreamBase::mDeviceId
int32_t mDeviceId
Definition: AudioStreamBase.h:160
oboe::AudioStreamBase::getContentType
ContentType getContentType() const
Definition: AudioStreamBase.h:116
oboe::AudioStreamBase::mUsage
Usage mUsage
Definition: AudioStreamBase.h:181
oboe::Usage
Usage
Definition: Definitions.h:263
oboe::AudioStreamBase::getSampleRate
int32_t getSampleRate() const
Definition: AudioStreamBase.h:61
oboe::AudioStreamBase::mSampleRate
int32_t mSampleRate
Definition: AudioStreamBase.h:158
oboe::AudioStreamBase::getCallback
AudioStreamCallback * getCallback() const
Definition: AudioStreamBase.h:104
oboe::Usage::Media
oboe::AudioStreamBase::mFramesPerBurst
int32_t mFramesPerBurst
Definition: AudioStreamBase.h:169
oboe::AudioStreamBase::getSharingMode
SharingMode getSharingMode() const
Definition: AudioStreamBase.h:89
oboe::AudioStreamBase
Definition: AudioStreamBase.h:29
oboe::AudioStreamBase::mBufferCapacityInFrames
int32_t mBufferCapacityInFrames
Definition: AudioStreamBase.h:162
oboe::AudioStreamBase::getSampleRateConversionQuality
SampleRateConversionQuality getSampleRateConversionQuality() const
Definition: AudioStreamBase.h:145
oboe::AudioStreamBase::operator=
AudioStreamBase & operator=(const AudioStreamBase &)=default
oboe::AudioStreamBase::getBufferSizeInFrames
virtual int32_t getBufferSizeInFrames()
Definition: AudioStreamBase.h:79
oboe::AudioFormat
AudioFormat
Definition: Definitions.h:94
oboe::kUnspecified
constexpr int32_t kUnspecified
Definition: Definitions.h:32
oboe::AudioStreamBase::getBufferCapacityInFrames
virtual int32_t getBufferCapacityInFrames() const
Definition: AudioStreamBase.h:84
oboe
Definition: AudioStream.h:31
oboe::SampleRateConversionQuality
SampleRateConversionQuality
Definition: Definitions.h:235
oboe::AudioStreamBase::mInputPreset
InputPreset mInputPreset
Definition: AudioStreamBase.h:187
oboe::AudioStreamBase::mStreamCallback
AudioStreamCallback * mStreamCallback
Definition: AudioStreamBase.h:152
oboe::Direction
Direction
Definition: Definitions.h:78
oboe::AudioStreamBase::getDirection
Direction getDirection() const
Definition: AudioStreamBase.h:56
oboe::SharingMode
SharingMode
Definition: Definitions.h:167
oboe::InputPreset
InputPreset
Definition: Definitions.h:372
oboe::AudioStreamBase::mFramesPerCallback
int32_t mFramesPerCallback
Definition: AudioStreamBase.h:154
oboe::AudioStreamBase::getUsage
Usage getUsage() const
Definition: AudioStreamBase.h:111
oboe::AudioStreamBase::getInputPreset
InputPreset getInputPreset() const
Definition: AudioStreamBase.h:121