cec: don't allow client registrations when the processor thread isn't running
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 14 May 2012 08:47:10 +0000 (10:47 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 14 May 2012 08:47:10 +0000 (10:47 +0200)
src/lib/CECProcessor.cpp

index 0714d2a659b7f31c025d3ff15e6730465fdb10fb..d9981b9368d37e8d53c86510bca6fb5a1337eaf4 100644 (file)
@@ -81,9 +81,7 @@ bool CCECProcessor::Start(const char *strPort, uint16_t iBaudRate /* = CEC_SERIA
   // create the processor thread
   if (!IsRunning())
   {
-    if (CreateThread())
-      m_libcec->AddLog(CEC_LOG_DEBUG, "processor thread started");
-    else
+    if (!CreateThread())
     {
       m_libcec->AddLog(CEC_LOG_ERROR, "could not create a processor thread");
       return false;
@@ -645,7 +643,7 @@ CCECTuner *CCECProcessor::GetTuner(cec_logical_address address) const
 
 bool CCECProcessor::RegisterClient(CCECClient *client)
 {
-  if (!client)
+  if (!client || !IsRunning())
     return false;
 
   // unregister the client first if it's already been marked as registered
@@ -732,7 +730,8 @@ void CCECProcessor::UnregisterClient(CCECClient *client)
   if (!client)
     return;
 
-  m_libcec->AddLog(CEC_LOG_NOTICE, "unregistering client: %s", client->GetConnectionInfo().c_str());
+  if (client->IsRegistered())
+    m_libcec->AddLog(CEC_LOG_NOTICE, "unregistering client: %s", client->GetConnectionInfo().c_str());
 
   // notify the client that it will be unregistered
   client->OnUnregister();