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 94d4c7ad4910fedf95a85967bb835ae2c77dcb7c..8217e4edf93c340a4da94d7aa54d9947901cac03 100644 (file)
@@ -816,20 +816,17 @@ uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */)
 
 CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bSuppressUpdate /* = true */)
 {
-  if (m_configuration.logicalAddresses.primary != CECDEVICE_UNKNOWN)
-  {
-    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;