cec: added GetCurrentConfiguration()/cec_get_current_configuration()
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 9 Feb 2012 23:13:42 +0000 (00:13 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 9 Feb 2012 23:13:42 +0000 (00:13 +0100)
include/cec.h
include/cecc.h
src/cec-config/cec-config.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/LibCECC.cpp

index c3fbe10aa880563d01daff86be5c4bb2ed5c2333..35f41c9a7136bbc8fd0227431a83c83bb0fb3974 100644 (file)
@@ -369,6 +369,13 @@ namespace CEC
      */
     virtual cec_logical_addresses GetLogicalAddresses(void) = 0;
 
+    /*!
+     * @brief Get libCEC's current configuration.
+     * @param configuration The configuration.
+     * @return True when the configuration was updated, false otherwise.
+     */
+    virtual bool GetCurrentConfiguration(libcec_configuration *configuration) = 0;
+
     virtual const char *ToString(const cec_menu_state state) = 0;
     virtual const char *ToString(const cec_version version) = 0;
     virtual const char *ToString(const cec_power_status status) = 0;
index 050271b6b98dea4bef9564800ab9905249088e93..d8cb791f87b2769a372ce251d11f3d4288915fdc 100644 (file)
@@ -41,9 +41,9 @@ extern "C" {
 #endif
 
 #ifdef __cplusplus
-extern DECLSPEC int cec_initialise(CEC::libcec_configuration *configuration);
+extern DECLSPEC int cec_initialise(const CEC::libcec_configuration *configuration);
 #else
-extern DECLSPEC int cec_initialise(libcec_configuration *configuration);
+extern DECLSPEC int cec_initialise(const libcec_configuration *configuration);
 #endif
 
 #ifdef __cplusplus
@@ -272,6 +272,13 @@ extern DECLSPEC CEC::cec_logical_addresses cec_get_logical_addresses(void);
 extern DECLSPEC cec_logical_addresses cec_get_logical_addresses(void);
 #endif
 
+#ifdef __cplusplus
+extern DECLSPEC int cec_get_current_configuration(CEC::libcec_configuration *configuration);
+#else
+extern DECLSPEC int cec_get_current_configuration(libcec_configuration *configuration);
+#endif
+
+
 #ifdef __cplusplus
 };
 #endif
index 7b69bf883d21e343183e2de0988410f425071981..180cb1408fb96e7c98348fc392692f4b194eec4a 100644 (file)
@@ -348,10 +348,9 @@ int main (int argc, char *argv[])
     return 1;
 
   bool bAddressOk(false);
-  uint16_t iAddress(0xFFFF);
   while (!bAddressOk)
   {
-    iAddress = FindPhysicalAddress();
+    uint16_t iAddress = FindPhysicalAddress();
 
     PrintToStdOut("Physical address: %4X", iAddress);
     PrintToStdOut("Is this correct (y/n)?");
@@ -359,12 +358,13 @@ int main (int argc, char *argv[])
     getline(cin, input);
     cin.clear();
     bAddressOk = (input == "y" || input == "Y");
+    g_config.iPhysicalAddress = iAddress;
   }
 
   PrintToStdOut("=== USB-CEC Adapter Configuration Summary ===\n");
   bool bHasAudiosystem = g_parser->IsActiveDevice(CECDEVICE_AUDIOSYSTEM);
 
-  PrintToStdOut("Physical address: %4X", iAddress);
+  PrintToStdOut("Physical address: %4X", g_config.iPhysicalAddress);
 
   g_parser->StandbyDevices();
   g_parser->Close();
index 6eeb38df53a6d4fc25cecf3a554b61de7e04f0f1..1e655507e814ead3c7c0288198545dc7b6325270 100644 (file)
@@ -1369,3 +1369,13 @@ bool CCECProcessor::SetStreamPath(uint16_t iPhysicalAddress)
   // stream path changes are sent by the TV
   return m_busDevices[CECDEVICE_TV]->GetHandler()->TransmitSetStreamPath(iPhysicalAddress);
 }
+
+bool CCECProcessor::GetCurrentConfiguration(libcec_configuration *configuration)
+{
+  configuration->iPhysicalAddress = m_iPhysicalAddress;
+  configuration->iHDMIPort = m_iHDMIPort;
+  configuration->baseDevice = m_iBaseDevice;
+  snprintf(configuration->strDeviceName, 13, m_strDeviceName.c_str());
+  configuration->deviceTypes = m_types;
+  return true;
+}
index b05beb84044736e7327e384d9b2010e119ab7d91..50d6bf253b6376d8e3d9be90e8e1a77148d30a63 100644 (file)
@@ -100,6 +100,7 @@ namespace CEC
       virtual bool EnablePhysicalAddressDetection(void) { return false; };
       void SetStandardLineTimeout(uint8_t iTimeout);
       void SetRetryLineTimeout(uint8_t iTimeout);
+      virtual bool GetCurrentConfiguration(libcec_configuration *configuration);
 
       bool SetLineTimeout(uint8_t iTimeout);
 
index 9da2ba55a4e474995bf82796bbae68991f0483e4..fd85ea5f863a3e22efe5baa4d3bb496c713216a3 100644 (file)
@@ -540,3 +540,8 @@ const char *CLibCEC::ToString(const cec_client_version version)
 {
   return m_cec->ToString(version);
 }
+
+bool CLibCEC::GetCurrentConfiguration(libcec_configuration *configuration)
+{
+  return m_cec->GetCurrentConfiguration(configuration);
+}
\ No newline at end of file
index 6dabdc25f45025ca5bcf34c791d33c06b9a7f3ae..c9713530ccccbcb61ec876b5da839ac86fba1aad 100644 (file)
@@ -102,6 +102,7 @@ namespace CEC
       virtual bool SetStreamPath(cec_logical_address iAddress);
       virtual bool SetStreamPath(uint16_t iPhysicalAddress);
       virtual cec_logical_addresses GetLogicalAddresses(void);
+      virtual bool GetCurrentConfiguration(libcec_configuration *configuration);
 
       const char *ToString(const cec_menu_state state);
       const char *ToString(const cec_version version);
index b57b1074b66a4c9c1d06129d690289d5939a1251..d852c532878ec3238a7067acfa75e161dff9d147 100644 (file)
@@ -390,4 +390,9 @@ cec_logical_addresses cec_get_logical_addresses(void)
   return addr;
 }
 
+int cec_get_current_configuration(libcec_configuration *configuration)
+{
+  return cec_parser ? (cec_parser->GetCurrentConfiguration(configuration) ? 1 : 0) : -1;
+}
+
 //@}