Skip to content
Permalink
Browse files

Added advances settings for action when TV goes standby

Added advances settings for action when TV goes standby : Pause
playback, Stop playback, Exit Kodi
  • Loading branch information...
Alexey D. Filimonov authored and popcornmix committed Sep 22, 2015
1 parent e2e1ba7 commit 5a9f7bb7ec666accfc5f5f202e10582782aa88da
@@ -16,7 +16,7 @@
<setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
<setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="6" />
<setting key="cec_wake_screensaver" type="bool" value="1" label="36010" order="7" />
<setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011" />
<setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="8" lvalues="36028|13005|13011|13009|36043|36045" />
<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" configurable="0" />
@@ -55,6 +55,10 @@ using namespace CEC;
#define LOCALISED_ID_TV_AVR 36039
#define LOCALISED_ID_STOP 36044
#define LOCALISED_ID_PAUSE 36045
#define LOCALISED_ID_POWEROFF 13005
#define LOCALISED_ID_SUSPEND 13011
#define LOCALISED_ID_QUIT 13009
#define LOCALISED_ID_IGNORE 36028

#define LOCALISED_ID_NONE 231

@@ -656,6 +660,36 @@ void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage)
CLog::Log(LOGWARNING, "%s - TV menu language set to unknown value '%s'", __FUNCTION__, strLanguage);
}

void CPeripheralCecAdapter::OnTvStandby(void)
{
int iActionOnTvStandby = GetSettingInt("standby_pc_on_tv_standby");
switch (iActionOnTvStandby)
{
case LOCALISED_ID_POWEROFF:
m_bStarted = false;
g_application.ExecuteXBMCAction("Shutdown");
break;
case LOCALISED_ID_SUSPEND:
m_bStarted = false;
g_application.ExecuteXBMCAction("Suspend");
break;
case LOCALISED_ID_QUIT:
m_bStarted = false;
g_application.ExecuteXBMCAction("Quit");
break;
case LOCALISED_ID_PAUSE:
m_bStarted = false;
g_application.OnAction(CAction(ACTION_PAUSE));
break;
case LOCALISED_ID_STOP:
g_application.StopPlaying();
break;
default:
CLog::Log(LOGERROR, "%s - Unexpected [standby_pc_on_tv_standby] setting value", __FUNCTION__);
break;
}
}

void CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command* command)
{
CPeripheralCecAdapter *adapter = static_cast<CPeripheralCecAdapter *>(cbParam);
@@ -667,16 +701,10 @@ void CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command* command
switch (command->opcode)
{
case CEC_OPCODE_STANDBY:
/* a device was put in standby mode */
if (command->initiator == CECDEVICE_TV &&
(adapter->m_configuration.bPowerOffOnStandby == 1 || adapter->m_bShutdownOnStandby) &&
(!adapter->m_standbySent.IsValid() || CDateTime::GetCurrentDateTime() - adapter->m_standbySent > CDateTimeSpan(0, 0, 0, SCREENSAVER_TIMEOUT)))
{
adapter->m_bStarted = false;
if (adapter->m_configuration.bPowerOffOnStandby == 1)
g_application.ExecuteXBMCAction("Suspend");
else if (adapter->m_bShutdownOnStandby)
g_application.ExecuteXBMCAction("Shutdown");
adapter->OnTvStandby();
}
break;
case CEC_OPCODE_SET_MENU_LANGUAGE:
@@ -1397,8 +1425,8 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)

// read the mutually exclusive boolean settings
int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));
m_configuration.bPowerOffOnStandby = iStandbyAction == 13011 ? 1 : 0;
m_bShutdownOnStandby = iStandbyAction == 13005;
m_configuration.bPowerOffOnStandby = iStandbyAction == LOCALISED_ID_SUSPEND ? 1 : 0;
m_bShutdownOnStandby = iStandbyAction == LOCALISED_ID_POWEROFF;

#if defined(CEC_DOUBLE_TAP_TIMEOUT_MS_OLD)
// double tap prevention timeout in ms. libCEC uses 50ms units for this in 2.2.0, so divide by 50
@@ -1410,7 +1438,7 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)

if (GetSettingBool("pause_playback_on_deactivate"))
{
SetSetting("pause_or_stop_playback_on_deactivate", 36045);
SetSetting("pause_or_stop_playback_on_deactivate", LOCALISED_ID_PAUSE);
SetSetting("pause_playback_on_deactivate", false);
}
}
@@ -144,6 +144,7 @@ namespace PERIPHERALS

void SetAudioSystemConnected(bool bSetTo);
void SetMenuLanguage(const char *strLanguage);
void OnTvStandby(void);

// callbacks from libCEC
static void CecLogMessage(void *cbParam, const CEC::cec_log_message* message);

0 comments on commit 5a9f7bb

Please sign in to comment.
You can’t perform that action at this time.