transmit an abort message when the vendor id is requested for philips, instead of...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index d50045af89eebe2ad5e3aaefbd5d29755d8a95ea..6703e87ccd3d0be9c1b3e1cbd84552c7f4037b12 100644 (file)
@@ -537,9 +537,6 @@ bool CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
   {
     LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): physical address changed from %04x to %04x", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress, iNewAddress);
     m_iPhysicalAddress = iNewAddress;
-
-    if (m_processor->GetDevices()->GetActiveSourceAddress() == iNewAddress)
-      MarkAsActiveSource();
   }
   return true;
 }
@@ -646,6 +643,8 @@ bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool
   {
     MarkBusy();
     bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse);
+    if (!bReturn)
+      SetPowerStatus(CEC_POWER_STATUS_UNKNOWN);
     MarkReady();
   }
   return bReturn;
@@ -749,7 +748,7 @@ bool CCECBusDevice::TransmitVendorID(const cec_logical_address destination, bool
   else
   {
     LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) -> %s (%X): vendor id %s (%x)", GetLogicalAddressName(), m_iLogicalAddress, ToString(destination), destination, ToString((cec_vendor_id)iVendorId), iVendorId);
-    bReturn = m_handler->TransmitVendorID(m_iLogicalAddress, iVendorId, bIsReply);
+    bReturn = m_handler->TransmitVendorID(m_iLogicalAddress, destination, iVendorId, bIsReply);
   }
   MarkReady();
   return bReturn;
@@ -1125,26 +1124,36 @@ bool CCECBusDevice::TransmitPendingActiveSourceCommands(void)
 
 void CCECBusDevice::SetActiveRoute(uint16_t iRoute)
 {
+  SetPowerStatus(CEC_POWER_STATUS_ON);
+
   CCECDeviceMap* map = m_processor->GetDevices();
   if (!map)
     return;
 
-  CCECBusDevice* previouslyActive = map->GetActiveSource();
-  if (!previouslyActive)
+  CCECBusDevice* newRoute = m_processor->GetDeviceByPhysicalAddress(iRoute, true);
+  if (newRoute && newRoute->IsHandledByLibCEC())
+  {
+    newRoute->ActivateSource();
     return;
+  }
 
   CECDEVICEVEC devices;
   m_processor->GetDevices()->GetChildrenOf(devices, this);
 
   for (CECDEVICEVEC::iterator it = devices.begin(); it != devices.end(); it++)
   {
-    if (!CCECTypeUtils::PhysicalAddressIsIncluded(iRoute, (*it)->GetCurrentPhysicalAddress()))
+    if ((*it)->GetCurrentPhysicalAddress() == iRoute && (*it)->IsHandledByLibCEC())
+      (*it)->ActivateSource();
+    else if (!CCECTypeUtils::PhysicalAddressIsIncluded(iRoute, (*it)->GetCurrentPhysicalAddress()))
       (*it)->MarkAsInactiveSource();
   }
 }
 
 void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /* = CEC_INVALID_PHYSICAL_ADDRESS */)
 {
+  if (iNewAddress != CEC_INVALID_PHYSICAL_ADDRESS)
+    SetPowerStatus(CEC_POWER_STATUS_ON);
+
   CLockObject lock(m_mutex);
   if (iNewAddress != m_iStreamPath)
   {