Oboe 1.2 A library for creating real-time audio apps on Android

AudioStreamBase.h
1 /*
2 * Copyright 2015 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #ifndef OBOE_STREAM_BASE_H_
18 #define OBOE_STREAM_BASE_H_
19
20 #include <memory>
21 #include "oboe/AudioStreamCallback.h"
22 #include "oboe/Definitions.h"
23
24 namespace oboe {
25
29 class AudioStreamBase {
30 public:
31
32 AudioStreamBase() {}
33
34 virtual ~AudioStreamBase() = default;
35
36 // This class only contains primitives so we can use default constructor and copy methods.
37
41 AudioStreamBase(const AudioStreamBase&) = default;
42
46 AudioStreamBase& operator=(const AudioStreamBase&) = default;
47
51 int32_t getChannelCount() const { return mChannelCount; }
52
56 Direction getDirection() const { return mDirection; }
57
61 int32_t getSampleRate() const { return mSampleRate; }
62
66 int32_t getFramesPerCallback() const { return mFramesPerCallback; }
67
71 AudioFormat getFormat() const { return mFormat; }
72
79 virtual int32_t getBufferSizeInFrames() { return mBufferSizeInFrames; }
80
84 virtual int32_t getBufferCapacityInFrames() const { return mBufferCapacityInFrames; }
85
89 SharingMode getSharingMode() const { return mSharingMode; }
90
94 PerformanceMode getPerformanceMode() const { return mPerformanceMode; }
95
99 int32_t getDeviceId() const { return mDeviceId; }
100
104 AudioStreamCallback* getCallback() const {
105 return mStreamCallback;
106 }
107
111 Usage getUsage() const { return mUsage; }
112
116 ContentType getContentType() const { return mContentType; }
117
121 InputPreset getInputPreset() const { return mInputPreset; }
122
126 SessionId getSessionId() const { return mSessionId; }
127
131 bool isChannelConversionAllowed() const {
132 return mChannelConversionAllowed;
133 }
134
138 bool isFormatConversionAllowed() const {
139 return mFormatConversionAllowed;
140 }
141
145 SampleRateConversionQuality getSampleRateConversionQuality() const {
146 return mSampleRateConversionQuality;
147 }
148
149 protected:
150
152 AudioStreamCallback *mStreamCallback = nullptr;
154 int32_t mFramesPerCallback = kUnspecified;
156 int32_t mChannelCount = kUnspecified;
158 int32_t mSampleRate = kUnspecified;
160 int32_t mDeviceId = kUnspecified;
162 int32_t mBufferCapacityInFrames = kUnspecified;
164 int32_t mBufferSizeInFrames = kUnspecified;
169 int32_t mFramesPerBurst = kUnspecified;
170
172 SharingMode mSharingMode = SharingMode::Shared;
174 AudioFormat mFormat = AudioFormat::Unspecified;
176 Direction mDirection = Direction::Output;
178 PerformanceMode mPerformanceMode = PerformanceMode::None;
179
181 Usage mUsage = Usage::Media;
183 ContentType mContentType = ContentType::Music;
187 InputPreset mInputPreset = InputPreset::VoiceRecognition;
189 SessionId mSessionId = SessionId::None;
190
191 // Control whether Oboe can convert channel counts to achieve optimal results.
192 bool mChannelConversionAllowed = false;
193 // Control whether Oboe can convert data formats to achieve optimal results.
194 bool mFormatConversionAllowed = false;
195 // Control whether and how Oboe can convert sample rates to achieve optimal results.
196 SampleRateConversionQuality mSampleRateConversionQuality = SampleRateConversionQuality::None;
197 };
198
199 } // namespace oboe
200
201 #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