From: Lars Op den Kamp Date: Thu, 8 Mar 2012 14:19:44 +0000 (+0100) Subject: cec: ping the adapter every 15 seconds. bugzid: 541 X-Git-Tag: upstream/2.2.0~1^2~31^2~97 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=ae54110f1dfbf0a0772ab6e849c80025381454cb;p=deb_libcec.git cec: ping the adapter every 15 seconds. bugzid: 541 --- diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index f56bdf4..85c92f3 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -40,6 +40,8 @@ using namespace std; using namespace CEC; using namespace PLATFORM; +#define CEC_ADAPTER_PING_TIMEOUT 15000 + void *CUSBCECAdapterProcessor::Process(void) { cec_command command; @@ -221,6 +223,7 @@ void *CUSBCECAdapterCommunication::Process(void) cec_command command; command.Clear(); bool bCommandReceived(false); + CTimeout pingTimeout(CEC_ADAPTER_PING_TIMEOUT); while (!IsStopped()) { { @@ -233,6 +236,13 @@ void *CUSBCECAdapterCommunication::Process(void) if (!IsStopped() && bCommandReceived) m_messageProcessor->AddCommand(command); + /* ping the adapter every 15 seconds */ + if (pingTimeout.TimeLeft() == 0) + { + pingTimeout.Init(CEC_ADAPTER_PING_TIMEOUT); + PingAdapter(); + } + if (!IsStopped()) { Sleep(5);