From: Lars Op den Kamp Date: Thu, 12 Jan 2012 16:27:43 +0000 (+0100) Subject: cec: added typedefs for the callback methods X-Git-Tag: upstream/2.2.0~1^2~41^2~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c3039d2e99a31c129c982d271f25c9c56e353643;p=deb_libcec.git cec: added typedefs for the callback methods --- diff --git a/include/cectypes.h b/include/cectypes.h index 3b81bdc..b8ae24d 100644 --- a/include/cectypes.h +++ b/include/cectypes.h @@ -866,29 +866,33 @@ typedef struct cec_logical_addresses #endif } cec_logical_addresses; -struct ICECCallbacks +typedef int (__cdecl *CBCecLogMessageType)(const CEC::cec_log_message &); +typedef int (__cdecl* CBCecKeyPressType)(const cec_keypress &key); +typedef int (__cdecl* CBCecCommandType)(const cec_command &command); + +typedef struct ICECCallbacks { /*! * @brief Transfer a log message from libCEC to the client. * @param message The message to transfer. * @return 1 when ok, 0 otherwise. */ - int (*CecLogMessage)(const cec_log_message &message); + CBCecLogMessageType CBCecLogMessage; /*! * @brief Transfer a keypress from libCEC to the client. * @param key The keypress to transfer. * @return 1 when ok, 0 otherwise. */ - int (*CecKeyPress)(const cec_keypress &key); + CBCecKeyPressType CBCecKeyPress; /*! * @brief Transfer a CEC command from libCEC to the client. * @param command The command to transfer. * @return 1 when ok, 0 otherwise. */ - int (*CecCommand)(const cec_command &command); -}; + CBCecCommandType CBCecCommand; +} ICECCallbacks; #ifdef UNUSED #elif defined(__GNUC__) diff --git a/src/lib/LibCEC.cpp b/src/lib/LibCEC.cpp index a8b8c70..55af180 100644 --- a/src/lib/LibCEC.cpp +++ b/src/lib/LibCEC.cpp @@ -347,7 +347,7 @@ void CLibCEC::AddLog(cec_log_level level, const string &strMessage) snprintf(message.message, sizeof(message.message), "%s", strMessage.c_str()); if (m_callbacks) - m_callbacks->CecLogMessage(message); + m_callbacks->CBCecLogMessage(message); else m_logBuffer.Push(message); } @@ -357,7 +357,7 @@ void CLibCEC::AddKey(cec_keypress &key) { CLockObject lock(&m_mutex); if (m_callbacks) - m_callbacks->CecKeyPress(key); + m_callbacks->CBCecKeyPress(key); else m_keyBuffer.Push(key); m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN; @@ -375,7 +375,7 @@ void CLibCEC::AddKey(void) key.keycode = m_iCurrentButton; if (m_callbacks) - m_callbacks->CecKeyPress(key); + m_callbacks->CBCecKeyPress(key); else m_keyBuffer.Push(key); m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN; @@ -388,7 +388,7 @@ void CLibCEC::AddCommand(const cec_command &command) CLockObject lock(&m_mutex); if (m_callbacks) { - m_callbacks->CecCommand(command); + m_callbacks->CBCecCommand(command); } else if (m_commandBuffer.Push(command)) { diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 43b0119..5858eb6 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -177,9 +177,9 @@ int CecCommand(const cec_command &UNUSED(command)) void EnableCallbacks(ICECAdapter *adapter) { - g_callbacks.CecLogMessage = &CecLogMessage; - g_callbacks.CecKeyPress = &CecKeyPress; - g_callbacks.CecCommand = &CecCommand; + g_callbacks.CBCecLogMessage = &CecLogMessage; + g_callbacks.CBCecKeyPress = &CecKeyPress; + g_callbacks.CBCecCommand = &CecCommand; adapter->EnableCallbacks(&g_callbacks); }