cec: fix loop when initialising LG
authorLars Op den Kamp <lars@opdenkamp.eu>
Sun, 12 Feb 2012 14:34:53 +0000 (15:34 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Sun, 12 Feb 2012 14:36:50 +0000 (15:36 +0100)
src/lib/devices/CECPlaybackDevice.cpp
src/lib/implementations/SLCommandHandler.cpp
src/lib/implementations/SLCommandHandler.h

index 6f0a8487a8c268a92005691cdd3f96eb2580f228..3e255bf553d81db931fd4152c2f820f44cd5b261 100644 (file)
@@ -57,7 +57,7 @@ cec_deck_info CCECPlaybackDevice::GetDeckStatus(void)
 void CCECPlaybackDevice::SetDeckStatus(cec_deck_info deckStatus)
 {
   CLockObject lock(m_mutex);
-  if (m_deckStatus != deckStatus && m_deckStatus != CEC_DECK_INFO_OTHER_STATUS_LG)
+  if (m_deckStatus != deckStatus)
   {
     CLibCEC::AddLog(CEC_LOG_DEBUG, ">> %s (%X): deck status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_deckStatus), ToString(deckStatus));
     m_deckStatus = deckStatus;
index 0de151d6234221e12ced9d240da32e7b06460580..fef6a4a0e05a5973eff9b7dbf869faca8c76386c 100644 (file)
@@ -57,7 +57,7 @@ CSLCommandHandler::CSLCommandHandler(CCECBusDevice *busDevice) :
   /* imitate LG devices */
   if (primary && m_busDevice->GetLogicalAddress() != primary->GetLogicalAddress())
     primary->SetVendorId(CEC_VENDOR_LG);
-  SetLGDeckStatus();
+  SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
 
   /* LG TVs don't always reply to CEC version requests, so just set it to 1.3a */
   if (m_busDevice->GetLogicalAddress() == CECDEVICE_TV)
@@ -196,7 +196,7 @@ void CSLCommandHandler::HandleVendorCommandPowerOn(const cec_command &command)
     device->TransmitPowerState(command.initiator);
     device->SetPowerStatus(CEC_POWER_STATUS_ON);
 
-    SetLGDeckStatus();
+    SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
     device->SetActiveSource();
     TransmitImageViewOn(device->GetLogicalAddress(), command.initiator);
   }
@@ -215,12 +215,25 @@ void CSLCommandHandler::HandleVendorCommandPowerOnStatus(const cec_command &comm
 void CSLCommandHandler::HandleVendorCommandSLConnect(const cec_command &command)
 {
   m_bSLEnabled = true;
-  SetLGDeckStatus();
-
   CCECBusDevice *primary = m_processor->GetPrimaryDevice();
 
-  primary->SetActiveSource();
   TransmitVendorCommand05(primary->GetLogicalAddress(), command.initiator);
+
+  CCECPlaybackDevice *playback = (primary->GetType() == CEC_DEVICE_TYPE_PLAYBACK_DEVICE || primary->GetType() == CEC_DEVICE_TYPE_RECORDING_DEVICE) ?
+      (CCECPlaybackDevice *)primary : NULL;
+  if (playback)
+  {
+    SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS);
+    playback->TransmitDeckStatus(CECDEVICE_TV);
+    PLATFORM::CEvent::Sleep(2000);
+  }
+
+  primary->SetActiveSource();
+  primary->TransmitImageViewOn();
+
+  SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
+  if (playback)
+    playback->TransmitDeckStatus(CECDEVICE_TV);
 }
 
 void CSLCommandHandler::TransmitVendorCommand05(const cec_logical_address iSource, const cec_logical_address iDestination)
@@ -232,14 +245,13 @@ void CSLCommandHandler::TransmitVendorCommand05(const cec_logical_address iSourc
   Transmit(response, false);
 }
 
-void CSLCommandHandler::SetLGDeckStatus(void)
+void CSLCommandHandler::SetDeckStatus(cec_deck_info deckStatus)
 {
-  /* LG TVs only route keypresses when the deck status is set to 0x20 */
   CCECBusDevice *device = m_processor->GetDeviceByType(CEC_DEVICE_TYPE_PLAYBACK_DEVICE);
   if (device)
-    ((CCECPlaybackDevice *)device)->SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
+    ((CCECPlaybackDevice *)device)->SetDeckStatus(deckStatus);
 
   device = m_processor->GetDeviceByType(CEC_DEVICE_TYPE_RECORDING_DEVICE);
   if (device)
-    ((CCECPlaybackDevice *)device)->SetDeckStatus(CEC_DECK_INFO_OTHER_STATUS_LG);
+    ((CCECPlaybackDevice *)device)->SetDeckStatus(deckStatus);
 }
index 8b006962ef82acfb7ee6c9ee582bad5f4bbc8d70..55f1beaeee6f960680ff13755b5a990a44eb4185 100644 (file)
@@ -60,7 +60,7 @@ namespace CEC
     virtual void HandleVendorCommandSLConnect(const cec_command &command);
     virtual void TransmitVendorCommand05(const cec_logical_address iSource, const cec_logical_address iDestination);
 
-    virtual void SetLGDeckStatus(void);
+    virtual void SetDeckStatus(cec_deck_info deckStatus);
 
     bool    m_bSLEnabled;
     bool    m_bPowerStateReset;