From: Lars Op den Kamp Date: Thu, 9 Feb 2012 23:13:42 +0000 (+0100) Subject: cec: added GetCurrentConfiguration()/cec_get_current_configuration() X-Git-Tag: upstream/2.2.0~1^2~35^2~123 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=d40928b571290a0d7d9191adc1c847608cca55e2;p=deb_libcec.git cec: added GetCurrentConfiguration()/cec_get_current_configuration() --- diff --git a/include/cec.h b/include/cec.h index c3fbe10..35f41c9 100644 --- a/include/cec.h +++ b/include/cec.h @@ -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; diff --git a/include/cecc.h b/include/cecc.h index 050271b..d8cb791 100644 --- a/include/cecc.h +++ b/include/cecc.h @@ -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 diff --git a/src/cec-config/cec-config.cpp b/src/cec-config/cec-config.cpp index 7b69bf8..180cb14 100644 --- a/src/cec-config/cec-config.cpp +++ b/src/cec-config/cec-config.cpp @@ -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(); diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 6eeb38d..1e65550 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -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; +} diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index b05beb8..50d6bf2 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -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); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index 9da2ba5..fd85ea5 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -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 diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 6dabdc2..c971353 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -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); diff --git a/src/lib/LibCECC.cpp b/src/lib/LibCECC.cpp index b57b107..d852c53 100644 --- a/src/lib/LibCECC.cpp +++ b/src/lib/LibCECC.cpp @@ -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; +} + //@}