-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Issue Report
Description
When you quit an OMX process, the wrapper sends a SIGTERM signal:
python-omxplayer-wrapper/omxplayer/player.py
Lines 213 to 219 in a9875e3
| def _terminate_process(self, process): | |
| try: | |
| process_group_id = os.getpgid(process.pid) | |
| os.killpg(process_group_id, signal.SIGTERM) | |
| logger.debug('SIGTERM Sent to pid: %s' % process_group_id) | |
| except OSError: | |
| logger.error('Could not find the process to kill') |
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 alsaparameter. - 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.
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-L221
BTW thanks for the great library. It's been really useful 👍
Environment details
- OS (
lsb_release -a):
Distributor ID: Raspbian
Description: Raspbian GNU/Linux 10 (buster)
Release: 10
Codename: buster
| Software | Version |
|---|---|
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) |