cec: don't try to match a device with PA 0xFFFF. don't change the power status of...
[deb_libcec.git] / src / lib / CECProcessor.cpp
index 9c04b423bb2b100b0d0b651b129206023c76e9a5..8217e4edf93c340a4da94d7aa54d9947901cac03 100644 (file)
@@ -542,6 +542,10 @@ bool CCECProcessor::SetActiveSource(uint16_t iStreamPath)
     device->SetActiveSource();
     bReturn = true;
   }
+  else
+  {
+    CLibCEC::AddLog(CEC_LOG_DEBUG, "device with PA '%04x' not found", iStreamPath);
+  }
 
   return bReturn;
 }
@@ -812,17 +816,17 @@ uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */)
 
 CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bSuppressUpdate /* = true */)
 {
-  if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress() == iPhysicalAddress)
-    return m_busDevices[m_configuration.logicalAddresses.primary];
+  CCECBusDevice *device(NULL);
 
-  CCECBusDevice *device = NULL;
-  for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
+  // invalid PA
+  if (iPhysicalAddress == 0xFFFF)
+    return device;
+
+  // check each device until we found a match
+  for (unsigned int iPtr = 0; !device && iPtr < 16; iPtr++)
   {
     if (m_busDevices[iPtr]->GetPhysicalAddress(bSuppressUpdate) == iPhysicalAddress)
-    {
       device = m_busDevices[iPtr];
-      break;
-    }
   }
 
   return device;