cec: set the correct ackmask on startup
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 30 Oct 2011 10:22:11 +0000 (11:22 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 30 Oct 2011 10:22:11 +0000 (11:22 +0100)
src/lib/AdapterCommunication.cpp
src/lib/AdapterCommunication.h
src/lib/CECProcessor.cpp

index 3b0ca015454a1250a40da236358bf2f3e0206161..d3eecf45ea7f1045ef466ba38e1291f71f0186ca 100644 (file)
@@ -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();
 }
index 9a3d1268cf008c0686ee86151632e5e90b6e52ac..2ec6e3b60c3481597f22b6f4894dc6ec6f16bbca 100644 (file)
@@ -113,5 +113,6 @@ namespace CEC
     CecBuffer<CCECAdapterMessagePtr> m_outBuffer;
     CMutex                           m_mutex;
     CCondition                       m_rcvCondition;
+    CCondition                       m_startCondition;
   };
 };
index f7634512e3b6d10636023bb68019f956aba4b033..d5ee321ce90954fa485cd33a978dd610c55f003a 100644 (file)
@@ -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);