Open kyp44 opened 2 years ago
Was just able to reproduce this on a different machine, though this is also running Ubuntu 20.04.3 LTS with Python 3.8.10.
I'm not sure if this is related, but it have the same smell...
I have a simple application that, from time to time, plays a short WAV file. When I play with with block=False
, I can play it exactly four times (consistently four) and then it stops working. With 'stops working' I mean that the Python app works just fine, no complaints there, but that there is no sound audible through the speakers. Also, other software supposedly playing sounds stop producing any.
What I see, is that every time playsound
is being triggered, another line is permanently added to the the listing produced by lsof /dev/snd/pcmC0D0p
.
When I set block=True
, however, this problem is solved (but it of course creates other problems for my use case :-)). Then, lsof
only lists my app while the sound is being played.
I looks like the application launched by playsound
in non-blocking mode never releases its grip on the sound device.
Does anyone here perhaps have a clue how to avoid this problem?
Platform: Raspberry Pi, Linux kernel 5.10.103-v7l+, Python 3.7.3, playsound 1.3.0
I am experiencing issues when playing a lot of short sound clips very often asynchronously, which don't happen if I play them with blocking instead.
I rigged up a little test program (
demo.py
in demo.zip) that demonstrates the problem. On my system, the sounds stop playing after about 34 seconds. The program runs in silence for about another 1:20 and thenplaysound
throws aPlaysoundException
, which is shown in the attachedoutput.txt
. This behavior is very consistent currently on repeated runs. Also included isdemo-block.py
, which is identical but blocks instead when callingplaysound
. This seems to run indefinitely with sounds always playing. If I run both at the same time, I hear audio from both untildemo.py
stops playing audio, at which point the blocking version completely blocks (seemingly at a lower level than Python as I can't SIGINT out of it with Ctrl+C) until eitherdemo.py
is broken or terminates because of the exception, at which pointdemo-block.py
continues running normally and playing sounds.This may very be an issue with
pulseaudio
and/orgstreamer
(which I understand is used byplaysound
) rather thanplaysound
, but it's almost like playing too many sounds asynchronously screws something up somewhere as though something is not being cleaned up properly after each asynchronous clip is done playing, and some limit is reached. In any case let me know whether my test program does or does not reproduce this problem or anything similar for anyone else.Lastly, I did check that all the tests pass just fine with the latest
playsound
cloned from here.If it matters, I am on Ubuntu 20.04.3 LTS and using Python 3.8.10. Please let me know if there's any other info I can gather or other scenarios to try.