cec: don't send active source commands when the physical address is invalid or unknown
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 21 Jun 2012 08:58:10 +0000 (10:58 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 21 Jun 2012 08:58:10 +0000 (10:58 +0200)
src/lib/devices/CECBusDevice.cpp

index e1697c3b877d1ece1040e8b6ee84cca265108b0b..3fb30e8a8dff6f6d7a9c75677f121d8cffc05685 100644 (file)
@@ -945,9 +945,18 @@ void CCECBusDevice::MarkAsInactiveSource(void)
 bool CCECBusDevice::TransmitActiveSource(void)
 {
   bool bSendActiveSource(false);
+  uint16_t iPhysicalAddress(CEC_INVALID_PHYSICAL_ADDRESS);
 
   {
     CLockObject lock(m_mutex);
+    if (!HasValidPhysicalAddress())
+    {
+      LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X) has an invalid physical address, not sending active source commands", GetLogicalAddressName(), m_iLogicalAddress);
+      return false;
+    }
+
+    iPhysicalAddress = m_iPhysicalAddress;
+
     if (m_powerStatus != CEC_POWER_STATUS_ON && m_powerStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
       LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress);
     else if (m_bActiveSource)
@@ -963,7 +972,7 @@ bool CCECBusDevice::TransmitActiveSource(void)
   if (bSendActiveSource)
   {
     MarkBusy();
-    bActiveSourceSent = m_handler->TransmitActiveSource(m_iLogicalAddress, m_iPhysicalAddress);
+    bActiveSourceSent = m_handler->TransmitActiveSource(m_iLogicalAddress, iPhysicalAddress);
     MarkReady();
   }