cec: moved SetVendorId(const cec_datapacket &packet) to CCECCommandHandler
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 10 Nov 2011 17:30:00 +0000 (18:30 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 10 Nov 2011 18:00:15 +0000 (19:00 +0100)
src/lib/devices/CECBusDevice.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h

index 64b084a7da24be73b037505c04d93d2ef288e4db..a7ec1ec98e5e596d84132999c71dcc26289975e2 100644 (file)
@@ -291,21 +291,6 @@ void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
   }
 }
 
-void CCECBusDevice::SetVendorId(const cec_datapacket &data)
-{
-  if (data.size < 3)
-  {
-    AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
-    return;
-  }
-
-  uint64_t iVendorId = ((uint64_t)data[0] << 3) +
-                       ((uint64_t)data[1] << 2) +
-                        (uint64_t)data[2];
-
-  SetVendorId(iVendorId, data.size >= 4 ? data[3] : 0);
-}
-
 void CCECBusDevice::SetVendorId(uint64_t iVendorId, uint8_t iVendorClass /* = 0 */)
 {
   m_vendor.vendor = (cec_vendor_id)iVendorId;
index 33644d8709d3972bb0ed6082f04ede397428ac0e..122c4be1c51e2eaedbc681b9c5b2a163992e67c2 100644 (file)
@@ -167,19 +167,13 @@ bool CCECCommandHandler::HandleDeviceCecVersion(const cec_command &command)
 
 bool CCECCommandHandler::HandleDeviceVendorCommandWithId(const cec_command &command)
 {
-  CCECBusDevice *device = GetDevice(command.initiator);
-  if (device)
-    device->SetVendorId(command.parameters);
-
+  SetVendorId(command);
   return true;
 }
 
 bool CCECCommandHandler::HandleDeviceVendorId(const cec_command &command)
 {
-  CCECBusDevice *device = GetDevice(command.initiator);
-  if (device)
-    device->SetVendorId(command.parameters);
-
+  SetVendorId(command);
   return true;
 }
 
@@ -402,3 +396,21 @@ CCECBusDevice *CCECCommandHandler::GetDeviceByPhysicalAddress(uint16_t iPhysical
 
   return device;
 }
+
+
+void CCECCommandHandler::SetVendorId(const cec_command &command)
+{
+  if (command.parameters.size < 3)
+  {
+    m_busDevice->AddLog(CEC_LOG_WARNING, "invalid vendor ID received");
+    return;
+  }
+
+  uint64_t iVendorId = ((uint64_t)command.parameters[0] << 3) +
+                       ((uint64_t)command.parameters[1] << 2) +
+                        (uint64_t)command.parameters[2];
+
+  CCECBusDevice *device = GetDevice((cec_logical_address) command.initiator);
+  if (device)
+    device->SetVendorId(iVendorId, iVendorId);
+}
index b5c168b115e75f9915583d7f580161b6afb24430..9ef20aee0bfd58e62ae6108ea2c6c9553f3c2dd7 100644 (file)
@@ -71,6 +71,8 @@ namespace CEC
 
     virtual CCECBusDevice *GetDevice(cec_logical_address iLogicalAddress) const;
     virtual CCECBusDevice *GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress) const;
+
+    virtual void SetVendorId(const cec_command &command);
     CCECBusDevice *m_busDevice;
   };
 };