Debian Codegraph @

external/portaudio/pa_win_wasapi.h

raw symbols SCIP
1 #ifndef PA_WIN_WASAPI_H
2 #define PA_WIN_WASAPI_H
3 /*
4 * $Id: $
5 * PortAudio Portable Real-Time Audio Library
6 * WASAPI specific extensions
7 *
8 * Copyright (c) 1999-2018 Ross Bencina and Phil Burk
9 * Copyright (c) 2006-2010 David Viens
10 * Copyright (c) 2010-2018 Dmitry Kostjuchenko
11 *
12 * Permission is hereby granted, free of charge, to any person obtaining
13 * a copy of this software and associated documentation files
14 * (the "Software"), to deal in the Software without restriction,
15 * including without limitation the rights to use, copy, modify, merge,
16 * publish, distribute, sublicense, and/or sell copies of the Software,
17 * and to permit persons to whom the Software is furnished to do so,
18 * subject to the following conditions:
19 *
20 * The above copyright notice and this permission notice shall be
21 * included in all copies or substantial portions of the Software.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
27 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
28 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 */
31
32 /*
33 * The text above constitutes the entire PortAudio license; however,
34 * the PortAudio community also makes the following non-binding requests:
35 *
36 * Any person wishing to distribute modifications to the Software is
37 * requested to send the modifications to the original developer so that
38 * they can be incorporated into the canonical version. It is also
39 * requested that these non-binding requests be included along with the
40 * license above.
41 */
42
43 /** @file
44 @ingroup public_header
45 @brief WASAPI-specific PortAudio API extension header file.
46 */
47
48 #include "portaudio.h"
49 #include "pa_win_waveformat.h"
50
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif /* __cplusplus */
55
56
57 /* Stream setup flags. */
58 typedef enum PaWasapiFlags
59 {
60 /* put WASAPI into exclusive mode */
61 paWinWasapiExclusive = (1 << 0),
62
63 /* allow to skip internal PA processing completely */
64 paWinWasapiRedirectHostProcessor = (1 << 1),
65
66 /* assign custom channel mask */
67 paWinWasapiUseChannelMask = (1 << 2),
68
69 /* select non-Event driven method of data read/write
70 Note: WASAPI Event driven core is capable of 2ms latency!!!, but Polling
71 method can only provide 15-20ms latency. */
72 paWinWasapiPolling = (1 << 3),
73
74 /* force custom thread priority setting, must be used if PaWasapiStreamInfo::threadPriority
75 is set to a custom value */
76 paWinWasapiThreadPriority = (1 << 4),
77
78 /* force explicit sample format and do not allow PA to select suitable working format, API will
79 fail if provided sample format is not supported by audio hardware in Exclusive mode
80 or system mixer in Shared mode */
81 paWinWasapiExplicitSampleFormat = (1 << 5),
82
83 /* allow API to insert system-level channel matrix mixer and sample rate converter to allow
84 playback formats that do not match the current configured system settings.
85 this is in particular required for streams not matching the system mixer sample rate.
86 only applies in Shared mode. */
87 paWinWasapiAutoConvert = (1 << 6)
88 }
89 PaWasapiFlags;
90 #define paWinWasapiExclusive (paWinWasapiExclusive)
91 #define paWinWasapiRedirectHostProcessor (paWinWasapiRedirectHostProcessor)
92 #define paWinWasapiUseChannelMask (paWinWasapiUseChannelMask)
93 #define paWinWasapiPolling (paWinWasapiPolling)
94 #define paWinWasapiThreadPriority (paWinWasapiThreadPriority)
95 #define paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat)
96 #define paWinWasapiAutoConvert (paWinWasapiAutoConvert)
97
98
99 /* Stream state.
100
101 @note Multiple states can be united into a bitmask.
102 @see PaWasapiStreamStateCallback, PaWasapi_SetStreamStateHandler
103 */
104 typedef enum PaWasapiStreamState
105 {
106 /* state change was caused by the error:
107
108 Example:
109 1) If thread execution stopped due to AUDCLNT_E_RESOURCES_INVALIDATED then state
110 value will contain paWasapiStreamStateError|paWasapiStreamStateThreadStop.
111 */
112 paWasapiStreamStateError = (1 << 0),
113
114 /* processing thread is preparing to start execution */
115 paWasapiStreamStateThreadPrepare = (1 << 1),
116
117 /* processing thread started execution (enters its loop) */
118 paWasapiStreamStateThreadStart = (1 << 2),
119
120 /* processing thread stopped execution */
121 paWasapiStreamStateThreadStop = (1 << 3)
122 }
123 PaWasapiStreamState;
124 #define paWasapiStreamStateError (paWasapiStreamStateError)
125 #define paWasapiStreamStateThreadPrepare (paWasapiStreamStateThreadPrepare)
126 #define paWasapiStreamStateThreadStart (paWasapiStreamStateThreadStart)
127 #define paWasapiStreamStateThreadStop (paWasapiStreamStateThreadStop)
128
129
130 /* Host processor.
131
132 Allows to skip internal PA processing completely. paWinWasapiRedirectHostProcessor flag
133 must be set to the PaWasapiStreamInfo::flags member in order to have host processor
134 redirected to this callback.
135
136 Use with caution! inputFrames and outputFrames depend solely on final device setup.
137 To query max values of inputFrames/outputFrames use PaWasapi_GetFramesPerHostBuffer.
138 */
139 typedef void (*PaWasapiHostProcessorCallback) (void *inputBuffer, long inputFrames,
140 void *outputBuffer, long outputFrames, void *userData);
141
142
143 /* Stream state handler.
144
145 @param pStream Pointer to PaStream object.
146 @param stateFlags State flags, a collection of values from PaWasapiStreamState enum.
147 @param errorId Error id provided by system API (HRESULT).
148 @param userData Pointer to user data.
149
150 @see PaWasapiStreamState
151 */
152 typedef void (*PaWasapiStreamStateCallback) (PaStream *pStream, unsigned int stateFlags,
153 unsigned int errorId, void *pUserData);
154
155
156 /* Device role. */
157 typedef enum PaWasapiDeviceRole
158 {
159 eRoleRemoteNetworkDevice = 0,
160 eRoleSpeakers,
161 eRoleLineLevel,
162 eRoleHeadphones,
163 eRoleMicrophone,
164 eRoleHeadset,
165 eRoleHandset,
166 eRoleUnknownDigitalPassthrough,
167 eRoleSPDIF,
168 eRoleHDMI,
169 eRoleUnknownFormFactor
170 }
171 PaWasapiDeviceRole;
172
173
174 /* Jack connection type. */
175 typedef enum PaWasapiJackConnectionType
176 {
177 eJackConnTypeUnknown,
178 eJackConnType3Point5mm,
179 eJackConnTypeQuarter,
180 eJackConnTypeAtapiInternal,
181 eJackConnTypeRCA,
182 eJackConnTypeOptical,
183 eJackConnTypeOtherDigital,
184 eJackConnTypeOtherAnalog,
185 eJackConnTypeMultichannelAnalogDIN,
186 eJackConnTypeXlrProfessional,
187 eJackConnTypeRJ11Modem,
188 eJackConnTypeCombination
189 }
190 PaWasapiJackConnectionType;
191
192
193 /* Jack geometric location. */
194 typedef enum PaWasapiJackGeoLocation
195 {
196 eJackGeoLocUnk = 0,
197 eJackGeoLocRear = 0x1, /* matches EPcxGeoLocation::eGeoLocRear */
198 eJackGeoLocFront,
199 eJackGeoLocLeft,
200 eJackGeoLocRight,
201 eJackGeoLocTop,
202 eJackGeoLocBottom,
203 eJackGeoLocRearPanel,
204 eJackGeoLocRiser,
205 eJackGeoLocInsideMobileLid,
206 eJackGeoLocDrivebay,
207 eJackGeoLocHDMI,
208 eJackGeoLocOutsideMobileLid,
209 eJackGeoLocATAPI,
210 eJackGeoLocReserved5,
211 eJackGeoLocReserved6,
212 }
213 PaWasapiJackGeoLocation;
214
215
216 /* Jack general location. */
217 typedef enum PaWasapiJackGenLocation
218 {
219 eJackGenLocPrimaryBox = 0,
220 eJackGenLocInternal,
221 eJackGenLocSeparate,
222 eJackGenLocOther
223 }
224 PaWasapiJackGenLocation;
225
226
227 /* Jack's type of port. */
228 typedef enum PaWasapiJackPortConnection
229 {
230 eJackPortConnJack = 0,
231 eJackPortConnIntegratedDevice,
232 eJackPortConnBothIntegratedAndJack,
233 eJackPortConnUnknown
234 }
235 PaWasapiJackPortConnection;
236
237
238 /* Thread priority. */
239 typedef enum PaWasapiThreadPriority
240 {
241 eThreadPriorityNone = 0,
242 eThreadPriorityAudio, //!< Default for Shared mode.
243 eThreadPriorityCapture,
244 eThreadPriorityDistribution,
245 eThreadPriorityGames,
246 eThreadPriorityPlayback,
247 eThreadPriorityProAudio, //!< Default for Exclusive mode.
248 eThreadPriorityWindowManager
249 }
250 PaWasapiThreadPriority;
251
252
253 /* Stream descriptor. */
254 typedef struct PaWasapiJackDescription
255 {
256 unsigned long channelMapping;
257 unsigned long color; /* derived from macro: #define RGB(r,g,b) ((COLORREF)(((BYTE)(r)|((WORD)((BYTE)(g))<<8))|(((DWORD)(BYTE)(b))<<16))) */
258 PaWasapiJackConnectionType connectionType;
259 PaWasapiJackGeoLocation geoLocation;
260 PaWasapiJackGenLocation genLocation;
261 PaWasapiJackPortConnection portConnection;
262 unsigned int isConnected;
263 }
264 PaWasapiJackDescription;
265
266
267 /** Stream category.
268 Note:
269 - values are equal to WASAPI AUDIO_STREAM_CATEGORY enum
270 - supported since Windows 8.0, noop on earlier versions
271 - values 1,2 are deprecated on Windows 10 and not included into enumeration
272
273 @version Available as of 19.6.0
274 */
275 typedef enum PaWasapiStreamCategory
276 {
277 eAudioCategoryOther = 0,
278 eAudioCategoryCommunications = 3,
279 eAudioCategoryAlerts = 4,
280 eAudioCategorySoundEffects = 5,
281 eAudioCategoryGameEffects = 6,
282 eAudioCategoryGameMedia = 7,
283 eAudioCategoryGameChat = 8,
284 eAudioCategorySpeech = 9,
285 eAudioCategoryMovie = 10,
286 eAudioCategoryMedia = 11
287 }
288 PaWasapiStreamCategory;
289
290
291 /** Stream option.
292 Note:
293 - values are equal to WASAPI AUDCLNT_STREAMOPTIONS enum
294 - supported since Windows 8.1, noop on earlier versions
295
296 @version Available as of 19.6.0
297 */
298 typedef enum PaWasapiStreamOption
299 {
300 eStreamOptionNone = 0, //!< default
301 eStreamOptionRaw = 1, //!< bypass WASAPI Audio Engine DSP effects, supported since Windows 8.1
302 eStreamOptionMatchFormat = 2 //!< force WASAPI Audio Engine into a stream format, supported since Windows 10
303 }
304 PaWasapiStreamOption;
305
306
307 /* Stream descriptor. */
308 typedef struct PaWasapiStreamInfo
309 {
310 unsigned long size; /**< sizeof(PaWasapiStreamInfo) */
311 PaHostApiTypeId hostApiType; /**< paWASAPI */
312 unsigned long version; /**< 1 */
313
314 unsigned long flags; /**< collection of PaWasapiFlags */
315
316 /** Support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
317 paWinWasapiUseChannelMask this allows you to specify which speakers
318 to address in a multichannel stream. Constants for channelMask
319 are specified in pa_win_waveformat.h. Will be used only if
320 paWinWasapiUseChannelMask flag is specified.
321 */
322 PaWinWaveFormatChannelMask channelMask;
323
324 /** Delivers raw data to callback obtained from GetBuffer() methods skipping
325 internal PortAudio processing inventory completely. userData parameter will
326 be the same that was passed to Pa_OpenStream method. Will be used only if
327 paWinWasapiRedirectHostProcessor flag is specified.
328 */
329 PaWasapiHostProcessorCallback hostProcessorOutput;
330 PaWasapiHostProcessorCallback hostProcessorInput;
331
332 /** Specifies thread priority explicitly. Will be used only if paWinWasapiThreadPriority flag
333 is specified.
334
335 Please note, if Input/Output streams are opened simultaneously (Full-Duplex mode)
336 you shall specify same value for threadPriority or othervise one of the values will be used
337 to setup thread priority.
338 */
339 PaWasapiThreadPriority threadPriority;
340
341 /** Stream category.
342 @see PaWasapiStreamCategory
343 @version Available as of 19.6.0
344 */
345 PaWasapiStreamCategory streamCategory;
346
347 /** Stream option.
348 @see PaWasapiStreamOption
349 @version Available as of 19.6.0
350 */
351 PaWasapiStreamOption streamOption;
352 }
353 PaWasapiStreamInfo;
354
355
356 /** Returns pointer to WASAPI's IAudioClient object of the stream.
357
358 @param pStream Pointer to PaStream object.
359 @param pAudioClient Pointer to pointer of IAudioClient.
360 @param bOutput TRUE (1) for output stream, FALSE (0) for input stream.
361
362 @return Error code indicating success or failure.
363 */
364 PaError PaWasapi_GetAudioClient( PaStream *pStream, void **pAudioClient, int bOutput );
365
366
367 /** Update device list.
368
369 This function is available if PA_WASAPI_MAX_CONST_DEVICE_COUNT is defined during compile time
370 with maximum constant WASAPI device count (recommended value - 32).
371 If PA_WASAPI_MAX_CONST_DEVICE_COUNT is set to 0 (or not defined) during compile time the implementation
372 will not define PaWasapi_UpdateDeviceList() and thus updating device list can only be possible by calling
373 Pa_Terminate() and then Pa_Initialize().
374
375 @return Error code indicating success or failure.
376 */
377 PaError PaWasapi_UpdateDeviceList();
378
379
380 /** Get current audio format of the device assigned to the opened stream.
381
382 Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
383 Use this function to reconfirm format if PA's processor is overridden and
384 paWinWasapiRedirectHostProcessor flag is specified.
385
386 @param pStream Pointer to PaStream object.
387 @param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
388 @param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
389 @param bOutput TRUE (1) for output stream, FALSE (0) for input stream.
390
391 @return Non-negative value indicating the number of bytes copied into format descriptor
392 or, a PaErrorCode (which is always negative) if PortAudio is not initialized
393 or an error is encountered.
394 */
395 int PaWasapi_GetDeviceCurrentFormat( PaStream *pStream, void *pFormat, unsigned int formatSize, int bOutput );
396
397
398 /** Get default audio format for the device in Shared Mode.
399
400 Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure and obtained
401 by getting the device property with a PKEY_AudioEngine_DeviceFormat key.
402
403 @param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
404 @param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
405 @param device Device index.
406
407 @return Non-negative value indicating the number of bytes copied into format descriptor
408 or, a PaErrorCode (which is always negative) if PortAudio is not initialized
409 or an error is encountered.
410 */
411 int PaWasapi_GetDeviceDefaultFormat( void *pFormat, unsigned int formatSize, PaDeviceIndex device );
412
413
414 /** Get mix audio format for the device in Shared Mode.
415
416 Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structureand obtained by
417 IAudioClient::GetMixFormat.
418
419 @param pFormat Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
420 @param formatSize Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
421 @param device Device index.
422
423 @return Non-negative value indicating the number of bytes copied into format descriptor
424 or, a PaErrorCode (which is always negative) if PortAudio is not initialized
425 or an error is encountered.
426 */
427 int PaWasapi_GetDeviceMixFormat( void *pFormat, unsigned int formatSize, PaDeviceIndex device );
428
429
430 /** Get device role (PaWasapiDeviceRole enum).
431
432 @param device Device index.
433
434 @return Non-negative value indicating device role or, a PaErrorCode (which is always negative)
435 if PortAudio is not initialized or an error is encountered.
436 */
437 int/*PaWasapiDeviceRole*/ PaWasapi_GetDeviceRole( PaDeviceIndex device );
438
439
440 /** Get device IMMDevice pointer
441
442 @param device Device index.
443 @param pAudioClient Pointer to pointer of IMMDevice.
444
445 @return Error code indicating success or failure.
446 */
447 PaError PaWasapi_GetIMMDevice( PaDeviceIndex device, void **pIMMDevice );
448
449
450 /** Boost thread priority of calling thread (MMCSS).
451
452 Use it for Blocking Interface only inside the thread which makes calls to Pa_WriteStream/Pa_ReadStream.
453
454 @param pTask Handle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority
455 method to revert thread priority to initial state.
456
457 @param priorityClass Id of thread priority of PaWasapiThreadPriority type. Specifying
458 eThreadPriorityNone does nothing.
459
460 @return Error code indicating success or failure.
461 @see PaWasapi_RevertThreadPriority
462 */
463 PaError PaWasapi_ThreadPriorityBoost( void **pTask, PaWasapiThreadPriority priorityClass );
464
465
466 /** Boost thread priority of calling thread (MMCSS).
467
468 Use it for Blocking Interface only inside the thread which makes calls to Pa_WriteStream/Pa_ReadStream.
469
470 @param pTask Task handle obtained by PaWasapi_BoostThreadPriority method.
471
472 @return Error code indicating success or failure.
473 @see PaWasapi_BoostThreadPriority
474 */
475 PaError PaWasapi_ThreadPriorityRevert( void *pTask );
476
477
478 /** Get number of frames per host buffer.
479
480 It is max value of frames of WASAPI buffer which can be locked for operations.
481 Use this method as helper to find out max values of inputFrames/outputFrames
482 of PaWasapiHostProcessorCallback.
483
484 @param pStream Pointer to PaStream object.
485 @param pInput Pointer to variable to receive number of input frames. Can be NULL.
486 @param pOutput Pointer to variable to receive number of output frames. Can be NULL.
487
488 @return Error code indicating success or failure.
489 @see PaWasapiHostProcessorCallback
490 */
491 PaError PaWasapi_GetFramesPerHostBuffer( PaStream *pStream, unsigned int *pInput, unsigned int *pOutput );
492
493
494 /** Get number of jacks associated with a WASAPI device.
495
496 Use this method to determine if there are any jacks associated with the provided WASAPI device.
497 Not all audio devices will support this capability. This is valid for both input and output devices.
498
499 @note Not available on UWP platform.
500
501 @param device Device index.
502 @param pJackCount Pointer to variable to receive number of jacks.
503
504 @return Error code indicating success or failure.
505 @see PaWasapi_GetJackDescription
506 */
507 PaError PaWasapi_GetJackCount( PaDeviceIndex device, int *pJackCount );
508
509
510 /** Get the jack description associated with a WASAPI device and jack number.
511
512 Before this function is called, use PaWasapi_GetJackCount to determine the
513 number of jacks associated with device. If jcount is greater than zero, then
514 each jack from 0 to jcount can be queried with this function to get the jack
515 description.
516
517 @note Not available on UWP platform.
518
519 @param device Device index.
520 @param jackIndex Jack index.
521 @param pJackDescription Pointer to PaWasapiJackDescription.
522
523 @return Error code indicating success or failure.
524 @see PaWasapi_GetJackCount
525 */
526 PaError PaWasapi_GetJackDescription( PaDeviceIndex device, int jackIndex, PaWasapiJackDescription *pJackDescription );
527
528
529 /** Set stream state handler.
530
531 @param pStream Pointer to PaStream object.
532 @param fnStateHandler Pointer to state handling function.
533 @param pUserData Pointer to user data.
534
535 @return Error code indicating success or failure.
536 */
537 PaError PaWasapi_SetStreamStateHandler( PaStream *pStream, PaWasapiStreamStateCallback fnStateHandler, void *pUserData );
538
539
540 /** Set default device Id.
541
542 By default implementation will use the DEVINTERFACE_AUDIO_RENDER and
543 DEVINTERFACE_AUDIO_CAPTURE Ids if device Id is not provided explicitly. These default Ids
544 will not allow to use Exclusive mode on UWP/WinRT platform and thus you must provide
545 device Id explicitly via this API before calling the Pa_OpenStream().
546
547 Device Ids on UWP platform are obtainable via:
548 Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId() or
549 Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId() API.
550
551 After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
552
553 Call this function before calling Pa_IsFormatSupported() when Exclusive mode is requested.
554
555 See an example in the IMPORTANT notes.
556
557 @note UWP/WinRT platform only.
558
559 @param pId Device Id, pointer to the 16-bit Unicode string (WCHAR). If NULL then device Id
560 will be reset to the default, e.g. DEVINTERFACE_AUDIO_RENDER or DEVINTERFACE_AUDIO_CAPTURE.
561 @param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
562
563 @return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
564 for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
565 be returned.
566 */
567 PaError PaWasapiWinrt_SetDefaultDeviceId( const unsigned short *pId, int bOutput );
568
569
570 /** Populate the device list.
571
572 By default the implementation will rely on DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE as
573 default devices. If device Id is provided by PaWasapiWinrt_SetDefaultDeviceId() then those
574 device Ids will be used as default and only devices for the device list.
575
576 By populating the device list you can provide an additional available audio devices of the system to PA
577 which are obtainable by:
578 Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(selector) where selector is obtainable by
579 Windows::Media::Devices::MediaDevice::GetAudioRenderSelector() or
580 Windows::Media::Devices::MediaDevice::GetAudioCaptureSelector() API.
581
582 After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
583
584 You must call PaWasapi_UpdateDeviceList() to update the internal device list of the implementation after
585 calling this function.
586
587 See an example in the IMPORTANT notes.
588
589 @note UWP/WinRT platform only.
590
591 @param pId Array of device Ids, pointer to the array of pointers of 16-bit Unicode string (WCHAR). If NULL
592 and count is also 0 then device Ids will be reset to the default. Required.
593 @param pName Array of device Names, pointer to the array of pointers of 16-bit Unicode string (WCHAR). Optional.
594 @param pRole Array of device Roles, see PaWasapiDeviceRole and PaWasapi_GetDeviceRole() for more details. Optional.
595 @param count Number of devices, the number of array elements (pId, pName, pRole). Maximum count of devices
596 is limited by PA_WASAPI_DEVICE_MAX_COUNT.
597 @param bOutput TRUE (1) for output (render), FALSE (0) for input (capture).
598
599 @return Error code indicating success or failure. Will return paIncompatibleStreamHostApi if library is not compiled
600 for UWP/WinRT platform. If Id is longer than PA_WASAPI_DEVICE_ID_LEN characters paBufferTooBig will
601 be returned. If Name is longer than PA_WASAPI_DEVICE_NAME_LEN characters paBufferTooBig will
602 be returned.
603 */
604 PaError PaWasapiWinrt_PopulateDeviceList( const unsigned short **pId, const unsigned short **pName,
605 const PaWasapiDeviceRole *pRole, unsigned int count, int bOutput );
606
607
608 /*
609 IMPORTANT:
610
611 WASAPI is implemented for Callback and Blocking interfaces. It supports Shared and Exclusive
612 share modes.
613
614 Exclusive Mode:
615
616 Exclusive mode allows to deliver audio data directly to hardware bypassing
617 software mixing.
618 Exclusive mode is specified by 'paWinWasapiExclusive' flag.
619
620 Callback Interface:
621
622 Provides best audio quality with low latency. Callback interface is implemented in
623 two versions:
624
625 1) Event-Driven:
626 This is the most powerful WASAPI implementation which provides glitch-free
627 audio at around 3ms latency in Exclusive mode. Lowest possible latency for this mode is
628 3 ms for HD Audio class audio chips. For the Shared mode latency can not be
629 lower than 20 ms.
630
631 2) Poll-Driven:
632 Polling is another 2-nd method to operate with WASAPI. It is less efficient than Event-Driven
633 and provides latency at around 10-13ms. Polling must be used to overcome a system bug
634 under Windows Vista x64 when application is WOW64(32-bit) and Event-Driven method simply
635 times out (event handle is never signalled on buffer completion). Please note, such WOW64 bug
636 does not exist in Vista x86 or Windows 7.
637 Polling can be setup by specifying 'paWinWasapiPolling' flag. Our WASAPI implementation detects
638 WOW64 bug and sets 'paWinWasapiPolling' automatically.
639
640 Thread priority:
641
642 Normally thread priority is set automatically and does not require modification. Although
643 if user wants some tweaking thread priority can be modified by setting 'paWinWasapiThreadPriority'
644 flag and specifying 'PaWasapiStreamInfo::threadPriority' with value from PaWasapiThreadPriority
645 enum.
646
647 Blocking Interface:
648
649 Blocking interface is implemented but due to above described Poll-Driven method can not
650 deliver lowest possible latency. Specifying too low latency in Shared mode will result in
651 distorted audio although Exclusive mode adds stability.
652
653 8.24 format:
654
655 If paCustomFormat is specified as sample format then the implementation will understand it
656 as valid 24-bits inside 32-bit container (e.g. wBitsPerSample = 32, Samples.wValidBitsPerSample = 24).
657
658 By using paCustomFormat there will be small optimization when samples are be copied
659 with Copy_24_To_24 by PA processor instead of conversion from packed 3-byte (24-bit) data
660 with Int24_To_Int32.
661
662 Pa_IsFormatSupported:
663
664 To check format with correct Share Mode (Exclusive/Shared) you must supply PaWasapiStreamInfo
665 with flags paWinWasapiExclusive set through member of PaStreamParameters::hostApiSpecificStreamInfo
666 structure.
667
668 If paWinWasapiExplicitSampleFormat flag is provided then implementation will not try to select
669 suitable close format and will return an error instead of paFormatIsSupported. By specifying
670 paWinWasapiExplicitSampleFormat flag it is possible to find out what sample formats are
671 supported by Exclusive or Shared modes.
672
673 Pa_OpenStream:
674
675 To set desired Share Mode (Exclusive/Shared) you must supply
676 PaWasapiStreamInfo with flags paWinWasapiExclusive set through member of
677 PaStreamParameters::hostApiSpecificStreamInfo structure.
678
679 Coding style for parameters and structure members of the public API:
680
681 1) bXXX - boolean, [1 (TRUE), 0 (FALSE)]
682 2) pXXX - pointer
683 3) fnXXX - pointer to function
684 4) structure members are never prefixed with a type distinguisher
685
686
687 UWP/WinRT:
688
689 This platform has number of limitations which do not allow to enumerate audio devices without
690 an additional external help. Enumeration is possible though from C++/CX, check the related API
691 Windows::Devices::Enumeration::DeviceInformation::FindAllAsync().
692
693 The main limitation is an absence of the device enumeration from inside the PA's implementation.
694 This problem can be solved by using the following functions:
695
696 PaWasapiWinrt_SetDefaultDeviceId() - to set default input/output device,
697 PaWasapiWinrt_PopulateDeviceList() - to populate device list with devices.
698
699 Here is an example of populating the device list which can also be updated dynamically depending on
700 whether device was removed from or added to the system:
701
702 ----------------
703
704 std::vector<const UINT16 *> ids, names;
705 std::vector<PaWasapiDeviceRole> role;
706
707 ids.resize(count);
708 names.resize(count);
709 role.resize(count);
710
711 for (UINT32 i = 0; i < count; ++i)
712 {
713 ids[i] = (const UINT16 *)device_ids[i].c_str();
714 names[i] = (const UINT16 *)device_names[i].c_str();
715 role[i] = eRoleUnknownFormFactor;
716 }
717
718 PaWasapiWinrt_SetDefaultDeviceId((const UINT16 *)default_device_id.c_str(), !capture);
719 PaWasapiWinrt_PopulateDeviceList(ids.data(), names.data(), role.data(), count, !capture);
720 PaWasapi_UpdateDeviceList();
721
722 ----------------
723 */
724
725 #ifdef __cplusplus
726 }
727 #endif /* __cplusplus */
728
729 #endif /* PA_WIN_WASAPI_H */