From c30acafa9bab18c07d0f27e2935c9df3d95de4ec Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Fri, 11 May 2012 09:16:06 +0200 Subject: [PATCH] cec: fixed abi --- include/cectypes.h | 57 +------------------ src/lib/CECProcessor.cpp | 5 +- src/lib/LibCEC.cpp | 23 ++++++-- src/lib/LibCEC.h | 37 ++++++++---- .../adapter/USBCECAdapterCommunication.cpp | 1 + src/lib/devices/CECDeviceMap.cpp | 4 +- 6 files changed, 55 insertions(+), 72 deletions(-) diff --git a/include/cectypes.h b/include/cectypes.h index 759eb4f..d70fc81 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -908,19 +908,6 @@ typedef struct cec_device_type_list cec_device_type types[5]; /**< the list of device types */ #ifdef __cplusplus - cec_device_type_list operator+ (const cec_device_type_list &other) - { - cec_device_type_list retVal; - for (unsigned int iPtr = 0; iPtr < 5; iPtr++) - { - if (other.types[iPtr] != CEC_DEVICE_TYPE_RESERVED) - retVal.Add(other.types[iPtr]); - if (types[iPtr] != CEC_DEVICE_TYPE_RESERVED) - retVal.Add(types[iPtr]); - } - return retVal; - } - /*! * @deprecated Use Clear() instead. * @brief Clear this list. @@ -963,7 +950,7 @@ typedef struct cec_device_type_list * @param type The type to check. * @return True when set, false otherwise. */ - bool IsSet(const cec_device_type type) const + bool IsSet(cec_device_type type) { bool bReturn(false); for (unsigned int iPtr = 0; !bReturn && iPtr < 5; iPtr++) @@ -1016,9 +1003,6 @@ typedef struct cec_logical_addresses int addresses[16]; /**< the list of addresses */ #ifdef __cplusplus - cec_logical_addresses(void) { Clear(); } - virtual ~cec_logical_addresses(void) { Clear(); } - /*! * @brief Clear this list. */ @@ -1079,7 +1063,7 @@ typedef struct cec_logical_addresses * @param address The address to check. * @return True when set, false otherwise. */ - bool IsSet(const cec_logical_address address) const { return addresses[(int) address] == 1; } + bool IsSet(cec_logical_address address) const { return addresses[(int) address] == 1; } /*! * @brief Check whether an address is set in this list. @@ -1100,27 +1084,6 @@ typedef struct cec_logical_addresses { return !(*this == other); } - - cec_logical_addresses operator+ (const cec_logical_addresses &other) - { - cec_logical_addresses retVal; - for (unsigned int iPtr = 0; iPtr < 16; iPtr++) - { - if (other.IsSet((cec_logical_address)iPtr) || IsSet((cec_logical_address)iPtr)) - retVal.Set((cec_logical_address)iPtr); - } - return retVal; - } - - cec_logical_addresses &operator+= (const cec_logical_addresses &other) - { - for (unsigned int iPtr = 0; iPtr < 16; iPtr++) - { - if (other.IsSet((cec_logical_address)iPtr)) - Set((cec_logical_address)iPtr); - } - return *this; - } #endif } cec_logical_addresses; @@ -1140,22 +1103,6 @@ struct libcec_parameter { libcec_parameter_type paramType; /**< the type of this parameter */ void* paramData; /**< the value of this parameter */ - -#ifdef __cplusplus - libcec_parameter(void) - { - paramType = CEC_PARAMETER_TYPE_UNKOWN; - paramData = NULL; - } - - libcec_parameter(const char *strMessage) - { - paramType = CEC_PARAMETER_TYPE_STRING; - paramData = (void*)strMessage; - } - - virtual ~libcec_parameter(void) {} -#endif }; struct libcec_configuration; diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 0add41b..bce22c0 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -659,7 +659,9 @@ bool CCECProcessor::RegisterClient(CCECClient *client) { const char *strUpgradeMessage = "The firmware of this adapter can be upgraded. Please visit http://blog.pulse-eight.com/ for more information."; m_libcec->AddLog(CEC_LOG_WARNING, strUpgradeMessage); - client->Alert(CEC_ALERT_SERVICE_DEVICE, libcec_parameter(strUpgradeMessage)); + libcec_parameter param; + param.paramData = (void*)strUpgradeMessage; param.paramType = CEC_PARAMETER_TYPE_STRING; + client->Alert(CEC_ALERT_SERVICE_DEVICE, param); } else { @@ -728,6 +730,7 @@ cec_logical_address CCECProcessor::GetLogicalAddress(void) const cec_logical_addresses CCECProcessor::GetLogicalAddresses(void) const { cec_logical_addresses addresses; + addresses.Clear(); for (map::const_iterator client = m_clients.begin(); client != m_clients.end(); client++) addresses.Set(client->first); diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index daa0b55..a204a4b 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -48,9 +48,16 @@ using namespace std; using namespace CEC; using namespace PLATFORM; -CLibCEC::CLibCEC(void) : - m_client(NULL), - m_iStartTime(GetTimeMs()) +CLibCEC::CLibCEC(const char *UNUSED(strDeviceName), cec_device_type_list UNUSED(types), uint16_t UNUSED(iPhysicalAddress) /* = 0 */) : + m_iStartTime(GetTimeMs()), + m_client(NULL) +{ + m_cec = new CCECProcessor(this); +} + +CLibCEC::CLibCEC(libcec_configuration *UNUSED(configuration)) : + m_iStartTime(GetTimeMs()), + m_client(NULL) { m_cec = new CCECProcessor(this); } @@ -339,6 +346,7 @@ cec_osd_name CLibCEC::GetDeviceOSDName(cec_logical_address iAddress) cec_logical_addresses CLibCEC::GetLogicalAddresses(void) { cec_logical_addresses addresses; + addresses.Clear(); if (m_cec) addresses = m_cec->GetLogicalAddresses(); return addresses; @@ -937,7 +945,7 @@ void * CECInitialise(libcec_configuration *configuration) if (!configuration) return NULL; - CLibCEC *lib = new CLibCEC; + CLibCEC *lib = new CLibCEC(NULL); CCECClient *client(NULL); if (lib) client = lib->RegisterClient(configuration); @@ -998,3 +1006,10 @@ bool CLibCEC::GetDeviceInformation(const char *strPort, libcec_configuration *co return m_cec->GetDeviceInformation(strPort, config, iTimeoutMs); } + +void CLibCEC::AddKey(const cec_keypress &UNUSED(key)) {} +void CLibCEC::AddCommand(const cec_command &UNUSED(command)) {} +void CLibCEC::ConfigurationChanged(const libcec_configuration &UNUSED(config)) {} +void CLibCEC::SetCurrentButton(cec_user_control_code UNUSED(iButtonCode)) {} +CLibCEC *CLibCEC::GetInstance(void) { return NULL; } +void CLibCEC::SetInstance(CLibCEC *UNUSED(instance)) {} diff --git a/src/lib/LibCEC.h b/src/lib/LibCEC.h index 6b23dac..673b525 100644 --- a/src/lib/LibCEC.h +++ b/src/lib/LibCEC.h @@ -44,7 +44,8 @@ namespace CEC class CLibCEC : public ICECAdapter { public: - CLibCEC(void); + CLibCEC(const char *strDeviceName, cec_device_type_list types, uint16_t iPhysicalAddress = 0); + CLibCEC(libcec_configuration *configuration); virtual ~CLibCEC(void); /*! @@ -80,14 +81,11 @@ namespace CEC bool SetMenuState(cec_menu_state state, bool bSendUpdate = true); bool SetOSDString(cec_logical_address iLogicalAddress, cec_display_control duration, const char *strMessage); bool SwitchMonitoring(bool bEnable); - cec_version GetDeviceCecVersion(cec_logical_address iAddress); bool GetDeviceMenuLanguage(cec_logical_address iAddress, cec_menu_language *language); uint64_t GetDeviceVendorId(cec_logical_address iAddress); uint16_t GetDevicePhysicalAddress(cec_logical_address iAddress); cec_power_status GetDevicePowerStatus(cec_logical_address iAddress); - cec_osd_name GetDeviceOSDName(cec_logical_address iAddress); - bool PollDevice(cec_logical_address iAddress); cec_logical_addresses GetActiveDevices(void); bool IsActiveDevice(cec_logical_address iAddress); @@ -98,6 +96,7 @@ namespace CEC uint8_t MuteAudio(bool bSendRelease = true); bool SendKeypress(cec_logical_address iDestination, cec_user_control_code key, bool bWait = true); bool SendKeyRelease(cec_logical_address iDestination, bool bWait = true); + cec_osd_name GetDeviceOSDName(cec_logical_address iAddress); bool EnablePhysicalAddressDetection(void); cec_logical_address GetActiveSource(void); bool IsActiveSource(cec_logical_address iAddress); @@ -125,27 +124,43 @@ namespace CEC const char *ToString(const cec_server_version version); const char *ToString(const cec_device_type type); - static bool IsValidPhysicalAddress(uint16_t iPhysicalAddress); - static cec_device_type GetType(cec_logical_address address); static uint16_t GetMaskForType(cec_logical_address address); static uint16_t GetMaskForType(cec_device_type type); bool GetDeviceInformation(const char *strPort, libcec_configuration *config, uint32_t iTimeoutMs = CEC_DEFAULT_CONNECT_TIMEOUT); //@} - void AddLog(const cec_log_level level, const char *strFormat, ...); + void AddLog(const cec_log_level level, const char *strFormat, ...); + static void AddKey(void) {} //UNUSED + static void AddKey(const cec_keypress &key); //UNUSED + static void AddCommand(const cec_command &command); //UNUSED + static void ConfigurationChanged(const libcec_configuration &config); //UNUSED + static void SetCurrentButton(cec_user_control_code iButtonCode); //UNUSED void CheckKeypressTimeout(void); void Alert(const libcec_alert type, const libcec_parameter ¶m); + static CLibCEC *GetInstance(void); //UNUSED + static void SetInstance(CLibCEC *instance); //UNUSED + static bool IsValidPhysicalAddress(uint16_t iPhysicalAddress); CCECClient *RegisterClient(libcec_configuration *configuration); void UnregisterClients(void); - protected: + CCECProcessor * m_cec; - CCECClient * m_client; - int64_t m_iStartTime; - PLATFORM::CMutex m_mutex; + protected: + int64_t m_iStartTime; + cec_user_control_code m_iCurrentButton; //UNUSED + int64_t m_buttontime; //UNUSED + PLATFORM::SyncedBuffer m_logBuffer; //UNUSED + PLATFORM::SyncedBuffer m_keyBuffer; //UNUSED + PLATFORM::SyncedBuffer m_commandBuffer; //UNUSED + ICECCallbacks * m_callbacks; //UNUSED + void * m_cbParam; //UNUSED + PLATFORM::CMutex m_mutex; + PLATFORM::CMutex m_logMutex; //UNUSED + + CCECClient * m_client; std::vector m_clients; }; }; diff --git a/src/lib/adapter/USBCECAdapterCommunication.cpp b/src/lib/adapter/USBCECAdapterCommunication.cpp index b08801f..680918d 100644 --- a/src/lib/adapter/USBCECAdapterCommunication.cpp +++ b/src/lib/adapter/USBCECAdapterCommunication.cpp @@ -190,6 +190,7 @@ void CUSBCECAdapterCommunication::Close(void) m_port->Close(); libcec_parameter param; + param.paramData = NULL; param.paramType = CEC_PARAMETER_TYPE_UNKOWN; LIB_CEC->Alert(CEC_ALERT_CONNECTION_LOST, param); } diff --git a/src/lib/devices/CECDeviceMap.cpp b/src/lib/devices/CECDeviceMap.cpp index 2603e33..5580527 100644 --- a/src/lib/devices/CECDeviceMap.cpp +++ b/src/lib/devices/CECDeviceMap.cpp @@ -235,10 +235,11 @@ void CCECDeviceMap::FilterActive(CECDEVICEVEC &devices) void CCECDeviceMap::FilterTypes(const cec_device_type_list &types, CECDEVICEVEC &devices) { + cec_device_type_list t(types);//silly, but needed to retain abi CECDEVICEVEC newDevices; for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++) { - if (types.IsSet((*it)->GetType())) + if (t.IsSet((*it)->GetType())) newDevices.push_back(*it); } devices = newDevices; @@ -258,6 +259,7 @@ void CCECDeviceMap::FilterType(const cec_device_type type, CECDEVICEVEC &devices cec_logical_addresses CCECDeviceMap::ToLogicalAddresses(const CECDEVICEVEC &devices) { cec_logical_addresses addresses; + addresses.Clear(); for (CECDEVICEVEC::const_iterator it = devices.begin(); it != devices.end(); it++) addresses.Set((*it)->GetLogicalAddress()); return addresses; -- 2.34.1