Commit graph portaudio/src/hostapi/wasapi/pa_win_wasapi.c
Author SHA1 Message Date
Ross Bencina
46f97c7c20 Merge branch 'master' into hotplug 2016-09-03 14:19:23 +10:00
Ross Bencina
d41ba780b2 hotplug: added connectionId parameter to PaDeviceInfo and bumped struct version number. added PaUtil_MakeDeviceConnectionId() function and used it to initialize connectionId in all host APIs. updated patest_refresh_device_list to display connection id. NOTE: persistent connection ids have not been implemented in dsound and wdmks, so refreshing the device list will change connection ids. 2016-09-02 20:27:39 +10:00
Ross Bencina
89f8f75a27 Merge of old SVN hotplug branch into current git HEAD. Includes hotplug support for DirectSound, WDM/KS. Both are working running in debugger but WDM/KS seems to be crashing in stand-alone build. I removed the use of struct _PaInternalInfo in hotplug/pa_front.c to reduce the size of the change. pa_win_dsound.c involved the most intricate changes due to other changes that had been made in the mean time. I've also initialized function ptrs ScanDeviceInfos, CommitDeviceInfos, DisposeDeviceInfos so this should build on all platforms. 2016-08-27 17:51:40 +10:00
dmitrykos
319b19203a wasapi: replaced InterlockedCompareExchange with InterlockedOr and added clarifying comment why Interlocked API is used 2016-08-26 22:31:45 +03:00
dmitrykos
dae0d7f8e7 wasapi: reverted the usage of Interlocked APIs for PaWasapiStream::running 2016-08-26 09:43:50 +03:00
dmitrykos
46bce3c39f wasapi: use InterlockedXXX APIs to secure inter-thread r/w access to variables to avoid possible deadlocks or logic corruption 2016-08-24 22:04:17 +03:00
dmitrykos
ef449bb5bf wasapi: more cleanup - normalized WIN32_WINRT to PA_WINRT, removed excessive declarations from SignalObjectAndWait, ActivateAudioInterfaceCompletionHandler set of functions 2016-08-14 19:01:20 +03:00
dmitrykos
326549c55e wasapi: use Windows common Sleep() API instead of PA_Sleep()
use GetTickCount64() API which is awailable for Windows Store app instead of _ftime_s()
remove WAVEFORMAT and WAVEFORMATEX declaration and use the corresponding Windows include file instead
2016-08-14 10:52:36 +03:00
dmitrykos
26c0dc4458 wasapi: code cleanup, removed compiler warnings 2016-08-08 21:09:15 +03:00
dmitrykos
2e7545f17f wasapi: ported to WinRT (UWP)
os: compatibility fixes for compilation of PortAudio as Windows Store library (only WASAPI hostapi is compatible with Windows Store APIs)
2016-08-03 22:39:41 +03:00
Phil Burk
ed463ba658 Normalize all the line endings 2016-05-18 22:13:20 -07:00
dmitrykos
f7b2d1542f wasapi: correction to the previous commit 2015-10-21 14:25:07 +00:00
dmitrykos
58eca02986 wasapi: workaround to avoid PaWasapi_Initialize() failure when enumerating devices and device fails to report min/default periods with IAudioClient::GetDevicePeriod(): ignore error and assign WASAPI common known period values for min/default 2015-10-20 16:02:39 +00: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
robiwan
3438e46e74 Minor refactoring to remove some warnings 2012-06-29 11:44:12 +00:00
dmitrykos
4ae4fa0ef9 wasapi: provide meaningful error code when opening the stream and error occurred instead of just paInvalidDevice 2012-04-16 08:16:20 +00:00
dmitrykos
5701b05e0f wasapi: zero wasapi host api rep immediately after init. prevents (unlikely) issue with trying to free uninited allocations if com init fails during Pa_Initialize() (Ross Bencina) 2012-04-02 12:25:14 +00:00
dmitrykos
341eb04550 wasapi:
- fixed possible buffer overrun inside WASAPI for Output poll-driven mode according ticket #196 (thanks to Ross Bencina for spotting this and proposing the solution)
2012-02-16 15:02:08 +00:00
dmitrykos
9bc432b603 wasapi:
- fixed device name incorrect in case it contains non-Latin characters (thanks to Robert Bielik for proposed solution), now it is converted to UTF-8 encoded string
- fixed damaged audio (pops & clicks) for Input exclusive event-driven mode if specified latency was below 23 ms
2012-02-16 14:49:28 +00:00
rossb
52ab9d6600 refactored COM initialization for dsound, asio and wasapi to new source file pa_win_coinitialize.c. fixes com uninitialisation bugs in error cases. resolves ticket #128 2011-05-09 20:05:34 +00:00
rossb
cbd24dc45c renamed PaUtil_GetBufferProcessorInputLatency to PaUtil_GetBufferProcessorInputLatencyFrames and PaUtil_GetBufferProcessorOutputLatency to PaUtil_GetBufferProcessorOutputLatencyFrames. see ticket #161 2011-05-02 17:07:11 +00:00
dmitrykos
ff61de145b wasapi:
- fixed warning of incompatible type usage when ring-buffer is used for blocking interface
 - fixed compilation using MSYS with MinGW compiler (regenerate makefile with configure)
