From: Lars Op den Kamp Date: Thu, 11 Oct 2012 12:58:53 +0000 (+0200) Subject: fixed - if we failed to get the physical address of the device that we are connected... X-Git-Tag: upstream/2.2.0~1^2~15^2^2~3 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a99c6deaca45d81a72bf26c2b1af825e6fb78077;p=deb_libcec.git fixed - if we failed to get the physical address of the device that we are connected to in the config, then try to use the address that was persisted in the eeprom before resetting to the default value, 1.0.0.0. closes #50. --- diff --git a/src/lib/CECClient.cpp b/src/lib/CECClient.cpp index 9a28916..f85a53c 100644 --- a/src/lib/CECClient.cpp +++ b/src/lib/CECClient.cpp @@ -184,8 +184,18 @@ bool CCECClient::SetHDMIPort(const cec_logical_address iBaseDevice, const uint8_ // set the default address when something went wrong if (!bReturn) { - LIB_CEC->AddLog(CEC_LOG_WARNING, "failed to set the physical address to %04X, setting it to the default value %04X", iPhysicalAddress, CEC_DEFAULT_PHYSICAL_ADDRESS); - iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS; + uint16_t iEepromAddress = m_processor->GetPhysicalAddressFromEeprom(); + if (CLibCEC::IsValidPhysicalAddress(iEepromAddress)) + { + LIB_CEC->AddLog(CEC_LOG_WARNING, "failed to set the physical address to %04X, setting it to the value that was persisted in the eeprom, %04X", iPhysicalAddress, iEepromAddress); + iPhysicalAddress = iEepromAddress; + bReturn = true; + } + else + { + LIB_CEC->AddLog(CEC_LOG_WARNING, "failed to set the physical address to %04X, setting it to the default value %04X", iPhysicalAddress, CEC_DEFAULT_PHYSICAL_ADDRESS); + iPhysicalAddress = CEC_DEFAULT_PHYSICAL_ADDRESS; + } } // and set the address diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 97f57a4..cc6adda 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -701,6 +701,14 @@ bool CCECProcessor::AllocateLogicalAddresses(CCECClient* client) return true; } +uint16_t CCECProcessor::GetPhysicalAddressFromEeprom(void) +{ + libcec_configuration config; config.Clear(); + if (m_communication) + m_communication->GetConfiguration(config); + return config.iPhysicalAddress; +} + bool CCECProcessor::RegisterClient(CCECClient *client) { if (!client) diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index dff892e..5593a2c 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -77,6 +77,7 @@ namespace CEC bool RegisterClient(CCECClient *client); bool UnregisterClient(CCECClient *client); void UnregisterClients(void); + uint16_t GetPhysicalAddressFromEeprom(void); CCECClient *GetPrimaryClient(void); CCECClient *GetClient(const cec_logical_address address);