cec: use the vlcommandhandler for the primary device that is handled by libCEC when...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 24 Apr 2012 20:29:54 +0000 (22:29 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 24 Apr 2012 20:34:19 +0000 (22:34 +0200)
src/lib/implementations/VLCommandHandler.cpp
src/lib/implementations/VLCommandHandler.h

index 87a3037e432a4bde4f872b7a820ee7c2e04bcf93..59146973d7de5b6006f253946c9964abe2217a71 100644 (file)
@@ -48,6 +48,17 @@ CVLCommandHandler::CVLCommandHandler(CCECBusDevice *busDevice) :
     m_bPowerUpEventReceived(false)
 {
   m_vendorId = CEC_VENDOR_PANASONIC;
+
+  /* use the VL commandhandler for the primary device that is handled by libCEC */
+  if (busDevice->GetLogicalAddress() == CECDEVICE_TV)
+  {
+    CCECBusDevice *primary = m_processor->GetPrimaryDevice();
+    if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
+    {
+      primary->SetVendorId(CEC_VENDOR_PANASONIC);
+      primary->ReplaceHandler(false);
+    }
+  }
 }
 
 bool CVLCommandHandler::InitHandler(void)
@@ -89,15 +100,11 @@ bool CVLCommandHandler::TransmitActiveSource(const cec_logical_address iInitiato
 {
   bool bPowerUpEventReceived(false);
 
+  CCECBusDevice *tv = m_processor->m_busDevices[CECDEVICE_TV];
+  if (tv && tv->GetVendorId(false) == CEC_VENDOR_PANASONIC)
   {
-    CLockObject lock(m_mutex);
-    if (!m_bPowerUpEventReceived)
-    {
-      // just assume it's been sent when the tv is powered on
-      cec_power_status powerStatus = m_processor->m_busDevices[CECDEVICE_TV]->GetPowerStatus();
-      m_bPowerUpEventReceived = (powerStatus == CEC_POWER_STATUS_ON);
-    }
-    bPowerUpEventReceived = m_bPowerUpEventReceived;
+    CVLCommandHandler *handler = static_cast<CVLCommandHandler *>(tv->GetHandler());
+    bPowerUpEventReceived = handler ? handler->PowerUpEventReceived() : false;
   }
 
   if (!bPowerUpEventReceived)
@@ -130,3 +137,18 @@ bool CVLCommandHandler::TransmitPendingActiveSourceCommands(void)
   }
   return true;
 }
+
+bool CVLCommandHandler::PowerUpEventReceived(void)
+{
+  {
+    CLockObject lock(m_mutex);
+    if (m_bPowerUpEventReceived)
+      return true;
+  }
+
+  cec_power_status powerStatus = m_busDevice->GetPowerStatus();
+
+  CLockObject lock(m_mutex);
+  m_bPowerUpEventReceived = (powerStatus == CEC_POWER_STATUS_ON);
+  return m_bPowerUpEventReceived;
+}
index 18b75070d9531a3ce69d7500955d5eee1d2513c2..6770947ab892f2407708f5f00eda9b58db71298e 100644 (file)
@@ -46,6 +46,8 @@ namespace CEC
     virtual bool TransmitActiveSource(const cec_logical_address iInitiator, uint16_t iPhysicalAddress);
     virtual bool TransmitPendingActiveSourceCommands(void);
 
+    bool PowerUpEventReceived(void);
+
   private:
     PLATFORM::CMutex m_mutex;
     bool             m_bActiveSourcePending;