bastibe / SoundCard

A Pure-Python Real-Time Audio Library
https://soundcard.readthedocs.io
BSD 3-Clause "New" or "Revised" License
689 stars 70 forks source link

avoid garbage collection related stream creation failure #105

Closed rikvanriel closed 4 years ago

rikvanriel commented 4 years ago

C has pointers, Python does not. Python has garbage collection, C does not. The function pa_channel_map_init_auto returns, on success, a pointer to the same pa_channel_map object that was passed to the function as a parameter.

Apparently this confuses Pyton/CFFI, which can sometimes garbage collect that old (now properly initialized) object, resulting in pa_stream_new getting a pa_channel_map object that is not properly initialized, and throwing an error.

Using separate variable names for the pa_channel_map object passed to pa_channel_map_init_auto and the one returned seems to avoid that issue, even though they are the same structure.

Signed-off-by: Rik van Riel riel@surriel.com

bastibe commented 4 years ago

Thank you very much for your invaluable collaboration in finding and fixing this issue!

rikvanriel commented 4 years ago

Thank you for the great library.

Figuring this one out was a fun project to do together.