Commit Graph

124 Commits

Author SHA1 Message Date
Derek f749f2187e Bump version 2021-12-14 21:48:36 -07:00
Derek 2ee560056e Use Py_ssize_t for tuple return on stream methods 2021-12-14 21:46:11 -07:00
Hubert Pham 7090e25bcb Version bump. 2017-03-18 16:32:59 -07:00
Hubert Pham 045ebc7767 Merge branch 'docs-fix' 2017-03-18 11:23:57 -07:00
Hubert Pham 653fdfeb87 Remove generated files from source distribution. 2017-03-18 10:59:11 -07:00
Hubert Pham 281a8f32e7 Fix get_output_latency docstring. 2017-02-28 21:20:36 -08:00
Hubert Pham 39de78a74a Merge branch 'use-after-free-fix' 2017-02-26 20:00:35 -08:00
Hubert Pham 2e696d98c0 Fix use-after-free error.
Many thanks to Blaise Potard for spotting the issue and submitting a
patch!
2017-02-26 19:58:48 -08:00
Hubert Pham 833ebc0b14 Version bump. 2017-01-11 20:03:43 -08:00
Hubert Pham fe528b2050 Update references to examples and tests. 2017-01-10 20:05:59 -08:00
Hubert Pham 8285b9bc5c Merge branch 'gil-fix' 2017-01-10 18:55:03 -08:00
Hubert Pham a0f6d13628 Tests: remove dependence on scipy. 2017-01-09 22:14:21 -08:00
Hubert Pham 47a80684e1 Release the GIL before PortAudio stream calls.
This commit adds logic to release the GIL for these PortAudio routines:

Pa_IsStreamStopped
Pa_IsStreamActive
Pa_GetStreamTime
Pa_GetStreamCpuLoad
Pa_GetStreamWriteAvailable
Pa_GetStreamReadAvailable
Pa_Initialize
Pa_Terminate
2017-01-09 20:55:43 -08:00
Hubert Pham 439327bcd7 Minor fix on int type to fix compiler warnings.
Also trivial formatting fixes.
2017-01-09 20:44:09 -08:00
Hubert Pham c9bc0193b0 Add tests to detect potential sources of deadlock. 2017-01-09 20:06:04 -08:00
Hubert Pham 884cedae7f Release GIL when calling Pa_{Open,Start}Stream.
On macOS/OSX, CoreAudio may require a device-level lock for certain
operations, e.g., opening a stream or delivering audio data to a
callback. If the lock acquisition order between the device lock and the
Python GIL is inconsistent, deadlock might occur. Michael Graczyk
identified one such instance, where:

- an input stream, running in thread A, acquires the device lock,
  followed by the GIL, in order to call the user's Python input callback
  handler;
- that callback makes a call that releases the GIL (e.g., I/O)
- thread B acquires the GIL and opens a PyAudio stream, eventually
  invoking Pa_OpenStream. Note that prior to this patch, calling
  Pa_OpenStream did _not_ release the GIL.
- While holding the GIL, Pa_OpenStream attempts to acquire the device
  lock.
- Meanwhile, thread A (still holding the device lock) attempts to
  reacquire the GIL (e.g., once the I/O call is complete).

This commit:

(a) updates the implementation to release the GIL before calling
    Pa_OpenStream and Pa_StartStream. Hopefully this change will bring
    the code closer to the discipline of always acquiring the device
    lock before the GIL. Thanks Michael for the patch!

(b) adds a unit test to reproduce the problem (on CoreAudio systems).

