Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[cec] activate source when playback starts #1419

Merged
merged 5 commits into from

2 participants

@opdenkamp
Collaborator

optional, configurable via peripheral settings, and enabled by default

@opdenkamp opdenkamp was assigned
@mkortstiege
Collaborator

Looks good to me. Always wondered why there's no ping on playback start.

@opdenkamp
Collaborator

included a fix for this issue: Pulse-Eight/libcec#48 (deadlock when switching the TV to XBMC when the screensaver was active)

@opdenkamp opdenkamp merged commit ed8746c into xbmc:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 20, 2012
  1. @opdenkamp

    [cec] added ActivateSource()

    opdenkamp authored
  2. @opdenkamp
  3. @opdenkamp

    [cec] fixed - don't activate the source directly in CPeripheralCecAda…

    opdenkamp authored
    …pter::Announce(). this leads to a deadlock when libCEC wakes up the screensaver
  4. @opdenkamp

    [cec] added StandbyDevices()

    opdenkamp authored
  5. @opdenkamp
This page is out of date. Refresh to see the latest.
View
69 xbmc/peripherals/devices/PeripheralCecAdapter.cpp
@@ -88,7 +88,9 @@ CPeripheralCecAdapter::CPeripheralCecAdapter(const PeripheralType type, const Pe
m_bIsMuted(false), // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
m_bGoingToStandby(false),
m_bIsRunning(false),
- m_bDeviceRemoved(false)
+ m_bDeviceRemoved(false),
+ m_bActiveSourcePending(false),
+ m_bStandbyPending(false)
{
m_currentButton.iButton = 0;
m_currentButton.iDuration = 0;
@@ -138,15 +140,10 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
if (bIgnoreDeactivate)
CLog::Log(LOGDEBUG, "%s - ignoring OnScreensaverDeactivated for power action", __FUNCTION__);
}
- if (m_configuration.bPowerOffScreensaver == 1 && !bIgnoreDeactivate)
+ if (m_configuration.bPowerOffScreensaver == 1 && !bIgnoreDeactivate &&
+ m_configuration.bActivateSource == 1)
{
- // power off/on on screensaver is set, and devices to wake are set
- if (!m_configuration.wakeDevices.IsEmpty())
- m_cecAdapter->PowerOnDevices(CECDEVICE_BROADCAST);
-
- // the option to make XBMC the active source is set
- if (m_configuration.bActivateSource == 1)
- m_cecAdapter->SetActiveSource();
+ ActivateSource();
}
}
else if (flag == GUI && !strcmp(sender, "xbmc") && !strcmp(message, "OnScreensaverActivated") && m_bIsReady)
@@ -157,7 +154,7 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
m_screensaverLastActivated = CDateTime::GetCurrentDateTime();
// only power off when we're the active source
if (m_cecAdapter->IsLibCECActiveSource())
- m_cecAdapter->StandbyDevices(CECDEVICE_BROADCAST);
+ StandbyDevices();
}
}
else if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnSleep"))
@@ -174,6 +171,12 @@ void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender,
CLog::Log(LOGDEBUG, "%s - reconnecting to the CEC adapter after standby mode", __FUNCTION__);
ReopenConnection();
}
+ else if (flag == Player && !strcmp(sender, "xbmc") && !strcmp(message, "OnPlay"))
+ {
+ // activate the source when playback started, and the option is enabled
+ if (m_configuration.bActivateSource)
+ ActivateSource();
+ }
}
bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
@@ -371,6 +374,12 @@ void CPeripheralCecAdapter::Process(void)
ProcessVolumeChange();
if (!m_bStop)
+ ProcessActivateSource();
+
+ if (!m_bStop)
+ ProcessStandbyDevices();
+
+ if (!m_bStop)
Sleep(5);
}
@@ -1610,4 +1619,44 @@ void CPeripheralCecAdapter::ReopenConnection(void)
Create();
}
+void CPeripheralCecAdapter::ActivateSource(void)
+{
+ CSingleLock lock(m_critSection);
+ m_bActiveSourcePending = true;
+}
+
+void CPeripheralCecAdapter::ProcessActivateSource(void)
+{
+ bool bActivate(false);
+
+ {
+ CSingleLock lock(m_critSection);
+ bActivate = m_bActiveSourcePending;
+ m_bActiveSourcePending = false;
+ }
+
+ if (bActivate)
+ m_cecAdapter->SetActiveSource();
+}
+
+void CPeripheralCecAdapter::StandbyDevices(void)
+{
+ CSingleLock lock(m_critSection);
+ m_bStandbyPending = true;
+}
+
+void CPeripheralCecAdapter::ProcessStandbyDevices(void)
+{
+ bool bStandby(false);
+
+ {
+ CSingleLock lock(m_critSection);
+ bStandby = m_bStandbyPending;
+ m_bStandbyPending = false;
+ }
+
+ if (bStandby)
+ m_cecAdapter->StandbyDevices(CECDEVICE_BROADCAST);
+}
+
#endif
View
7 xbmc/peripherals/devices/PeripheralCecAdapter.h
@@ -110,6 +110,9 @@ namespace PERIPHERALS
void PushCecKeypress(const CEC::cec_keypress &key);
+ void ActivateSource(void);
+ void StandbyDevices(void);
+
protected:
bool OpenConnection(void);
void SetConfigurationFromSettings(void);
@@ -125,6 +128,8 @@ namespace PERIPHERALS
static void CecSourceActivated(void *param, const CEC::cec_logical_address address, const uint8_t activated);
bool IsRunning(void) const;
void ReopenConnection(void);
+ void ProcessActivateSource(void);
+ void ProcessStandbyDevices(void);
void GetNextKey(void);
bool InitialiseFeature(const PeripheralFeature feature);
@@ -156,6 +161,8 @@ namespace PERIPHERALS
CEC::ICECCallbacks m_callbacks;
CCriticalSection m_critSection;
CEC::libcec_configuration m_configuration;
+ bool m_bActiveSourcePending;
+ bool m_bStandbyPending;
};
class CPeripheralCecAdapterUpdateThread : public CThread
Something went wrong with that request. Please try again.