Skip to content

Commit

Permalink
Merge pull request #7160 from mk01/master_SAR_cec
Browse files Browse the repository at this point in the history
[CEC] change bool setting "pause playback on changing source" into
  • Loading branch information
MartijnKaijser committed Aug 31, 2015
2 parents 108c034 + 4cb03fb commit ae2f1ce
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
22 changes: 20 additions & 2 deletions addons/resource.language.en_gb/resources/strings.po
Expand Up @@ -1008,12 +1008,14 @@ msgctxt "#230"
msgid "Video filters"
msgstr ""

#. Name of an action to perform on a specific event, like changing the CEC source away from Kodi
#: system/peripherals.xml
#: xbmc/addons/GUIViewStateAddonBrowser.cpp
#: xbmc/dialogs/GUIDialogMediaSource.cpp
#: xbmc/playlists/SmartPlaylist.cpp
#: system/settings/settings.xml
#: xbmc/LangInfo.cpp
#: ###this documented usage does not cover all usecases yet###
msgctxt "#231"
msgid "None"
msgstr ""
Expand Down Expand Up @@ -14863,7 +14865,7 @@ msgstr ""

#: system/peripherals.xml
msgctxt "#36033"
msgid "Pause playback when switching to another source"
msgid "Action when switching to another source"
msgstr ""

#empty string with id 36034
Expand Down Expand Up @@ -14914,7 +14916,23 @@ msgctxt "#36042"
msgid "Use limited colour range (16-235)"
msgstr ""

#empty strings from id 36043 to 36100
#empty strings from id 36043

#. Name of an action to perform on a specific event, like changing the CEC source away from Kodi
#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp
#: system/peripherals.xml
msgctxt "#36044"
msgid "Stop Playback"
msgstr ""

#. Name of an action to perform on a specific event, like changing the CEC source away from Kodi
#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp
#: system/peripherals.xml
msgctxt "#36045"
msgid "Pause Playback"
msgstr ""

#empty strings from id 36046 to 36100
#strings from 36100 to 36999 are reserved for settings descriptions

#. Description of settings section "Appearance"
Expand Down
3 changes: 2 additions & 1 deletion system/peripherals.xml
Expand Up @@ -19,7 +19,8 @@
<setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011" />
<setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="9" />
<setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="10" />
<setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" order="11" />
<setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" configurable="0" />
<setting key="pause_or_stop_playback_on_deactivate" type="enum" value="231" label="36033" order="11" lvalues="231|36044|36045" />
<setting key="connected_device" type="enum" label="36019" value="36037" lvalues="36037|36038" order="12" />
<setting key="cec_hdmi_port" type="int" value="1" min="1" max="15" label="36015" order="13" />
<setting key="physical_address" type="string" label="36021" value="0" order="14" />
Expand Down
21 changes: 19 additions & 2 deletions xbmc/peripherals/devices/PeripheralCecAdapter.cpp
Expand Up @@ -53,6 +53,9 @@ using namespace std;
#define LOCALISED_ID_TV 36037
#define LOCALISED_ID_AVR 36038
#define LOCALISED_ID_TV_AVR 36039
#define LOCALISED_ID_STOP 36044
#define LOCALISED_ID_PAUSE 36045

#define LOCALISED_ID_NONE 231

/* time in seconds to suppress source activation after receiving OnStop */
Expand Down Expand Up @@ -1152,7 +1155,7 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log
if (activated == 1)
g_application.WakeUpScreenSaverAndDPMS();

if (adapter->GetSettingBool("pause_playback_on_deactivate"))
if (adapter->GetSettingInt("pause_or_stop_playback_on_deactivate") != LOCALISED_ID_NONE)
{
bool bShowingSlideshow = (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW);
CGUIWindowSlideShow *pSlideShow = bShowingSlideshow ? (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW) : NULL;
Expand All @@ -1165,7 +1168,8 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log
else if (bPausedAndActivated)
adapter->m_bPlaybackPaused = false;

if (bPlayingAndDeactivated || bPausedAndActivated)
if ((bPlayingAndDeactivated || bPausedAndActivated)
&& adapter->GetSettingInt("pause_or_stop_playback_on_deactivate") == LOCALISED_ID_PAUSE)
{
if (pSlideShow)
// pause/resume slideshow
Expand All @@ -1174,6 +1178,13 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log
// pause/resume player
CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_PAUSE);
}
else if (adapter->GetSettingInt("pause_or_stop_playback_on_deactivate") == LOCALISED_ID_STOP)
{
if (pSlideShow)
pSlideShow->OnAction(CAction(ACTION_STOP));
else
CApplicationMessenger::GetInstance().SendMsg(TMSG_MEDIA_STOP);
}
}
}

Expand Down Expand Up @@ -1372,6 +1383,12 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
// backwards compatibility. will be removed once the next major release of libCEC is out
m_configuration.iDoubleTapTimeoutMs = GetSettingInt("double_tap_timeout_ms");
#endif

if (GetSettingBool("pause_playback_on_deactivate"))
{
SetSetting("pause_or_stop_playback_on_deactivate", 36045);
SetSetting("pause_playback_on_deactivate", false);
}
}

void CPeripheralCecAdapter::ReadLogicalAddresses(const std::string &strString, cec_logical_addresses &addresses)
Expand Down

0 comments on commit ae2f1ce

Please sign in to comment.