cec: optionally pause playback when switching to another source, and resume playback...
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 31 Jul 2012 15:07:18 +0000 (17:07 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 31 Jul 2012 15:07:18 +0000 (17:07 +0200)
language/English/strings.po
system/peripherals.xml
xbmc/peripherals/devices/PeripheralCecAdapter.cpp

index f0527a2..938a664 100644 (file)
@@ -9499,3 +9499,7 @@ msgctxt "#36032"
 msgid "The port is busy. Only one program can access the CEC adapter"
 msgstr ""
 
+msgctxt "#36033"
+msgid "Pause playback when switching to another source"
+msgstr ""
+
index 9589295..cf0c6c4 100644 (file)
     <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="7" />
     <setting key="send_inactive_source" type="bool" value="1" label="36025" order="8" />
     <setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
-    <setting key="physical_address" type="string" label="36021" value="0" order="10" />
-    <setting key="cec_hdmi_port" type="int" value="1" min="1" max="15" label="36015" order="11" />
-    <setting key="connected_device" type="int" label="36019" value="0" min="0" max="15" step="1" order="12" />
-    <setting key="port" type="string" value="" label="36022" order="13" />
+    <setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" order="10" />
+    <setting key="physical_address" type="string" label="36021" value="0" order="11" />
+    <setting key="cec_hdmi_port" type="int" value="1" min="1" max="15" label="36015" order="12" />
+    <setting key="connected_device" type="int" label="36019" value="0" min="0" max="15" step="1" order="13" />
+    <setting key="port" type="string" value="" label="36022" order="14" />
 
     <setting key="tv_vendor" type="int" value="0" configurable="0" />
     <setting key="device_name" type="string" value="XBMC" configurable="0" />
index 130bb93..549c229 100644 (file)
 #include "DynamicDll.h"
 #include "threads/SingleLock.h"
 #include "dialogs/GUIDialogKaiToast.h"
+#include "guilib/GUIWindowManager.h"
 #include "guilib/LocalizeStrings.h"
 #include "peripherals/Peripherals.h"
 #include "peripherals/bus/PeripheralBus.h"
+#include "pictures/GUIWindowSlideShow.h"
 #include "settings/GUISettings.h"
 #include "settings/Settings.h"
 #include "utils/log.h"
@@ -1127,11 +1129,33 @@ void CPeripheralCecAdapter::OnSettingChanged(const CStdString &strChangedSetting
   }
 }
 
-void CPeripheralCecAdapter::CecSourceActivated(void *param, const CEC::cec_logical_address address, const uint8_t activated)
+void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_logical_address address, const uint8_t activated)
 {
+  CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
+  if (!adapter)
+    return;
+
   // wake up the screensaver, so the user doesn't switch to a black screen
   if (activated == 1)
     g_application.WakeUpScreenSaverAndDPMS();
+
+  if (adapter->GetSettingBool("pause_playback_on_deactivate"))
+  {
+    bool bShowingSlideshow = (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW);
+    CGUIWindowSlideShow *pSlideShow = bShowingSlideshow ? (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW) : NULL;
+
+    if (pSlideShow)
+    {
+      // pause/resume slideshow
+      pSlideShow->OnAction(CAction(ACTION_PAUSE));
+    }
+    else if ((g_application.IsPlaying() && activated == 0) ||
+             (g_application.IsPaused() && activated == 1))
+    {
+      // pause/resume player
+      CApplicationMessenger::Get().MediaPause();
+    }
+  }
 }
 
 int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message &message)