cec: don't try to do anything before the processor thread has started
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 21 Dec 2011 23:25:33 +0000 (00:25 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 21 Dec 2011 23:56:34 +0000 (00:56 +0100)
src/lib/CECProcessor.cpp

index 0aa876010df847c9848dc4e0b766d80353f74c0b..cc5cd40573215beb827bf3979b42a4206444de0b 100644 (file)
@@ -149,9 +149,23 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = 38400 */,
       m_controller->AddLog(CEC_LOG_ERROR, "could not create a processor thread");
       return false;
     }
-
     lock.Leave();
 
+    if (m_logicalAddresses.IsEmpty() && !FindLogicalAddresses())
+    {
+      m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses");
+      StopThread(true);
+      return false;
+    }
+    else
+    {
+      /* only set our OSD name and active source for the primary device */
+      m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName;
+      m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true;
+
+      SetAckMask(m_logicalAddresses.AckMask());
+    }
+
     m_busDevices[CECDEVICE_TV]->GetVendorId();
 
     if (SetHDMIPort(m_iBaseDevice, m_iHDMIPort, true))
@@ -248,21 +262,7 @@ void *CCECProcessor::Process(void)
   cec_command           command;
   CCECAdapterMessage    msg;
 
-  if (m_logicalAddresses.IsEmpty() && !FindLogicalAddresses())
-  {
-    CLockObject lock(&m_mutex);
-    m_controller->AddLog(CEC_LOG_ERROR, "could not detect our logical addresses");
-    m_startCondition.Signal();
-    return NULL;
-  }
-  else
   {
-    /* only set our OSD name and active source for the primary device */
-    m_busDevices[m_logicalAddresses.primary]->m_strDeviceName = m_strDeviceName;
-    m_busDevices[m_logicalAddresses.primary]->m_bActiveSource = true;
-
-    SetAckMask(m_logicalAddresses.AckMask());
-
     CLockObject lock(&m_mutex);
     m_bStarted = true;
     m_controller->AddLog(CEC_LOG_DEBUG, "processor thread started");