From: Lars Op den Kamp Date: Sat, 8 Oct 2011 01:17:16 +0000 (+0200) Subject: cec: shorter lock times. copy currentframe while locked before processing it X-Git-Tag: upstream/2.2.0~1^2~277 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=76321de48985ea8a09dfce9650be843fafbba541;p=deb_libcec.git cec: shorter lock times. copy currentframe while locked before processing it --- diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 627ce27..68f31a4 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -132,7 +132,7 @@ void *CAdapterCommunication::Process(void) { CLockObject lock(&m_mutex, true); if (lock.IsLocked()) - bSignal = ReadFromDevice(100); + bSignal = ReadFromDevice(50); } if (bSignal) diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 29daf53..4f2caa7 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -85,17 +85,23 @@ void *CCECProcessor::Process(void) while (!IsStopped()) { bool bParseFrame(false); + cec_frame msg; + msg.clear(); + { CLockObject lock(&m_mutex); - cec_frame msg; - msg.clear(); - - if (m_communication->IsOpen() && m_communication->Read(msg, CEC_BUTTON_TIMEOUT)) + if (m_communication->IsOpen() && m_communication->Read(msg, 50)) bParseFrame = ParseMessage(msg) && !IsStopped(); + + if (bParseFrame) + { + msg.clear(); + msg = m_currentframe; + } } if (bParseFrame) - ParseCurrentFrame(); + ParseCurrentFrame(msg); m_controller->CheckKeypressTimeout(); @@ -489,11 +495,8 @@ bool CCECProcessor::ParseMessage(cec_frame &msg) return bReturn; } -void CCECProcessor::ParseCurrentFrame(void) +void CCECProcessor::ParseCurrentFrame(cec_frame &frame) { - cec_frame frame = m_currentframe; - m_currentframe.clear(); - uint8_t initiator = frame.data[0] >> 4; uint8_t destination = frame.data[0] & 0xF; diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 5c8d8ab..660fee0 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -74,7 +74,7 @@ namespace CEC private: bool WaitForAck(uint32_t iTimeout = 1000); bool ParseMessage(cec_frame &msg); - void ParseCurrentFrame(void); + void ParseCurrentFrame(cec_frame &frame); cec_frame m_currentframe; uint16_t m_physicaladdress;