2011-03-08 17:20:07 +00:00
dmitrykos
3fb0ef9e30 wasapi: fixed the bug when on stream stop/start/stop/start sequence callback could be called with number of samples smaller than requested by user in Pa_OpenStream 2011-02-21 22:41:06 +00:00
dmitrykos
f588f3cd5d wasapi: - releasing Input/Output buffer if error occurred inside the processing routine 2011-02-03 15:37:12 +00:00
dmitrykos
2b0faea85c wasapi:
- fixed blocking interface, Input and Output
 - improved Exclusive Input device latency tunning
 - applied path provided by Jean-François Charron (D-BOX Technologies Inc.) which improves handling of COM objects in multi-threaded environment and initialization stage which could under certain conditions return paNoError event when initialization failed
2011-02-03 15:15:44 +00:00
dmitrykos
272adbefc7 wasapi: allow mono input/output streams be created when Blocking interface is used. Thanks to Chris (c319chris@aol.com) for providing the patch. 2011-01-03 18:33:32 +00:00
dmitrykos
8b6f0610b6 wasapi: fixed audio device not released to other applications if WASAPI Exclusive stream is stopped but not yet closed. Bug does not affect Shared mode streams. Fixed possible object's leakage in situation when WASAPI thread encountered an error and stopped and user decided to start stream again without prior closing it. 2010-12-26 16:36:52 +00:00
dmitrykos
41645b30d5 wasapi: fixed audio gain is decreased by 2 when audio stream is opened for capturing and 1 (Mono) channel selected, this bug occurs only if non-Stereo input source used (mono mic). 2010-12-26 16:17:56 +00:00
dmitrykos
f1e8193ae1 wasapi:
- using WAVE_FORMAT_PCM for mono/stereo 8/16-bit stream configuration to avoid possible driver refusal upon audio client creation
 - modified default speaker mask for 5.1 and 7.1 configuration to _SURROUND (correct) versions, added default speaker configuration for 2.1, 4.1, 6.1 cases
2010-11-07 08:23:51 +00:00
dmitrykos
7b3d837bbb wasapi: fixed audio stream failing to open on Windows 7 in Exclusive mode if suggestedLatency parameter is 0 and user framesPerBuffer is less than 3 milliseconds 2010-11-06 01:16:34 +00:00
dmitrykos
e5b04a89da wasapi: fixed capturing (Input stream) if Polling mode is used, ProcessInputBuffer was broken erroneously returning AUDCLNT_S_BUFFER_EMPTY and thus breaking Input thread. 2010-10-20 17:32:04 +00:00
dmitrykos
738b8ad327 wasapi: improved audio quality stability in Shared mode if framesPerBuffer (from user-side) value is lower than 10 milliseconds, now even 1 frame provides stable quality. Exclusive mode is also affected by this improvement. 2010-10-20 17:00:54 +00:00
dmitrykos
52a9ce20ad wasapi:
- fixed compile under MinGW64 compiler (gcc version 4.5.1 20100702)
 - cleaned portability typedefs, thanks to MinGW64 project added KS headers which also work well for MinGW32 (tested: gcc version 4.5.0)
wdmks:
 - made it possible to use additional WDM/KS info for WMME/DS back-ends by defining PAWIN_USE_WDMKS_DEVICE_INFO for compilation by MinGW32/64 compilers if you include modified headers located in '\src\hostapi\wasapi\mingw-include'
2010-08-24 17:44:00 +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
24c304db21 wasapi:
- fixed compilation by MinGW, was failing due to double ambiguous jack describing enums used in KS
ds:
 - fixed compile by MinGW, was failing due to missing casts to LPVOID * and usage of UINT instead of DWORD by PaWinDsStream::previousPlayCursor
