cec: check if the processor thread is marked as initialised, not if the thread is...
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 7c2e08a0ac537ef7c3dca64513058c15c5698f47..e90d5cb59038a62f8917bbb8cab61f52e24bc43e 100644 (file)
@@ -86,9 +86,6 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = CEC_SERIA
     }
   }
 
-  // mark as initialised
-  SetCECInitialised(true);
-
   return true;
 }
 
@@ -156,6 +153,9 @@ bool CCECProcessor::OpenConnection(const char *strPort, uint16_t iBaudRate, uint
 
   m_libcec->AddLog(CEC_LOG_NOTICE, "connection opened");
 
+  // mark as initialised
+  SetCECInitialised(true);
+
   return bReturn;
 }
 
@@ -615,8 +615,11 @@ CCECTuner *CCECProcessor::GetTuner(cec_logical_address address) const
 
 bool CCECProcessor::RegisterClient(CCECClient *client)
 {
-  if (!client || !IsRunning())
+  if (!client || !CECInitialised())
+  {
+    m_libcec->AddLog(CEC_LOG_ERROR, "failed to register a new CEC client: CEC processor is not initialised");
     return false;
+  }
 
   // unregister the client first if it's already been marked as registered
   if (client->IsRegistered())