diff options
-rw-r--r-- | AudioManagerDaemon/src/main.cpp | 1 | ||||
-rw-r--r-- | CHANGELOG | 5 | ||||
-rw-r--r-- | PluginControlInterface/include/ControlSender.h | 39 | ||||
-rw-r--r-- | PluginControlInterface/src/ControlSender.cpp | 82 | ||||
-rw-r--r-- | PluginRoutingInterfaceAsync/src/RoutingSenderAsync.cpp | 20 | ||||
-rw-r--r-- | includes/config.h | 10 |
6 files changed, 99 insertions, 58 deletions
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp index 54c4639..82bac88 100644 --- a/AudioManagerDaemon/src/main.cpp +++ b/AudioManagerDaemon/src/main.cpp @@ -33,6 +33,7 @@ //todo: there is a bug in the visible flags of sinks and sources. fix it. //todo: make sure all configurations are tested //todo: clean up startup sequences controller, command and routing interfaces---- +//todo: add getMainConnectionData in commandreceive interface to retrieve infos about mainconnections #include <config.h> #include <SocketHandler.h> #ifdef WITH_DBUS_WRAPPER @@ -1,3 +1,8 @@ +commit 2ddacca29eccd4192add2b17ad6af357b52ea29b +Author: Frank Herchet <frank.fh.herchet@bmw.de> + + * fix some methods in CAmTelnetMenuHelper + commit a0042153abf05408409d06c5183efe0905b18055 Author: Frank Herchet <frank.fh.herchet@bmw.de> 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) diff --git a/PluginRoutingInterfaceAsync/src/RoutingSenderAsync.cpp b/PluginRoutingInterfaceAsync/src/RoutingSenderAsync.cpp index 0b0b027..5027452 100644 --- a/PluginRoutingInterfaceAsync/src/RoutingSenderAsync.cpp +++ b/PluginRoutingInterfaceAsync/src/RoutingSenderAsync.cpp @@ -247,7 +247,7 @@ pPool(pool), // //a timeout happened if(errno == ETIMEDOUT) { - logError("Worker::timedWait timeout waiting error"); + logInfo("Worker::timedWait timed out - no bug !"); return (false); } else //failure in waiting, nevertheless, we quit the thread... @@ -768,12 +768,12 @@ std::vector<am_Sink_s> AsyncRoutingSender::createSinkTable() std::vector<am_MainSoundProperty_s> listMainSoundProperties; am_MainSoundProperty_s msp; - msp.type=MSP_BASS; - msp.value=5; + msp.type = MSP_BASS; + msp.value = 5; listMainSoundProperties.push_back(msp); - msp.type=MSP_MID; + msp.type = MSP_MID; listMainSoundProperties.push_back(msp); - msp.type=MSP_TREBLE; + msp.type = MSP_TREBLE; listMainSoundProperties.push_back(msp); for (int16_t i = 0; i <= 10; i++) { @@ -787,11 +787,11 @@ std::vector<am_Sink_s> AsyncRoutingSender::createSinkTable() item.available.availability = A_AVAILABLE; item.available.availabilityReason = AR_UNKNOWN; item.listSoundProperties.push_back(sp); - item.listMainSoundProperties=listMainSoundProperties; + item.listMainSoundProperties = listMainSoundProperties; item.visible = true; item.listConnectionFormats.push_back(CF_ANALOG); - item.muteState=MS_MUTED; - item.mainVolume=0; + item.muteState = MS_MUTED; + item.mainVolume = 0; table.push_back(item); } return (table); @@ -831,7 +831,7 @@ void AsyncRoutingSender::insertConnectionSafe(am_connectionID_t connectionID, am void AsyncRoutingSender::removeHandleSafe(uint16_t handle) { pthread_mutex_lock(&mMapHandleWorkerMutex); - if (mMapHandleWorker.erase(handle)) + if (!mMapHandleWorker.erase(handle)) { logError("AsyncRoutingSender::removeHandle could not remove handle"); } @@ -841,7 +841,7 @@ void AsyncRoutingSender::removeHandleSafe(uint16_t handle) void AsyncRoutingSender::removeConnectionSafe(am_connectionID_t connectionID) { pthread_mutex_lock(&mMapConnectionMutex); - if (mMapConnectionIDRoute.erase(connectionID)) + if (!mMapConnectionIDRoute.erase(connectionID)) { logError("AsyncRoutingSender::removeConnectionSafe could not remove connection"); } diff --git a/includes/config.h b/includes/config.h index 0ba258a..a055ddd 100644 --- a/includes/config.h +++ b/includes/config.h @@ -1,7 +1,7 @@ #ifndef _CONFIG_H #define _CONFIG_H -#define DAEMONVERSION "ver-0.0.1-37-ga004215" +#define DAEMONVERSION "ver-0.0.9-14-g2ddacca" #define WITH_DBUS_WRAPPER #define WITH_SOCKETHANDLER_LOOP @@ -10,9 +10,9 @@ #define WITH_TELNET #define GLIB_DBUS_TYPES_TOLERANT -#define DEFAULT_PLUGIN_COMMAND_DIR "/home/demo/git/AudioManager/bin/plugins/command" -#define DEFAULT_PLUGIN_ROUTING_DIR "/home/demo/git/AudioManager/bin/plugins/routing" -#define CONTROLLER_PLUGIN "/home/demo/git/AudioManager/bin/plugins/control/libPluginControlInterface.so" +#define DEFAULT_PLUGIN_COMMAND_DIR "/home/christian/workspace/AudioManager/bin/plugins/command" +#define DEFAULT_PLUGIN_ROUTING_DIR "/home/christian/workspace/AudioManager/bin/plugins/routing" +#define CONTROLLER_PLUGIN "/home/christian/workspace/AudioManager/bin/plugins/control/libPluginControlInterface.so" #define DEFAULT_TELNETPORT 6060 #define MAX_TELNETCONNECTIONS 3 @@ -20,6 +20,6 @@ #define DBUS_SERVICE_PREFIX "org.genivi.audiomanager" #define DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager" -#define INTROSPECTION_COMMAND_XML_FILE "/home/demo/git/AudioManager/includes/dbus/CommandInterface.xml" +#define INTROSPECTION_COMMAND_XML_FILE "/home/christian/workspace/AudioManager/includes/dbus/CommandInterface.xml" #endif /* _CONFIG_H */ |