Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1576 from Pulse-Eight/libcec2

[cec] libCEC 2.0.0 support
  • Loading branch information...
commit 922dfc46ef06a8fe7a00f90b195cb735bbdfcff7 2 parents ad6ef9b + 415d11c
Lars Op den Kamp opdenkamp authored
4 configure.in
View
@@ -1449,9 +1449,9 @@ if test "x$use_libcec" != "xno"; then
# libcec is dyloaded, so we need to check for its headers and link any depends.
if test "x$use_libcec" != "xno"; then
if test "x$use_libcec" != "xauto"; then
- PKG_CHECK_MODULES([CEC],[libcec >= 1.8.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
+ PKG_CHECK_MODULES([CEC],[libcec >= 2.0.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
else
- PKG_CHECK_MODULES([CEC],[libcec >= 1.8.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
+ PKG_CHECK_MODULES([CEC],[libcec >= 2.0.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
fi
if test "x$use_libcec" != "xno"; then
26 language/English/strings.po
View
@@ -10914,7 +10914,7 @@ msgid "Product ID"
msgstr ""
#empty strings from id 35505 to 35999
-
+#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp
msgctxt "#36000"
msgid "Pulse-Eight CEC adapter"
msgstr ""
@@ -10965,11 +10965,7 @@ msgctxt "#36012"
msgid "Could not initialise the CEC adapter. Please check your settings."
msgstr ""
-msgctxt "#36013"
-msgid "Unsupported libCEC interface version. %d is greater than the version XBMC supports (%d)"
-msgstr ""
-
-#empty string with id 36014
+#empty strings from id 36013 to 36014
msgctxt "#36015"
msgid "HDMI port number"
@@ -11061,3 +11057,21 @@ msgstr ""
msgctxt "#36036"
msgid "On start/stop"
msgstr ""
+
+#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp
+msgctxt "#36037"
+msgid "TV"
+msgstr ""
+
+msgctxt "#36038"
+msgid "Amplifier / AVR device"
+msgstr ""
+
+msgctxt "#36039"
+msgid "TV and AVR device (explicit)"
+msgstr ""
+
+msgctxt "#36040"
+msgid "Unsupported libCEC interface version. %x is lower than the version XBMC supports (%x)"
+msgstr ""
+
2  lib/libcec/Makefile
View
@@ -7,7 +7,7 @@
# lib name, version
LIBNAME=libcec
-VERSION=1.8.1
+VERSION=2.0.0
SOURCE=$(LIBNAME)-$(VERSION)
# download location and format
2  project/BuildDependencies/scripts/libcec_d.txt
View
@@ -1,3 +1,3 @@
; filename source of the file
-libcec-1.8.1.zip http://mirrors.xbmc.org/build-deps/win32/
+libcec-2.0.0.zip http://mirrors.xbmc.org/build-deps/win32/
34 system/peripherals.xml
View
@@ -12,12 +12,12 @@
<peripheral vendor_product="2708:1001" bus="rpi" name="Raspberry Pi CEC Adapter" mapTo="cec">
<setting key="enabled" type="bool" value="1" label="305" order="1" />
<setting key="activate_source" type="bool" value="1" label="36020" order="2" />
- <setting key="wake_devices" type="string" value="0" label="36007" order="3" />
- <setting key="standby_devices" type="string" value="0" label="36008" order="4" />
- <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="5" />
- <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="6" lvalues="36028|13005|13011" />
- <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="wake_devices" type="enum" value="36037" label="36007" lvalues="36037|36038|36039|231" order="3" />
+ <setting key="standby_devices" type="enum" value="36037" label="36008" lvalues="36037|36038|36039|231" order="4" />
+ <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="7" />
+ <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="7" lvalues="36028|13005|13011" />
+ <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="8" />
<setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
<setting key="tv_vendor" type="int" value="0" configurable="0" />
@@ -27,27 +27,33 @@
<setting key="cec_hdmi_port" type="int" value="1" label="36015" configurable="0" />
<setting key="connected_device" type="int" label="36019" value="0" configurable="0" />
<setting key="port" type="string" value="" label="36022" configurable="0" />
+ <setting key="wake_devices_advanced" type="string" value="" configurable="0" />
+ <setting key="standby_devices_advanced" type="string" value="" configurable="0" />
+ <setting key="double_tap_timeout_ms" type="int" min="0" value="2000" configurable="0" />
</peripheral>
<peripheral vendor_product="2548:1001,2548:1002" bus="usb" name="Pulse-Eight CEC Adapter" mapTo="cec">
<setting key="enabled" type="bool" value="1" label="305" order="1" />
<setting key="activate_source" type="bool" value="1" label="36020" order="2" />
- <setting key="wake_devices" type="string" value="0" label="36007" order="3" />
- <setting key="standby_devices" type="string" value="0" label="36008" order="4" />
- <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="5" />
- <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="6" lvalues="36028|13005|13011" />
- <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="wake_devices" type="enum" value="36037" label="36007" lvalues="36037|36038|36039|231" order="3" />
+ <setting key="standby_devices" type="enum" value="36037" label="36008" lvalues="36037|36038|36039|231" order="4" />
+ <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="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="7" lvalues="36028|13005|13011" />
+ <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="8" />
<setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
<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="connected_device" type="enum" label="36019" value="36037" lvalues="36037|36038" 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="physical_address" type="string" label="36021" value="0" 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" />
<setting key="device_type" type="int" value="1" configurable="0" />
+ <setting key="wake_devices_advanced" type="string" value="" configurable="0" />
+ <setting key="standby_devices_advanced" type="string" value="" configurable="0" />
+ <setting key="double_tap_timeout_ms" type="int" min="0" value="2000" configurable="0" />
</peripheral>
<peripheral vendor_product="15C2:32,15C2:33,15C2:34,15C2:35,15C2:36,15C2:37,15C2:38,15C2:39,15C2:3A,15C2:3B,15C2:3C,15C2:3D,15C2:3E,15C2:3F,15C2:41,15C2:42,15C2:43,15C2:44,15C2:45,15C2:46" bus="usb" name="iMON HID device" mapTo="imon">
2  tools/darwin/depends/libcec/Makefile
View
@@ -3,7 +3,7 @@ include ../config.site.mk
# lib name, version
LIBNAME=libcec
-VERSION=1.8.1
+VERSION=2.0.0
SOURCE=$(LIBNAME)-$(VERSION)
ARCHIVE=$(SOURCE).tar.gz
202 xbmc/peripherals/devices/PeripheralCecAdapter.cpp
View
@@ -44,13 +44,18 @@ using namespace ANNOUNCEMENT;
using namespace CEC;
using namespace std;
-#define CEC_LIB_SUPPORTED_VERSION 0x1700
+#define CEC_LIB_SUPPORTED_VERSION 0x2000
/* time in seconds to ignore standby commands from devices after the screensaver has been activated */
#define SCREENSAVER_TIMEOUT 10
#define VOLUME_CHANGE_TIMEOUT 250
#define VOLUME_REFRESH_TIMEOUT 100
+#define LOCALISED_ID_TV 36037
+#define LOCALISED_ID_AVR 36038
+#define LOCALISED_ID_TV_AVR 36039
+#define LOCALISED_ID_NONE 231
+
class DllLibCECInterface
{
public:
@@ -76,27 +81,9 @@ CPeripheralCecAdapter::CPeripheralCecAdapter(const PeripheralType type, const Pe
CPeripheralHID(type, busType, strLocation, strDeviceName, iVendorId, iProductId),
CThread("CEC Adapter"),
m_dll(NULL),
- m_cecAdapter(NULL),
- m_bStarted(false),
- m_bHasButton(false),
- m_bIsReady(false),
- m_bHasConnectedAudioSystem(false),
- m_strMenuLanguage("???"),
- m_lastKeypress(0),
- m_lastChange(VOLUME_CHANGE_NONE),
- m_iExitCode(0),
- 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_bActiveSourcePending(false),
- m_bStandbyPending(false)
+ m_cecAdapter(NULL)
{
- m_currentButton.iButton = 0;
- m_currentButton.iDuration = 0;
- m_screensaverLastActivated.SetValid(false);
-
- m_configuration.Clear();
+ ResetMembers();
m_features.push_back(FEATURE_CEC);
}
@@ -119,6 +106,34 @@ CPeripheralCecAdapter::~CPeripheralCecAdapter(void)
}
}
+void CPeripheralCecAdapter::ResetMembers(void)
+{
+ if (m_cecAdapter && m_dll)
+ m_dll->CECDestroy(m_cecAdapter);
+ m_cecAdapter = NULL;
+ delete m_dll;
+ m_dll = NULL;
+ m_bStarted = false;
+ m_bHasButton = false;
+ m_bIsReady = false;
+ m_bHasConnectedAudioSystem = false;
+ m_strMenuLanguage = "???";
+ m_lastKeypress = 0;
+ m_lastChange = VOLUME_CHANGE_NONE;
+ m_iExitCode = 0;
+ 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_bActiveSourcePending = false;
+ m_bStandbyPending = false;
+
+ m_currentButton.iButton = 0;
+ m_currentButton.iDuration = 0;
+ m_screensaverLastActivated.SetValid(false);
+ m_configuration.Clear();
+}
+
void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
{
if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnQuit") && m_bIsReady)
@@ -183,6 +198,12 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
{
if (feature == FEATURE_CEC && !m_bStarted && GetSettingBool("enabled"))
{
+ // hide settings that have an override set
+ if (!GetSettingString("wake_devices_advanced").IsEmpty())
+ SetSettingVisible("wake_devices", false);
+ if (!GetSettingString("standby_devices_advanced").IsEmpty())
+ SetSettingVisible("standby_devices", false);
+
SetConfigurationFromSettings();
m_callbacks.Clear();
m_callbacks.CBCecLogMessage = &CecLogMessage;
@@ -211,11 +232,11 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
if (m_configuration.serverVersion < CEC_LIB_SUPPORTED_VERSION)
{
/* unsupported libcec version */
- CLog::Log(LOGERROR, g_localizeStrings.Get(36013).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
+ CLog::Log(LOGERROR, g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
// display warning: incompatible libCEC
CStdString strMessage;
- strMessage.Format(g_localizeStrings.Get(36013).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
+ strMessage.Format(g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), strMessage);
m_bError = true;
if (m_cecAdapter)
@@ -240,15 +261,10 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
void CPeripheralCecAdapter::SetVersionInfo(const libcec_configuration &configuration)
{
- m_strVersionInfo.Format("libCEC %s", m_cecAdapter->ToString((cec_server_version)configuration.serverVersion));
-
- // append firmware version number
- if (configuration.serverVersion >= CEC_SERVER_VERSION_1_6_0)
- m_strVersionInfo.AppendFormat(" - firmware v%d", configuration.iFirmwareVersion);
+ m_strVersionInfo.Format("libCEC %s - firmware v%d", m_cecAdapter->ToString((cec_server_version)configuration.serverVersion), configuration.iFirmwareVersion);
// append firmware build date
- if (configuration.serverVersion >= CEC_SERVER_VERSION_1_6_2 &&
- configuration.iFirmwareBuildDate != CEC_FW_BUILD_UNKNOWN)
+ if (configuration.iFirmwareBuildDate != CEC_FW_BUILD_UNKNOWN)
{
CDateTime dt((time_t)configuration.iFirmwareBuildDate);
m_strVersionInfo.AppendFormat(" (%s)", dt.GetAsDBDate().c_str());
@@ -629,7 +645,7 @@ void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage)
CLog::Log(LOGWARNING, "%s - TV menu language set to unknown value '%s'", __FUNCTION__, strLanguage);
}
-int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command &command)
+int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command command)
{
CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
if (!adapter)
@@ -703,7 +719,7 @@ int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command &command)
return 1;
}
-int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration &config)
+int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration config)
{
CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
if (!adapter)
@@ -714,7 +730,7 @@ int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configur
return 1;
}
-int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter &data)
+int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter data)
{
CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
if (!adapter)
@@ -759,7 +775,7 @@ int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, con
return 1;
}
-int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress &key)
+int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress key)
{
CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
if (!adapter)
@@ -1168,7 +1184,7 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log
}
}
-int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message &message)
+int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message message)
{
CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
if (!adapter)
@@ -1224,15 +1240,14 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
bChanged |= SetSetting("device_type", (int)config.deviceTypes[0]);
// hide the "connected device" and "hdmi port number" settings when the PA was autodetected
- bool bPAAutoDetected(config.serverVersion >= CEC_SERVER_VERSION_1_7_0 &&
- config.bAutodetectAddress == 1);
+ bool bPAAutoDetected(config.bAutodetectAddress == 1);
SetSettingVisible("connected_device", !bPAAutoDetected);
SetSettingVisible("cec_hdmi_port", !bPAAutoDetected);
// set the connected device
m_configuration.baseDevice = config.baseDevice;
- bChanged |= SetSetting("connected_device", (int)config.baseDevice);
+ bChanged |= SetSetting("connected_device", config.baseDevice == CECDEVICE_AUDIOSYSTEM ? LOCALISED_ID_AVR : LOCALISED_ID_TV);
// set the HDMI port number
m_configuration.iHDMIPort = config.iHDMIPort;
@@ -1255,19 +1270,11 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
// set the devices to wake when starting
m_configuration.wakeDevices = config.wakeDevices;
- CStdString strWakeDevices;
- for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
- if (config.wakeDevices[iPtr])
- strWakeDevices.AppendFormat(" %X", iPtr);
- bChanged |= SetSetting("wake_devices", strWakeDevices.Trim());
+ bChanged |= WriteLogicalAddresses(config.wakeDevices, "wake_devices", "wake_devices_advanced");
// set the devices to power off when stopping
m_configuration.powerOffDevices = config.powerOffDevices;
- CStdString strPowerOffDevices;
- for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
- if (config.powerOffDevices[iPtr])
- strPowerOffDevices.AppendFormat(" %X", iPtr);
- bChanged |= SetSetting("standby_devices", strPowerOffDevices.Trim());
+ bChanged |= WriteLogicalAddresses(config.powerOffDevices, "standby_devices", "standby_devices_advanced");
// set the boolean settings
m_configuration.bUseTVMenuLanguage = config.bUseTVMenuLanguage;
@@ -1281,21 +1288,14 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
m_configuration.bPowerOffOnStandby = config.bPowerOffOnStandby;
- if (config.serverVersion >= CEC_SERVER_VERSION_1_5_1)
- m_configuration.bSendInactiveSource = config.bSendInactiveSource;
+ m_configuration.bSendInactiveSource = config.bSendInactiveSource;
bChanged |= SetSetting("send_inactive_source", m_configuration.bSendInactiveSource == 1);
- if (config.serverVersion >= CEC_SERVER_VERSION_1_6_0)
- {
- m_configuration.iFirmwareVersion = config.iFirmwareVersion;
- m_configuration.bShutdownOnStandby = config.bShutdownOnStandby;
- }
+ m_configuration.iFirmwareVersion = config.iFirmwareVersion;
+ m_configuration.bShutdownOnStandby = config.bShutdownOnStandby;
- if (config.serverVersion >= CEC_SERVER_VERSION_1_6_2)
- {
- memcpy(m_configuration.strDeviceLanguage, config.strDeviceLanguage, 3);
- m_configuration.iFirmwareBuildDate = config.iFirmwareBuildDate;
- }
+ memcpy(m_configuration.strDeviceLanguage, config.strDeviceLanguage, 3);
+ m_configuration.iFirmwareBuildDate = config.iFirmwareBuildDate;
SetVersionInfo(m_configuration);
@@ -1309,8 +1309,8 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
{
- // client version 1.7.1
- m_configuration.clientVersion = CEC_CLIENT_VERSION_1_7_1;
+ // client version 2.0.0
+ m_configuration.clientVersion = CEC_CLIENT_VERSION_2_0_0;
// device name 'XBMC'
snprintf(m_configuration.strDeviceName, 13, "%s", GetSettingString("device_name").c_str());
@@ -1341,9 +1341,10 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
// set the connected device
int iConnectedDevice = GetSettingInt("connected_device");
- if (iConnectedDevice == CECDEVICE_TV ||
- iConnectedDevice == CECDEVICE_AUDIOSYSTEM)
- m_configuration.baseDevice = (cec_logical_address)iConnectedDevice;
+ if (iConnectedDevice == LOCALISED_ID_AVR)
+ m_configuration.baseDevice = CECDEVICE_AUDIOSYSTEM;
+ else if (iConnectedDevice == LOCALISED_ID_TV)
+ m_configuration.baseDevice = CECDEVICE_TV;
// set the HDMI port number
int iHDMIPort = GetSettingInt("cec_hdmi_port");
@@ -1358,14 +1359,20 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
m_configuration.tvVendor = iVendor;
// read the devices to wake when starting
- CStdString strWakeDevices = CStdString(GetSettingString("wake_devices")).Trim();
+ CStdString strWakeDevices = CStdString(GetSettingString("wake_devices_advanced")).Trim();
m_configuration.wakeDevices.Clear();
- ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
+ if (!strWakeDevices.IsEmpty())
+ ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
+ else
+ ReadLogicalAddresses(GetSettingInt("wake_devices"), m_configuration.wakeDevices);
// read the devices to power off when stopping
- CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices")).Trim();
+ CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices_advanced")).Trim();
m_configuration.powerOffDevices.Clear();
- ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
+ if (!strStandbyDevices.IsEmpty())
+ ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
+ else
+ ReadLogicalAddresses(GetSettingInt("standby_devices"), m_configuration.powerOffDevices);
// read the boolean settings
m_configuration.bUseTVMenuLanguage = GetSettingBool("use_tv_menu_language") ? 1 : 0;
@@ -1377,6 +1384,9 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));
m_configuration.bPowerOffOnStandby = iStandbyAction == 13011 ? 1 : 0;
m_configuration.bShutdownOnStandby = iStandbyAction == 13005 ? 1 : 0;
+
+ // double tap prevention timeout in ms
+ m_configuration.iDoubleTapTimeoutMs = GetSettingInt("double_tap_timeout_ms");
}
void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, cec_logical_addresses &addresses)
@@ -1393,6 +1403,51 @@ void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, ce
}
}
+void CPeripheralCecAdapter::ReadLogicalAddresses(int iLocalisedId, cec_logical_addresses &addresses)
+{
+ addresses.Clear();
+ switch (iLocalisedId)
+ {
+ case LOCALISED_ID_TV:
+ addresses.Set(CECDEVICE_TV);
+ break;
+ case LOCALISED_ID_AVR:
+ addresses.Set(CECDEVICE_AUDIOSYSTEM);
+ break;
+ case LOCALISED_ID_TV_AVR:
+ addresses.Set(CECDEVICE_TV);
+ addresses.Set(CECDEVICE_AUDIOSYSTEM);
+ break;
+ case LOCALISED_ID_NONE:
+ default:
+ break;
+ }
+}
+
+bool CPeripheralCecAdapter::WriteLogicalAddresses(const cec_logical_addresses& addresses, const string& strSettingName, const string& strAdvancedSettingName)
+{
+ bool bChanged(false);
+
+ // only update the advanced setting if it was set by the user
+ if (!GetSettingString(strAdvancedSettingName).IsEmpty())
+ {
+ CStdString strPowerOffDevices;
+ for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
+ if (addresses[iPtr])
+ strPowerOffDevices.AppendFormat(" %X", iPtr);
+ bChanged = SetSetting(strAdvancedSettingName, strPowerOffDevices.Trim());
+ }
+
+ int iSettingPowerOffDevices = LOCALISED_ID_NONE;
+ if (addresses[CECDEVICE_TV] && addresses[CECDEVICE_AUDIOSYSTEM])
+ iSettingPowerOffDevices = LOCALISED_ID_TV_AVR;
+ else if (addresses[CECDEVICE_TV])
+ iSettingPowerOffDevices = LOCALISED_ID_TV;
+ else if (addresses[CECDEVICE_AUDIOSYSTEM])
+ iSettingPowerOffDevices = LOCALISED_ID_AVR;
+ return SetSetting(strSettingName, iSettingPowerOffDevices) || bChanged;
+}
+
CPeripheralCecAdapterUpdateThread::CPeripheralCecAdapterUpdateThread(CPeripheralCecAdapter *adapter, libcec_configuration *configuration) :
CThread("CEC Adapter Update Thread"),
m_adapter(adapter),
@@ -1611,15 +1666,20 @@ void CPeripheralCecAdapter::OnDeviceRemoved(void)
void CPeripheralCecAdapter::ReopenConnection(void)
{
+ // stop running thread
{
CSingleLock lock(m_critSection);
m_iExitCode = EXITCODE_RESTARTAPP;
CAnnouncementManager::RemoveAnnouncer(this);
StopThread(false);
}
-
StopThread();
- Create();
+
+ // reset all members to their defaults
+ ResetMembers();
+
+ // reopen the connection
+ InitialiseFeature(FEATURE_CEC);
}
void CPeripheralCecAdapter::ActivateSource(void)
14 xbmc/peripherals/devices/PeripheralCecAdapter.h
View
@@ -119,12 +119,14 @@ namespace PERIPHERALS
void SetConfigurationFromLibCEC(const CEC::libcec_configuration &config);
void SetVersionInfo(const CEC::libcec_configuration &configuration);
static void ReadLogicalAddresses(const CStdString &strString, CEC::cec_logical_addresses &addresses);
- static int CecKeyPress(void *cbParam, const CEC::cec_keypress &key);
+ static void ReadLogicalAddresses(int iLocalisedId, CEC::cec_logical_addresses &addresses);
+ bool WriteLogicalAddresses(const CEC::cec_logical_addresses& addresses, const std::string& strSettingName, const std::string& strAdvancedSettingName);
+ static int CecKeyPress(void *cbParam, const CEC::cec_keypress key);
void PushCecKeypress(const CecButtonPress &key);
- static int CecLogMessage(void *cbParam, const CEC::cec_log_message &message);
- static int CecCommand(void *cbParam, const CEC::cec_command &command);
- static int CecConfiguration(void *cbParam, const CEC::libcec_configuration &config);
- static int CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter &data);
+ static int CecLogMessage(void *cbParam, const CEC::cec_log_message message);
+ static int CecCommand(void *cbParam, const CEC::cec_command command);
+ static int CecConfiguration(void *cbParam, const CEC::libcec_configuration config);
+ static int CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter data);
static void CecSourceActivated(void *param, const CEC::cec_logical_address address, const uint8_t activated);
bool IsRunning(void) const;
void ReopenConnection(void);
@@ -139,6 +141,8 @@ namespace PERIPHERALS
static bool FindConfigLocation(CStdString &strString);
static bool TranslateComPort(CStdString &strPort);
+ void ResetMembers(void);
+
DllLibCEC* m_dll;
CEC::ICECAdapter* m_cecAdapter;
bool m_bStarted;
Please sign in to comment.
Something went wrong with that request. Please try again.