cec: don't send standby or inactive source messages when rebooting
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 27 Feb 2012 21:13:45 +0000 (22:13 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 27 Mar 2012 14:05:14 +0000 (16:05 +0200)
xbmc/Application.cpp
xbmc/peripherals/devices/PeripheralCecAdapter.cpp
xbmc/peripherals/devices/PeripheralCecAdapter.h

index 4aa0c23..4bc71ee 100644 (file)
@@ -3308,7 +3308,8 @@ void CApplication::Stop(int exitCode)
 {
   try
   {
-    CAnnouncementManager::Announce(System, "xbmc", "OnQuit");
+    CVariant vExitCode(exitCode);
+    CAnnouncementManager::Announce(System, "xbmc", "OnQuit", vExitCode);
 
     // cancel any jobs from the jobmanager
     CJobManager::GetInstance().CancelJobs();
index 658a9ea..6c129ee 100644 (file)
@@ -33,6 +33,7 @@
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "utils/log.h"
+#include "utils/Variant.h"
 
 #include <libcec/cec.h>
 
@@ -77,7 +78,8 @@ CPeripheralCecAdapter::CPeripheralCecAdapter(const PeripheralType type, const Pe
   m_bHasConnectedAudioSystem(false),
   m_strMenuLanguage("???"),
   m_lastKeypress(0),
-  m_lastChange(VOLUME_CHANGE_NONE)
+  m_lastChange(VOLUME_CHANGE_NONE),
+  m_iExitCode(0)
 {
   m_button.iButton = 0;
   m_button.iDuration = 0;
@@ -107,6 +109,7 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
 {
   if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnQuit") && m_bIsReady)
   {
+    m_iExitCode = data.asInteger(0);
     StopThread(false);
   }
   else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverDeactivated") && m_bIsReady)
@@ -305,12 +308,25 @@ void CPeripheralCecAdapter::Process(void)
 
   delete m_queryThread;
 
-  if (m_cecAdapter->IsLibCECActiveSource())
+  if (m_iExitCode != EXITCODE_REBOOT)
   {
-    if (m_configuration.bPowerOffOnStandby == 1)
-      m_cecAdapter->StandbyDevices();
-    else if (m_configuration.bSendInactiveSource == 1)
-      m_cecAdapter->SetInactiveView();
+    if (m_cecAdapter->IsLibCECActiveSource())
+    {
+      if (!m_configuration.powerOffDevices.IsEmpty())
+      {
+        CLog::Log(LOGDEBUG, "%s - sending standby commands", __FUNCTION__);
+        m_cecAdapter->StandbyDevices();
+      }
+      else if (m_configuration.bSendInactiveSource == 1)
+      {
+        CLog::Log(LOGDEBUG, "%s - sending inactive source commands", __FUNCTION__);
+        m_cecAdapter->SetInactiveView();
+      }
+    }
+    else
+    {
+      CLog::Log(LOGDEBUG, "%s - XBMC is not the active source, not sending any standby commands", __FUNCTION__);
+    }
   }
 
   m_cecAdapter->Close();
index 4c3e069..de4e745 100644 (file)
@@ -116,6 +116,7 @@ namespace PERIPHERALS
     std::queue<CecVolumeChange>       m_volumeChangeQueue;
     unsigned int                      m_lastKeypress;
     CecVolumeChange                   m_lastChange;
+    int                               m_iExitCode;
     CPeripheralCecAdapterUpdateThread*m_queryThread;
     CEC::ICECCallbacks                m_callbacks;
     CCriticalSection                  m_critSection;