bit less bus and log spamming while waiting for the tv to power up
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 15 Oct 2012 11:26:45 +0000 (13:26 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 15 Oct 2012 11:26:45 +0000 (13:26 +0200)
src/lib/devices/CECBusDevice.cpp
src/lib/implementations/CECCommandHandler.cpp
src/lib/implementations/CECCommandHandler.h
src/lib/implementations/VLCommandHandler.cpp
src/lib/implementations/VLCommandHandler.h

index a33a9c3ede3b5e152694664b7b5327a09f4dc376..5137cfbc00ad08ce7bf7940cd9fde57e30586484 100644 (file)
@@ -618,7 +618,6 @@ bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool
       !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
   {
     MarkBusy();
-    LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
     bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bWaitForResponse);
     MarkReady();
   }
index da578b1173fa394d9c389dbe9cef427f5746945b..831825da263fdeb2167e890583fd50070cdaeed3 100644 (file)
@@ -48,6 +48,7 @@ using namespace PLATFORM;
 
 #define LIB_CEC     m_busDevice->GetProcessor()->GetLib()
 #define ToString(p) CCECTypeUtils::ToString(p)
+#define REQUEST_POWER_STATUS_TIMEOUT 5000
 
 CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice,
                                        int32_t iTransmitTimeout /* = CEC_DEFAULT_TRANSMIT_TIMEOUT */,
@@ -62,7 +63,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice,
     m_bHandlerInited(false),
     m_bOPTSendDeckStatusUpdateOnActiveSource(false),
     m_vendorId(CEC_VENDOR_UNKNOWN),
-    m_iActiveSourcePending(iActiveSourcePending)
+    m_iActiveSourcePending(iActiveSourcePending),
+    m_iPowerStatusRequested(0)
 {
 }
 
@@ -868,6 +870,16 @@ bool CCECCommandHandler::TransmitRequestPhysicalAddress(const cec_logical_addres
 
 bool CCECCommandHandler::TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse /* = true */)
 {
+  if (iDestination == CECDEVICE_TV)
+  {
+    int64_t now(GetTimeMs());
+    if (now - m_iPowerStatusRequested < REQUEST_POWER_STATUS_TIMEOUT)
+      return true;
+    m_iPowerStatusRequested = now;
+  }
+
+  LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< requesting power status of '%s' (%X)", m_busDevice->GetLogicalAddressName(), iDestination);
+
   cec_command command;
   cec_command::Format(command, iInitiator, iDestination, CEC_OPCODE_GIVE_DEVICE_POWER_STATUS);
 
@@ -1128,7 +1140,9 @@ bool CCECCommandHandler::ActivateSource(bool bTransmitDelayedCommandsOnly /* = f
         if (m_iActiveSourcePending == 0 || GetTimeMs() < m_iActiveSourcePending)
           return false;
 
+#ifdef CEC_DEBUGGING
         LIB_CEC->AddLog(CEC_LOG_DEBUG, "transmitting delayed activate source command");
+#endif
       }
     }
 
index fca8a966fa6aca7a4809cce9c9fad9727bf863f8..1a6cd567c264881e2a50f9f2ff27f05cf4429f19 100644 (file)
@@ -152,15 +152,16 @@ namespace CEC
 
     virtual bool SourceSwitchAllowed(void) { return true; }
 
-    CCECBusDevice *                       m_busDevice;
-    CCECProcessor *                       m_processor;
-    int32_t                               m_iTransmitTimeout;
-    int32_t                               m_iTransmitWait;
-    int8_t                                m_iTransmitRetries;
-    bool                                  m_bHandlerInited;
-    bool                                  m_bOPTSendDeckStatusUpdateOnActiveSource;
-    cec_vendor_id                         m_vendorId;
-    int64_t                               m_iActiveSourcePending;
-    PLATFORM::CMutex                      m_mutex;
+    CCECBusDevice *  m_busDevice;
+    CCECProcessor *  m_processor;
+    int32_t          m_iTransmitTimeout;
+    int32_t          m_iTransmitWait;
+    int8_t           m_iTransmitRetries;
+    bool            m_bHandlerInited;
+    bool            m_bOPTSendDeckStatusUpdateOnActiveSource;
+    cec_vendor_id    m_vendorId;
+    int64_t          m_iActiveSourcePending;
+    PLATFORM::CMutex m_mutex;
+    int64_t          m_iPowerStatusRequested;
   };
 };
index d14bec66cd1fe0c71cd569ab3bec21c53ab0a390..b7cdb7a20b166ab84a1ccca5abe27a3d39335dc4 100644 (file)
@@ -45,8 +45,6 @@
 #define VL_POWERED_DOWN 0x01
 #define VL_UNKNOWN1     0x06
 
-#define VL_REQUEST_POWER_STATUS_TIMEOUT 5000
-
 using namespace CEC;
 using namespace PLATFORM;
 
@@ -63,8 +61,7 @@ CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice,
                                      int64_t iActiveSourcePending /* = 0 */) :
     CCECCommandHandler(busDevice, iTransmitTimeout, iTransmitWait, iTransmitRetries, iActiveSourcePending),
     m_iPowerUpEventReceived(0),
-    m_bCapabilitiesSent(false),
-    m_iPowerStatusRequested(0)
+    m_bCapabilitiesSent(false)
 {
   m_vendorId = CEC_VENDOR_PANASONIC;
 }
@@ -253,16 +250,9 @@ 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_iPowerStatusRequested = GetTimeMs();
-  return CCECCommandHandler::TransmitRequestPowerStatus(iInitiator, iDestination, bWaitForResponse);
-}
-
 bool CVLCommandHandler::SourceSwitchAllowed(void)
 {
-  int64_t now(GetTimeMs());
-  if (!PowerUpEventReceived() && now - m_iPowerStatusRequested > VL_REQUEST_POWER_STATUS_TIMEOUT)
+  if (!PowerUpEventReceived())
     TransmitRequestPowerStatus(m_processor->GetPrimaryDevice()->GetLogicalAddress(), CECDEVICE_TV, false);
 
   return PowerUpEventReceived();
index b878ca97bee17da48f243a1d40db99920f12a03d..3ad80b49150b53749bc61d0f306f972631a5a00c 100644 (file)
@@ -55,7 +55,6 @@ namespace CEC
     bool PowerUpEventReceived(void);
     bool SupportsDeviceType(const cec_device_type type) const { return type != CEC_DEVICE_TYPE_RECORDING_DEVICE; };
     cec_device_type GetReplacementDeviceType(const cec_device_type type) const { return type == CEC_DEVICE_TYPE_RECORDING_DEVICE ? CEC_DEVICE_TYPE_PLAYBACK_DEVICE : type; }
-    bool TransmitRequestPowerStatus(const cec_logical_address iInitiator, const cec_logical_address iDestination, bool bWaitForResponse = true);
 
     bool SourceSwitchAllowed(void);
 
@@ -67,6 +66,5 @@ namespace CEC
     PLATFORM::CMutex m_mutex;
     uint64_t         m_iPowerUpEventReceived;
     bool             m_bCapabilitiesSent;
-    int64_t          m_iPowerStatusRequested;
   };
 };