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.
dmitrykos [Sat, 9 Mar 2019 10:43:14 +0000 (12:43 +0200)]
wasapi: set IAudioClient2+ properties before GetClosestFormat() in order to avoid failing with unsupported format error if PaWasapiStreamCategory is other than default, for example eAudioCategorySpeech
dmitrykos [Sat, 23 Feb 2019 21:02:38 +0000 (23:02 +0200)]
wasapi: Improved audio output stability in Exclusive mode for some UAC2 DACs with custom USB Audio driver by calculating buffer periodicity being equal (or almost equal) to the requested user frames (Capturing is excluded from this implementation as it has not yet been tested but can be included if tests show the improvement), cleanup/refactor some code to make it better readable
dmitrykos [Mon, 24 Dec 2018 12:20:29 +0000 (14:20 +0200)]
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
Etienne Dechamps [Sun, 25 Nov 2018 10:28:56 +0000 (10:28 +0000)]
Treat DirectSound just like any other standard Windows SDK library.
Currently the CMake build system goes through complicated logic to
find the DirectX SDK. This is completely unnecessary, because modern
versions of the Windows SDK include dsound.h and dsound.lib in the
standard paths, so it can be treated just like the other Windows OS
libraries and we can safely assume it is available.
This commit simplifies the logic and will allow the vcpkg portaudio
port to align with portaudio stream, by getting rid of this patch:
https://github.com/Microsoft/vcpkg/blob/95f9ce56f32618cceda97d54af16e3d6c57fc4b3/ports/portaudio/find_dsound.patch
I have verified that PortAudio CMake still builds with this commit
with the following toolchains:
- Windows Visual Studio 2017 native CMake support
- mingw-w64 on Windows (msys2)
- mingw-w64 cross-compiling from Debian Unstable
dmitrykos [Wed, 12 Dec 2018 21:29:44 +0000 (23:29 +0200)]
wasapi: relax check for a latency range when deciding to switch from Event to Poll mode to have 1-21 ms range fine tuneable, add check for a min period when correcting period for UAC1 devices to avoid failure to initialize audio client due to invalid period error
dmitrykos [Mon, 10 Dec 2018 08:50:31 +0000 (10:50 +0200)]
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
WASAPI: fixed MonoToStereo converter could write beyond the allowed memory region if sample format is packed 24-bit integer, fixed DEF file by adding missing WASAPI API
dmitrykos [Sun, 21 Oct 2018 10:21:28 +0000 (13:21 +0300)]
wasapi: fixed MonoToStereo converter could write beyond the allowed memory region if sample format is packed 24-bit integer, fixed DEF file by adding missing WASAPI API
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.
dmitrykos [Sat, 30 Jun 2018 09:21:59 +0000 (12:21 +0300)]
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())
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()
wasapi: correction to PaWasapi_UpdateDeviceList() API by making it unavailable by default unless PA_WASAPI_MAX_CONST_DEVICE_COUNT is explicitly defined
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().
dmitrykos [Mon, 29 May 2017 19:44:36 +0000 (22:44 +0300)]
wasapi: corrected GetWindowsVersion() to return Windows 10 (was max Windows 8)
wasapi: use IAudioClient3 for Windows 10 for best compatibility
wasapi: fix compilation when Windows 10 SDK (10.0.15063.0) is used by removing SignalObjectAndWait() definition which creates duplicates with the system defined SignalObjectAndWait() (since 10.0.15063.0 it is supported by the OS again)
Ross Bencina [Sun, 25 Sep 2016 07:34:16 +0000 (17:34 +1000)]
Fix formatting of version API doxygen comments in portaudio.h. Add additional documentation details, see also, and version information (e.g. `Available as of 19.5.0`).
Phil Burk [Sat, 24 Sep 2016 15:53:28 +0000 (08:53 -0700)]
pa_mac_core: fix whitespace and missing semicolon
It compiled without the semicolon because it was followed by a VDBUG,
which was followed by a semicolon. The VDBUG was disabled so its
semicolon finished the line above.
Ross Bencina [Fri, 23 Sep 2016 08:49:00 +0000 (18:49 +1000)]
Doxygen document tweaks: * Link to our Wiki for latest MinGW build information. * Fix for latest doxygen: non-displaying links on main page (add space before <br>). * Remove broken link to java binding docs (not compiled). * Update link to mailing list.
Nick Appleton [Thu, 15 Sep 2016 12:52:44 +0000 (22:52 +1000)]
address all problems picked up by cmakelint except for line-length related comments. don't use min() in paex_record_file as it is a macro specific to windows.
only build x86 plain converters in Visual Studio due because of assembly syntax. add library dependencies for asio to get MinGW builds linking. disable WASAPI when using MinGW as I cannot get it to work.
dmitrykos [Mon, 29 Aug 2016 06:54:49 +0000 (09:54 +0300)]
wasapi: return E_NOINTERFACE in PaActivateAudioInterfaceCompletionHandler::QueryInterface, use C-style API for calling interface functions (in order to be unified with the rest of WASAPI code)