cec: fixed abi
authorLars Op den Kamp <lars@opdenkamp.eu>
Fri, 11 May 2012 07:16:06 +0000 (09:16 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Fri, 11 May 2012 07:50:13 +0000 (09:50 +0200)
include/cectypes.h
src/lib/CECProcessor.cpp
src/lib/LibCEC.cpp
src/lib/LibCEC.h
src/lib/adapter/USBCECAdapterCommunication.cpp
src/lib/devices/CECDeviceMap.cpp

index 759eb4fa50c941b24f3eaf27c8d2ecfdd4e6d600..d70fc81f7f50aa726eed8a916206564c47c067e2 100644 (file)
@@ -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;
index 0add41b67ca42cb3763ee54fffff890a151b528c..bce22c046cdcfb23c61dfabd0930999826553897 100644 (file)
@@ -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<cec_logical_address, CCECClient *>::const_iterator client = m_clients.begin(); client != m_clients.end(); client++)
     addresses.Set(client->first);
 
index daa0b551d4749f1f5bfdffd2d50139662e2066ed..a204a4bc1a4f7cb0d9c40bf8a8950f70adf72000 100644 (file)
@@ -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)) {}
index 6b23dacc55f2c84c487bc069690ccfddd303df7e..673b5258c9a3205d6b33414c8d7c105f4bece723 100644 (file)
@@ -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 &param);
+      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<cec_log_message> m_logBuffer;                  //UNUSED
+      PLATFORM::SyncedBuffer<cec_keypress>    m_keyBuffer;                  //UNUSED
+      PLATFORM::SyncedBuffer<cec_command>     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<CCECClient *> m_clients;
   };
 };
index b08801fae211a27d4756a586efb673e0c16f7d46..680918d3f427e9098487e81912164ef5ea9ea7fb 100644 (file)
@@ -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);
 }
 
index 2603e33d2de82fb22b37a71bcb880fc2f8754da9..558052732880d34d98d5fefd78d3066472cfa1c2 100644 (file)
@@ -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;