omnicronos
Posts: 1
Joined: Sat Jan 12, 2013 6:02 am

libcec locks up after using omxplayer?

Sat Jan 12, 2013 6:45 am

Hi all,
I'm having a problem with libcec and omxplayer and I'm hoping that someone can offer some insight.

I have been trying to put together a frontend to omxplayer that uses libcec for remote control.
When I first start up my application the remote works correctly. However, after I fork/exec omxplayer, libcec seems to stop receiving CEC events.

To try to rule out my application I did a test last night. I started the cec test client (that is part of the libcec source) so that it was dumping the CEC events to the console. In a separate console I started omxplayer. While omxplayer was running, I pressed buttons on the remote. Then quit omxplayer and looked at the cec log.

The log seems to show that libcec is receiving events right up until omxplayer starts. After omxplayer stops, libcec stops receiving events and won't unload.

Both omxplayer and libcec were built from source.

Has anyone seen anything similar?

slowdog
Posts: 2
Joined: Sat Feb 09, 2013 11:09 pm

Re: libcec locks up after using omxplayer?

Sat Feb 09, 2013 11:45 pm

I see this behaviour too, and stumbled on a workaround.

The symptoms are as you describe: The libcec program receives events before omxplayer starts, and even while omxplayer is running, but after omxplayer exits, no more events are seen.

I have no idea why that happens, but by accident I discovered this: Even after omxplayer exits, libcec continues to receive events as long as another process that has called bcm_host_init() (from /opt/vc/lib/libbcm_host.so) is running. That process doesn't have to do anything more than call bcm_host_init() and wait, but it must not be the parent process of omxplayer.

So in my (python) omxplayer frontend I do this:

Code: Select all

if os.fork() == 0:
    ctypes.CDLL('libbcm_host.so').bcm_host_init()
    while True:
        time.sleep(999)
at startup to create such a process, and now my remote control continues to work.

With this hack in place, omxplayer prints the message "tvservice-client: Failed to connect to TV service: -1" every time it starts, but seems to work fine.

If anyone has a scientific explanation for this behaviour, I'd love to hear it :)

My libcec is from a version "2.0.2-1" binary package from Michael Gorven's repository. My omxplayer is from raspbian package omxplayer_0.2.1~git20120916~2612f1d7 (not the latest version, since that fails to work at all for me, as described by others here.

Return to “General programming discussion”