fixed - don't keep trying to send 'image view on' commands to the TV when no TV is...
[deb_libcec.git] / src / lib / implementations / VLCommandHandler.cpp
index a60f897f105ff61c4832d72a94950341a2846d6b..00e062bc8c3920096dbf6abca8a1dfd424058797 100644 (file)
@@ -61,7 +61,8 @@ CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice,
                                      int64_t iActiveSourcePending /* = 0 */) :
     CCECCommandHandler(busDevice, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending),
     m_iPowerUpEventReceived(0),
-    m_bCapabilitiesSent(false)
+    m_bCapabilitiesSent(false),
+    m_bPowerStatusRequested(false)
 {
   m_vendorId = CEC_VENDOR_PANASONIC;
 }
@@ -161,8 +162,11 @@ bool CVLCommandHandler::PowerUpEventReceived(void)
 
   if (m_busDevice->GetLogicalAddress() != CECDEVICE_TV)
   {
+    CCECBusDevice* tv = m_processor->GetTV();
+    if (tv && tv->GetStatus() != CEC_DEVICE_STATUS_PRESENT)
+      return true;
+
     // get the status from the TV
-    CCECBusDevice *tv = m_processor->GetTV();
     if (tv && tv->GetCurrentVendorId() == CEC_VENDOR_PANASONIC)
     {
       CVLCommandHandler *handler = static_cast<CVLCommandHandler *>(tv->GetHandler());
@@ -246,8 +250,17 @@ int CVLCommandHandler::HandleVendorCommand(const cec_command &command)
   return CEC_ABORT_REASON_INVALID_OPERAND;
 }
 
+bool CVLCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */)
+{
+  m_bPowerStatusRequested = true;
+  return CCECCommandHandler::TransmitRequestPowerStatus(iInitiator, iDestination, bWaitForResponse);
+}
+
 bool CVLCommandHandler::SourceSwitchAllowed(void)
 {
+  if (!PowerUpEventReceived() && !m_bPowerStatusRequested)
+    TransmitRequestPowerStatus(m_processor->GetPrimaryDevice()->GetLogicalAddress(), CECDEVICE_TV, false);
+
   return PowerUpEventReceived();
 }