xref: /aosp_15_r20/external/oboe/include/oboe/OboeExtensions.h (revision 05767d913155b055644481607e6fa1e35e2fe72c)
1 /*
2  * Copyright 2022 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_EXTENSIONS_
18 #define OBOE_EXTENSIONS_
19 
20 #include <stdint.h>
21 
22 #include "oboe/Definitions.h"
23 #include "oboe/AudioStream.h"
24 
25 namespace oboe {
26 
27 /**
28  * The definitions below are only for testing.
29  * They are not recommended for use in an application.
30  * They may change or be removed at any time.
31  */
32 class OboeExtensions {
33 public:
34 
35     /**
36     * @returns true if the device supports AAudio MMAP
37     */
38     static bool isMMapSupported();
39 
40     /**
41     * @returns true if the AAudio MMAP data path can be selected
42     */
43     static bool isMMapEnabled();
44 
45     /**
46      * Controls whether the AAudio MMAP data path can be selected when opening a stream.
47      * It has no effect after the stream has been opened.
48      * It only affects the application that calls it. Other apps are not affected.
49      *
50      * @param enabled
51      * @return 0 or a negative error code
52      */
53     static int32_t setMMapEnabled(bool enabled);
54 
55     /**
56      * @param oboeStream
57      * @return true if the AAudio MMAP data path is used on the stream
58      */
59     static bool isMMapUsed(oboe::AudioStream *oboeStream);
60 };
61 
62 } // namespace oboe
63 
64 #endif // OBOE_LATENCY_TUNER_
65