cec: mark the active source as active and other devices as inactive. removed duplicat...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 3c371f4be990b9c415aa2ae4f7b94f8621bdb260..49ca7db7ce64592db298735d361d040f08b23149 100644 (file)
@@ -107,14 +107,23 @@ void CCECBusDevice::PollVendorId(void)
 
 bool CCECBusDevice::PowerOn(void)
 {
-  CStdString strLog;
-  strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
-  AddLog(CEC_LOG_DEBUG, strLog.c_str());
+  cec_power_status current = GetPowerStatus();
+  if (current != CEC_POWER_STATUS_ON &&
+      current != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
+  {
+    CStdString strLog;
+    strLog.Format("<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
+    AddLog(CEC_LOG_DEBUG, strLog.c_str());
 
-  cec_command command;
-  cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+    SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
 
-  return m_processor->Transmit(command);
+    cec_command command;
+    cec_command::format(command, GetMyLogicalAddress(), m_iLogicalAddress, CEC_OPCODE_IMAGE_VIEW_ON);
+
+    return m_processor->Transmit(command);
+  }
+
+  return true;
 }
 
 bool CCECBusDevice::Standby(void)
@@ -295,6 +304,9 @@ void CCECBusDevice::SetStreamPath(uint16_t iNewAddress, uint16_t iOldAddress /*
     AddLog(CEC_LOG_DEBUG, strLog.c_str());
 
     m_iStreamPath = iNewAddress;
+
+    if (iNewAddress > 0)
+      SetPowerStatus(CEC_POWER_STATUS_ON);
   }
 }
 
@@ -379,20 +391,6 @@ bool CCECBusDevice::TransmitActiveSource(void)
   return false;
 }
 
-bool CCECBusDevice::TransmitActiveView(void)
-{
-  CStdString strLog;
-  strLog.Format("<< %s (%X) -> broadcast (F): active view (%4x)", GetLogicalAddressName(), m_iLogicalAddress, m_iPhysicalAddress);
-  AddLog(CEC_LOG_NOTICE, strLog);
-
-  cec_command command;
-  cec_command::format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_ACTIVE_SOURCE);
-  command.parameters.push_back((m_iPhysicalAddress >> 8) & 0xFF);
-  command.parameters.push_back(m_iPhysicalAddress & 0xFF);
-
-  return m_processor->Transmit(command);
-}
-
 bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest)
 {
   CStdString strLog;
@@ -424,17 +422,6 @@ bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest)
   return m_processor->Transmit(command);
 }
 
-bool CCECBusDevice::TransmitDeckStatus(cec_logical_address dest)
-{
-  // need to support opcodes play and deck control before doing anything with this
-  CStdString strLog;
-  strLog.Format("<< %s (%X) -> %s (%X): deck status feature abort", GetLogicalAddressName(), m_iLogicalAddress, CCECCommandHandler::ToString(dest), dest);
-  AddLog(CEC_LOG_NOTICE, strLog);
-
-  m_processor->TransmitAbort(dest, CEC_OPCODE_GIVE_DECK_STATUS);
-  return false;
-}
-
 bool CCECBusDevice::TransmitInactiveView(void)
 {
   CStdString strLog;