diff options
author | christian mueller <christian.ei.mueller@bmw.de> | 2012-02-09 17:20:18 +0100 |
---|---|---|
committer | christian mueller <christian.ei.mueller@bmw.de> | 2012-02-09 17:20:18 +0100 |
commit | e124310a45e6e7798a077fa44ef3ee518193b2cf (patch) | |
tree | 5fb3b14934438d567ee76f9dc978a326542ddbd7 /PluginControlInterface | |
parent | 2ddacca29eccd4192add2b17ad6af357b52ea29b (diff) | |
download | audiomanager-e124310a45e6e7798a077fa44ef3ee518193b2cf.tar.gz |
* modify RoutingSender Async to match with TestHMI
* modify ControlSenderPlugin to have dummy behaviour
Diffstat (limited to 'PluginControlInterface')
-rw-r--r-- | PluginControlInterface/include/ControlSender.h | 39 | ||||
-rw-r--r-- | PluginControlInterface/src/ControlSender.cpp | 82 |
2 files changed, 78 insertions, 43 deletions
diff --git a/PluginControlInterface/include/ControlSender.h b/PluginControlInterface/include/ControlSender.h index d21856b..bd8d88f 100644 --- a/PluginControlInterface/include/ControlSender.h +++ b/PluginControlInterface/include/ControlSender.h @@ -96,20 +96,49 @@ private: class findHandle { - am_Handle_s mHandle; + handleStatus mHandle; public: - explicit findHandle(am_Handle_s handle) : + explicit findHandle(handleStatus handle) : mHandle(handle) { } - bool operator()(handleStatus* handle) const + bool operator()(const handleStatus& handle) const { - return (handle->handle.handle == mHandle.handle); + return (handle.handle.handle == mHandle.handle.handle); + } + }; + + struct checkHandle + { + + handleStatus mHandleStatus; + explicit checkHandle(const handleStatus& value) : + mHandleStatus(value) + { + } + + bool operator()(const handleStatus &value) + { + return !value.status; + } + }; + + struct checkMainConnectionID + { + am_MainConnection_s mMainConnection; + explicit checkMainConnectionID(const am_MainConnection_s& mainConnection) : + mMainConnection(mainConnection) + { + } + bool operator()(const am_MainConnection_s& mainConnection) + { + if (mMainConnection.connectionID == mainConnection.connectionID) + return true; + return false; } }; std::vector<mainConnectionSet> mListOpenConnections; - ; }; #endif /* CONTROLSENDER_H_ */ diff --git a/PluginControlInterface/src/ControlSender.cpp b/PluginControlInterface/src/ControlSender.cpp index c65059d..4592459 100644 --- a/PluginControlInterface/src/ControlSender.cpp +++ b/PluginControlInterface/src/ControlSender.cpp @@ -26,6 +26,7 @@ #include "ControlSender.h" #include "control/ControlReceiveInterface.h" #include <cassert> +#include <algorithm> using namespace am; @@ -40,8 +41,7 @@ extern "C" void destroyControlPluginInterface(ControlSendInterface* controlSendI } ControlSenderPlugin::ControlSenderPlugin() : - mControlReceiveInterface(NULL), - mListOpenConnections() + mControlReceiveInterface(NULL), mListOpenConnections() { } @@ -83,29 +83,40 @@ am_Error_e ControlSenderPlugin::hookUserConnectionRequest(const am_sourceID_t so for (; it != listRoutes[0].route.end(); ++it) { mControlReceiveInterface->connect(handle, connectionID, it->connectionFormat, it->sourceID, it->sinkID); - //this is primitive and works only for one connect at a time... otherwise the handles get mixed up! handleStatus status; - status.handle=handle; - status.status=false; + status.handle = handle; + status.status = false; listHandleStaus.push_back(status); } am_MainConnection_s mainConnectionData; - mainConnectionData.connectionID=0; - mainConnectionData.connectionState=CS_CONNECTING; - mainConnectionData.delay=0; - mainConnectionData.route=listRoutes[0]; - mControlReceiveInterface->enterMainConnectionDB(mainConnectionData,mainConnectionID); + mainConnectionData.connectionID = 0; + mainConnectionData.connectionState = CS_CONNECTING; + mainConnectionData.delay = 0; + mainConnectionData.route = listRoutes[0]; + mControlReceiveInterface->enterMainConnectionDB(mainConnectionData, mainConnectionID); mainConnectionSet set; - set.connectionID=mainConnectionID; - set.listHandleStaus=listHandleStaus; + set.connectionID = mainConnectionID; + set.listHandleStaus = listHandleStaus; mListOpenConnections.push_back(set); return E_OK; } am_Error_e ControlSenderPlugin::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) { - (void) connectionID; - return E_NOT_USED; +// //first check if there is a connectionID like that +// std::vector<am_MainConnection_s> listMainConnections; +// mControlReceiveInterface->getListMainConnections(listMainConnections); +// std::vector<am_MainConnection_s>::iterator it(listMainConnections.begin()); +// am_MainConnection_s mainConnection; +// mainConnection=connectionID; +// if(listMainConnections.end()==(it=std::find(listMainConnections.begin(),listMainConnections.end(),checkMainConnectionID(mainConnection)))) +// return E_NON_EXISTENT; +// +// std::vector<am_RoutingElement_s>::iterator routeIterator(it->route.route.begin()); +// for(;routeIterator!=it->route.route.end();++routeIterator) +// { +// mControlReceiveInterface->disconnect(handle,routeIterator->) +// } } am_Error_e ControlSenderPlugin::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty) @@ -270,31 +281,26 @@ void ControlSenderPlugin::hookSystemTimingInformationChanged(const am_mainConnec void ControlSenderPlugin::cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) { - (void)errorID; - //here is no error check !!!! - //\todo: add error check here - //\todo: algorith can be much better written here + (void) errorID; + //\todo:error checking std::vector<mainConnectionSet>::iterator it(mListOpenConnections.begin()); -// for(;it!=mListOpenConnections.end();++it) -// { -// std::vector<handleStatus>::iterator hit; -// hit=std::find_if(it->listHandleStaus.begin(),it->listHandleStaus.end(),findHandle); -// } -// -// bool allOk = true; -// std::list<handleStack>::iterator it(mListOpenHandles.begin()); -// -// for (; it != mListOpenHandles.end(); ++it) -// { -// if (it->handle.handle == handle.handle) -// it->ok = true; -// allOk = allOk && it->ok; -// } -// -// if (allOk) -// { -// mControlReceiveInterface->changeMainConnectionStateDB(mCurrentID,CS_CONNECTED); -// } + for (; it != mListOpenConnections.end(); ++it) + { + std::vector<handleStatus>::iterator hit; + handleStatus status; + status.status=true; + status.handle=handle; + hit = std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), findHandle(status)); + if (hit == it->listHandleStaus.end()) + continue; + hit->status=true; + if (it->listHandleStaus.end()==std::find_if(it->listHandleStaus.begin(),it->listHandleStaus.end(),checkHandle(status))) + { + mControlReceiveInterface->changeMainConnectionStateDB(it->connectionID, CS_CONNECTED); + mListOpenConnections.erase(it); + break; + } + } } void ControlSenderPlugin::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) |