Oboe
A library for creating real-time audio apps on Android
Loading...
Searching...
No Matches
Definitions.h
1/*
2 * Copyright (C) 2016 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_DEFINITIONS_H
18#define OBOE_DEFINITIONS_H
19
20#include <cstdint>
21#include <type_traits>
22
23// Oboe needs to be able to build on old NDKs so we use hard coded constants.
24// The correctness of these constants is verified in "aaudio/AAudioLoader.cpp".
25
26namespace oboe {
27
31 constexpr int32_t kUnspecified = 0;
32
33 // TODO: Investigate using std::chrono
37 constexpr int64_t kNanosPerMicrosecond = 1000;
38
42 constexpr int64_t kNanosPerMillisecond = kNanosPerMicrosecond * 1000;
43
47 constexpr int64_t kMillisPerSecond = 1000;
48
52 constexpr int64_t kNanosPerSecond = kNanosPerMillisecond * kMillisPerSecond;
53
57 enum class StreamState : int32_t { // aaudio_stream_state_t
58 Uninitialized = 0, // AAUDIO_STREAM_STATE_UNINITIALIZED,
59 Unknown = 1, // AAUDIO_STREAM_STATE_UNKNOWN,
60 Open = 2, // AAUDIO_STREAM_STATE_OPEN,
61 Starting = 3, // AAUDIO_STREAM_STATE_STARTING,
62 Started = 4, // AAUDIO_STREAM_STATE_STARTED,
63 Pausing = 5, // AAUDIO_STREAM_STATE_PAUSING,
64 Paused = 6, // AAUDIO_STREAM_STATE_PAUSED,
65 Flushing = 7, // AAUDIO_STREAM_STATE_FLUSHING,
66 Flushed = 8, // AAUDIO_STREAM_STATE_FLUSHED,
67 Stopping = 9, // AAUDIO_STREAM_STATE_STOPPING,
68 Stopped = 10, // AAUDIO_STREAM_STATE_STOPPED,
69 Closing = 11, // AAUDIO_STREAM_STATE_CLOSING,
70 Closed = 12, // AAUDIO_STREAM_STATE_CLOSED,
71 Disconnected = 13, // AAUDIO_STREAM_STATE_DISCONNECTED,
72 };
73
77 enum class Direction : int32_t { // aaudio_direction_t
78
82 Output = 0, // AAUDIO_DIRECTION_OUTPUT,
83
87 Input = 1, // AAUDIO_DIRECTION_INPUT,
88 };
89
93 enum class AudioFormat : int32_t { // aaudio_format_t
97 Invalid = -1, // AAUDIO_FORMAT_INVALID,
98
104 Unspecified = 0, // AAUDIO_FORMAT_UNSPECIFIED,
105
109 I16 = 1, // AAUDIO_FORMAT_PCM_I16,
110
118 Float = 2, // AAUDIO_FORMAT_PCM_FLOAT,
119
129 I24 = 3, // AAUDIO_FORMAT_PCM_I24_PACKED
130
140 I32 = 4, // AAUDIO_FORMAT_PCM_I32
141
154 IEC61937 = 5, // AAUDIO_FORMAT_IEC61937
155
159 MP3 = 6, // AAUDIO_FORMAT_MP3
160
164 AAC_LC, // AAUDIO_FORMAT_AAC_LC
165
169 AAC_HE_V1, // AAUDIO_FORMAT_AAC_HE_V1,
170
174 AAC_HE_V2, // AAUDIO_FORMAT_AAC_HE_V2
175
179 AAC_ELD, // AAUDIO_FORMAT_AAC_ELD
180
184 AAC_XHE, // AAUDIO_FORMAT_AAC_XHE
185
189 OPUS, // AAUDIO_FORMAT_OPUS
190 };
191
195 enum class DataCallbackResult : int32_t { // aaudio_data_callback_result_t
196 // Indicates to the caller that the callbacks should continue.
197 Continue = 0, // AAUDIO_CALLBACK_RESULT_CONTINUE,
198
199 // Indicates to the caller that the callbacks should stop immediately.
200 Stop = 1, // AAUDIO_CALLBACK_RESULT_STOP,
201 };
202
207 enum class Result : int32_t { // aaudio_result_t
208 OK = 0, // AAUDIO_OK
209 ErrorBase = -900, // AAUDIO_ERROR_BASE,
210 ErrorDisconnected = -899, // AAUDIO_ERROR_DISCONNECTED,
211 ErrorIllegalArgument = -898, // AAUDIO_ERROR_ILLEGAL_ARGUMENT,
212 ErrorInternal = -896, // AAUDIO_ERROR_INTERNAL,
213 ErrorInvalidState = -895, // AAUDIO_ERROR_INVALID_STATE,
214 ErrorInvalidHandle = -892, // AAUDIO_ERROR_INVALID_HANDLE,
215 ErrorUnimplemented = -890, // AAUDIO_ERROR_UNIMPLEMENTED,
216 ErrorUnavailable = -889, // AAUDIO_ERROR_UNAVAILABLE,
217 ErrorNoFreeHandles = -888, // AAUDIO_ERROR_NO_FREE_HANDLES,
218 ErrorNoMemory = -887, // AAUDIO_ERROR_NO_MEMORY,
219 ErrorNull = -886, // AAUDIO_ERROR_NULL,
220 ErrorTimeout = -885, // AAUDIO_ERROR_TIMEOUT,
221 ErrorWouldBlock = -884, // AAUDIO_ERROR_WOULD_BLOCK,
222 ErrorInvalidFormat = -883, // AAUDIO_ERROR_INVALID_FORMAT,
223 ErrorOutOfRange = -882, // AAUDIO_ERROR_OUT_OF_RANGE,
224 ErrorNoService = -881, // AAUDIO_ERROR_NO_SERVICE,
225 ErrorInvalidRate = -880, // AAUDIO_ERROR_INVALID_RATE,
226 // Reserved for future AAudio result types
227 Reserved1,
228 Reserved2,
229 Reserved3,
230 Reserved4,
231 Reserved5,
232 Reserved6,
233 Reserved7,
234 Reserved8,
235 Reserved9,
236 Reserved10,
237 ErrorClosed = -869,
238 };
239
243 enum class SharingMode : int32_t { // aaudio_sharing_mode_t
244
253 Exclusive = 0, // AAUDIO_SHARING_MODE_EXCLUSIVE,
254
262 Shared = 1, // AAUDIO_SHARING_MODE_SHARED,
263 };
264
268 enum class PerformanceMode : int32_t { // aaudio_performance_mode_t
269
273 None = 10, // AAUDIO_PERFORMANCE_MODE_NONE,
274
278 PowerSaving = 11, // AAUDIO_PERFORMANCE_MODE_POWER_SAVING,
279
283 LowLatency = 12, // AAUDIO_PERFORMANCE_MODE_LOW_LATENCY
284
293 PowerSavingOffloaded = 13, // AAUDIO_PERFORMANCE_MODE_POWER_SAVING_OFFLOADED
294 };
295
299 enum class AudioApi : int32_t {
303 Unspecified = kUnspecified,
304
309 OpenSLES,
310
316 AAudio
317 };
318
324 enum class SampleRateConversionQuality : int32_t {
328 None,
333 Fastest,
337 Low,
341 Medium,
345 High,
349 Best,
350 };
351
361 enum class Usage : int32_t { // aaudio_usage_t
365 Media = 1, // AAUDIO_USAGE_MEDIA
366
370 VoiceCommunication = 2, // AAUDIO_USAGE_VOICE_COMMUNICATION
371
375 VoiceCommunicationSignalling = 3, // AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING
376
380 Alarm = 4, // AAUDIO_USAGE_ALARM
381
386 Notification = 5, // AAUDIO_USAGE_NOTIFICATION
387
391 NotificationRingtone = 6, // AAUDIO_USAGE_NOTIFICATION_RINGTONE
392
396 NotificationEvent = 10, // AAUDIO_USAGE_NOTIFICATION_EVENT
397
401 AssistanceAccessibility = 11, // AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY
402
406 AssistanceNavigationGuidance = 12, // AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
407
411 AssistanceSonification = 13, // AAUDIO_USAGE_ASSISTANCE_SONIFICATION
412
416 Game = 14, // AAUDIO_USAGE_GAME
417
421 Assistant = 16, // AAUDIO_USAGE_ASSISTANT
422 };
423
424
437 enum ContentType : int32_t { // aaudio_content_type_t
438
442 Speech = 1, // AAUDIO_CONTENT_TYPE_SPEECH
443
447 Music = 2, // AAUDIO_CONTENT_TYPE_MUSIC
448
452 Movie = 3, // AAUDIO_CONTENT_TYPE_MOVIE
453
458 Sonification = 4, // AAUDIO_CONTENT_TYPE_SONIFICATION
459 };
460
470 enum InputPreset : int32_t { // aaudio_input_preset_t
474 Generic = 1, // AAUDIO_INPUT_PRESET_GENERIC
475
479 Camcorder = 5, // AAUDIO_INPUT_PRESET_CAMCORDER
480
484 VoiceRecognition = 6, // AAUDIO_INPUT_PRESET_VOICE_RECOGNITION
485
489 VoiceCommunication = 7, // AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION
490
496 Unprocessed = 9, // AAUDIO_INPUT_PRESET_UNPROCESSED
497
503 VoicePerformance = 10, // AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE
504
505 };
506
514 enum SessionId {
520 None = -1, // AAUDIO_SESSION_ID_NONE
521
529 Allocate = 0, // AAUDIO_SESSION_ID_ALLOCATE
530 };
531
542 enum ChannelCount : int32_t {
546 Unspecified = kUnspecified,
547
551 Mono = 1,
552
556 Stereo = 2,
557 };
558
573 enum class ChannelMask : uint32_t { // aaudio_channel_mask_t
574 Unspecified = kUnspecified,
575 FrontLeft = 1 << 0,
576 FrontRight = 1 << 1,
577 FrontCenter = 1 << 2,
578 LowFrequency = 1 << 3,
579 BackLeft = 1 << 4,
580 BackRight = 1 << 5,
581 FrontLeftOfCenter = 1 << 6,
582 FrontRightOfCenter = 1 << 7,
583 BackCenter = 1 << 8,
584 SideLeft = 1 << 9,
585 SideRight = 1 << 10,
586 TopCenter = 1 << 11,
587 TopFrontLeft = 1 << 12,
588 TopFrontCenter = 1 << 13,
589 TopFrontRight = 1 << 14,
590 TopBackLeft = 1 << 15,
591 TopBackCenter = 1 << 16,
592 TopBackRight = 1 << 17,
593 TopSideLeft = 1 << 18,
594 TopSideRight = 1 << 19,
595 BottomFrontLeft = 1 << 20,
596 BottomFrontCenter = 1 << 21,
597 BottomFrontRight = 1 << 22,
598 LowFrequency2 = 1 << 23,
599 FrontWideLeft = 1 << 24,
600 FrontWideRight = 1 << 25,
601
605 Mono = FrontLeft,
606
610 Stereo = FrontLeft |
611 FrontRight,
612
616 CM2Point1 = FrontLeft |
617 FrontRight |
618 LowFrequency,
619
623 Tri = FrontLeft |
624 FrontRight |
625 FrontCenter,
626
630 TriBack = FrontLeft |
631 FrontRight |
632 BackCenter,
633
637 CM3Point1 = FrontLeft |
638 FrontRight |
639 FrontCenter |
640 LowFrequency,
641
645 CM2Point0Point2 = FrontLeft |
646 FrontRight |
647 TopSideLeft |
648 TopSideRight,
649
653 CM2Point1Point2 = CM2Point0Point2 |
654 LowFrequency,
655
659 CM3Point0Point2 = FrontLeft |
660 FrontRight |
661 FrontCenter |
662 TopSideLeft |
663 TopSideRight,
664
668 CM3Point1Point2 = CM3Point0Point2 |
669 LowFrequency,
670
674 Quad = FrontLeft |
675 FrontRight |
676 BackLeft |
677 BackRight,
678
682 QuadSide = FrontLeft |
683 FrontRight |
684 SideLeft |
685 SideRight,
686
690 Surround = FrontLeft |
691 FrontRight |
692 FrontCenter |
693 BackCenter,
694
698 Penta = Quad |
699 FrontCenter,
700
704 CM5Point1 = FrontLeft |
705 FrontRight |
706 FrontCenter |
707 LowFrequency |
708 BackLeft |
709 BackRight,
710
714 CM5Point1Side = FrontLeft |
715 FrontRight |
716 FrontCenter |
717 LowFrequency |
718 SideLeft |
719 SideRight,
720
724 CM6Point1 = FrontLeft |
725 FrontRight |
726 FrontCenter |
727 LowFrequency |
728 BackLeft |
729 BackRight |
730 BackCenter,
731
735 CM7Point1 = CM5Point1 |
736 SideLeft |
737 SideRight,
738
742 CM5Point1Point2 = CM5Point1 |
743 TopSideLeft |
744 TopSideRight,
745
749 CM5Point1Point4 = CM5Point1 |
750 TopFrontLeft |
751 TopFrontRight |
752 TopBackLeft |
753 TopBackRight,
754
758 CM7Point1Point2 = CM7Point1 |
759 TopSideLeft |
760 TopSideRight,
761
765 CM7Point1Point4 = CM7Point1 |
766 TopFrontLeft |
767 TopFrontRight |
768 TopBackLeft |
769 TopBackRight,
770
774 CM9Point1Point4 = CM7Point1Point4 |
775 FrontWideLeft |
776 FrontWideRight,
777
781 CM9Point1Point6 = CM9Point1Point4 |
782 TopSideLeft |
783 TopSideRight,
784
788 FrontBack = FrontCenter |
789 BackCenter,
790 };
791
795 enum class SpatializationBehavior : int32_t {
796
800 Unspecified = kUnspecified,
801
806 Auto = 1,
807
812 Never = 2,
813 };
814
822 enum class PrivacySensitiveMode : int32_t {
823
828 Unspecified = kUnspecified,
829
833 Disabled = 1,
834
838 Enabled = 2,
839 };
840
849 enum class AllowedCapturePolicy : int32_t {
854 Unspecified = kUnspecified,
865 All = 1,
873 System = 2,
881 None = 3,
882 };
883
892 enum class DeviceType : int32_t {
896 BuiltinEarpiece = 1,
897
902 BuiltinSpeaker = 2,
903
908 WiredHeadset = 3,
909
913 WiredHeadphones = 4,
914
918 LineAnalog = 5,
919
923 LineDigital = 6,
924
928 BluetoothSco = 7,
929
933 BluetoothA2dp = 8,
934
938 Hdmi = 9,
939
943 HdmiArc = 10,
944
948 UsbDevice = 11,
949
953 UsbAccessory = 12,
954
958 Dock = 13,
959
963 FM = 14,
964
968 BuiltinMic = 15,
969
973 FMTuner = 16,
974
978 TVTuner = 17,
979
983 Telephony = 18,
984
988 AuxLine = 19,
989
993 IP = 20,
994
998 Bus = 21,
999
1003 UsbHeadset = 22,
1004
1008 HearingAid = 23,
1009
1017 BuiltinSpeakerSafe = 24,
1018
1023 RemoteSubmix = 25,
1029 BleHeadset = 26,
1030
1034 BleSpeaker = 27,
1035
1039 HdmiEarc = 29,
1040
1044 BleBroadcast = 30,
1045
1050 DockAnalog = 31
1051 };
1052
1058 enum class MMapPolicy : int32_t {
1062 Unspecified = kUnspecified,
1063
1067 Never = 1,
1068
1074 Auto,
1075
1079 Always
1080 };
1081
1086 enum class FlushFromAccuracy : int32_t {
1091 Undefined = 0, // AAUDIO_FLUSH_FROM_ACCURACY_UNDEFINED
1092
1097 Accurate = 1, // AAUDIO_FLUSH_FROM_ACCURACY_ACCURATE
1098 };
1099
1103 enum class FallbackMode : int32_t {
1107 Default = 0, // AAUDIO_FALLBACK_MODE_DEFAULT
1111 Mute = 1, // AAUDIO_FALLBACK_MODE_MUTE
1116 Fail = 2, // AAUDIO_FALLBACK_MODE_FAIL
1117 };
1118
1123 enum class StretchMode : int32_t {
1127 Default = 0, // AAUDIO_STRETCH_MODE_DEFAULT
1131 Voice = 1, // AAUDIO_STRETCH_MODE_VOICE
1132 };
1133
1141 FallbackMode fallbackMode;
1145 StretchMode stretchMode;
1151 float pitch;
1156 float speed;
1157 };
1158
1178
1179 public:
1180
1182 static int32_t SampleRate;
1184 static int32_t FramesPerBurst;
1186 static int32_t ChannelCount;
1187
1188 };
1189
1194 int64_t position; // in frames
1195 int64_t timestamp; // in nanoseconds
1196 };
1197
1199 public:
1200
1201 static bool areWorkaroundsEnabled() {
1202 return mWorkaroundsEnabled;
1203 }
1204
1210 static void setWorkaroundsEnabled(bool enabled) {
1211 mWorkaroundsEnabled = enabled;
1212 }
1213
1214 private:
1215 static bool mWorkaroundsEnabled;
1216 };
1217} // namespace oboe
1218
1219#endif // OBOE_DEFINITIONS_H
Definition Definitions.h:1177
static int32_t SampleRate
Definition Definitions.h:1182
static int32_t FramesPerBurst
Definition Definitions.h:1184
static int32_t ChannelCount
Definition Definitions.h:1186
Definition Definitions.h:1198
static void setWorkaroundsEnabled(bool enabled)
Definition Definitions.h:1210
Definition Definitions.h:1193
Definition Definitions.h:1137
float pitch
Definition Definitions.h:1151
float speed
Definition Definitions.h:1156
FallbackMode fallbackMode
Definition Definitions.h:1141
StretchMode stretchMode
Definition Definitions.h:1145