From: Lars Op den Kamp Date: Fri, 28 Oct 2011 07:53:46 +0000 (+0200) Subject: cec: set the physical address in CCECBusDevice X-Git-Tag: upstream/2.2.0~1^2~199 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=4e4be5cfa5a9589546e58b743d05ce31d94c7f7e;p=deb_libcec.git cec: set the physical address in CCECBusDevice --- diff --git a/src/lib/CECBusDevice.cpp b/src/lib/CECBusDevice.cpp index 45f30a5..19f4e66 100644 --- a/src/lib/CECBusDevice.cpp +++ b/src/lib/CECBusDevice.cpp @@ -127,6 +127,15 @@ void CCECBusDevice::PollVendorId(void) } } +void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress, uint16_t iOldAddress /* = 0 */) +{ + CStdString strLog; + strLog.Format(">> %i changed physical address from %04x to %04x", GetLogicalAddress(), m_iPhysicalAddress, iNewAddress); + AddLog(CEC_LOG_DEBUG, strLog.c_str()); + + m_iPhysicalAddress = iNewAddress; +} + const char *CCECBusDevice::CECVendorIdToString(const uint64_t iVendorId) { switch (iVendorId) diff --git a/src/lib/CECBusDevice.h b/src/lib/CECBusDevice.h index 9cc7fdc..7f96e6f 100644 --- a/src/lib/CECBusDevice.h +++ b/src/lib/CECBusDevice.h @@ -48,6 +48,7 @@ namespace CEC virtual cec_logical_address GetLogicalAddress(void) const { return m_iLogicalAddress; } virtual uint16_t GetPhysicalAddress(void) const { return m_iPhysicalAddress; } + virtual void SetPhysicalAddress(uint16_t iNewAddress, uint16_t iOldAddress = 0); virtual cec_logical_address GetMyLogicalAddress(void) const; virtual uint16_t GetMyPhysicalAddress(void) const; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 9514347..9e3867e 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -196,11 +196,8 @@ bool CCECCommandHandler::HandleRoutingChange(const cec_command &command) { uint16_t iOldAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]); uint16_t iNewAddress = ((uint16_t)command.parameters[2] << 8) | ((uint16_t)command.parameters[3]); - CStdString strLog; - strLog.Format(">> %i changed physical address from %04x to %04x", command.initiator, iOldAddress, iNewAddress); - m_busDevice->AddLog(CEC_LOG_DEBUG, strLog.c_str()); - m_busDevice->GetProcessor()->AddCommand(command); + m_busDevice->SetPhysicalAddress(iNewAddress, iOldAddress); } return true; }