From: Lars Op den Kamp Date: Thu, 10 Nov 2011 17:30:00 +0000 (+0100) Subject: cec: moved SetVendorId(const cec_datapacket &packet) to CCECCommandHandler X-Git-Tag: upstream/2.2.0~1^2~90 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=181b347542a6ed9dc1f9ea7bca2051c72b49a9df;p=deb_libcec.git cec: moved SetVendorId(const cec_datapacket &packet) to CCECCommandHandler --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 64b084a..a7ec1ec 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -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; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 33644d8..122c4be 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -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); +} diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index b5c168b..9ef20ae 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -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; }; };