Repository navigation
Fix minor bugs with queue and teardown - #83
Conversation
There was a problem hiding this comment.
I would normally try to stay on released versions, but if you like to depend on a development version, that's also fine for me.
There was a problem hiding this comment.
v19.7.0 is from 2021 and there's been no tag since (!). There are a few years of upstream fixes (e.g. CoreAudio alignment)
| if not self.closed: | ||
| self.close() |
There was a problem hiding this comment.
I didn't check this, but I have the feeling that close() should be idempotent, shouldn't it?
But then, PortAudio behaves strangely in some cases ... for example, in the past I had to call stop() before close(), see https://github.com/spatialaudio/python-sounddevice/blob/283f40d6ebdedda2c0d609c41a6a14476c1dc87e/src/sounddevice.py#L2966-L2969
There was a problem hiding this comment.
Yeah close() currently tolerates repeat calls (passes NULL to Pa_CloseStream and ignores any error), the closed check is just a shortcut so could be dropped. I could add a self.abort to this, too, to make it maybe safer as well...
There was a problem hiding this comment.
Note that there were problems with abort() in older PortAudio versions (see spatialaudio/python-sounddevice#75 (comment)), but that's probably not relevant anymore.
There was a problem hiding this comment.
From that thread it looks like the hang was with 2010/2014-era PortAudio builds and had already been fixed upstream by 2017, so I think we might as well keep the abort()
AFAICT, you are the only (regular) contributor, so if you like to have any of this, feel free to add it! |
|
Thanks for the update! Now that I'm thinking a bit more about this ... there's really no need to push the |
* upstream/master: Bump pypa/cibuildwheel from 4.3.4 to 4.3.5 in the actions group (spatialaudio#85) Bump pypa/cibuildwheel from 4.3.1 to 4.3.4 in the actions group (spatialaudio#84)
* upstream/master: Update news and add agentic guidance (spatialaudio#86)
|
Okay should be done now @mgeier ! |
|
Thanks! I think your implementation is perfectly fine, but I'm quite pedantic, so I have more suggestions (not necessarily requests, though):
If you do both (and maybe even only with point 1?), I would do both, but I think it would also be possible to do only one of them. All this is of course a matter of style and taste, the only real argument is consistency with the existing code. What do you think? |
|
Makes sense to me! There's now a local |
Fix a few minor bugs I came across:
memsetcall for input-only streams__del__for mixers that ensure they are closed. Otherwise a garbage-collected mixer could keep calling a callback with a freed state.RuntimeErrorif you try to enqueue an action and it would otherwise be silently ignored because the queue is full.Bumped the PortAudio dep while I was in there. I found these because I asked Claude Opus 5.5 to investigate queue / PortAudio use since I've occasionally in CIs seen failures related to a queue being full. Opus made some suggestions, I had it implement them, and I reviewed and vouch for them. They all seem like reasonable / useful hardenings to me.
(This repo has no agentic guidance and we probably don't need it yet, but happy to talk more about it if desired. In MNE-Python we've had some nice improvements in terms of efficiency and bugs by having experts use it IMO, so I'll use it a bit here, too, to make little fixes/improvements unless there are objections! I could for example have it add some minimal unit tests, which could help us find some bugs as well.)