Debian Codegraph @

portaudio/portaudio/include/pa_mac_core.h

raw symbols SCIP
1 #ifndef PA_MAC_CORE_H
2 #define PA_MAC_CORE_H
3 /*
4 * PortAudio Portable Real-Time Audio Library
5 * Macintosh Core Audio specific extensions
6 * portaudio.h should be included before this file.
7 *
8 * Copyright (c) 2005-2006 Bjorn Roche
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files
12 * (the "Software"), to deal in the Software without restriction,
13 * including without limitation the rights to use, copy, modify, merge,
14 * publish, distribute, sublicense, and/or sell copies of the Software,
15 * and to permit persons to whom the Software is furnished to do so,
16 * subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
25 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30 /*
31 * The text above constitutes the entire PortAudio license; however,
32 * the PortAudio community also makes the following non-binding requests:
33 *
34 * Any person wishing to distribute modifications to the Software is
35 * requested to send the modifications to the original developer so that
36 * they can be incorporated into the canonical version. It is also
37 * requested that these non-binding requests be included along with the
38 * license above.
39 */
40
41 /** @file
42 * @ingroup public_header
43 * @brief CoreAudio-specific PortAudio API extension header file.
44 */
45
46 #include "portaudio.h"
47
48 #include <AudioUnit/AudioUnit.h>
49 #include <AudioToolbox/AudioToolbox.h>
50
51 // Audio workgroups are only supported from MacOS 11 onwards.
52 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
53 #include <os/workgroup.h>
54 #endif
55
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60
61 /**
62 * A pointer to a paMacCoreStreamInfo may be passed as
63 * the hostApiSpecificStreamInfo in the PaStreamParameters struct
64 * when opening a stream or querying the format. Use NULL, for the
65 * defaults. Note that for duplex streams, flags for input and output
66 * should be the same or behaviour is undefined.
67 */
68 typedef struct
69 {
70 unsigned long size; /**size of whole structure including this header */
71 PaHostApiTypeId hostApiType; /**host API for which this data is intended */
72 unsigned long version; /**structure version */
73 unsigned long flags; /** flags to modify behaviour */
74 SInt32 const * channelMap; /** Channel map for HAL channel mapping , if not needed, use NULL;*/
75 unsigned long channelMapSize; /** Channel map size for HAL channel mapping , if not needed, use 0;*/
76 } PaMacCoreStreamInfo;
77
78 /**
79 * Functions
80 */
81
82
83 /** Use this function to initialize a paMacCoreStreamInfo struct
84 * using the requested flags. Note that channel mapping is turned
85 * off after a call to this function.
86 * @param data The datastructure to initialize
87 * @param flags The flags to initialize the datastructure with.
88 */
89 void PaMacCore_SetupStreamInfo( PaMacCoreStreamInfo *data, unsigned long flags );
90
91 /** call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.
92 * @param data The stream info structure to assign a channel mapping to
93 * @param channelMap The channel map array, as described in notes.txt. This array pointer will be used directly (ie the underlying data will not be copied), so the caller should not free the array until after the stream has been opened.
94 * @param channelMapSize The size of the channel map array.
95 */
96 void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const channelMap, unsigned long channelMapSize );
97
98 /**
99 * Retrieve the AudioDeviceID of the input device assigned to an open stream
100 *
101 * @param s The stream to query.
102 *
103 * @return A valid AudioDeviceID, or NULL if an error occurred.
104 */
105 AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
106
107 /**
108 * Retrieve the AudioDeviceID of the output device assigned to an open stream
109 *
110 * @param s The stream to query.
111 *
112 * @return A valid AudioDeviceID, or NULL if an error occurred.
113 */
114 AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
115
116 /**
117 * Returns a statically allocated string with the device's name
118 * for the given channel. NULL will be returned on failure.
119 *
120 * This function's implementation is not complete!
121 *
122 * @param device The PortAudio device index.
123 * @param channel The channel number who's name is requested.
124 * @return a statically allocated string with the name of the device.
125 * Because this string is statically allocated, it must be
126 * copied if it is to be saved and used by the user after
127 * another call to this function.
128 *
129 */
130 const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
131
132
133 /** Retrieve the range of legal native buffer sizes for the specified device, in sample frames.
134
135 @param device The global index of the PortAudio device about which the query is being made.
136 @param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
137 @param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
138
139 @see kAudioDevicePropertyBufferFrameSizeRange in the CoreAudio SDK.
140 */
141 PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
142 long *minBufferSizeFrames, long *maxBufferSizeFrames );
143
144
145 /**
146 * Retrieve the audio workgroup of the specified device. (Mac OS 11 and higher only)
147 *
148 * @param device The global index of the PortAudio device about which the query is being made.
149 * @param workgroup A pointer to the location which will receive the workgroup value.
150 *
151 * @see kAudioDevicePropertyIOThreadOSWorkgroup in the CoreAudio SDK.
152 */
153 #if __MAC_OS_X_VERSION_MIN_REQUIRED >= 110000
154 PaError PaMacCore_GetOSWorkgroup( PaDeviceIndex device, os_workgroup_t *workgroup );
155 #endif
156
157 /**
158 * Flags
159 */
160
161 /**
162 * The following flags alter the behaviour of PA on the mac platform.
163 * they can be ORed together. These should work both for opening and
164 * checking a device.
165 */
166
167 /** Allows PortAudio to change things like the device's frame size,
168 * which allows for much lower latency, but might disrupt the device
169 * if other programs are using it, even when you are just Querying
170 * the device. */
171 #define paMacCoreChangeDeviceParameters (0x01)
172
173 /** In combination with the above flag,
174 * causes the stream opening to fail, unless the exact sample rates
175 * are supported by the device. */
176 #define paMacCoreFailIfConversionRequired (0x02)
177
178 /** These flags set the SR conversion quality, if required. The weird ordering
179 * allows Maximum Quality to be the default.*/
180 #define paMacCoreConversionQualityMin (0x0100)
181 #define paMacCoreConversionQualityMedium (0x0200)
182 #define paMacCoreConversionQualityLow (0x0300)
183 #define paMacCoreConversionQualityHigh (0x0400)
184 #define paMacCoreConversionQualityMax (0x0000)
185
186 /**
187 * Here are some "preset" combinations of flags (above) to get to some
188 * common configurations. THIS IS OVERKILL, but if more flags are added
189 * it won't be.
190 */
191
192 /**This is the default setting: do as much sample rate conversion as possible
193 * and as little mucking with the device as possible. */
194 #define paMacCorePlayNice (0x00)
195 /**This setting is tuned for pro audio apps. It allows SR conversion on input
196 and output, but it tries to set the appropriate SR on the device.*/
197 #define paMacCorePro (0x01)
198 /**This is a setting to minimize CPU usage and still play nice.*/
199 #define paMacCoreMinimizeCPUButPlayNice (0x0100)
200 /**This is a setting to minimize CPU usage, even if that means interrupting the device. */
201 #define paMacCoreMinimizeCPU (0x0101)
202
203
204 #ifdef __cplusplus
205 }
206 #endif /** __cplusplus */
207
208 #endif /** PA_MAC_CORE_H */