fixed - if we failed to get the physical address of the device that we are connected...
[deb_libcec.git] / src / lib / CECClient.cpp
index 6be95b735b2bf560226b1857b215f0fa5d2ddeb6..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
@@ -1344,7 +1354,7 @@ bool CCECClient::IsLibCECActiveSource(void)
     cec_logical_address activeSource = m_processor->GetActiveSource();
     CCECBusDevice *device = m_processor->GetDevice(activeSource);
     if (device)
-      bReturn = device->IsHandledByLibCEC();
+      bReturn = device->IsHandledByLibCEC() && !device->GetHandler()->ActiveSourcePending();
   }
   return bReturn;
 }
@@ -1377,7 +1387,7 @@ void CCECClient::CallbackAddKey(const cec_keypress &key)
     int64_t now = GetTimeMs();
     if (m_lastKeypress.keycode != key.keycode ||
         key.duration > 0 ||
-        now - m_iLastKeypressTime >= CEC_DOUBLE_TAP_TIMEOUT_MS)
+        now - m_iLastKeypressTime >= m_configuration.iDoubleTapTimeoutMs)
     {
       // no double tap
       if (key.duration == 0)