libarmbox: hdmi_cec fix device

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
TangoCash
2018-10-09 23:10:21 +02:00
committed by Thilo Graf
parent 08984d1c35
commit 7c40bbf4f1

View File

@@ -20,6 +20,7 @@
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/poll.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
@@ -110,7 +111,7 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
if (hdmiFd == -1) if (hdmiFd == -1)
{ {
hdmiFd = open(CEC_DEVICE, O_RDWR | O_NONBLOCK); hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC);
} }
if (hdmiFd >= 0) if (hdmiFd >= 0)
@@ -462,6 +463,8 @@ bool hdmi_cec::Stop()
return false; return false;
running = false; running = false;
OpenThreads::Thread::cancel();
if (hdmiFd >= 0) if (hdmiFd >= 0)
{ {
@@ -474,9 +477,16 @@ bool hdmi_cec::Stop()
void hdmi_cec::run() 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();
} }
} }