fixed - if we failed to get the physical address of the device that we are connected...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 11 Oct 2012 12:58:53 +0000 (14:58 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 11 Oct 2012 13:01:06 +0000 (15:01 +0200)
src/lib/CECClient.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h

index 9a28916b48bf0a42ff7bd0bd17ac06f651f7f30a..f85a53c2a6cae81bae6d17134ffa6b2fc3313f6e 100644 (file)
@@ -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
index 97f57a47ac67a2758850e6bdfbab5fcb08eb04ca..cc6adda8bf4826bfb0c28f63975bae66e60bfd94 100644 (file)
@@ -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)
index dff892e8b9ee2b1e5e588640705a451ff9977605..5593a2cc99e5be970756bd2d778df3f91e27ba50 100644 (file)
@@ -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);