Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update with latest version 0.2.11 #8

Open
wants to merge 37 commits into
base: master
Choose a base branch
from

Conversation

evandrocoan
Copy link

hubertpham and others added 30 commits September 21, 2015 23:26
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!
Previously IOErrors raised had strerror and errno arguments swapped,
which this change fixes.

Thanks to Sami Liedes for the report!
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!
Also trivial formatting fixes.
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
Many thanks to Blaise Potard for spotting the issue and submitting a
patch!
@R030t1
Copy link

R030t1 commented Apr 30, 2020

I think this has been blocking my use of pyaudio on my systems with newer libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants