cec: fixed - don't request the PA of devices when handling an incoming CEC command...
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 26 Apr 2012 09:29:17 +0000 (11:29 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 26 Apr 2012 09:29:17 +0000 (11:29 +0200)
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h
src/lib/implementations/SLCommandHandler.cpp
src/lib/implementations/VLCommandHandler.cpp

index 07e7d8f0dc4003b3d4ee280e88a9cd306a282318..9c04b423bb2b100b0d0b651b129206023c76e9a5 100644 (file)
@@ -409,7 +409,7 @@ bool CCECProcessor::ChangeDeviceType(cec_device_type from, cec_device_type to)
       newDevice->SetOSDName(previousDevice->GetOSDName(false));
       previousDevice->SetOSDName(ToString(previousDevice->GetLogicalAddress()));
 
-      newDevice->SetPhysicalAddress(previousDevice->GetPhysicalAddress(false));
+      newDevice->SetPhysicalAddress(previousDevice->GetPhysicalAddress());
       previousDevice->SetPhysicalAddress(0xFFFF);
 
       newDevice->SetPowerStatus(previousDevice->GetPowerStatus(false));
@@ -525,7 +525,7 @@ bool CCECProcessor::SetActiveSource(cec_device_type type /* = CEC_DEVICE_TYPE_RE
   }
 
   m_busDevices[addr]->SetActiveSource();
-  if (m_busDevices[addr]->GetPhysicalAddress(false) != 0xFFFF)
+  if (m_busDevices[addr]->GetPhysicalAddress() != 0xFFFF)
     bReturn = m_busDevices[addr]->ActivateSource();
 
   return bReturn;
@@ -536,7 +536,7 @@ bool CCECProcessor::SetActiveSource(uint16_t iStreamPath)
   bool bReturn(false);
 
   // suppress polls when searching for a device
-  CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath, false, true);
+  CCECBusDevice *device = GetDeviceByPhysicalAddress(iStreamPath);
   if (device)
   {
     device->SetActiveSource();
@@ -649,7 +649,7 @@ bool CCECProcessor::PhysicalAddressInUse(uint16_t iPhysicalAddress)
 {
   for (unsigned int iPtr = 0; iPtr < 15; iPtr++)
   {
-    if (m_busDevices[iPtr]->GetPhysicalAddress(false) == iPhysicalAddress)
+    if (m_busDevices[iPtr]->GetPhysicalAddress() == iPhysicalAddress)
       return true;
   }
   return false;
@@ -810,15 +810,15 @@ uint8_t CCECProcessor::MuteAudio(bool bSendRelease /* = true */)
   return status;
 }
 
-CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh /* = false */, bool bSuppressPoll /* = false */) const
+CCECBusDevice *CCECProcessor::GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bSuppressUpdate /* = true */)
 {
-  if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false) == iPhysicalAddress)
+  if (m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress() == iPhysicalAddress)
     return m_busDevices[m_configuration.logicalAddresses.primary];
 
   CCECBusDevice *device = NULL;
   for (unsigned int iPtr = 0; iPtr < 16; iPtr++)
   {
-    if (m_busDevices[iPtr]->GetPhysicalAddress(bRefresh, bSuppressPoll) == iPhysicalAddress)
+    if (m_busDevices[iPtr]->GetPhysicalAddress(bSuppressUpdate) == iPhysicalAddress)
     {
       device = m_busDevices[iPtr];
       break;
@@ -896,7 +896,7 @@ uint64_t CCECProcessor::GetDeviceVendorId(cec_logical_address iAddress)
 uint16_t CCECProcessor::GetDevicePhysicalAddress(cec_logical_address iAddress)
 {
   if (m_busDevices[iAddress])
-    return m_busDevices[iAddress]->GetPhysicalAddress(false);
+    return m_busDevices[iAddress]->GetPhysicalAddress();
   return false;
 }
 
@@ -1023,7 +1023,7 @@ bool CCECProcessor::IsPresentDeviceType(cec_device_type type)
 uint16_t CCECProcessor::GetPhysicalAddress(void) const
 {
   if (!m_configuration.logicalAddresses.IsEmpty() && m_busDevices[m_configuration.logicalAddresses.primary])
-    return m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress(false);
+    return m_busDevices[m_configuration.logicalAddresses.primary]->GetPhysicalAddress();
   return false;
 }
 
index d5571046202caacc27b158d27af8be09c58cf5a9..acefd8b0a4840c1c1eab17ae8f51917853f00af9 100644 (file)
@@ -109,7 +109,7 @@ namespace CEC
       bool                  OnCommandReceived(const cec_command &command);
 
       bool                  IsMonitoring(void) const { return m_bMonitor; }
-      CCECBusDevice *       GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bRefresh = false, bool bSuppressPoll = false) const;
+      CCECBusDevice *       GetDeviceByPhysicalAddress(uint16_t iPhysicalAddress, bool bSuppressUpdate = true);
       CCECBusDevice *       GetDeviceByType(cec_device_type type) const;
       CCECBusDevice *       GetPrimaryDevice(void) const;
       cec_version           GetDeviceCecVersion(cec_logical_address iAddress);
index cfdc520b3934f27610faa1c19b2b319ad77bb2dc..51ddfeca68af118baca2ed31bda586c1d0921cee 100644 (file)
@@ -278,21 +278,23 @@ bool CCECBusDevice::RequestOSDName(bool bWaitForResponse /* = true */)
   return bReturn;
 }
 
-uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */, bool bSuppressPoll /* = false */)
+uint16_t CCECBusDevice::GetPhysicalAddress(bool bSuppressUpdate /* = true */)
 {
-  bool bIsPresent(GetStatus(false, bSuppressPoll) == CEC_DEVICE_STATUS_PRESENT);
-  bool bRequestUpdate(false);
+  if (!bSuppressUpdate)
   {
-    CLockObject lock(m_mutex);
-    bRequestUpdate = bIsPresent &&
-      (m_iPhysicalAddress == 0xFFFF || bUpdate);
-  }
+    bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT);
+    bool bRequestUpdate(false);
+    {
+      CLockObject lock(m_mutex);
+      bRequestUpdate = bIsPresent && m_iPhysicalAddress == 0xFFFF;
+    }
 
-  if (bRequestUpdate)
-  {
-    CheckVendorIdRequested();
-    if (!RequestPhysicalAddress())
-      CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address");
+    if (bRequestUpdate)
+    {
+      CheckVendorIdRequested();
+      if (!RequestPhysicalAddress())
+        CLibCEC::AddLog(CEC_LOG_ERROR, "failed to request the physical address");
+    }
   }
 
   CLockObject lock(m_mutex);
@@ -644,7 +646,7 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /*
     m_iStreamPath = iNewAddress;
 
     // suppress polls when searching for a device
-    CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress, false, true);
+    CCECBusDevice *device = m_processor->GetDeviceByPhysicalAddress(iNewAddress);
     if (device)
     {
       // if a device is found with the new physical address, mark it as active, which will automatically mark all other devices as inactive
@@ -653,7 +655,7 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /*
     else
     {
       // try to find the device with the old address, and mark it as inactive when found
-      device = m_processor->GetDeviceByPhysicalAddress(iOldAddress, false, true);
+      device = m_processor->GetDeviceByPhysicalAddress(iOldAddress);
       if (device)
         device->SetInactiveSource();
     }
index 377bec395e1732b9b702df941d3f39df0621cbdd..803f6f6ea4a514ab2f142ef8281106e2d2107e73 100644 (file)
@@ -63,7 +63,7 @@ namespace CEC
     virtual cec_logical_address   GetMyLogicalAddress(void) const;
     virtual uint16_t              GetMyPhysicalAddress(void) const;
     virtual CStdString            GetOSDName(bool bUpdate = false);
-    virtual uint16_t              GetPhysicalAddress(bool bUpdate = false, bool bSuppressPoll = false);
+    virtual uint16_t              GetPhysicalAddress(bool bSuppressUpdate = true);
     virtual cec_power_status      GetPowerStatus(bool bUpdate = false);
     virtual CCECProcessor *       GetProcessor(void) const { return m_processor; }
     virtual cec_device_type       GetType(void) const { return m_type; }
index 5b8a7295949d7ba46affddeb4e12ca6285ce340f..f32209b332f0f22df0df8e5399b83340adde63d6 100644 (file)
@@ -127,7 +127,7 @@ bool CSLCommandHandler::HandleActiveSource(const cec_command &command)
   {
     uint16_t iAddress = ((uint16_t)command.parameters[0] << 8) | ((uint16_t)command.parameters[1]);
     CCECBusDevice *primary = m_processor->GetPrimaryDevice();
-    bool bSendPowerOffState(iAddress != primary->GetPhysicalAddress(false) && primary->IsActiveSource());
+    bool bSendPowerOffState(iAddress != primary->GetPhysicalAddress() && primary->IsActiveSource());
 
     m_processor->SetActiveSource(iAddress);
     if (bSendPowerOffState)
index 59146973d7de5b6006f253946c9964abe2217a71..e8cf7c8c4d01f0aede754d5c2c71f76d94185c50 100644 (file)
@@ -133,7 +133,7 @@ bool CVLCommandHandler::TransmitPendingActiveSourceCommands(void)
   if (bTransmitCommand)
   {
     CLibCEC::AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command");
-    return CCECCommandHandler::TransmitActiveSource(m_busDevice->GetLogicalAddress(), m_busDevice->GetPhysicalAddress(false, true));
+    return CCECCommandHandler::TransmitActiveSource(m_busDevice->GetLogicalAddress(), m_busDevice->GetPhysicalAddress());
   }
   return true;
 }