annotate src/portaudio_20161030_catalina_patch/include/pa_win_wasapi.h @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents d43aab368df9
children
rev   line source
cannam@162 1 #ifndef PA_WIN_WASAPI_H
cannam@162 2 #define PA_WIN_WASAPI_H
cannam@162 3 /*
cannam@162 4 * $Id: $
cannam@162 5 * PortAudio Portable Real-Time Audio Library
cannam@162 6 * DirectSound specific extensions
cannam@162 7 *
cannam@162 8 * Copyright (c) 1999-2007 Ross Bencina and Phil Burk
cannam@162 9 *
cannam@162 10 * Permission is hereby granted, free of charge, to any person obtaining
cannam@162 11 * a copy of this software and associated documentation files
cannam@162 12 * (the "Software"), to deal in the Software without restriction,
cannam@162 13 * including without limitation the rights to use, copy, modify, merge,
cannam@162 14 * publish, distribute, sublicense, and/or sell copies of the Software,
cannam@162 15 * and to permit persons to whom the Software is furnished to do so,
cannam@162 16 * subject to the following conditions:
cannam@162 17 *
cannam@162 18 * The above copyright notice and this permission notice shall be
cannam@162 19 * included in all copies or substantial portions of the Software.
cannam@162 20 *
cannam@162 21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@162 22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@162 23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
cannam@162 24 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
cannam@162 25 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@162 26 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@162 27 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@162 28 */
cannam@162 29
cannam@162 30 /*
cannam@162 31 * The text above constitutes the entire PortAudio license; however,
cannam@162 32 * the PortAudio community also makes the following non-binding requests:
cannam@162 33 *
cannam@162 34 * Any person wishing to distribute modifications to the Software is
cannam@162 35 * requested to send the modifications to the original developer so that
cannam@162 36 * they can be incorporated into the canonical version. It is also
cannam@162 37 * requested that these non-binding requests be included along with the
cannam@162 38 * license above.
cannam@162 39 */
cannam@162 40
cannam@162 41 /** @file
cannam@162 42 @ingroup public_header
cannam@162 43 @brief WASAPI-specific PortAudio API extension header file.
cannam@162 44 */
cannam@162 45
cannam@162 46 #include "portaudio.h"
cannam@162 47 #include "pa_win_waveformat.h"
cannam@162 48
cannam@162 49 #ifdef __cplusplus
cannam@162 50 extern "C"
cannam@162 51 {
cannam@162 52 #endif /* __cplusplus */
cannam@162 53
cannam@162 54
cannam@162 55 /* Setup flags */
cannam@162 56 typedef enum PaWasapiFlags
cannam@162 57 {
cannam@162 58 /* puts WASAPI into exclusive mode */
cannam@162 59 paWinWasapiExclusive = (1 << 0),
cannam@162 60
cannam@162 61 /* allows to skip internal PA processing completely */
cannam@162 62 paWinWasapiRedirectHostProcessor = (1 << 1),
cannam@162 63
cannam@162 64 /* assigns custom channel mask */
cannam@162 65 paWinWasapiUseChannelMask = (1 << 2),
cannam@162 66
cannam@162 67 /* selects non-Event driven method of data read/write
cannam@162 68 Note: WASAPI Event driven core is capable of 2ms latency!!!, but Polling
cannam@162 69 method can only provide 15-20ms latency. */
cannam@162 70 paWinWasapiPolling = (1 << 3),
cannam@162 71
cannam@162 72 /* forces custom thread priority setting, must be used if PaWasapiStreamInfo::threadPriority
cannam@162 73 is set to a custom value */
cannam@162 74 paWinWasapiThreadPriority = (1 << 4)
cannam@162 75 }
cannam@162 76 PaWasapiFlags;
cannam@162 77 #define paWinWasapiExclusive (paWinWasapiExclusive)
cannam@162 78 #define paWinWasapiRedirectHostProcessor (paWinWasapiRedirectHostProcessor)
cannam@162 79 #define paWinWasapiUseChannelMask (paWinWasapiUseChannelMask)
cannam@162 80 #define paWinWasapiPolling (paWinWasapiPolling)
cannam@162 81 #define paWinWasapiThreadPriority (paWinWasapiThreadPriority)
cannam@162 82
cannam@162 83
cannam@162 84 /* Host processor. Allows to skip internal PA processing completely.
cannam@162 85 You must set paWinWasapiRedirectHostProcessor flag to PaWasapiStreamInfo::flags member
cannam@162 86 in order to have host processor redirected to your callback.
cannam@162 87 Use with caution! inputFrames and outputFrames depend solely on final device setup.
cannam@162 88 To query maximal values of inputFrames/outputFrames use PaWasapi_GetFramesPerHostBuffer.
cannam@162 89 */
cannam@162 90 typedef void (*PaWasapiHostProcessorCallback) (void *inputBuffer, long inputFrames,
cannam@162 91 void *outputBuffer, long outputFrames,
cannam@162 92 void *userData);
cannam@162 93
cannam@162 94 /* Device role. */
cannam@162 95 typedef enum PaWasapiDeviceRole
cannam@162 96 {
cannam@162 97 eRoleRemoteNetworkDevice = 0,
cannam@162 98 eRoleSpeakers,
cannam@162 99 eRoleLineLevel,
cannam@162 100 eRoleHeadphones,
cannam@162 101 eRoleMicrophone,
cannam@162 102 eRoleHeadset,
cannam@162 103 eRoleHandset,
cannam@162 104 eRoleUnknownDigitalPassthrough,
cannam@162 105 eRoleSPDIF,
cannam@162 106 eRoleHDMI,
cannam@162 107 eRoleUnknownFormFactor
cannam@162 108 }
cannam@162 109 PaWasapiDeviceRole;
cannam@162 110
cannam@162 111
cannam@162 112 /* Jack connection type. */
cannam@162 113 typedef enum PaWasapiJackConnectionType
cannam@162 114 {
cannam@162 115 eJackConnTypeUnknown,
cannam@162 116 eJackConnType3Point5mm,
cannam@162 117 eJackConnTypeQuarter,
cannam@162 118 eJackConnTypeAtapiInternal,
cannam@162 119 eJackConnTypeRCA,
cannam@162 120 eJackConnTypeOptical,
cannam@162 121 eJackConnTypeOtherDigital,
cannam@162 122 eJackConnTypeOtherAnalog,
cannam@162 123 eJackConnTypeMultichannelAnalogDIN,
cannam@162 124 eJackConnTypeXlrProfessional,
cannam@162 125 eJackConnTypeRJ11Modem,
cannam@162 126 eJackConnTypeCombination
cannam@162 127 }
cannam@162 128 PaWasapiJackConnectionType;
cannam@162 129
cannam@162 130
cannam@162 131 /* Jack geometric location. */
cannam@162 132 typedef enum PaWasapiJackGeoLocation
cannam@162 133 {
cannam@162 134 eJackGeoLocUnk = 0,
cannam@162 135 eJackGeoLocRear = 0x1, /* matches EPcxGeoLocation::eGeoLocRear */
cannam@162 136 eJackGeoLocFront,
cannam@162 137 eJackGeoLocLeft,
cannam@162 138 eJackGeoLocRight,
cannam@162 139 eJackGeoLocTop,
cannam@162 140 eJackGeoLocBottom,
cannam@162 141 eJackGeoLocRearPanel,
cannam@162 142 eJackGeoLocRiser,
cannam@162 143 eJackGeoLocInsideMobileLid,
cannam@162 144 eJackGeoLocDrivebay,
cannam@162 145 eJackGeoLocHDMI,
cannam@162 146 eJackGeoLocOutsideMobileLid,
cannam@162 147 eJackGeoLocATAPI,
cannam@162 148 eJackGeoLocReserved5,
cannam@162 149 eJackGeoLocReserved6,
cannam@162 150 }
cannam@162 151 PaWasapiJackGeoLocation;
cannam@162 152
cannam@162 153
cannam@162 154 /* Jack general location. */
cannam@162 155 typedef enum PaWasapiJackGenLocation
cannam@162 156 {
cannam@162 157 eJackGenLocPrimaryBox = 0,
cannam@162 158 eJackGenLocInternal,
cannam@162 159 eJackGenLocSeparate,
cannam@162 160 eJackGenLocOther
cannam@162 161 }
cannam@162 162 PaWasapiJackGenLocation;
cannam@162 163
cannam@162 164
cannam@162 165 /* Jack's type of port. */
cannam@162 166 typedef enum PaWasapiJackPortConnection
cannam@162 167 {
cannam@162 168 eJackPortConnJack = 0,
cannam@162 169 eJackPortConnIntegratedDevice,
cannam@162 170 eJackPortConnBothIntegratedAndJack,
cannam@162 171 eJackPortConnUnknown
cannam@162 172 }
cannam@162 173 PaWasapiJackPortConnection;
cannam@162 174
cannam@162 175
cannam@162 176 /* Thread priority. */
cannam@162 177 typedef enum PaWasapiThreadPriority
cannam@162 178 {
cannam@162 179 eThreadPriorityNone = 0,
cannam@162 180 eThreadPriorityAudio, //!< Default for Shared mode.
cannam@162 181 eThreadPriorityCapture,
cannam@162 182 eThreadPriorityDistribution,
cannam@162 183 eThreadPriorityGames,
cannam@162 184 eThreadPriorityPlayback,
cannam@162 185 eThreadPriorityProAudio, //!< Default for Exclusive mode.
cannam@162 186 eThreadPriorityWindowManager
cannam@162 187 }
cannam@162 188 PaWasapiThreadPriority;
cannam@162 189
cannam@162 190
cannam@162 191 /* Stream descriptor. */
cannam@162 192 typedef struct PaWasapiJackDescription
cannam@162 193 {
cannam@162 194 unsigned long channelMapping;
cannam@162 195 unsigned long color; /* derived from macro: #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) */
cannam@162 196 PaWasapiJackConnectionType connectionType;
cannam@162 197 PaWasapiJackGeoLocation geoLocation;
cannam@162 198 PaWasapiJackGenLocation genLocation;
cannam@162 199 PaWasapiJackPortConnection portConnection;
cannam@162 200 unsigned int isConnected;
cannam@162 201 }
cannam@162 202 PaWasapiJackDescription;
cannam@162 203
cannam@162 204
cannam@162 205 /** Stream category.
cannam@162 206 Note:
cannam@162 207 - values are equal to WASAPI AUDIO_STREAM_CATEGORY enum
cannam@162 208 - supported since Windows 8.0, noop on earler versions
cannam@162 209 - values 1,2 are deprecated on Windows 10 and not included into enumeration
cannam@162 210
cannam@162 211 @version Available as of 19.6.0
cannam@162 212 */
cannam@162 213 typedef enum PaWasapiStreamCategory
cannam@162 214 {
cannam@162 215 eAudioCategoryOther = 0,
cannam@162 216 eAudioCategoryCommunications = 3,
cannam@162 217 eAudioCategoryAlerts = 4,
cannam@162 218 eAudioCategorySoundEffects = 5,
cannam@162 219 eAudioCategoryGameEffects = 6,
cannam@162 220 eAudioCategoryGameMedia = 7,
cannam@162 221 eAudioCategoryGameChat = 8,
cannam@162 222 eAudioCategorySpeech = 9,
cannam@162 223 eAudioCategoryMovie = 10,
cannam@162 224 eAudioCategoryMedia = 11
cannam@162 225 }
cannam@162 226 PaWasapiStreamCategory;
cannam@162 227
cannam@162 228
cannam@162 229 /** Stream option.
cannam@162 230 Note:
cannam@162 231 - values are equal to WASAPI AUDCLNT_STREAMOPTIONS enum
cannam@162 232 - supported since Windows 8.1, noop on earler versions
cannam@162 233
cannam@162 234 @version Available as of 19.6.0
cannam@162 235 */
cannam@162 236 typedef enum PaWasapiStreamOption
cannam@162 237 {
cannam@162 238 eStreamOptionNone = 0, //!< default
cannam@162 239 eStreamOptionRaw = 1, //!< bypass WASAPI Audio Engine DSP effects, supported since Windows 8.1
cannam@162 240 eStreamOptionMatchFormat = 2 //!< force WASAPI Audio Engine into a stream format, supported since Windows 10
cannam@162 241 }
cannam@162 242 PaWasapiStreamOption;
cannam@162 243
cannam@162 244
cannam@162 245 /* Stream descriptor. */
cannam@162 246 typedef struct PaWasapiStreamInfo
cannam@162 247 {
cannam@162 248 unsigned long size; /**< sizeof(PaWasapiStreamInfo) */
cannam@162 249 PaHostApiTypeId hostApiType; /**< paWASAPI */
cannam@162 250 unsigned long version; /**< 1 */
cannam@162 251
cannam@162 252 unsigned long flags; /**< collection of PaWasapiFlags */
cannam@162 253
cannam@162 254 /** Support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
cannam@162 255 paWinWasapiUseChannelMask this allows you to specify which speakers
cannam@162 256 to address in a multichannel stream. Constants for channelMask
cannam@162 257 are specified in pa_win_waveformat.h. Will be used only if
cannam@162 258 paWinWasapiUseChannelMask flag is specified.
cannam@162 259 */
cannam@162 260 PaWinWaveFormatChannelMask channelMask;
cannam@162 261
cannam@162 262 /** Delivers raw data to callback obtained from GetBuffer() methods skipping
cannam@162 263 internal PortAudio processing inventory completely. userData parameter will
cannam@162 264 be the same that was passed to Pa_OpenStream method. Will be used only if
cannam@162 265 paWinWasapiRedirectHostProcessor flag is specified.
cannam@162 266 */
cannam@162 267 PaWasapiHostProcessorCallback hostProcessorOutput;
cannam@162 268 PaWasapiHostProcessorCallback hostProcessorInput;
cannam@162 269
cannam@162 270 /** Specifies thread priority explicitly. Will be used only if paWinWasapiThreadPriority flag
cannam@162 271 is specified.
cannam@162 272
cannam@162 273 Please note, if Input/Output streams are opened simultaniously (Full-Duplex mode)
cannam@162 274 you shall specify same value for threadPriority or othervise one of the values will be used
cannam@162 275 to setup thread priority.
cannam@162 276 */
cannam@162 277 PaWasapiThreadPriority threadPriority;
cannam@162 278
cannam@162 279 /** Stream category.
cannam@162 280 @see PaWasapiStreamCategory
cannam@162 281 @version Available as of 19.6.0
cannam@162 282 */
cannam@162 283 PaWasapiStreamCategory streamCategory;
cannam@162 284
cannam@162 285 /** Stream option.
cannam@162 286 @see PaWasapiStreamOption
cannam@162 287 @version Available as of 19.6.0
cannam@162 288 */
cannam@162 289 PaWasapiStreamOption streamOption;
cannam@162 290 }
cannam@162 291 PaWasapiStreamInfo;
cannam@162 292
cannam@162 293
cannam@162 294 /** Returns default sound format for device. Format is represented by PaWinWaveFormat or
cannam@162 295 WAVEFORMATEXTENSIBLE structure.
cannam@162 296
cannam@162 297 @param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
cannam@162 298 @param nFormatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
cannam@162 299 @param nDevice Device index.
cannam@162 300
cannam@162 301 @return Non-negative value indicating the number of bytes copied into format decriptor
cannam@162 302 or, a PaErrorCode (which are always negative) if PortAudio is not initialized
cannam@162 303 or an error is encountered.
cannam@162 304 */
cannam@162 305 int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int nFormatSize, PaDeviceIndex nDevice );
cannam@162 306
cannam@162 307
cannam@162 308 /** Returns device role (PaWasapiDeviceRole enum).
cannam@162 309
cannam@162 310 @param nDevice device index.
cannam@162 311
cannam@162 312 @return Non-negative value indicating device role or, a PaErrorCode (which are always negative)
cannam@162 313 if PortAudio is not initialized or an error is encountered.
cannam@162 314 */
cannam@162 315 int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex nDevice );
cannam@162 316
cannam@162 317
cannam@162 318 /** Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread
cannam@162 319 which makes calls to Pa_WriteStream/Pa_ReadStream.
cannam@162 320
cannam@162 321 @param hTask Handle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority
cannam@162 322 method to revert thread priority to initial state.
cannam@162 323
cannam@162 324 @param nPriorityClass Id of thread priority of PaWasapiThreadPriority type. Specifying
cannam@162 325 eThreadPriorityNone does nothing.
cannam@162 326
cannam@162 327 @return Error code indicating success or failure.
cannam@162 328 @see PaWasapi_RevertThreadPriority
cannam@162 329 */
cannam@162 330 PaError PaWasapi_ThreadPriorityBoost( void **hTask, PaWasapiThreadPriority nPriorityClass );
cannam@162 331
cannam@162 332
cannam@162 333 /** Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread
cannam@162 334 which makes calls to Pa_WriteStream/Pa_ReadStream.
cannam@162 335
cannam@162 336 @param hTask Task handle obtained by PaWasapi_BoostThreadPriority method.
cannam@162 337 @return Error code indicating success or failure.
cannam@162 338 @see PaWasapi_BoostThreadPriority
cannam@162 339 */
cannam@162 340 PaError PaWasapi_ThreadPriorityRevert( void *hTask );
cannam@162 341
cannam@162 342
cannam@162 343 /** Get number of frames per host buffer. This is maximal value of frames of WASAPI buffer which
cannam@162 344 can be locked for operations. Use this method as helper to findout maximal values of
cannam@162 345 inputFrames/outputFrames of PaWasapiHostProcessorCallback.
cannam@162 346
cannam@162 347 @param pStream Pointer to PaStream to query.
cannam@162 348 @param nInput Pointer to variable to receive number of input frames. Can be NULL.
cannam@162 349 @param nOutput Pointer to variable to receive number of output frames. Can be NULL.
cannam@162 350 @return Error code indicating success or failure.
cannam@162 351 @see PaWasapiHostProcessorCallback
cannam@162 352 */
cannam@162 353 PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *nInput, unsigned int *nOutput );
cannam@162 354
cannam@162 355
cannam@162 356 /** Get number of jacks associated with a WASAPI device. Use this method to determine if
cannam@162 357 there are any jacks associated with the provided WASAPI device. Not all audio devices
cannam@162 358 will support this capability. This is valid for both input and output devices.
cannam@162 359 @param nDevice device index.
cannam@162 360 @param jcount Number of jacks is returned in this variable
cannam@162 361 @return Error code indicating success or failure
cannam@162 362 @see PaWasapi_GetJackDescription
cannam@162 363 */
cannam@162 364 PaError PaWasapi_GetJackCount(PaDeviceIndex nDevice, int *jcount);
cannam@162 365
cannam@162 366
cannam@162 367 /** Get the jack description associated with a WASAPI device and jack number
cannam@162 368 Before this function is called, use PaWasapi_GetJackCount to determine the
cannam@162 369 number of jacks associated with device. If jcount is greater than zero, then
cannam@162 370 each jack from 0 to jcount can be queried with this function to get the jack
cannam@162 371 description.
cannam@162 372 @param nDevice device index.
cannam@162 373 @param jindex Which jack to return information
cannam@162 374 @param KSJACK_DESCRIPTION This structure filled in on success.
cannam@162 375 @return Error code indicating success or failure
cannam@162 376 @see PaWasapi_GetJackCount
cannam@162 377 */
cannam@162 378 PaError PaWasapi_GetJackDescription(PaDeviceIndex nDevice, int jindex, PaWasapiJackDescription *pJackDescription);
cannam@162 379
cannam@162 380
cannam@162 381 /*
cannam@162 382 IMPORTANT:
cannam@162 383
cannam@162 384 WASAPI is implemented for Callback and Blocking interfaces. It supports Shared and Exclusive
cannam@162 385 share modes.
cannam@162 386
cannam@162 387 Exclusive Mode:
cannam@162 388
cannam@162 389 Exclusive mode allows to deliver audio data directly to hardware bypassing
cannam@162 390 software mixing.
cannam@162 391 Exclusive mode is specified by 'paWinWasapiExclusive' flag.
cannam@162 392
cannam@162 393 Callback Interface:
cannam@162 394
cannam@162 395 Provides best audio quality with low latency. Callback interface is implemented in
cannam@162 396 two versions:
cannam@162 397
cannam@162 398 1) Event-Driven:
cannam@162 399 This is the most powerful WASAPI implementation which provides glitch-free
cannam@162 400 audio at around 3ms latency in Exclusive mode. Lowest possible latency for this mode is
cannam@162 401 3 ms for HD Audio class audio chips. For the Shared mode latency can not be
cannam@162 402 lower than 20 ms.
cannam@162 403
cannam@162 404 2) Poll-Driven:
cannam@162 405 Polling is another 2-nd method to operate with WASAPI. It is less efficient than Event-Driven
cannam@162 406 and provides latency at around 10-13ms. Polling must be used to overcome a system bug
cannam@162 407 under Windows Vista x64 when application is WOW64(32-bit) and Event-Driven method simply
cannam@162 408 times out (event handle is never signalled on buffer completion). Please note, such WOW64 bug
cannam@162 409 does not exist in Vista x86 or Windows 7.
cannam@162 410 Polling can be setup by speciying 'paWinWasapiPolling' flag. Our WASAPI implementation detects
cannam@162 411 WOW64 bug and sets 'paWinWasapiPolling' automatically.
cannam@162 412
cannam@162 413 Thread priority:
cannam@162 414
cannam@162 415 Normally thread priority is set automatically and does not require modification. Although
cannam@162 416 if user wants some tweaking thread priority can be modified by setting 'paWinWasapiThreadPriority'
cannam@162 417 flag and specifying 'PaWasapiStreamInfo::threadPriority' with value from PaWasapiThreadPriority
cannam@162 418 enum.
cannam@162 419
cannam@162 420 Blocking Interface:
cannam@162 421
cannam@162 422 Blocking interface is implemented but due to above described Poll-Driven method can not
cannam@162 423 deliver lowest possible latency. Specifying too low latency in Shared mode will result in
cannam@162 424 distorted audio although Exclusive mode adds stability.
cannam@162 425
cannam@162 426 Pa_IsFormatSupported:
cannam@162 427
cannam@162 428 To check format with correct Share Mode (Exclusive/Shared) you must supply
cannam@162 429 PaWasapiStreamInfo with flags paWinWasapiExclusive set through member of
cannam@162 430 PaStreamParameters::hostApiSpecificStreamInfo structure.
cannam@162 431
cannam@162 432 Pa_OpenStream:
cannam@162 433
cannam@162 434 To set desired Share Mode (Exclusive/Shared) you must supply
cannam@162 435 PaWasapiStreamInfo with flags paWinWasapiExclusive set through member of
cannam@162 436 PaStreamParameters::hostApiSpecificStreamInfo structure.
cannam@162 437 */
cannam@162 438
cannam@162 439 #ifdef __cplusplus
cannam@162 440 }
cannam@162 441 #endif /* __cplusplus */
cannam@162 442
cannam@162 443 #endif /* PA_WIN_WASAPI_H */