From: Lars Op den Kamp Date: Sun, 30 Oct 2011 10:22:11 +0000 (+0100) Subject: cec: set the correct ackmask on startup X-Git-Tag: upstream/2.2.0~1^2~175 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=b9eea66dd7e19a4baf9e89f4fd6b3c2f281ba7a7;p=deb_libcec.git cec: set the correct ackmask on startup --- diff --git a/src/lib/AdapterCommunication.cpp b/src/lib/AdapterCommunication.cpp index 3b0ca01..d3eecf4 100644 --- a/src/lib/AdapterCommunication.cpp +++ b/src/lib/AdapterCommunication.cpp @@ -147,7 +147,8 @@ bool CAdapterCommunication::Open(const char *strPort, uint16_t iBaudRate /* = 38 if (CreateThread()) { - m_controller->AddLog(CEC_LOG_DEBUG, "communication thread created"); + m_startCondition.Wait(&m_mutex); + m_controller->AddLog(CEC_LOG_DEBUG, "communication thread started"); return true; } else @@ -161,14 +162,17 @@ bool CAdapterCommunication::Open(const char *strPort, uint16_t iBaudRate /* = 38 void CAdapterCommunication::Close(void) { CLockObject lock(&m_mutex); - StopThread(); - + m_startCondition.Broadcast(); m_rcvCondition.Broadcast(); + StopThread(); } void *CAdapterCommunication::Process(void) { - m_controller->AddLog(CEC_LOG_DEBUG, "communication thread started"); + { + CLockObject lock(&m_mutex); + m_startCondition.Signal(); + } while (!IsStopped()) { @@ -372,5 +376,5 @@ bool CAdapterCommunication::PingAdapter(void) bool CAdapterCommunication::IsOpen(void) const { - return !IsStopped() && m_port->IsOpen(); + return !IsStopped() && m_port->IsOpen() && IsRunning(); } diff --git a/src/lib/AdapterCommunication.h b/src/lib/AdapterCommunication.h index 9a3d126..2ec6e3b 100644 --- a/src/lib/AdapterCommunication.h +++ b/src/lib/AdapterCommunication.h @@ -113,5 +113,6 @@ namespace CEC CecBuffer m_outBuffer; CMutex m_mutex; CCondition m_rcvCondition; + CCondition m_startCondition; }; }; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index f763451..d5ee321 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -42,7 +42,7 @@ using namespace CEC; using namespace std; CCECProcessor::CCECProcessor(CLibCEC *controller, CAdapterCommunication *serComm, const char *strDeviceName, cec_logical_address iLogicalAddress /* = CECDEVICE_PLAYBACKDEVICE1 */, uint16_t iPhysicalAddress /* = CEC_DEFAULT_PHYSICAL_ADDRESS*/) : - m_iLogicalAddress(iLogicalAddress), + m_iLogicalAddress(CECDEVICE_UNKNOWN), m_strDeviceName(strDeviceName), m_communication(serComm), m_controller(controller), @@ -91,6 +91,8 @@ void *CCECProcessor::Process(void) CCECAdapterMessage msg; CCECAdapterMessagePtr msgPtr; + m_communication->SetAckMask(0x1 << (uint8_t)m_iLogicalAddress); + while (!IsStopped()) { bool bParseFrame(false);