No description
Find a file
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
examples Add duration for wire callback example. 2017-01-08 12:18:07 -08:00
sphinx Version bump. 2015-10-18 15:38:54 -07:00
src Release GIL when calling Pa_{Open,Start}Stream. 2017-01-08 19:12:51 -08:00
tests Release GIL when calling Pa_{Open,Start}Stream. 2017-01-08 19:12:51 -08:00
.gitignore Add .gitignore. 2010-08-14 17:56:35 -04:00
CHANGELOG Version bump. 2015-10-18 15:38:54 -07:00
INSTALL Update INSTALL instructions. 2015-10-18 15:38:22 -07:00
Makefile Version bump. 2015-10-18 15:38:54 -07:00
MANIFEST.in Rename test -> examples. 2016-12-25 09:49:26 -08:00
README Version bump. 2015-10-18 15:38:54 -07:00
setup.py Version bump. 2015-10-18 15:38:54 -07:00

======================================================================
PyAudio v0.2.9: Python Bindings for PortAudio.
======================================================================

See: http://people.csail.mit.edu/hubert/pyaudio/

PyAudio provides Python bindings for PortAudio v19, the cross-platform
audio I/O library. Using PyAudio, you can easily use Python to play
and record audio on a variety of platforms.

See INSTALL for compilation hints.

======================================================================

PyAudio : Python Bindings for PortAudio.

Copyright (c) 2006 Hubert Pham

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

======================================================================