From: Lars Op den Kamp Date: Thu, 10 Nov 2011 20:35:21 +0000 (+0100) Subject: cec: added ToString(cec_version) X-Git-Tag: upstream/2.2.0~1^2~61 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c686413b0994df7037af7f08751a58f2d84045d4;p=deb_libcec.git cec: added ToString(cec_version) --- diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index d83ccb2..dc6d4f8 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -247,28 +247,10 @@ bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const //@{ void CCECBusDevice::SetCecVersion(const cec_version newVersion) { - CStdString strLog; m_cecVersion = newVersion; - switch (newVersion) - { - case CEC_VERSION_1_2: - strLog.Format("%s (%X): CEC version 1.2", GetLogicalAddressName(), m_iLogicalAddress); - break; - case CEC_VERSION_1_2A: - strLog.Format("%s (%X): CEC version 1.2a", GetLogicalAddressName(), m_iLogicalAddress); - break; - case CEC_VERSION_1_3: - strLog.Format("%s (%X): CEC version 1.3", GetLogicalAddressName(), m_iLogicalAddress); - break; - case CEC_VERSION_1_3A: - strLog.Format("%s (%X): CEC version 1.3a", GetLogicalAddressName(), m_iLogicalAddress); - break; - default: - strLog.Format("%s (%X): unknown CEC version", GetLogicalAddressName(), m_iLogicalAddress); - m_cecVersion = CEC_VERSION_UNKNOWN; - break; - } + CStdString strLog; + strLog.Format("%s (%X): CEC version %s", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(newVersion)); AddLog(CEC_LOG_DEBUG, strLog); } @@ -400,25 +382,7 @@ bool CCECBusDevice::TransmitActiveSource(void) bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) { CStdString strLog; - strLog.Format("<< %s (%X) -> %s (%X): cec version ", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest); - switch (m_cecVersion) - { - case CEC_VERSION_1_2: - strLog.append("1.2"); - break; - case CEC_VERSION_1_2A: - strLog.append("1.2a"); - break; - case CEC_VERSION_1_3: - strLog.append("1.3"); - break; - case CEC_VERSION_1_3A: - strLog.append("1.3a"); - break; - default: - strLog.append("unknown"); - break; - } + strLog.Format("<< %s (%X) -> %s (%X): cec version %s", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest, CCECCommandHandler::ToString(m_cecVersion)); AddLog(CEC_LOG_NOTICE, strLog); cec_command command; diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index 1725639..b52b8aa 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -465,6 +465,23 @@ void CCECCommandHandler::SetVendorId(const cec_command &command) device->SetVendorId(iVendorId, command.parameters.size > 3 ? command.parameters[3] : 0); } +const char *CCECCommandHandler::ToString(const cec_version version) +{ + switch (version) + { + case CEC_VERSION_1_2: + return "1.2"; + case CEC_VERSION_1_2A: + return "1.2a"; + case CEC_VERSION_1_3: + return "1.3"; + case CEC_VERSION_1_3A: + return "1.3a"; + default: + return "unknown"; + } +} + const char *CCECCommandHandler::ToString(const cec_power_status status) { switch (status) diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index a290764..7185ede 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -47,6 +47,7 @@ namespace CEC virtual bool HandleCommand(const cec_command &command); virtual cec_vendor_id GetVendorId(void) { return CEC_VENDOR_UNKNOWN; }; + static const char *ToString(const cec_version version); static const char *ToString(const cec_power_status status); static const char *ToString(const cec_deck_info status); static const char* ToString(const cec_logical_address address);