cec: added bWait parameter to volume change methods.
[deb_libcec.git] / src / lib / implementations / CECCommandHandler.cpp
index 0a39333e54c52f8a410f066481fe56062c78b0e1..9debd5d9423cd3ad0fd47fc35400674c997b2278 100644 (file)
@@ -150,9 +150,7 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command)
     break;
   }
 
-  if (command.destination == CECDEVICE_BROADCAST || m_busDevice->MyLogicalAddressContains(command.destination))
-    m_busDevice->GetProcessor()->AddCommand(command);
-
+  m_busDevice->GetProcessor()->AddCommand(command);
   return bHandled;
 }
 
@@ -341,11 +339,7 @@ bool CCECCommandHandler::HandleReportPhysicalAddress(const cec_command &command)
   if (command.parameters.size == 3)
   {
     uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
-    cec_device_type type = (cec_device_type)command.parameters[2];
-
-    CCECBusDevice *device = GetDevice(command.initiator);
-    if (device && device->GetType() == type)
-      device->SetPhysicalAddress(iNewAddress);
+    SetPhysicalAddress(command.initiator, iNewAddress);
   }
   return true;
 }
@@ -393,13 +387,7 @@ bool CCECCommandHandler::HandleRoutingInformation(const cec_command &command)
   if (command.parameters.size == 2)
   {
     uint16_t iNewAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
-
-    CCECBusDevice *device = GetDevice(command.initiator);
-    if (device)
-    {
-      device->SetStreamPath(iNewAddress);
-      return true;
-    }
+    m_busDevice->GetProcessor()->SetStreamPath(iNewAddress);
   }
 
   return false;
@@ -601,6 +589,22 @@ void CCECCommandHandler::SetVendorId(const cec_command &command)
     device->SetVendorId(iVendorId);
 }
 
+void CCECCommandHandler::SetPhysicalAddress(cec_logical_address iAddress, uint16_t iNewAddress)
+{
+  if (!m_busDevice->MyLogicalAddressContains(iAddress))
+  {
+    bool bOurAddress(m_busDevice->GetProcessor()->GetPhysicalAddress() == iNewAddress);
+    GetDevice(iAddress)->SetPhysicalAddress(iNewAddress);
+    if (bOurAddress)
+    {
+      /* another device reported the same physical address as ours
+       * since we don't have physical address detection yet, we'll just use the
+       * given address, increased by 0x100 for now */
+      m_busDevice->GetProcessor()->SetPhysicalAddress(iNewAddress + 0x100);
+    }
+  }
+}
+
 const char *CCECCommandHandler::ToString(const cec_menu_state state)
 {
   switch (state)