cec: give priority to messages from the TV. removed the global lock in CCECProcessor...
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 4685132619bba76bc243da41281dd9ab1c88b4fb..96b5c7349db3a7253250d172f0fc87970ed638c0 100644 (file)
@@ -132,7 +132,10 @@ CCECProcessor::~CCECProcessor(void)
   Close();
 
   for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+  {
     delete m_busDevices[iPtr];
+    m_busDevices[iPtr] = NULL;
+  }
 }
 
 void CCECProcessor::Close(void)
@@ -453,23 +456,27 @@ void CCECProcessor::ReplaceHandlers(void)
 
 bool CCECProcessor::OnCommandReceived(const cec_command &command)
 {
-  ParseCommand(command);
-  return true;
+  return m_inBuffer.Push(command);
 }
 
 void *CCECProcessor::Process(void)
 {
   CLibCEC::AddLog(CEC_LOG_DEBUG, "processor thread started");
 
+  cec_command command;
+  command.Clear();
+
   while (!IsStopped() && m_communication->IsOpen())
   {
+    if (m_inBuffer.Pop(command, 500))
+      ParseCommand(command);
+
     if (IsInitialised())
     {
       ReplaceHandlers();
 
       m_controller->CheckKeypressTimeout();
     }
-    Sleep(5);
   }
 
   return NULL;
@@ -1599,6 +1606,7 @@ bool CCECProcessor::SetConfiguration(const libcec_configuration *configuration)
 
   // just copy these
   m_configuration.clientVersion        = configuration->clientVersion;
+  m_configuration.bUseTVMenuLanguage   = configuration->bUseTVMenuLanguage;
   m_configuration.bActivateSource      = configuration->bActivateSource;
   m_configuration.bGetSettingsFromROM  = configuration->bGetSettingsFromROM;
   m_configuration.powerOffDevices      = configuration->powerOffDevices;
@@ -1692,5 +1700,6 @@ bool CCECProcessor::GetDeviceInformation(const char *strPort, libcec_configurati
   config->iPhysicalAddress = m_communication->GetPhysicalAddress();
 
   delete m_communication;
+  m_communication = NULL;
   return true;
 }