2010-08-03 21:02:52 +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
e540964ffc wasapi: - fixed frames preloading for buffer mode - paUtilFixedHostBufferSize 2010-07-20 21:01:07 +00:00
dmitrykos
3ba45b5966 wasapi: - fixed occasional bug (affects Windows 7 mostly) which is related to stream start failure due to exceeding buffer size when preloading data for output stream in exclusive mode (thanks Ralph Irving for noticing and reporting this bug) 2010-07-20 19:01:17 +00:00
dmitrykos
f6d6f4e955 wasapi:
- fixed usage of uninitialized variable (Input)
2010-07-15 23:27:21 +00:00
dmitrykos
a243ad431c wasapi:
- reimplemented full-duplex processing to address changes to latency calculations (please note Exclusive mode due to some unknown reason will likely not be able to provide good audio quality yet)
 - fixed Pa_GetStreamInfo for WASAPI device if stream is opened as full-duplex (thanks to Reid Bishop for pointing to the bug)
2010-07-12 18:41:05 +00:00
dmitrykos
231eb48512 wasapi:
- fixed memory corruption if format is set to non-interlieved and mono <> stereo mini-mixer is used for to convert mono to stereo (conversion is done due to WASAPI limitation)
 - made WASAPI fully passing patest_wire.c (full-duplex combinations) for shared and exclusive modes
 - if WASAPI device failed to open due to unsupported format it will not crash top PA layer anymore
 - improved full-duplex mode for shared/exclusive (although exclusive full-duplex mode still produces audio glitches due to difference in input/output device buffer size due to unknown WASAPI reason, with shared mode all is ok)
 - exclusive mode will now work with 1 channel audio always, even if it is not supported by WASAPI natively (we use own mono <> stereo mini-mixer)
2010-07-09 23:57:51 +00:00
dmitrykos
f7ee62732e wasapi:
- fixed Exclusive/Event mode if latency used exceeds 100ms resulting in bad audio
 - fixed Exclusive mode if overall stream latency exceeds 1400-2000ms resulting in E_OUTOFMEMORY even under Vista, now PA WASAPI will gradually decrease overall latency until acceptable level
 - applied device period aligning if period was corrected
 - improved robustness of audio client creation
2010-07-08 21:03:08 +00:00
dmitrykos
0a4cf33379 wasapi:
- reimplemented suggestedLatency and framesPerBuffer parameters in Pa_OpenStream call to opearate by the following formula - 'hostBufferFrames = userFramesPerBuffer + max(userFramesPerBuffer, (suggestedLatency * sampleRate))' as discussed on PA mailing-lists
 - it is now possible to achieve 5.33ms latency in Polling & Exclusive mode (WOW64 or Native)
 - Polling method for output will benefit from direct WASAPI buffer pointer exposure to a user space through a callback (no copying)
2010-07-06 07:28:48 +00:00
dmitrykos
87d4873e95 wasapi:
- made framesPerBuffer and suggestedLatency behavior as per PA specification, e.g. framesPerBuffer set main device period, suggestedLatency is a surplus if not 0
 - fixed bug with Input in situation when WASAPI operates in native not-WOW64 process and using event mechanism would provide less frames to a user callback than expected (due to the fact as WASAPI's audio client provides only 1 packet per GetBuffer call which)
2010-06-28 21:29:16 +00:00
dmitrykos
fd47a09808 wasapi: fixed very rare bug causing a dead looping if WASAPI input stream is being aborted 2010-06-22 19:53:00 +00:00
dmitrykos
5444956b5c wasapi: fixed full-duplex failure (when host sample types differ) due to incorrect check made on I/O host buffer sizes 2010-06-10 09:45:54 +00:00
dmitrykos
23aed33a71 wasapi: fixed host-WASAPI related bug when selected 24-bit Input does not produce any audio, while 16 and 32-bits do, now if 24-bits selected by user (paInt24) PA WASAPI asks 32-bits (paFloat32) from WASAPI device and PA converters provide 24-bit data which is converted from 32-bit host buffer. 2010-06-10 09:09:19 +00:00
dmitrykos
d2568e4ae7 wasapi:
- implemented support for full-duplex mode (it always uses polling(pull) WASAPI behavior, if latency <15msec needed then event interface must be done)
 - fixed mono-to-stereo converter for input stream
 - mono-to-stereo converter will also automatically operate in shared mode (if WASAPI driver does not support mono for output, or only stereo for input)
2010-06-01 17:26:37 +00:00
dmitrykos
3e700ec6d2 wasapi:
- implemented support of non-Interlieved buffers (paNonInterleaved) for WASAPI blocking interface for input and output
 - blocking methods will now use PA sample converters
2010-05-31 09:46:49 +00:00
dmitrykos
9bb962b93b wasapi:
- re-enabled Event-driven mode for Windows 7 x64 platform if application runs as WOW64 process
2010-05-18 17:23:56 +00:00