Commit graph portaudio/include/pa_win_wasapi.h
Author SHA1 Message Date
Ross Bencina
c441223dfa
Clean up whitespace in include/ in preparation for .editorconfig. (#415)
* Clean up whitespace in include/ in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
2021-01-21 14:19:22 +11:00
luz paz
e1c3e59ee8 Fix user-facing and non-user-facing typos
Found via `codespell v2.1.dev0`
2020-12-11 20:24:05 -05:00
dmitrykos
a5fb8d94aa wasapi: Support multiple devices in the device list on Windows UWP/WinRT platform. All UWP/WinRT functions are now prefixed as PaWasapiWinrt_ to be clearly visible, therefore PaWasapi_SetDefaultInterfaceId() was renamed to PaWasapiWinrt_SetDefaultDeviceId(). Expanded Important notes regarding UWP/WinRT platform and how to make the fully-functional device list with the corresponding pseudo-code example for easier understanding of the functionality. 2020-10-26 16:40:25 +02:00
Jörn Heusipp
aa0748a5b5 wasapi: Add paWinWasapiAutoConvert flag, which sets AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY for Shared mode streams.
AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM is required in order to allow for sample rates other than the system mixer configured sample rate. Otherwise, WASAPI is limited to a single system configured sample rate in Shared mode, which is a severe limitation compared to other APIs supported by PortAudio.
AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY is recommended to be used additionally.
See <https://docs.microsoft.com/en-us/windows/desktop/coreaudio/audclnt-streamflags-xxx-constants> for documentation.

GetClosestFormat is modified to exit early when paWinWasapiAutoConvert is set in Shared mode because we trust the WASAPI conversions to succeed.

We restrict these changes to Windows 7 (and later) because documentation does not clearly state the minimum required Windows version. Windows Vista was not available for testing.

This patch has been in production in OpenMPT (<https://openmpt.org/>) since version 1.27.01.00 (2017-09-27). PortAudio WASAPI Shared mode is the default output device type in OpenMPT for Windows 7 (and later) and also for Wine setups.
2019-04-05 10:02:17 +03:00
dmitrykos
83ab55b62d wasapi: new API PaWasapi_SetStreamStateHandler() to be able to catch WASAPI error inside the rendering thread loop (and handle it gracefully, for example restart the stream), protect from dangling pointer during device list update, cleanup header 2018-12-24 14:20:29 +02:00
dmitrykos
d74ea7b610 wasapi: get channels count and sample rate from a mix format (IAudioClient::GetMixFormat) for a PaDeviceInfo to circumvent rare cases when WASAPI does not accept format provided PKEY_AudioEngine_DeviceFormat due to a wrong channel count (bug and solution reported by Etienne Dechamps (edechamps), discussion: http://app.assembla.com/spaces/portaudio/git/merge_requests/7024281), new PaWasapi_GetDeviceMixFormat API to get mix format provided by IAudioClient::GetMixFormat 2018-12-10 10:50:31 +02:00
dmitrykos
c3fee03ff1 wasapi: support Exclusive mode on UWP (use new function PaWasapi_SetDefaultInterfaceId to set device's interface id to make Exclusive mode work);
- support for explicit 8.24 format (24-bit inside 32-bit container) by specifying paCustomFormat (see IMPORTANT notes in the header file);
 - new flag paWinWasapiExplicitSampleFormat to force explicit format and avoid fallback to a closest working;
 - new function PaWasapi_GetDeviceCurrentFormat to get device format of the opened stream;
 - support PaWasapi_ThreadPriorityXXX API on UWP to boot thread priority;
 - improved selection of the closest format in Exclusive mode.
2018-09-06 20:45:22 +03:00
dmitrykos
a802290e83 wasapi: new PaWasapi_GetAudioClient() API to get pointer to IAudioClient from PaStream, workaround to get real Windows version in order to be able to create correct version of IAudioClient interface (Windows 10 was reported as Windows 8 when using just GetVersion()) 2018-06-30 12:21:59 +03:00
dmitrykos
d3e65ce690 wasapi: correction to PaWasapi_UpdateDeviceList() API by making it unavailable by default unless PA_WASAPI_MAX_CONST_DEVICE_COUNT is explicitly defined 2018-04-02 22:15:49 +03:00
dmitrykos
eb62287494 wasapi: new WASAPI specific API PaWasapi_UpdateDeviceList() which allows to update WASAPI device list dynamically without a need to call Pa_Terminate() and then Pa_Initialize().
This new implementation overcomes current limitation of Pa_GetDeviceCount() API which gives constant device count by making WASAPI device list constant (32 devices by default) where 32 device slots can either be filled with a real device info or be empty for a future device changes.

Constant device list size can be altered by PA_WASAPI_MAX_CONST_DEVICE_COUNT define during a compile time. If PA_WASAPI_MAX_CONST_DEVICE_COUNT is set to 0 then PaWasapi_UpdateDeviceList() will be unavailable as well as dynamic device list update functionality.

This implementation also detects the audio device format change if user alters it via Windows Audio Controller GUI.

This implementation also makes WASAPI backend ready for a future implementation of device list updates via PortAudio public API. See internal PaError UpdateDeviceList().
2018-04-02 21:50:16 +03:00
Ross Bencina
12f967356b Added Available as of version 19.6.0 doc comments for new wasapi host-api-specific APIs. 2016-09-25 17:55:12 +10:00
Phil Burk
ed463ba658 Normalize all the line endings 2016-05-18 22:13:20 -07:00
dmitrykos
4e194eaecf wasapi: support for setting the WASAPI's AudioClientProperties options via PaWasapiStreamInfo struct (__IAudioClient2_INTERFACE_DEFINED__ must be defined by Windows SDK (for Windows 8 and up) to have effect from these new options, otherwise it will be noop) 2015-10-19 11:03:31 +00:00
dmitrykos
9c7974c76c wasapi:
- fixed alignment missing for host buffer if overall buffer size was set to less than 3ms that results in device timeout
 - advanced Event driven mode and extended the range of host buffer size which can operate in this mode up up to 20.66 ms, e.g. your device buffer size will vary in range 3 - 20.66 ms, if goes above then Poll driven mode is switched on automatically
2010-08-06 20:25:07 +00:00
dmitrykos
f2badb7725 wasapi:
- added functionality to enumerate jacks and their description
 - added example which demonstrates jacks enumeration technique
Thanks Reid Bishop for providing the idea for this extended functionality and patch with implementation.
2010-07-23 10:04:03 +00:00
dmitrykos
50986ea63b wasapi:
- new method PaWasapi_GetFramesPerHostBuffer which allows to get number of input/output frames per host (WASAPI) buffer, this method helps to find out maximal values for PaWasapiHostProcessorCallback
 - documentation fixes
2010-04-16 08:31:19 +00:00
dmitrykos
75e59cb874 improved PaWasapi_ThreadPriorityBoost by providing enum PaWasapiThreadPriority with explicit thread priority values for convenience. it is possible to override default thread priority setting for Event/Poll-driven modes by specifying new flag paWinWasapiThreadPriority and setting priority value through PaWasapiStreamInfo::threadPriority member. 2010-02-17 10:11:40 +00:00
dmitrykos
01a0391237 finished WASAPI implementation:
- Callback/Blocking interface
 - Playback/Capture
 - Shared/Exclusive mode
to compile you must have installed recent Windows SDK(Vista SDK or higher) and min Visual Studio 2005 SP1. WASAPI is enabled by default, to disable you must define PA_NO_WASAPI prior compilation.
2010-02-16 09:46:08 +00:00