rossb [Sat, 12 Feb 2011 09:20:26 +0000 (09:20 +0000)]
fixed stream info inputLatency and outputLatency calculations. PaUtil_GetBufferProcessorOutputLatency returns latency in <frames>, code assumed it was in seconds.
rossb [Sat, 12 Feb 2011 09:19:37 +0000 (09:19 +0000)]
fixed stream info inputLatency and outputLatency calculations. PaUtil_GetBufferProcessorOutputLatency returns latency in <frames>, code assumed it was in seconds.
rossb [Sat, 12 Feb 2011 09:18:28 +0000 (09:18 +0000)]
fixed stream info inputLatency and outputLatency calculations. PaUtil_GetBufferProcessorOutputLatency returns latency in <frames>, code assumed it was in seconds.
dmitrykos [Fri, 11 Feb 2011 00:15:51 +0000 (00:15 +0000)]
alsa:
- implemented dynamic ALSA loading, you shall define PA_ALSA_DYNAMIC when compiling PortAudio library, by default PortAudio will use compile time linkage;
- added PA_ALSA_PATHNAME define to redefine ALSA library path and filename to some other name and location, has effect only together with PA_ALSA_DYNAMIC;
- added extension function (PaAlsa_SetLibraryPathName) which allows to set ALSA library path and filename during application run-time overwriting default set by PA_ALSA_PATHNAME during compilation;
- added API compatibility with Android OS (although ALSA may not be available on your device and usually requires 'root' access rights to open an audio device), some missing ALSA functions are replaced with stubs (needs more input from interested parties), to compile on Android you need to add ALSA headers (get it from Android GIT source-code tree) to compiler's searchable path.
dmitrykos [Wed, 9 Feb 2011 08:53:50 +0000 (08:53 +0000)]
alsa:
- fixed callback thread to exit normally if error condition was satisfied during stream processing (OnExit wasn't called), it was possible cause of crash if error happened inside the thread
- modified processing thread to timeout during poll() within around 2 seconds instead of 64 milliseconds, this will help to fix problems on systems with low processing power and possible CPU overloading, like portable ARM devices
- timeout of poll() will not cause stream to stop but will cause Alsa stream restart, poll timeout will now set 'xrun' event to 1
dmitrykos [Thu, 3 Feb 2011 15:15:44 +0000 (15:15 +0000)]
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
dmitrykos [Sun, 26 Dec 2010 16:36:52 +0000 (16:36 +0000)]
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.
dmitrykos [Sun, 26 Dec 2010 16:17:56 +0000 (16:17 +0000)]
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).
dmitrykos [Sun, 26 Dec 2010 15:58:30 +0000 (15:58 +0000)]
corrected Int24_To_Int16_Dither and implemented Int24_To_Int8_Dither, Float32_To_Int24 to use all 'double' types for optimal code generation (not mixing double with floats)
rossb [Sun, 26 Dec 2010 06:43:58 +0000 (06:43 +0000)]
disable dither conversion when host input format is 32 bit and user format is 24 bit. the converter for this is unimplemented anyway, and the host won't ever be sending us better than 24 bit data, so no need to dither it.
dmitrykos [Sat, 25 Dec 2010 13:26:17 +0000 (13:26 +0000)]
coreaudio: fixed incorrect value type used with OSAtomicOr32 API (xrunFlags were casted from long to unsigned int) which results in value truncation on systems where 'long' is 64 bits
richard_ash [Fri, 12 Nov 2010 17:16:21 +0000 (17:16 +0000)]
Commit fix for crash during full-duplex operation with PulseAudio. Reported by Al Dimond, fix proposed by Ross Bencina, acked by Dmitry Kostjuchenko. This fixes a bug with Dmitry's zero-copy optimisations. Fix works in Audacity (where the bug was found), so comitting upstream.
dmitrykos [Sun, 7 Nov 2010 08:23:51 +0000 (08:23 +0000)]
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
dmitrykos [Sat, 6 Nov 2010 01:16:34 +0000 (01:16 +0000)]
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
richard_ash [Fri, 29 Oct 2010 20:09:54 +0000 (20:09 +0000)]
Remove frome the list of directories created by configure a directory that no
longer has any contents and is not needed any more. Original patch by Benjamin Drung (Ubuntu)
rossb [Fri, 22 Oct 2010 02:23:33 +0000 (02:23 +0000)]
patch from Richard Ash: updated Makefile.in to set SHELL variable expected by newer versions of libtool (was breaking in builds on Debian without this)
dmitrykos [Wed, 20 Oct 2010 17:00:54 +0000 (17:00 +0000)]
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.
dmitrykos [Fri, 15 Oct 2010 20:39:23 +0000 (20:39 +0000)]
alsa: fixed Segmentation fault due to dangling pointer left by snd_lib_error_set_handler() call which set callback pointer to ALSA during PaAlsa_Initialize call. Segmentation fault happens only if application dynamically unloaded PortAudio while still using ALSA through other means, then next ALSA error which causes invocation of ALSA error handling callbacks would cause Segmentation fault. Bug reported in: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=563192, and re-announced by Phil Burk on 15.10.2010.
jack: fixed segmentation fault caused by PA Jack implementation if Pa_Initialize is called after Pa_Terminate due to bad pointer usage by realloc() call which was previously freed() in Pa_Terminate call. Many thanks to RJ Ryan for reporting, debugging and providing the solution for this bug.
alsa: avoid SetApproximateSampleRate() excessive log messages when Pa_IsFormatSupported API method is used to test for supported sample rates and some of them are not supported by device
dmitrykos [Tue, 24 Aug 2010 17:44:00 +0000 (17:44 +0000)]
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'
rossb [Fri, 20 Aug 2010 11:47:02 +0000 (11:47 +0000)]
Replaced broken PaStreamCallbackTimeInfo calculations with calculation based on CoreAudio ioProc timestamps. Notes: 1. inputBufferAdcTime is not computed correctly for all cases (eg full duplex with/without ring buffer). 2. This patch needs to be reviewed for the case where device and AUHAL sample rates differ (ie SRC is used) and if input and output sample rates differ. See FIXMES
dmitrykos [Fri, 6 Aug 2010 20:25:07 +0000 (20:25 +0000)]
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
dmitrykos [Tue, 3 Aug 2010 21:02:52 +0000 (21:02 +0000)]
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
dmitrykos [Mon, 2 Aug 2010 10:37:18 +0000 (10:37 +0000)]
alsa:
- trying to fix specific case of stream failing to open when min/max period is specifying fixed value with +/-1 difference, we try choosing middle then which seems to be aligned to 2
alsa:
- improved host buffer size calculation: taking into account obligatory double buffering utilising formula (userFrames + MAX( userFrames, SR * suggestedLatency)), aligning host buffer with user buffer size, additional testing of host buffer size to avoid failure on snd_pcm_hw_params_set_period_size_near, additional logging for more convenient debugging
alsa:
- fixed seg.fault (caused by assertion) when using non-interleaved host i/o, now paNonInterleaved flag is provided to PaUtil_InitializeBufferProcessor to signal processor about host format being non-interleaved
jack:
- fixed assertion in PA processor logics by informing processor that host format is non-interleaved (using paNonInterleaved flag) in PaUtil_InitializeBufferProcessor
- fixed rare timeout on WaitCondition reported earlier by increasing timeout from 1 second to 10 minutes
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.
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)
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)
optimized PA processor for case when host and user buffer match by type and size, now host buffer pointer will be passed to user space directly, additional copying of audio input/output data is thus avoided.
asio: apply paNonInterleaved flag on host formats for callback mode (required for processor compatibility).
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)
reverted changes from revisions 1516-1517 due to incorrectly made changes to processor's core which result in corrupted audio in some specific situations
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
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)
dmitrykos [Mon, 28 Jun 2010 21:35:04 +0000 (21:35 +0000)]
implemented optimization for NonAdaptingProcess processor: avoid copying of input/output from temp user buffer to host buffer by providing host buffer pointer directly to user, e.g. achieving processing of host buffer in place
dmitrykos [Mon, 28 Jun 2010 21:29:16 +0000 (21:29 +0000)]
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)
dmitrykos [Mon, 28 Jun 2010 21:19:15 +0000 (21:19 +0000)]
alsa: reverted broken specification (by me) according device latency being not dependent on user buffer size, now framesPerBuffer parameter and suggestedLatency set overall stream latency
dmitrykos [Thu, 10 Jun 2010 09:09:19 +0000 (09:09 +0000)]
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.
dmitrykos [Sun, 6 Jun 2010 17:36:33 +0000 (17:36 +0000)]
oss: fixed compile for systems missing 'pthread_cancel' series of functions, this allows to compile PortAudio under Android platform with OSS as audio host back-end
dmitrykos [Thu, 3 Jun 2010 20:09:33 +0000 (20:09 +0000)]
alsa:
- fixed latency setting dependence on user buffer size, now it is completely independent and user is able to set lowest possible/audible latency (approx. 3-4ms)
- fixed fixed min. latency for non-MMAPed devices, they do behave similar to MMAPed devices now without a limitation
dmitrykos [Tue, 1 Jun 2010 17:26:37 +0000 (17:26 +0000)]
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)
dmitrykos [Mon, 31 May 2010 09:46:49 +0000 (09:46 +0000)]
wasapi:
- implemented support of non-Interlieved buffers (paNonInterleaved) for WASAPI blocking interface for input and output
- blocking methods will now use PA sample converters
dmitrykos [Sun, 30 May 2010 22:14:00 +0000 (22:14 +0000)]
alsa:
- reverted buffer size (2048) hardcoding for non-MMAPed devices to avoid crash on wrong buffer size usage (whole area requires more work)
- optimized non-MMAPed device operation to avoid malloc(memset)/free usage on every processing call avoiding significant performance penalty
dmitrykos [Sun, 30 May 2010 07:28:41 +0000 (07:28 +0000)]
alsa:
- fixed deadlock in PaAlsaStream_WaitForFrames if device is paused, poll() results are now checked for 0 and if 64 times exceeded an error (paTimedOut) is returned
- removed hardcoded low-limit of latency for non-MMAPed devices, it is an obligation for user to set an acceptable/desired latency value
- tuned XRUN recovery sequence for MMAPed devices
dmitrykos [Mon, 17 May 2010 21:15:13 +0000 (21:15 +0000)]
wasapi:
- using WOW64 workaround (fall-back to a Poll-driven mode) for any WOW64 process regardless of Windows version due to report of same bug under Windows 7 x64
dmitrykos [Mon, 17 May 2010 18:37:00 +0000 (18:37 +0000)]
wasapi:
- fixed object (IAudioRenderClient/IAudioCaptureClient) leak if stream is stopped and restarted without closing
- improved IAudioClient event handle management on stream restart (not deleting/creating event handle but rather keeping it until stream is closed)
dmitrykos [Wed, 12 May 2010 18:08:45 +0000 (18:08 +0000)]
wasapi:
- fixed occasional crash-bug which may be caused by a lightweight application that starts stream, checks if stream is running and if not terminates the stream: WASAPI implementation wasn't taking such behavior into account and stream termination (with structure deallocation) could happen during a thread start causing a crash on bad pointer usage
- fixed Pa_IsStreamActive and similar not correctly reporting stopped stream if that was stopped from within a callback function (playback/capture) by returning paComplete
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
wasapi:
- added calling thread id checks to match Pa_Initialize/Pa_Uninitialize in the same calling thread, if not the case then console warning will be thrown and CoUninitialize will not be called (preferring leak over uninitializing user-side COM)
wasapi:
- fixed Windows 7/Server 2008 R2 and Future detection, this fixes minimal/maximal device periods correction
- added CO_E_NOTINITIALIZED to text errors with action to take for user in case it happens
wasapi:
- fixed crash in Pa_OpenStream call if WASAPI device did not open or something failed (happened on stream handle cleanup due to double attempt to free same pointer)
- improved the way WASAPI device is opening, such error as AUDCLNT_E_BUFFER_SIZE_ERROR which comes due to incorrectly small device period is fixed for Vista (and all other, including future) systems as well, latency will be corrected to device minimum (usually 3ms).
- if suggestedLatency is set to 0 in Pa_OpenStream call then WASAPI device will select device default latency (in Exclusive mode it is 10ms, in Shared 20ms)
- improved on-screen logging of WASAPI devices available during WASAPI initialization phase
fixed ASIO thiscall resolver for GCC 4.+: CALL_THISCALL_1_DOUBLE was failing due to strong optimization of GCC compiler, added EDX in clobbered register list to warn GCC that resolver uses it explicitly