From 7c40bbf4f1abc16543192e415b41cb6c149a055e Mon Sep 17 00:00:00 2001 From: TangoCash Date: Tue, 9 Oct 2018 23:10:21 +0200 Subject: [PATCH] libarmbox: hdmi_cec fix device Signed-off-by: Thilo Graf --- libarmbox/hdmi_cec.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/libarmbox/hdmi_cec.cpp b/libarmbox/hdmi_cec.cpp index a30e115..5d45bc9 100644 --- a/libarmbox/hdmi_cec.cpp +++ b/libarmbox/hdmi_cec.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -110,7 +111,7 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType) if (hdmiFd == -1) { - hdmiFd = open(CEC_DEVICE, O_RDWR | O_NONBLOCK); + hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); } if (hdmiFd >= 0) @@ -462,6 +463,8 @@ bool hdmi_cec::Stop() return false; running = false; + + OpenThreads::Thread::cancel(); if (hdmiFd >= 0) { @@ -474,9 +477,16 @@ bool hdmi_cec::Stop() void hdmi_cec::run() { - while (running && (hdmiFd >= 0)) + OpenThreads::Thread::setCancelModeAsynchronous(); + struct pollfd pfd; + + pfd.fd = hdmiFd; + pfd.events = (POLLIN | POLLPRI); + + while (running) { - Receive(); + if (poll(&pfd, 1, 0) > 0) + Receive(); } }