Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quit function on files with ALSA option locks up OMXPlayer #206

Open
DazB opened this issue Sep 7, 2020 · 0 comments
Open

Quit function on files with ALSA option locks up OMXPlayer #206

DazB opened this issue Sep 7, 2020 · 0 comments

Comments

@DazB
Copy link

DazB commented Sep 7, 2020

Issue Report

Description

When you quit an OMX process, the wrapper sends a SIGTERM signal:

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 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.

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant