When starting OMX processes with -o alsa parameter, after quitting a few videos, OMXPlayer freezes, and no other OMXPlayer process can start (even manually from the command line). Any OMXPlayer process currently running cannot be killed (even manually from htop). The only way to fix this by rebooting.
I found this issue when attempting to implement a video switching feature.
Problem reproduction
Start an OMX process as normal with the -o alsa parameter.
Call quit()
Do this a few more times, and eventually you will not be able to start any other process, or start OMXPlayer.
Fix
I believe the issue is due to the fact a SIGTERM sent to OMXPlayer does not call the internal OMXPlayer cleanup functions. When called with ALSA, this leaves some ALSA I/O things open (honestly don't know the details, this is an educated guess), and eventually causes OMXPlayer to completely lock up.
Issue Report
Description
When you quit an OMX process, the wrapper sends a SIGTERM signal: https://github.com/willprice/python-omxplayer-wrapper/blob/a9875e30ba0195df772259b909aaa9e80f2cab1a/omxplayer/player.py#L213-L219
When starting OMX processes with
-o alsa
parameter, after quitting a few videos, OMXPlayer freezes, and no other OMXPlayer process can start (even manually from the command line). Any OMXPlayer process currently running cannot be killed (even manually from htop). The only way to fix this by rebooting.I found this issue when attempting to implement a video switching feature.
Problem reproduction
-o alsa
parameter.quit()
Fix
I believe the issue is due to the fact a SIGTERM sent to OMXPlayer does not call the internal OMXPlayer cleanup functions. When called with ALSA, this leaves some ALSA I/O things open (honestly don't know the details, this is an educated guess), and eventually causes OMXPlayer to completely lock up.
Instead, call
_terminal_process
with SIGINT. This will call the internal cleanup functions, and allow the ALSA I/O to cleanup. When using SIGINT, I could no longer replicate the issue. Here is a link to a fork of my fix (the fork also includes other custom functions I added for my application): https://github.com/DazB/python-omxplayer-wrapper/blob/de0ca5eed87ca9094efa81d5b2099d5e9779be86/omxplayer/player.py#L215-L221BTW thanks for the great library. It's been really useful 👍
Environment details
lsb_release -a
):python-omxplayer-wrapper
0.1.0
python
(python --version
)3.7.3
omxplayer
(omxplayer --version
)2cfe612
(this is a custom build of OMXPlayer with slight modifications)