cec: added typedefs for the callback methods
authorLars Op den Kamp <lars@opdenkamp.eu>
Thu, 12 Jan 2012 16:27:43 +0000 (17:27 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Thu, 12 Jan 2012 16:28:31 +0000 (17:28 +0100)
include/cectypes.h
src/lib/LibCEC.cpp
src/testclient/main.cpp

index 3b81bdce41444c62a2b8280da875856e88e1b779..b8ae24dda13e70102fe705b9534d7603a72af50c 100644 (file)
@@ -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__)
index a8b8c70e5af975830c1415823a091e1990f416cb..55af1803b7c1d951a9937e2df2adc8d420214911 100644 (file)
@@ -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))
   {
index 43b01192a1e3f072ba775b297f40c6f3133250d1..5858eb6689050a7b2f3f01ed5d471488e7d4f226 100644 (file)
@@ -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);
 }