summaryrefslogtreecommitdiff
path: root/AudioManagerUtilities/include
diff options
context:
space:
mode:
Diffstat (limited to 'AudioManagerUtilities/include')
-rw-r--r--AudioManagerUtilities/include/CAmCommonAPIWrapper.h185
-rw-r--r--AudioManagerUtilities/include/CAmSocketHandler.h54
2 files changed, 120 insertions, 119 deletions
diff --git a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h
index 82328d6..a83b5b3 100644
--- a/AudioManagerUtilities/include/CAmCommonAPIWrapper.h
+++ b/AudioManagerUtilities/include/CAmCommonAPIWrapper.h
@@ -133,24 +133,25 @@ public:
* @return Pointer to the socket handler.
*/
CAmSocketHandler *getSocketHandler() const { return mpSocketHandler; }
-#if COMMONAPI_VERSION_NUMBER >= 300
- /**
- * \brief Register stub objects.
- *
- * Example: std::shared_ptr<ConcreteStubClass> aStub;
- * registerService( aStub, "local", "com.your_company.instance_name", "service-name");
- *
- * @param shStub: Shared pointer to a stub instance
- * @param domain: A string with the domain name, usually "local"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- * @param connectionId: A string connection id, which is used by CommonAPI to group applications
- *
- */
- template <class TStubImp> bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance, const CommonAPI::ConnectionId_t & connectionId)
- {
- return mRuntime->registerService(domain, instance, shStub, connectionId);
- }
-#endif
+
+ /**
+ * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
+ *
+ *
+ * Example: std::shared_ptr<ConcreteStubClass> aStub;
+ * registerService( aStub, "local", "com.your_company.instance_name", "service-name");
+ *
+ * @param shStub: Shared pointer to a stub instance
+ * @param domain: A string with the domain name, usually "local"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ * @param connectionId: A string connection id, which is used by CommonAPI to group applications
+ *
+ */
+ template <class TStubImp> bool __attribute__((deprecated)) registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/)
+ {
+ return mRuntime->registerService(domain, instance, shStub, mContext);
+ }
+
/**
* \brief Register stub objects.
*
@@ -181,61 +182,59 @@ public:
}
/**
- * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
- *
- * Register stub objects.
- *
- * Example: std::shared_ptr<ConcreteStubClass> aStub;
- * registerService( aStub, "local:com.your_company.interface_name:com.your_company.instance_name");
- *
- * @param shStub: Shared pointer to a stub instance
- * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
- *
- */
- template <class TStubImp> bool __attribute__((deprecated)) registerStub(const std::shared_ptr<TStubImp> & shStub, const std::string & address)
- {
- std::vector<std::string> parts = CommonAPI::split(address, ':');
- assert(parts.size()==3);
-
- return registerService(shStub, parts[0], parts[2]);
- }
-
- /**
- * \brief Deprecated method. Instead you should use bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance).
- *
- * Unregister stub objects.
- *
- * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
- *
- */
- bool __attribute__((deprecated)) unregisterStub(const std::string & address)
- {
- std::vector<std::string> parts = CommonAPI::split(address, ':');
- assert(parts.size()==3);
-
- return unregisterService(parts[0], parts[1], parts[2]);
- }
-
-#if COMMONAPI_VERSION_NUMBER >= 300
- /**
- * \brief Build proxy objects.
- *
- * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name", "client-name");
- *
- * @param domain: A string with the domain name, usually "local"
- * @param instance: Common-api instance string as example "com.your_company.instance_name"
- * @param connectionId: A string connection id, which is used by CommonAPI to group applications
- *
- * @return A proxy object.
- */
- template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
- std::shared_ptr<ProxyClass<AttributeExtensions...>> buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t & connectionId)
- {
- return mRuntime->buildProxy<ProxyClass>(domain, instance, connectionId);
- }
-#endif
-
- /**
+ * \brief Deprecated method. Instead you should use bool registerService(const std::shared_ptr<TStubImp> & shStub, const std::string & domain, const std::string & instance).
+ *
+ * Register stub objects.
+ *
+ * Example: std::shared_ptr<ConcreteStubClass> aStub;
+ * registerService( aStub, "local:com.your_company.interface_name:com.your_company.instance_name");
+ *
+ * @param shStub: Shared pointer to a stub instance
+ * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
+ *
+ */
+ template <class TStubImp> bool __attribute__((deprecated)) registerStub(const std::shared_ptr<TStubImp> & shStub, const std::string & address)
+ {
+ std::vector<std::string> parts = CommonAPI::split(address, ':');
+ assert(parts.size()==3);
+
+ return registerService(shStub, parts[0], parts[2]);
+ }
+
+ /**
+ * \brief Deprecated method. Instead you should use bool unregisterService(const std::string &domain, const std::string &interface, const std::string &instance).
+ *
+ * Unregister stub objects.
+ *
+ * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
+ *
+ */
+ bool __attribute__((deprecated)) unregisterStub(const std::string & address)
+ {
+ std::vector<std::string> parts = CommonAPI::split(address, ':');
+ assert(parts.size()==3);
+
+ return unregisterService(parts[0], parts[1], parts[2]);
+ }
+
+ /**
+ * \brief Deprecated method. This class is used only in single connection applications and no connectionId is needed. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
+ *
+ * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name", "client-name");
+ *
+ * @param domain: A string with the domain name, usually "local"
+ * @param instance: Common-api instance string as example "com.your_company.instance_name"
+ * @param connectionId: A string connection id, which is used by CommonAPI to group applications
+ *
+ * @return A proxy object.
+ */
+ template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
+ std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string &domain, const std::string &instance, const CommonAPI::ConnectionId_t __attribute__((__unused__)) & /*connectionId*/)
+ {
+ return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
+ }
+
+ /**
* \brief Build proxy objects.
*
* Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local", "com.your_company.instance_name");
@@ -250,26 +249,26 @@ public:
{
return mRuntime->buildProxy<ProxyClass>(domain, instance, mContext);
}
-
-
- /**
- * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
- *
- * Build proxy objects.
- * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local:com.your_company.interface_name:com.your_company.instance_name");
- *
- * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
- *
- * @return A proxy object.
- */
- template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
- std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string & address)
- {
- std::vector<std::string> parts=CommonAPI::split(address, ':');
- assert(parts.size()==3);
-
- return buildProxy<ProxyClass>(parts[0], parts[2]);
- }
+
+
+ /**
+ * \brief Deprecated method. Instead you should use buildProxy(const std::string &domain, const std::string &instance).
+ *
+ * Build proxy objects.
+ * Example: std::shared_ptr<AProxyClass<>> aProxy = buildProxy<AProxyClass>("local:com.your_company.interface_name:com.your_company.instance_name");
+ *
+ * @param address: Complete common-api address as example "local:com.your_company.interface_name:com.your_company.instance_name"
+ *
+ * @return A proxy object.
+ */
+ template<template<typename ...> class ProxyClass, typename ... AttributeExtensions>
+ std::shared_ptr<ProxyClass<AttributeExtensions...>> __attribute__((deprecated)) buildProxy(const std::string & address)
+ {
+ std::vector<std::string> parts=CommonAPI::split(address, ':');
+ assert(parts.size()==3);
+
+ return buildProxy<ProxyClass>(parts[0], parts[2]);
+ }
};
diff --git a/AudioManagerUtilities/include/CAmSocketHandler.h b/AudioManagerUtilities/include/CAmSocketHandler.h
index 717f792..db3207e 100644
--- a/AudioManagerUtilities/include/CAmSocketHandler.h
+++ b/AudioManagerUtilities/include/CAmSocketHandler.h
@@ -215,6 +215,15 @@ public:
*/
class CAmSocketHandler
{
+ typedef enum:uint8_t
+ {
+ ADD = 0u, // new, uninitialized element which needs to be added to ppoll array
+ UPDATE = 1u, // update of event information therefore update ppoll array
+ VALID = 2u, // it is a valid element in ppoll array
+ REMOVE = 3u, // remove from ppoll array and internal map
+ INVALID = 4u // uninit element requested to be removed from internal map only
+ } poll_states_e;
+
struct sh_poll_s //!<struct that holds information about polls
{
sh_pollHandle_t handle; //!<handle to uniquely adress a filedesriptor
@@ -224,9 +233,10 @@ class CAmSocketHandler
std::function<bool(const sh_pollHandle_t handle, void* userData)> checkCB; //check callback
std::function<bool(const sh_pollHandle_t handle, void* userData)> dispatchCB; //dispatch callback
void* userData;
+ poll_states_e state;
sh_poll_s() :
- handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0)
+ handle(0), pollfdValue(), prepareCB(), firedCB(), checkCB(), dispatchCB(), userData(0), state(ADD)
{}
};
@@ -244,7 +254,7 @@ class CAmSocketHandler
sh_timer_s() :
handle(0)
#ifdef WITH_TIMERFD
- , fd(0)
+ , fd(-1)
#endif
, countdown(), callback(), userData(0)
{}
@@ -271,42 +281,43 @@ class CAmSocketHandler
};
typedef std::reverse_iterator<sh_timer_s> rListTimerIter; //!<typedef for reverseiterator on timer lists
- typedef std::vector<pollfd> VectorListPollfd_t; //!<vector of filedescriptors
- typedef std::vector<sh_poll_s> VectorListPoll_t; //!<list for the callbacks
+ typedef std::vector<pollfd> VectorPollfd_t; //!<vector of filedescriptors
+ typedef std::map<int, sh_poll_s> MapShPoll_t; //!<list for the callbacks
typedef std::vector<sh_signal_s> VectorSignalHandlers_t; //!<list for the callbacks
typedef enum:uint8_t
{
- NO_ERROR = 0u, // OK
- PIPE_ERROR = 1u, // Pipe error
- FD_ERROR = 2u, // Invalid file descriptor
- SFD_ERROR = 4u,
+ NO_ERROR = 0u, // OK
+ FD_ERROR = 1u, // Invalid file descriptor
+ MT_ERROR = 2u // Multi-thread issue
} internal_codes_e;
typedef uint8_t internal_codes_t;
- int mPipe[2];
+ int mEventFd;
+ int mSignalFd;
bool mDispatchDone; //this starts / stops the mainloop
+ MapShPoll_t mMapShPoll; //!<list that holds all information for the ppoll
sh_identifier_s mSetPollKeys; //!A set of all used ppoll keys
- VectorListPoll_t mListPoll; //!<list that holds all information for the ppoll
sh_identifier_s mSetTimerKeys; //!A set of all used timer keys
std::list<sh_timer_s> mListTimer; //!<list of all timers
+#ifndef WITH_TIMERFD
std::list<sh_timer_s> mListActiveTimer; //!<list of all currently active timers
+#endif
sh_identifier_s mSetSignalhandlerKeys; //!A set of all used signal handler keys
VectorSignalHandlers_t mSignalHandlers;
- bool mRecreatePollfds; //!<when this is true, the poll list needs to be recreated
internal_codes_t mInternalCodes;
- sh_pollHandle_t mSignalFdHandle;
#ifndef WITH_TIMERFD
timespec mStartTime; //!<here the actual time is saved for timecorrection
#endif
+
private:
bool fdIsValid(const int fd) const;
+ void wakeupWorker(const std::string & func, const uint64_t value = 1u);
timespec* insertTime(timespec& buffertime);
#ifdef WITH_TIMERFD
am_Error_e createTimeFD(const itimerspec & timeouts, int & fd);
-
#else
void timerUp();
void timerCorrection();
@@ -408,28 +419,21 @@ private:
* @param a
* @return
*/
- inline static void fire(sh_poll_s& a);
-
- /**
- * functor to return all fired events
- * @param a
- * @return
- */
- inline static bool eventFired(const pollfd& a);
+ inline static void fire(const sh_poll_s& a);
/**
* functor to help find the items that do not need dispatching
* @param a
* @return
*/
- inline static bool noDispatching(const sh_poll_s& a);
+ inline static bool noDispatching(const sh_poll_s* a);
/**
* checks if dispatching is already finished
* @param a
* @return
*/
- inline static bool dispatchingFinished(const sh_poll_s& a);
+ inline static bool dispatchingFinished(const sh_poll_s* a);
/**
* timer fire callback
@@ -444,9 +448,7 @@ private:
* @return handle
*/
bool nextHandle(sh_identifier_s & handle);
-
- am_Error_e getFDPollData(const sh_pollHandle_t handle, sh_poll_s & outPollData);
-
+
public:
CAmSocketHandler();