cec: don't suppress physical address updates of a device in CCECProcessor::SetHDMIPort()
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 5ea6bd5de62d9501daded2a4b64db06d491781fb..0199b32ce44a540c8ce33b2c27623ee96126fe3f 100644 (file)
@@ -280,7 +280,10 @@ bool CCECProcessor::Initialise(void)
       CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set the physical address to %4x", m_configuration.iPhysicalAddress);
   }
   else if (m_configuration.iPhysicalAddress == 0 && (bReturn = SetHDMIPort(m_configuration.baseDevice, m_configuration.iHDMIPort, true)) == false)
+  {
     CLibCEC::AddLog(CEC_LOG_ERROR, "unable to set HDMI port %d on %s (%x)", m_configuration.iHDMIPort, ToString(m_configuration.baseDevice), (uint8_t)m_configuration.baseDevice);
+    bReturn = true;
+  }
 
   if (bReturn && m_configuration.bActivateSource == 1)
     m_busDevices[m_configuration.logicalAddresses.primary]->ActivateSource();
@@ -624,9 +627,7 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort,
 
   uint16_t iPhysicalAddress(0);
   if (iBaseDevice > CECDEVICE_TV)
-  {
-    iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress();
-  }
+    iPhysicalAddress = m_busDevices[iBaseDevice]->GetPhysicalAddress(false);
 
   if (iPhysicalAddress <= CEC_MAX_PHYSICAL_ADDRESS)
   {
@@ -643,9 +644,12 @@ bool CCECProcessor::SetHDMIPort(cec_logical_address iBaseDevice, uint8_t iPort,
   }
 
   if (!bReturn)
-    CLibCEC::AddLog(CEC_LOG_ERROR, "failed to set the physical address");
-  else
-    SetPhysicalAddress(iPhysicalAddress);
+  {
+    CLibCEC::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;
+  }
+
+  SetPhysicalAddress(iPhysicalAddress);
 
   return bReturn;
 }
@@ -1509,9 +1513,9 @@ const char *CCECProcessor::ToString(const cec_server_version version)
 
 bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */)
 {
+  bool bReturn(false);
   if (!m_communication && strPort)
   {
-    bool bReturn(false);
     IAdapterCommunication *comm = new CUSBCECAdapterCommunication(this, strPort);
     CTimeout timeout(CEC_DEFAULT_CONNECT_TIMEOUT);
     int iConnectTry(0);
@@ -1530,8 +1534,12 @@ bool CCECProcessor::StartBootloader(const char *strPort /* = NULL */)
   }
   else
   {
-    return m_communication->StartBootloader();
+    m_communication->StartBootloader();
+    Close();
+    bReturn = true;
   }
+
+  return bReturn;
 }
 
 bool CCECProcessor::PingAdapter(void)