cec: changed - libcec_configuration.bAutodetectAddress is now read-only, and will...
[deb_libcec.git] / src / lib / CECClient.cpp
index 6fe35d6d87bdbb298b3ebbed4608af38b3374807..ae0b9f6e0c7408c5a73758c43db5d37cfc5cc08a 100644 (file)
@@ -195,15 +195,19 @@ void CCECClient::ResetPhysicalAddress(void)
 
 void CCECClient::SetPhysicalAddress(const libcec_configuration &configuration)
 {
-  // try to autodetect the address
   bool bPASet(false);
-  if (m_processor->CECInitialised() && configuration.bAutodetectAddress == 1)
-    bPASet = AutodetectPhysicalAddress();
 
-  // try to use physical address setting
+  // override the physical address from configuration.iPhysicalAddress if it's set
   if (!bPASet && CLibCEC::IsValidPhysicalAddress(configuration.iPhysicalAddress))
     bPASet = SetPhysicalAddress(configuration.iPhysicalAddress);
 
+  // try to autodetect the address
+  if (!bPASet && m_processor->CECInitialised())
+  {
+    bPASet = AutodetectPhysicalAddress();
+    m_configuration.bAutodetectAddress = bPASet ? 1 : 0;
+  }
+
   // use the base device + hdmi port settings
   if (!bPASet)
     bPASet = SetHDMIPort(configuration.baseDevice, configuration.iHDMIPort);