libarmbox: fix hdmi_cec handling

Origin commit data
------------------
Branch: master
Commit: be90147047
Author: TangoCash <eric@loxat.de>
Date: 2018-10-07 (Sun, 07 Oct 2018)


------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
This commit is contained in:
TangoCash
2018-10-07 18:43:31 +02:00
committed by max_10
parent 85de1049ca
commit 3ce9018d4a

View File

@@ -60,9 +60,6 @@ hdmi_cec::hdmi_cec()
{ {
standby_cec_activ = autoview_cec_activ = false; standby_cec_activ = autoview_cec_activ = false;
hdmiFd = -1; hdmiFd = -1;
if (hdmiFd == -1)
hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC);
Start();
} }
hdmi_cec::~hdmi_cec() hdmi_cec::~hdmi_cec()
@@ -89,21 +86,18 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF) if (_deviceType == VIDEO_HDMI_CEC_MODE_OFF)
{ {
if (hdmiFd >= 0) Stop();
{ lt_debug("CEC OFF %s\n", __func__);
close(hdmiFd);
hdmiFd = -1;
Stop();
}
return false; return false;
} }
else else
deviceType = _deviceType; deviceType = _deviceType;
lt_debug("CEC ON %s\n", __func__);
if (hdmiFd == -1) if (hdmiFd == -1)
{ {
hdmiFd = open(CEC_DEVICE, O_RDWR | O_CLOEXEC); hdmiFd = open(CEC_DEVICE, O_RDWR | O_NONBLOCK);
Start();
} }
if (hdmiFd >= 0) if (hdmiFd >= 0)
@@ -180,6 +174,7 @@ bool hdmi_cec::SetCECMode(VIDEO_HDMI_CEC_MODE _deviceType)
if(autoview_cec_activ) if(autoview_cec_activ)
SetCECState(false); SetCECState(false);
Start();
return true; return true;
} }
@@ -441,12 +436,18 @@ bool hdmi_cec::Stop()
running = false; running = false;
if (hdmiFd >= 0)
{
close(hdmiFd);
hdmiFd = -1;
}
return (OpenThreads::Thread::join() == 0); return (OpenThreads::Thread::join() == 0);
} }
void hdmi_cec::run() void hdmi_cec::run()
{ {
while (running) while (running && (hdmiFd >= 0))
{ {
Receive(); Receive();
} }