Many thanks again to Michael Graczyk for identifying the issue and
contributing the fix!
2017-01-08 19:12:51 -08:00
Hubert Pham 50e08d41d4 Merge branch 'unittests' 2017-01-08 12:19:56 -08:00
Hubert Pham 7a61080270 Add duration for wire callback example. 2017-01-08 12:18:07 -08:00
Hubert Pham e59fa4a24e Add loopback-based tests. 2017-01-08 12:16:21 -08:00
Hubert Pham 870016f6d1 Skip overflow tests on GNU/Linux ALSA. 2017-01-08 12:16:09 -08:00
Hubert Pham bff409df19 Rename test -> examples. 2016-12-25 09:49:26 -08:00
Hubert Pham da8c238eee Add unit tests. 2016-12-25 09:49:26 -08:00
Hubert Pham dce064b428 Version bump. 2015-10-18 15:38:54 -07:00
Hubert Pham ab5e5b775e Update setup.py and cleanup. 2015-10-18 15:38:54 -07:00
Hubert Pham 5a4da7d870 Update INSTALL instructions. 2015-10-18 15:38:22 -07:00
Hubert Pham 0e5eb7cb9d Use setuptools when possible. 2015-10-18 04:00:13 -07:00
Hubert Pham 3e6adb4588 Update source code style for consistency. 2015-10-18 03:59:36 -07:00
Hubert Pham d786cc59a2 Update examples for Python 3 compatibility. 2015-10-18 03:49:48 -07:00
Hubert Pham ebea06b12c On C module import error, raise the exception rather than sys.exit. 2015-10-18 03:49:48 -07:00
Hubert Pham 1783aaf9bc Fix IOError arguments.
Previously IOErrors raised had strerror and errno arguments swapped,
which this change fixes.

Thanks to Sami Liedes for the report!
2015-10-18 03:49:04 -07:00
Hubert Pham 53ab5eb107 Fix overflow error handling logic for pa_read_stream.
This adds an optional parameter specifying whether an input overflow
exception should be raised (or ignored).  Previously, a code comment
conflicted with actual implementation, by suggesting that overflows
are ignored when in fact they are always surfaced.  Furthermore,
detecting an overflow condition was flawed.  This change allows
the user to decide whether exceptions are thrown, for API parity with
pa_write_stream.

Thanks to Tony Jacobson for the report and patch!
2015-09-21 23:26:28 -07:00
Hubert Pham fc7bd1d2b0 Update version. 2014-02-16 16:04:29 -08:00
Hubert Pham 7cefbc5718 setup.py: fix GNU/Linux static linking configuration. 2014-02-16 15:50:05 -08:00
Hubert Pham 7ec435d961 Fix deadlock when calling Pa_StopStream in callback mode.
Deadlock due to callback thread waiting for the GIL while the
GIL is still held by thread calling Pa_StopStream.  The fix is
to release the GIL before calling Pa_StopStream.

Much gratitude to Jason Roehm for the patch!
2014-02-16 15:49:38 -08:00
Hubert Pham f1abe26c96 Return raw bytes of audio device name to allow user to manage encoding. 2014-02-15 22:09:50 -08:00
Christoph Gohlke b9b1cb5a71 Conform to C89/ANSI standard to compile on MSVC.
Thanks to Christoph Gohlke for the patch!
2012-11-14 21:54:36 -05:00
Hubert Pham a0bdcab7b3 Update version. 2012-10-20 21:39:47 -04:00
Hubert Pham 9459d994b1 Play Wave test: stop stream. 2012-10-20 21:38:37 -04:00
Hubert Pham ed830f7b5b Merge branch 'sphinx-doc' 2012-10-20 21:36:43 -04:00
Hubert Pham 949d4b7271 Update MANIFEST.in to include sphinx directory. 2012-10-20 21:35:19 -04:00
Hubert Pham 930a5cd04b Conditionalize doc generation for Mac OS X specific classes. 2012-10-20 21:35:19 -04:00
Hubert Pham 2953234b0b Style: better conformance to PEP8. 2012-10-20 21:35:19 -04:00
Hubert Pham 806d8623e9 Docstring cleanup. 2012-10-20 21:35:19 -04:00
Hubert Pham 72a9bd1dd2 Refactor examples into a separate file. 2012-10-20 21:35:19 -04:00
Hubert Pham 9136083440 Add changes to pyaudio for sphinx. 2012-10-20 21:35:19 -04:00
Hubert Pham 1cb6b8c1f6 Makefile: update docs target for sphinx and necessary dependencies. 2012-10-20 21:35:15 -04:00
Hubert Pham d7bad725ed Sphinx: switch to nature theme. 2012-10-20 20:16:53 -04:00
Hubert Pham 39c41c8cae Add sphinx configuration. 2012-10-19 17:03:43 -04:00
Hubert Pham 679c1c2ead Updated example files for sphinx. 2012-10-19 17:03:42 -04:00
Hubert Pham 34e54db968 Merge branch 'callable' 2012-10-19 17:03:24 -04:00