cec: fixed - commands that were forwarded to clients used the source address of the...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 25 Jun 2012 09:50:42 +0000 (11:50 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 25 Jun 2012 14:58:25 +0000 (16:58 +0200)
src/lib/CECClient.cpp
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/implementations/CECCommandHandler.cpp

index accd5659fe9427d1cb9612da836208dcf8fada14..35dd415139169200414e7ffc19c0d79c56d4093e 100644 (file)
@@ -882,14 +882,17 @@ bool CCECClient::SetConfiguration(const libcec_configuration &configuration)
 
 void CCECClient::AddCommand(const cec_command &command)
 {
-  CLockObject lock(m_mutex);
+  if (command.destination == CECDEVICE_BROADCAST || GetLogicalAddresses().IsSet(command.destination))
+  {
+    CLockObject lock(m_mutex);
 
-  LIB_CEC->AddLog(CEC_LOG_NOTICE, ">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
+    LIB_CEC->AddLog(CEC_LOG_NOTICE, ">> %s (%X) -> %s (%X): %s (%2X)", ToString(command.initiator), command.initiator, ToString(command.destination), command.destination, ToString(command.opcode), command.opcode);
 
-  if (m_configuration.callbacks && m_configuration.callbacks->CBCecCommand)
-    m_configuration.callbacks->CBCecCommand(m_configuration.callbackParam, command);
-  else if (!m_commandBuffer.Push(command))
-    LIB_CEC->AddLog(CEC_LOG_WARNING, "command buffer is full");
+    if (m_configuration.callbacks && m_configuration.callbacks->CBCecCommand)
+      m_configuration.callbacks->CBCecCommand(m_configuration.callbackParam, command);
+    else if (!m_commandBuffer.Push(command))
+      LIB_CEC->AddLog(CEC_LOG_WARNING, "command buffer is full");
+  }
 }
 
 int CCECClient::MenuStateChanged(const cec_menu_state newState)
index 8838ff4157b48591a864082c436df100e9961e96..d41df7167f898bd51632b97b46314468d9da8ae0 100644 (file)
@@ -475,6 +475,13 @@ void CLibCEC::AddLog(const cec_log_level level, const char *strFormat, ...)
     (*it)->AddLog(message);
 }
 
+void CLibCEC::AddCommand(const cec_command &command)
+{
+  // send the command to all clients
+  for (vector<CCECClient *>::iterator it = m_clients.begin(); it != m_clients.end(); it++)
+    (*it)->AddCommand(command);
+}
+
 void CLibCEC::Alert(const libcec_alert type, const libcec_parameter &param)
 {
   // send the alert to all clients
@@ -599,7 +606,6 @@ bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *co
 
 // no longer being used
 void CLibCEC::AddKey(const cec_keypress &UNUSED(key)) {}
-void CLibCEC::AddCommand(const cec_command &UNUSED(command)) {}
 void CLibCEC::ConfigurationChanged(const libcec_configuration &UNUSED(config)) {}
 void CLibCEC::SetCurrentButton(cec_user_control_code UNUSED(iButtonCode)) {}
 CLibCEC *CLibCEC::GetInstance(void) { return NULL; }
index 0ef3e832d3d318218eda23c4beeccceefd40947e..6407e57a8fe479c28ba8151a11c6c29c4d7debbd 100644 (file)
@@ -134,7 +134,7 @@ namespace CEC
       void AddLog(const cec_log_level level, const char *strFormat, ...);
       static void AddKey(void) {}                                           //UNUSED
       static void AddKey(const cec_keypress &key);                          //UNUSED
-      static void AddCommand(const cec_command &command);                   //UNUSED
+      void AddCommand(const cec_command &command);
       static void ConfigurationChanged(const libcec_configuration &config); //UNUSED
       static void SetCurrentButton(cec_user_control_code iButtonCode);      //UNUSED
       void CheckKeypressTimeout(void);
index e06eb2bc8f14aacba99ec482d0895c598605ef5d..03165e9c2cf91ec613a4def5b4cd901f2dbcff5e 100644 (file)
@@ -73,9 +73,7 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command)
 
   int iHandled(CEC_ABORT_REASON_UNRECOGNIZED_OPCODE);
 
-  CCECClient *client = m_busDevice->GetClient();
-  if (client)
-    client->AddCommand(command);
+  LIB_CEC->AddCommand(command);
 
   switch(command.opcode)
   {