Skip to content
This repository
Browse code

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 authored October 10, 2012
4  configure.in
@@ -1449,9 +1449,9 @@ if test "x$use_libcec" != "xno"; then
1449 1449
   # libcec is dyloaded, so we need to check for its headers and link any depends.
1450 1450
   if test "x$use_libcec" != "xno"; then
1451 1451
     if test "x$use_libcec" != "xauto"; then
1452  
-      PKG_CHECK_MODULES([CEC],[libcec >= 1.8.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
  1452
+      PKG_CHECK_MODULES([CEC],[libcec >= 2.0.0],,[use_libcec="no";AC_MSG_ERROR($libcec_disabled)])
1453 1453
     else
1454  
-      PKG_CHECK_MODULES([CEC],[libcec >= 1.8.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
  1454
+      PKG_CHECK_MODULES([CEC],[libcec >= 2.0.0],,[use_libcec="no";AC_MSG_RESULT($libcec_disabled)])
1455 1455
     fi
1456 1456
 
1457 1457
     if test "x$use_libcec" != "xno"; then
26  language/English/strings.po
@@ -10914,7 +10914,7 @@ msgid "Product ID"
10914 10914
 msgstr ""
10915 10915
 
10916 10916
 #empty strings from id 35505 to 35999
10917  
-
  10917
+#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp
10918 10918
 msgctxt "#36000"
10919 10919
 msgid "Pulse-Eight CEC adapter"
10920 10920
 msgstr ""
@@ -10965,11 +10965,7 @@ msgctxt "#36012"
10965 10965
 msgid "Could not initialise the CEC adapter. Please check your settings."
10966 10966
 msgstr ""
10967 10967
 
10968  
-msgctxt "#36013"
10969  
-msgid "Unsupported libCEC interface version. %d is greater than the version XBMC supports (%d)"
10970  
-msgstr ""
10971  
-
10972  
-#empty string with id 36014
  10968
+#empty strings from id 36013 to 36014
10973 10969
 
10974 10970
 msgctxt "#36015"
10975 10971
 msgid "HDMI port number"
@@ -11061,3 +11057,21 @@ msgstr ""
11061 11057
 msgctxt "#36036"
11062 11058
 msgid "On start/stop"
11063 11059
 msgstr ""
  11060
+
  11061
+#: xbmc/peripherals/devices/PeripheralCecAdapter.cpp
  11062
+msgctxt "#36037"
  11063
+msgid "TV"
  11064
+msgstr ""
  11065
+
  11066
+msgctxt "#36038"
  11067
+msgid "Amplifier / AVR device"
  11068
+msgstr ""
  11069
+
  11070
+msgctxt "#36039"
  11071
+msgid "TV and AVR device (explicit)"
  11072
+msgstr ""
  11073
+
  11074
+msgctxt "#36040"
  11075
+msgid "Unsupported libCEC interface version. %x is lower than the version XBMC supports (%x)"
  11076
+msgstr ""
  11077
+
2  lib/libcec/Makefile
@@ -7,7 +7,7 @@
7 7
 
8 8
 # lib name, version
9 9
 LIBNAME=libcec
10  
-VERSION=1.8.1
  10
+VERSION=2.0.0
11 11
 SOURCE=$(LIBNAME)-$(VERSION)
12 12
 
13 13
 # download location and format
2  project/BuildDependencies/scripts/libcec_d.txt
... ...
@@ -1,3 +1,3 @@
1 1
 ; filename                        source of the file
2 2
 
3  
-libcec-1.8.1.zip                  http://mirrors.xbmc.org/build-deps/win32/
  3
+libcec-2.0.0.zip                  http://mirrors.xbmc.org/build-deps/win32/
34  system/peripherals.xml
@@ -12,12 +12,12 @@
12 12
   <peripheral vendor_product="2708:1001" bus="rpi" name="Raspberry Pi CEC Adapter" mapTo="cec">
13 13
     <setting key="enabled" type="bool" value="1" label="305" order="1" />
14 14
     <setting key="activate_source" type="bool" value="1" label="36020" order="2" />
15  
-    <setting key="wake_devices" type="string" value="0" label="36007" order="3" />
16  
-    <setting key="standby_devices" type="string" value="0" label="36008" order="4" />
17  
-    <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="5" />
18  
-    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="6" lvalues="36028|13005|13011" />
19  
-    <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="7" />
20  
-    <setting key="send_inactive_source" type="bool" value="1" label="36025" order="8" />
  15
+    <setting key="wake_devices" type="enum" value="36037" label="36007" lvalues="36037|36038|36039|231" order="3" />
  16
+    <setting key="standby_devices" type="enum" value="36037" label="36008" lvalues="36037|36038|36039|231" order="4" />
  17
+    <setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
  18
+    <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="7" />
  19
+    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="7" lvalues="36028|13005|13011" />
  20
+    <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="8" />
21 21
     <setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
22 22
 
23 23
     <setting key="tv_vendor" type="int" value="0" configurable="0" />
@@ -27,27 +27,33 @@
27 27
     <setting key="cec_hdmi_port" type="int" value="1" label="36015" configurable="0" />
28 28
     <setting key="connected_device" type="int" label="36019" value="0" configurable="0" />
29 29
     <setting key="port" type="string" value="" label="36022" configurable="0" />
  30
+    <setting key="wake_devices_advanced" type="string" value="" configurable="0" />
  31
+    <setting key="standby_devices_advanced" type="string" value="" configurable="0" />
  32
+    <setting key="double_tap_timeout_ms" type="int" min="0" value="2000" configurable="0" />
30 33
   </peripheral>
31 34
 
32 35
   <peripheral vendor_product="2548:1001,2548:1002" bus="usb" name="Pulse-Eight CEC Adapter" mapTo="cec">
33 36
     <setting key="enabled" type="bool" value="1" label="305" order="1" />
34 37
     <setting key="activate_source" type="bool" value="1" label="36020" order="2" />
35  
-    <setting key="wake_devices" type="string" value="0" label="36007" order="3" />
36  
-    <setting key="standby_devices" type="string" value="0" label="36008" order="4" />
37  
-    <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="5" />
38  
-    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="6" lvalues="36028|13005|13011" />
39  
-    <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="7" />
40  
-    <setting key="send_inactive_source" type="bool" value="1" label="36025" order="8" />
  38
+    <setting key="wake_devices" type="enum" value="36037" label="36007" lvalues="36037|36038|36039|231" order="3" />
  39
+    <setting key="standby_devices" type="enum" value="36037" label="36008" lvalues="36037|36038|36039|231" order="4" />
  40
+    <setting key="send_inactive_source" type="bool" value="1" label="36025" order="5" />
  41
+    <setting key="cec_standby_screensaver" type="bool" value="0" label="36009" order="6" />
  42
+    <setting key="standby_pc_on_tv_standby" type="enum" value="13011" label="36029" order="7" lvalues="36028|13005|13011" />
  43
+    <setting key="standby_tv_on_pc_standby" type="bool" value="1" label="36026" order="8" />
41 44
     <setting key="use_tv_menu_language" type="bool" value="1" label="36018" order="9" />
42 45
     <setting key="pause_playback_on_deactivate" type="bool" value="1" label="36033" order="10" />
43  
-    <setting key="physical_address" type="string" label="36021" value="0" order="11" />
  46
+    <setting key="connected_device" type="enum" label="36019" value="36037" lvalues="36037|36038" order="11" />
44 47
     <setting key="cec_hdmi_port" type="int" value="1" min="1" max="15" label="36015" order="12" />
45  
-    <setting key="connected_device" type="int" label="36019" value="0" min="0" max="15" step="1" order="13" />
  48
+    <setting key="physical_address" type="string" label="36021" value="0" order="13" />
46 49
     <setting key="port" type="string" value="" label="36022" order="14" />
47 50
 
48 51
     <setting key="tv_vendor" type="int" value="0" configurable="0" />
49 52
     <setting key="device_name" type="string" value="XBMC" configurable="0" />
50 53
     <setting key="device_type" type="int" value="1" configurable="0" />
  54
+    <setting key="wake_devices_advanced" type="string" value="" configurable="0" />
  55
+    <setting key="standby_devices_advanced" type="string" value="" configurable="0" />
  56
+    <setting key="double_tap_timeout_ms" type="int" min="0" value="2000" configurable="0" />
51 57
   </peripheral>
52 58
 
53 59
   <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
@@ -3,7 +3,7 @@ include ../config.site.mk
3 3
 
4 4
 # lib name, version
5 5
 LIBNAME=libcec
6  
-VERSION=1.8.1
  6
+VERSION=2.0.0
7 7
 SOURCE=$(LIBNAME)-$(VERSION)
8 8
 ARCHIVE=$(SOURCE).tar.gz
9 9
 
202  xbmc/peripherals/devices/PeripheralCecAdapter.cpp
@@ -44,13 +44,18 @@ using namespace ANNOUNCEMENT;
44 44
 using namespace CEC;
45 45
 using namespace std;
46 46
 
47  
-#define CEC_LIB_SUPPORTED_VERSION 0x1700
  47
+#define CEC_LIB_SUPPORTED_VERSION 0x2000
48 48
 
49 49
 /* time in seconds to ignore standby commands from devices after the screensaver has been activated */
50 50
 #define SCREENSAVER_TIMEOUT       10
51 51
 #define VOLUME_CHANGE_TIMEOUT     250
52 52
 #define VOLUME_REFRESH_TIMEOUT    100
53 53
 
  54
+#define LOCALISED_ID_TV           36037
  55
+#define LOCALISED_ID_AVR          36038
  56
+#define LOCALISED_ID_TV_AVR       36039
  57
+#define LOCALISED_ID_NONE         231
  58
+
54 59
 class DllLibCECInterface
55 60
 {
56 61
 public:
@@ -76,27 +81,9 @@ CPeripheralCecAdapter::CPeripheralCecAdapter(const PeripheralType type, const Pe
76 81
   CPeripheralHID(type, busType, strLocation, strDeviceName, iVendorId, iProductId),
77 82
   CThread("CEC Adapter"),
78 83
   m_dll(NULL),
79  
-  m_cecAdapter(NULL),
80  
-  m_bStarted(false),
81  
-  m_bHasButton(false),
82  
-  m_bIsReady(false),
83  
-  m_bHasConnectedAudioSystem(false),
84  
-  m_strMenuLanguage("???"),
85  
-  m_lastKeypress(0),
86  
-  m_lastChange(VOLUME_CHANGE_NONE),
87  
-  m_iExitCode(0),
88  
-  m_bIsMuted(false), // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
89  
-  m_bGoingToStandby(false),
90  
-  m_bIsRunning(false),
91  
-  m_bDeviceRemoved(false),
92  
-  m_bActiveSourcePending(false),
93  
-  m_bStandbyPending(false)
  84
+  m_cecAdapter(NULL)
94 85
 {
95  
-  m_currentButton.iButton = 0;
96  
-  m_currentButton.iDuration = 0;
97  
-  m_screensaverLastActivated.SetValid(false);
98  
-
99  
-  m_configuration.Clear();
  86
+  ResetMembers();
100 87
   m_features.push_back(FEATURE_CEC);
101 88
 }
102 89
 
@@ -119,6 +106,34 @@ CPeripheralCecAdapter::~CPeripheralCecAdapter(void)
119 106
   }
120 107
 }
121 108
 
  109
+void CPeripheralCecAdapter::ResetMembers(void)
  110
+{
  111
+  if (m_cecAdapter && m_dll)
  112
+    m_dll->CECDestroy(m_cecAdapter);
  113
+  m_cecAdapter               = NULL;
  114
+  delete m_dll;
  115
+  m_dll                      = NULL;
  116
+  m_bStarted                 = false;
  117
+  m_bHasButton               = false;
  118
+  m_bIsReady                 = false;
  119
+  m_bHasConnectedAudioSystem = false;
  120
+  m_strMenuLanguage          = "???";
  121
+  m_lastKeypress             = 0;
  122
+  m_lastChange               = VOLUME_CHANGE_NONE;
  123
+  m_iExitCode                = 0;
  124
+  m_bIsMuted                 = false; // TODO fetch the correct initial value when system audiostatus is implemented in libCEC
  125
+  m_bGoingToStandby          = false;
  126
+  m_bIsRunning               = false;
  127
+  m_bDeviceRemoved           = false;
  128
+  m_bActiveSourcePending     = false;
  129
+  m_bStandbyPending          = false;
  130
+
  131
+  m_currentButton.iButton    = 0;
  132
+  m_currentButton.iDuration  = 0;
  133
+  m_screensaverLastActivated.SetValid(false);
  134
+  m_configuration.Clear();
  135
+}
  136
+
122 137
 void CPeripheralCecAdapter::Announce(AnnouncementFlag flag, const char *sender, const char *message, const CVariant &data)
123 138
 {
124 139
   if (flag == System && !strcmp(sender, "xbmc") && !strcmp(message, "OnQuit") && m_bIsReady)
@@ -183,6 +198,12 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
183 198
 {
184 199
   if (feature == FEATURE_CEC && !m_bStarted && GetSettingBool("enabled"))
185 200
   {
  201
+    // hide settings that have an override set
  202
+    if (!GetSettingString("wake_devices_advanced").IsEmpty())
  203
+      SetSettingVisible("wake_devices", false);
  204
+    if (!GetSettingString("standby_devices_advanced").IsEmpty())
  205
+      SetSettingVisible("standby_devices", false);
  206
+
186 207
     SetConfigurationFromSettings();
187 208
     m_callbacks.Clear();
188 209
     m_callbacks.CBCecLogMessage           = &CecLogMessage;
@@ -211,11 +232,11 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
211 232
     if (m_configuration.serverVersion < CEC_LIB_SUPPORTED_VERSION)
212 233
     {
213 234
       /* unsupported libcec version */
214  
-      CLog::Log(LOGERROR, g_localizeStrings.Get(36013).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
  235
+      CLog::Log(LOGERROR, g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
215 236
 
216 237
       // display warning: incompatible libCEC
217 238
       CStdString strMessage;
218  
-      strMessage.Format(g_localizeStrings.Get(36013).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
  239
+      strMessage.Format(g_localizeStrings.Get(36040).c_str(), m_cecAdapter ? m_configuration.serverVersion : -1, CEC_LIB_SUPPORTED_VERSION);
219 240
       CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(36000), strMessage);
220 241
       m_bError = true;
221 242
       if (m_cecAdapter)
@@ -240,15 +261,10 @@ bool CPeripheralCecAdapter::InitialiseFeature(const PeripheralFeature feature)
240 261
 
241 262
 void CPeripheralCecAdapter::SetVersionInfo(const libcec_configuration &configuration)
242 263
 {
243  
-  m_strVersionInfo.Format("libCEC %s", m_cecAdapter->ToString((cec_server_version)configuration.serverVersion));
244  
-
245  
-  // append firmware version number
246  
-  if (configuration.serverVersion >= CEC_SERVER_VERSION_1_6_0)
247  
-    m_strVersionInfo.AppendFormat(" - firmware v%d", configuration.iFirmwareVersion);
  264
+  m_strVersionInfo.Format("libCEC %s - firmware v%d", m_cecAdapter->ToString((cec_server_version)configuration.serverVersion), configuration.iFirmwareVersion);
248 265
 
249 266
   // append firmware build date
250  
-  if (configuration.serverVersion >= CEC_SERVER_VERSION_1_6_2 &&
251  
-      configuration.iFirmwareBuildDate != CEC_FW_BUILD_UNKNOWN)
  267
+  if (configuration.iFirmwareBuildDate != CEC_FW_BUILD_UNKNOWN)
252 268
   {
253 269
     CDateTime dt((time_t)configuration.iFirmwareBuildDate);
254 270
     m_strVersionInfo.AppendFormat(" (%s)", dt.GetAsDBDate().c_str());
@@ -629,7 +645,7 @@ void CPeripheralCecAdapter::SetMenuLanguage(const char *strLanguage)
629 645
     CLog::Log(LOGWARNING, "%s - TV menu language set to unknown value '%s'", __FUNCTION__, strLanguage);
630 646
 }
631 647
 
632  
-int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command &command)
  648
+int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command command)
633 649
 {
634 650
   CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
635 651
   if (!adapter)
@@ -703,7 +719,7 @@ int CPeripheralCecAdapter::CecCommand(void *cbParam, const cec_command &command)
703 719
   return 1;
704 720
 }
705 721
 
706  
-int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration &config)
  722
+int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configuration config)
707 723
 {
708 724
   CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
709 725
   if (!adapter)
@@ -714,7 +730,7 @@ int CPeripheralCecAdapter::CecConfiguration(void *cbParam, const libcec_configur
714 730
   return 1;
715 731
 }
716 732
 
717  
-int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter &data)
  733
+int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, const libcec_parameter data)
718 734
 {
719 735
   CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
720 736
   if (!adapter)
@@ -759,7 +775,7 @@ int CPeripheralCecAdapter::CecAlert(void *cbParam, const libcec_alert alert, con
759 775
   return 1;
760 776
 }
761 777
 
762  
-int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress &key)
  778
+int CPeripheralCecAdapter::CecKeyPress(void *cbParam, const cec_keypress key)
763 779
 {
764 780
   CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
765 781
   if (!adapter)
@@ -1168,7 +1184,7 @@ void CPeripheralCecAdapter::CecSourceActivated(void *cbParam, const CEC::cec_log
1168 1184
   }
1169 1185
 }
1170 1186
 
1171  
-int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message &message)
  1187
+int CPeripheralCecAdapter::CecLogMessage(void *cbParam, const cec_log_message message)
1172 1188
 {
1173 1189
   CPeripheralCecAdapter *adapter = (CPeripheralCecAdapter *)cbParam;
1174 1190
   if (!adapter)
@@ -1224,15 +1240,14 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
1224 1240
   bChanged |= SetSetting("device_type", (int)config.deviceTypes[0]);
1225 1241
 
1226 1242
   // hide the "connected device" and "hdmi port number" settings when the PA was autodetected
1227  
-  bool bPAAutoDetected(config.serverVersion >= CEC_SERVER_VERSION_1_7_0 &&
1228  
-      config.bAutodetectAddress == 1);
  1243
+  bool bPAAutoDetected(config.bAutodetectAddress == 1);
1229 1244
 
1230 1245
   SetSettingVisible("connected_device", !bPAAutoDetected);
1231 1246
   SetSettingVisible("cec_hdmi_port", !bPAAutoDetected);
1232 1247
 
1233 1248
   // set the connected device
1234 1249
   m_configuration.baseDevice = config.baseDevice;
1235  
-  bChanged |= SetSetting("connected_device", (int)config.baseDevice);
  1250
+  bChanged |= SetSetting("connected_device", config.baseDevice == CECDEVICE_AUDIOSYSTEM ? LOCALISED_ID_AVR : LOCALISED_ID_TV);
1236 1251
 
1237 1252
   // set the HDMI port number
1238 1253
   m_configuration.iHDMIPort = config.iHDMIPort;
@@ -1255,19 +1270,11 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
1255 1270
 
1256 1271
   // set the devices to wake when starting
1257 1272
   m_configuration.wakeDevices = config.wakeDevices;
1258  
-  CStdString strWakeDevices;
1259  
-  for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
1260  
-    if (config.wakeDevices[iPtr])
1261  
-      strWakeDevices.AppendFormat(" %X", iPtr);
1262  
-  bChanged |= SetSetting("wake_devices", strWakeDevices.Trim());
  1273
+  bChanged |= WriteLogicalAddresses(config.wakeDevices, "wake_devices", "wake_devices_advanced");
1263 1274
 
1264 1275
   // set the devices to power off when stopping
1265 1276
   m_configuration.powerOffDevices = config.powerOffDevices;
1266  
-  CStdString strPowerOffDevices;
1267  
-  for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
1268  
-    if (config.powerOffDevices[iPtr])
1269  
-      strPowerOffDevices.AppendFormat(" %X", iPtr);
1270  
-  bChanged |= SetSetting("standby_devices", strPowerOffDevices.Trim());
  1277
+  bChanged |= WriteLogicalAddresses(config.powerOffDevices, "standby_devices", "standby_devices_advanced");
1271 1278
 
1272 1279
   // set the boolean settings
1273 1280
   m_configuration.bUseTVMenuLanguage = config.bUseTVMenuLanguage;
@@ -1281,21 +1288,14 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
1281 1288
 
1282 1289
   m_configuration.bPowerOffOnStandby = config.bPowerOffOnStandby;
1283 1290
 
1284  
-  if (config.serverVersion >= CEC_SERVER_VERSION_1_5_1)
1285  
-    m_configuration.bSendInactiveSource = config.bSendInactiveSource;
  1291
+  m_configuration.bSendInactiveSource = config.bSendInactiveSource;
1286 1292
   bChanged |= SetSetting("send_inactive_source", m_configuration.bSendInactiveSource == 1);
1287 1293
 
1288  
-  if (config.serverVersion >= CEC_SERVER_VERSION_1_6_0)
1289  
-  {
1290  
-    m_configuration.iFirmwareVersion = config.iFirmwareVersion;
1291  
-    m_configuration.bShutdownOnStandby = config.bShutdownOnStandby;
1292  
-  }
  1294
+  m_configuration.iFirmwareVersion = config.iFirmwareVersion;
  1295
+  m_configuration.bShutdownOnStandby = config.bShutdownOnStandby;
1293 1296
 
1294  
-  if (config.serverVersion >= CEC_SERVER_VERSION_1_6_2)
1295  
-  {
1296  
-    memcpy(m_configuration.strDeviceLanguage, config.strDeviceLanguage, 3);
1297  
-    m_configuration.iFirmwareBuildDate = config.iFirmwareBuildDate;
1298  
-  }
  1297
+  memcpy(m_configuration.strDeviceLanguage, config.strDeviceLanguage, 3);
  1298
+  m_configuration.iFirmwareBuildDate = config.iFirmwareBuildDate;
1299 1299
 
1300 1300
   SetVersionInfo(m_configuration);
1301 1301
 
@@ -1309,8 +1309,8 @@ void CPeripheralCecAdapter::SetConfigurationFromLibCEC(const CEC::libcec_configu
1309 1309
 
1310 1310
 void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
1311 1311
 {
1312  
-  // client version 1.7.1
1313  
-  m_configuration.clientVersion = CEC_CLIENT_VERSION_1_7_1;
  1312
+  // client version 2.0.0
  1313
+  m_configuration.clientVersion = CEC_CLIENT_VERSION_2_0_0;
1314 1314
 
1315 1315
   // device name 'XBMC'
1316 1316
   snprintf(m_configuration.strDeviceName, 13, "%s", GetSettingString("device_name").c_str());
@@ -1341,9 +1341,10 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
1341 1341
 
1342 1342
   // set the connected device
1343 1343
   int iConnectedDevice = GetSettingInt("connected_device");
1344  
-  if (iConnectedDevice == CECDEVICE_TV ||
1345  
-      iConnectedDevice == CECDEVICE_AUDIOSYSTEM)
1346  
-    m_configuration.baseDevice = (cec_logical_address)iConnectedDevice;
  1344
+  if (iConnectedDevice == LOCALISED_ID_AVR)
  1345
+    m_configuration.baseDevice = CECDEVICE_AUDIOSYSTEM;
  1346
+  else if (iConnectedDevice == LOCALISED_ID_TV)
  1347
+    m_configuration.baseDevice = CECDEVICE_TV;
1347 1348
 
1348 1349
   // set the HDMI port number
1349 1350
   int iHDMIPort = GetSettingInt("cec_hdmi_port");
@@ -1358,14 +1359,20 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
1358 1359
     m_configuration.tvVendor = iVendor;
1359 1360
 
1360 1361
   // read the devices to wake when starting
1361  
-  CStdString strWakeDevices = CStdString(GetSettingString("wake_devices")).Trim();
  1362
+  CStdString strWakeDevices = CStdString(GetSettingString("wake_devices_advanced")).Trim();
1362 1363
   m_configuration.wakeDevices.Clear();
1363  
-  ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
  1364
+  if (!strWakeDevices.IsEmpty())
  1365
+    ReadLogicalAddresses(strWakeDevices, m_configuration.wakeDevices);
  1366
+  else
  1367
+    ReadLogicalAddresses(GetSettingInt("wake_devices"), m_configuration.wakeDevices);
1364 1368
 
1365 1369
   // read the devices to power off when stopping
1366  
-  CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices")).Trim();
  1370
+  CStdString strStandbyDevices = CStdString(GetSettingString("standby_devices_advanced")).Trim();
1367 1371
   m_configuration.powerOffDevices.Clear();
1368  
-  ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
  1372
+  if (!strStandbyDevices.IsEmpty())
  1373
+    ReadLogicalAddresses(strStandbyDevices, m_configuration.powerOffDevices);
  1374
+  else
  1375
+    ReadLogicalAddresses(GetSettingInt("standby_devices"), m_configuration.powerOffDevices);
1369 1376
 
1370 1377
   // read the boolean settings
1371 1378
   m_configuration.bUseTVMenuLanguage   = GetSettingBool("use_tv_menu_language") ? 1 : 0;
@@ -1377,6 +1384,9 @@ void CPeripheralCecAdapter::SetConfigurationFromSettings(void)
1377 1384
   int iStandbyAction(GetSettingInt("standby_pc_on_tv_standby"));
1378 1385
   m_configuration.bPowerOffOnStandby = iStandbyAction == 13011 ? 1 : 0;
1379 1386
   m_configuration.bShutdownOnStandby = iStandbyAction == 13005 ? 1 : 0;
  1387
+
  1388
+  // double tap prevention timeout in ms
  1389
+  m_configuration.iDoubleTapTimeoutMs = GetSettingInt("double_tap_timeout_ms");
1380 1390
 }
1381 1391
 
1382 1392
 void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, cec_logical_addresses &addresses)
@@ -1393,6 +1403,51 @@ void CPeripheralCecAdapter::ReadLogicalAddresses(const CStdString &strString, ce
1393 1403
   }
1394 1404
 }
1395 1405
 
  1406
+void CPeripheralCecAdapter::ReadLogicalAddresses(int iLocalisedId, cec_logical_addresses &addresses)
  1407
+{
  1408
+  addresses.Clear();
  1409
+  switch (iLocalisedId)
  1410
+  {
  1411
+  case LOCALISED_ID_TV:
  1412
+    addresses.Set(CECDEVICE_TV);
  1413
+    break;
  1414
+  case LOCALISED_ID_AVR:
  1415
+    addresses.Set(CECDEVICE_AUDIOSYSTEM);
  1416
+    break;
  1417
+  case LOCALISED_ID_TV_AVR:
  1418
+    addresses.Set(CECDEVICE_TV);
  1419
+    addresses.Set(CECDEVICE_AUDIOSYSTEM);
  1420
+    break;
  1421
+  case LOCALISED_ID_NONE:
  1422
+  default:
  1423
+    break;
  1424
+  }
  1425
+}
  1426
+
  1427
+bool CPeripheralCecAdapter::WriteLogicalAddresses(const cec_logical_addresses& addresses, const string& strSettingName, const string& strAdvancedSettingName)
  1428
+{
  1429
+  bool bChanged(false);
  1430
+
  1431
+  // only update the advanced setting if it was set by the user
  1432
+  if (!GetSettingString(strAdvancedSettingName).IsEmpty())
  1433
+  {
  1434
+    CStdString strPowerOffDevices;
  1435
+    for (unsigned int iPtr = CECDEVICE_TV; iPtr <= CECDEVICE_BROADCAST; iPtr++)
  1436
+      if (addresses[iPtr])
  1437
+        strPowerOffDevices.AppendFormat(" %X", iPtr);
  1438
+    bChanged = SetSetting(strAdvancedSettingName, strPowerOffDevices.Trim());
  1439
+  }
  1440
+
  1441
+  int iSettingPowerOffDevices = LOCALISED_ID_NONE;
  1442
+  if (addresses[CECDEVICE_TV] && addresses[CECDEVICE_AUDIOSYSTEM])
  1443
+    iSettingPowerOffDevices = LOCALISED_ID_TV_AVR;
  1444
+  else if (addresses[CECDEVICE_TV])
  1445
+    iSettingPowerOffDevices = LOCALISED_ID_TV;
  1446
+  else if (addresses[CECDEVICE_AUDIOSYSTEM])
  1447
+    iSettingPowerOffDevices = LOCALISED_ID_AVR;
  1448
+  return SetSetting(strSettingName, iSettingPowerOffDevices) || bChanged;
  1449
+}
  1450
+
1396 1451
 CPeripheralCecAdapterUpdateThread::CPeripheralCecAdapterUpdateThread(CPeripheralCecAdapter *adapter, libcec_configuration *configuration) :
1397 1452
     CThread("CEC Adapter Update Thread"),
1398 1453
     m_adapter(adapter),
@@ -1611,15 +1666,20 @@ void CPeripheralCecAdapter::OnDeviceRemoved(void)
1611 1666
 
1612 1667
 void CPeripheralCecAdapter::ReopenConnection(void)
1613 1668
 {
  1669
+  // stop running thread
1614 1670
   {
1615 1671
     CSingleLock lock(m_critSection);
1616 1672
     m_iExitCode = EXITCODE_RESTARTAPP;
1617 1673
     CAnnouncementManager::RemoveAnnouncer(this);
1618 1674
     StopThread(false);
1619 1675
   }
1620  
-
1621 1676
   StopThread();
1622  
-  Create();
  1677
+
  1678
+  // reset all members to their defaults
  1679
+  ResetMembers();
  1680
+
  1681
+  // reopen the connection
  1682
+  InitialiseFeature(FEATURE_CEC);
1623 1683
 }
1624 1684
 
1625 1685
 void CPeripheralCecAdapter::ActivateSource(void)
14  xbmc/peripherals/devices/PeripheralCecAdapter.h
@@ -119,12 +119,14 @@ namespace PERIPHERALS
119 119
     void SetConfigurationFromLibCEC(const CEC::libcec_configuration &config);
120 120
     void SetVersionInfo(const CEC::libcec_configuration &configuration);
121 121
     static void ReadLogicalAddresses(const CStdString &strString, CEC::cec_logical_addresses &addresses);
122  
-    static int CecKeyPress(void *cbParam, const CEC::cec_keypress &key);
  122
+    static void ReadLogicalAddresses(int iLocalisedId, CEC::cec_logical_addresses &addresses);
  123
+    bool WriteLogicalAddresses(const CEC::cec_logical_addresses& addresses, const std::string& strSettingName, const std::string& strAdvancedSettingName);
  124
+    static int CecKeyPress(void *cbParam, const CEC::cec_keypress key);
123 125
     void PushCecKeypress(const CecButtonPress &key);
124  
-    static int CecLogMessage(void *cbParam, const CEC::cec_log_message &message);
125  
-    static int CecCommand(void *cbParam, const CEC::cec_command &command);
126  
-    static int CecConfiguration(void *cbParam, const CEC::libcec_configuration &config);
127  
-    static int CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter &data);
  126
+    static int CecLogMessage(void *cbParam, const CEC::cec_log_message message);
  127
+    static int CecCommand(void *cbParam, const CEC::cec_command command);
  128
+    static int CecConfiguration(void *cbParam, const CEC::libcec_configuration config);
  129
+    static int CecAlert(void *cbParam, const CEC::libcec_alert alert, const CEC::libcec_parameter data);
128 130
     static void CecSourceActivated(void *param, const CEC::cec_logical_address address, const uint8_t activated);
129 131
     bool IsRunning(void) const;
130 132
     void ReopenConnection(void);
@@ -139,6 +141,8 @@ namespace PERIPHERALS
139 141
     static bool FindConfigLocation(CStdString &strString);
140 142
     static bool TranslateComPort(CStdString &strPort);
141 143
 
  144
+    void ResetMembers(void);
  145
+
142 146
     DllLibCEC*                        m_dll;
143 147
     CEC::ICECAdapter*                 m_cecAdapter;
144 148
     bool                              m_bStarted;

0 notes on commit 922dfc4

Please sign in to comment.
Something went wrong with that request. Please try again.