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 };
156
160 enum class DataCallbackResult : int32_t { // aaudio_data_callback_result_t
161 // Indicates to the caller that the callbacks should continue.
162 Continue = 0, // AAUDIO_CALLBACK_RESULT_CONTINUE,
163
164 // Indicates to the caller that the callbacks should stop immediately.
165 Stop = 1, // AAUDIO_CALLBACK_RESULT_STOP,
166 };
167
172 enum class Result : int32_t { // aaudio_result_t
173 OK = 0, // AAUDIO_OK
174 ErrorBase = -900, // AAUDIO_ERROR_BASE,
175 ErrorDisconnected = -899, // AAUDIO_ERROR_DISCONNECTED,
176 ErrorIllegalArgument = -898, // AAUDIO_ERROR_ILLEGAL_ARGUMENT,
177 ErrorInternal = -896, // AAUDIO_ERROR_INTERNAL,
178 ErrorInvalidState = -895, // AAUDIO_ERROR_INVALID_STATE,
179 ErrorInvalidHandle = -892, // AAUDIO_ERROR_INVALID_HANDLE,
180 ErrorUnimplemented = -890, // AAUDIO_ERROR_UNIMPLEMENTED,
181 ErrorUnavailable = -889, // AAUDIO_ERROR_UNAVAILABLE,
182 ErrorNoFreeHandles = -888, // AAUDIO_ERROR_NO_FREE_HANDLES,
183 ErrorNoMemory = -887, // AAUDIO_ERROR_NO_MEMORY,
184 ErrorNull = -886, // AAUDIO_ERROR_NULL,
185 ErrorTimeout = -885, // AAUDIO_ERROR_TIMEOUT,
186 ErrorWouldBlock = -884, // AAUDIO_ERROR_WOULD_BLOCK,
187 ErrorInvalidFormat = -883, // AAUDIO_ERROR_INVALID_FORMAT,
188 ErrorOutOfRange = -882, // AAUDIO_ERROR_OUT_OF_RANGE,
189 ErrorNoService = -881, // AAUDIO_ERROR_NO_SERVICE,
190 ErrorInvalidRate = -880, // AAUDIO_ERROR_INVALID_RATE,
191 // Reserved for future AAudio result types
192 Reserved1,
193 Reserved2,
194 Reserved3,
195 Reserved4,
196 Reserved5,
197 Reserved6,
198 Reserved7,
199 Reserved8,
200 Reserved9,
201 Reserved10,
202 ErrorClosed = -869,
203 };
204
208 enum class SharingMode : int32_t { // aaudio_sharing_mode_t
209
218 Exclusive = 0, // AAUDIO_SHARING_MODE_EXCLUSIVE,
219
227 Shared = 1, // AAUDIO_SHARING_MODE_SHARED,
228 };
229
233 enum class PerformanceMode : int32_t { // aaudio_performance_mode_t
234
238 None = 10, // AAUDIO_PERFORMANCE_MODE_NONE,
239
243 PowerSaving = 11, // AAUDIO_PERFORMANCE_MODE_POWER_SAVING,
244
248 LowLatency = 12, // AAUDIO_PERFORMANCE_MODE_LOW_LATENCY
249 };
250
254 enum class AudioApi : int32_t {
258 Unspecified = kUnspecified,
259
264 OpenSLES,
265
271 AAudio
272 };
273
279 enum class SampleRateConversionQuality : int32_t {
283 None,
288 Fastest,
292 Low,
296 Medium,
300 High,
304 Best,
305 };
306
316 enum class Usage : int32_t { // aaudio_usage_t
320 Media = 1, // AAUDIO_USAGE_MEDIA
321
325 VoiceCommunication = 2, // AAUDIO_USAGE_VOICE_COMMUNICATION
326
330 VoiceCommunicationSignalling = 3, // AAUDIO_USAGE_VOICE_COMMUNICATION_SIGNALLING
331
335 Alarm = 4, // AAUDIO_USAGE_ALARM
336
341 Notification = 5, // AAUDIO_USAGE_NOTIFICATION
342
346 NotificationRingtone = 6, // AAUDIO_USAGE_NOTIFICATION_RINGTONE
347
351 NotificationEvent = 10, // AAUDIO_USAGE_NOTIFICATION_EVENT
352
356 AssistanceAccessibility = 11, // AAUDIO_USAGE_ASSISTANCE_ACCESSIBILITY
357
361 AssistanceNavigationGuidance = 12, // AAUDIO_USAGE_ASSISTANCE_NAVIGATION_GUIDANCE
362
366 AssistanceSonification = 13, // AAUDIO_USAGE_ASSISTANCE_SONIFICATION
367
371 Game = 14, // AAUDIO_USAGE_GAME
372
376 Assistant = 16, // AAUDIO_USAGE_ASSISTANT
377 };
378
379
392 enum ContentType : int32_t { // aaudio_content_type_t
393
397 Speech = 1, // AAUDIO_CONTENT_TYPE_SPEECH
398
402 Music = 2, // AAUDIO_CONTENT_TYPE_MUSIC
403
407 Movie = 3, // AAUDIO_CONTENT_TYPE_MOVIE
408
413 Sonification = 4, // AAUDIO_CONTENT_TYPE_SONIFICATION
414 };
415
425 enum InputPreset : int32_t { // aaudio_input_preset_t
429 Generic = 1, // AAUDIO_INPUT_PRESET_GENERIC
430
434 Camcorder = 5, // AAUDIO_INPUT_PRESET_CAMCORDER
435
439 VoiceRecognition = 6, // AAUDIO_INPUT_PRESET_VOICE_RECOGNITION
440
444 VoiceCommunication = 7, // AAUDIO_INPUT_PRESET_VOICE_COMMUNICATION
445
451 Unprocessed = 9, // AAUDIO_INPUT_PRESET_UNPROCESSED
452
458 VoicePerformance = 10, // AAUDIO_INPUT_PRESET_VOICE_PERFORMANCE
459
460 };
461
467 enum SessionId {
473 None = -1, // AAUDIO_SESSION_ID_NONE
474
482 Allocate = 0, // AAUDIO_SESSION_ID_ALLOCATE
483 };
484
495 enum ChannelCount : int32_t {
499 Unspecified = kUnspecified,
500
504 Mono = 1,
505
509 Stereo = 2,
510 };
511
526 enum class ChannelMask : uint32_t { // aaudio_channel_mask_t
527 Unspecified = kUnspecified,
528 FrontLeft = 1 << 0,
529 FrontRight = 1 << 1,
530 FrontCenter = 1 << 2,
531 LowFrequency = 1 << 3,
532 BackLeft = 1 << 4,
533 BackRight = 1 << 5,
534 FrontLeftOfCenter = 1 << 6,
535 FrontRightOfCenter = 1 << 7,
536 BackCenter = 1 << 8,
537 SideLeft = 1 << 9,
538 SideRight = 1 << 10,
539 TopCenter = 1 << 11,
540 TopFrontLeft = 1 << 12,
541 TopFrontCenter = 1 << 13,
542 TopFrontRight = 1 << 14,
543 TopBackLeft = 1 << 15,
544 TopBackCenter = 1 << 16,
545 TopBackRight = 1 << 17,
546 TopSideLeft = 1 << 18,
547 TopSideRight = 1 << 19,
548 BottomFrontLeft = 1 << 20,
549 BottomFrontCenter = 1 << 21,
550 BottomFrontRight = 1 << 22,
551 LowFrequency2 = 1 << 23,
552 FrontWideLeft = 1 << 24,
553 FrontWideRight = 1 << 25,
554
558 Mono = FrontLeft,
559
563 Stereo = FrontLeft |
564 FrontRight,
565
569 CM2Point1 = FrontLeft |
570 FrontRight |
571 LowFrequency,
572
576 Tri = FrontLeft |
577 FrontRight |
578 FrontCenter,
579
583 TriBack = FrontLeft |
584 FrontRight |
585 BackCenter,
586
590 CM3Point1 = FrontLeft |
591 FrontRight |
592 FrontCenter |
593 LowFrequency,
594
598 CM2Point0Point2 = FrontLeft |
599 FrontRight |
600 TopSideLeft |
601 TopSideRight,
602
606 CM2Point1Point2 = CM2Point0Point2 |
607 LowFrequency,
608
612 CM3Point0Point2 = FrontLeft |
613 FrontRight |
614 FrontCenter |
615 TopSideLeft |
616 TopSideRight,
617
621 CM3Point1Point2 = CM3Point0Point2 |
622 LowFrequency,
623
627 Quad = FrontLeft |
628 FrontRight |
629 BackLeft |
630 BackRight,
631
635 QuadSide = FrontLeft |
636 FrontRight |
637 SideLeft |
638 SideRight,
639
643 Surround = FrontLeft |
644 FrontRight |
645 FrontCenter |
646 BackCenter,
647
651 Penta = Quad |
652 FrontCenter,
653
657 CM5Point1 = FrontLeft |
658 FrontRight |
659 FrontCenter |
660 LowFrequency |
661 BackLeft |
662 BackRight,
663
667 CM5Point1Side = FrontLeft |
668 FrontRight |
669 FrontCenter |
670 LowFrequency |
671 SideLeft |
672 SideRight,
673
677 CM6Point1 = FrontLeft |
678 FrontRight |
679 FrontCenter |
680 LowFrequency |
681 BackLeft |
682 BackRight |
683 BackCenter,
684
688 CM7Point1 = CM5Point1 |
689 SideLeft |
690 SideRight,
691
695 CM5Point1Point2 = CM5Point1 |
696 TopSideLeft |
697 TopSideRight,
698
702 CM5Point1Point4 = CM5Point1 |
703 TopFrontLeft |
704 TopFrontRight |
705 TopBackLeft |
706 TopBackRight,
707
711 CM7Point1Point2 = CM7Point1 |
712 TopSideLeft |
713 TopSideRight,
714
718 CM7Point1Point4 = CM7Point1 |
719 TopFrontLeft |
720 TopFrontRight |
721 TopBackLeft |
722 TopBackRight,
723
727 CM9Point1Point4 = CM7Point1Point4 |
728 FrontWideLeft |
729 FrontWideRight,
730
734 CM9Point1Point6 = CM9Point1Point4 |
735 TopSideLeft |
736 TopSideRight,
737
741 FrontBack = FrontCenter |
742 BackCenter,
743 };
744
748 enum class SpatializationBehavior : int32_t {
749
753 Unspecified = kUnspecified,
754
759 Auto = 1,
760
765 Never = 2,
766 };
767
775 enum class PrivacySensitiveMode : int32_t {
776
781 Unspecified = kUnspecified,
782
786 Disabled = 1,
787
791 Enabled = 2,
792 };
793
802 enum class AllowedCapturePolicy : int32_t {
807 Unspecified = kUnspecified,
818 All = 1,
826 System = 2,
834 None = 3,
835 };
836
856
857 public:
858
865
866 };
867
872 int64_t position; // in frames
873 int64_t timestamp; // in nanoseconds
874 };
875
877 public:
878
879 static bool areWorkaroundsEnabled() {
880 return mWorkaroundsEnabled;
881 }
882
888 static void setWorkaroundsEnabled(bool enabled) {
889 mWorkaroundsEnabled = enabled;
890 }
891
892 private:
893 static bool mWorkaroundsEnabled;
894 };
895} // namespace oboe
896
897#endif // OBOE_DEFINITIONS_H
Definition Definitions.h:855
static int32_t SampleRate
Definition Definitions.h:860
static int32_t FramesPerBurst
Definition Definitions.h:862
static int32_t ChannelCount
Definition Definitions.h:864
Definition Definitions.h:876
static void setWorkaroundsEnabled(bool enabled)
Definition Definitions.h:888
Definition ResultWithValue.h:47
Definition Definitions.h:871