Uh oh!
There was an error while loading. Please reload this page.
Fix callback handling and flag initialization - #629
Conversation
mgeier
commented
May 23, 2026
Thanks for this PR! How can I reproduce the errors? Does this need a certain CFFI version? |
IzaCarlos
commented
May 23, 2026
You can reproduce (I'm very sure) by installing Python v3.14.4 w/cffi 2.0.0 and Sounddevice with 0.5.5, then use any application that opens a stream for a long time. As mentioned I applied some fixes to my sd installation and it has not been causing any more issues. |
Problem
On Python 3.14, cffi changed how it passes arguments to native callbacks
and how it validates
__init__return values. This caused two distinct errors:TypeError: __init__() should return None, not 'NoneType'cffi now intercepts and validates the return of
__init__at a lowerlevel, causing it to spuriously reject the standard
Nonereturn.TypeError: unsupported operand type(s) for &: '_CDataBase' and 'int'The
statusargument now arrives as a raw_CDataBaseobject insteadof a plain Python int, breaking bitwise operations in
_hasflag.Both errors surface in
_wrap_callbackand occur unpredictably duringstream callbacks, including during silence and active playback.
Fix
Bypass
CallbackFlags.__init__entirely in_wrap_callbackusing__new__, then set_flagsdirectly viaint()cast. This avoidsthe cffi
__init__interception and the_CDataBasebitwise issuein one shot.
Changes
In
_wrap_callback, replace:With:
Tested on