summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon
diff options
context:
space:
mode:
Diffstat (limited to 'AudioManagerDaemon')
-rw-r--r--AudioManagerDaemon/include/ControlReceiver.h6
-rw-r--r--AudioManagerDaemon/include/Router.h2
-rw-r--r--AudioManagerDaemon/src/ControlReceiver.cpp15
-rw-r--r--AudioManagerDaemon/src/DBusWrapper.cpp55
-rw-r--r--AudioManagerDaemon/src/DatabaseHandler.cpp4
-rw-r--r--AudioManagerDaemon/src/DatabaseObserver.cpp2
-rw-r--r--AudioManagerDaemon/src/Router.cpp52
-rw-r--r--AudioManagerDaemon/src/RoutingReceiver.cpp4
-rw-r--r--AudioManagerDaemon/src/RoutingSender.cpp8
-rw-r--r--AudioManagerDaemon/src/TelnetServer.cpp8
-rw-r--r--AudioManagerDaemon/src/main.cpp20
-rw-r--r--AudioManagerDaemon/test/controlInterface/MockInterfaces.h9
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp9
-rw-r--r--AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h4
-rw-r--r--AudioManagerDaemon/test/database/MockInterfaces.h3
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.cpp4
-rw-r--r--AudioManagerDaemon/test/database/databaseTest.h4
-rw-r--r--AudioManagerDaemon/test/routing/MockInterfaces.h2
-rw-r--r--AudioManagerDaemon/test/routing/routingTest.cpp196
-rw-r--r--AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h9
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp12
-rw-r--r--AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h3
-rw-r--r--AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp31
23 files changed, 272 insertions, 190 deletions
diff --git a/AudioManagerDaemon/include/ControlReceiver.h b/AudioManagerDaemon/include/ControlReceiver.h
index ac2168c..a40f800 100644
--- a/AudioManagerDaemon/include/ControlReceiver.h
+++ b/AudioManagerDaemon/include/ControlReceiver.h
@@ -35,6 +35,7 @@ class SocketHandler;
class DatabaseHandler;
class RoutingSender;
class CommandSender;
+class Router;
/**
* This class is used to receive all commands from the control interface
@@ -42,8 +43,8 @@ class CommandSender;
class ControlReceiver: public ControlReceiveInterface
{
public:
- ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler);
- ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender);
+ ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler, Router* iRouter);
+ ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, Router* iRouter);
virtual ~ControlReceiver();
am_Error_e getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s>& returnList);
am_Error_e connect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID);
@@ -116,6 +117,7 @@ private:
RoutingSender* mRoutingSender; //!< pointer to the routing send interface.
CommandSender* mCommandSender; //!< pointer to the command send interface
SocketHandler* mSocketHandler; //!< pointer to the socketHandler
+ Router* mRouter; //!< pointer to the Router
};
}
diff --git a/AudioManagerDaemon/include/Router.h b/AudioManagerDaemon/include/Router.h
index 68e33b6..ab7efab 100644
--- a/AudioManagerDaemon/include/Router.h
+++ b/AudioManagerDaemon/include/Router.h
@@ -41,7 +41,7 @@ public:
virtual ~Router();
private:
- am_Error_e findBestWay(std::vector<am_RoutingElement_s>& listRoute, std::vector<am_RoutingElement_s>::iterator routeIterator, std::vector<am_gatewayID_t>::iterator gatewayIterator, int choiceNumber);
+ am_Error_e findBestWay(std::vector<am_RoutingElement_s>& listRoute, std::vector<am_RoutingElement_s>::iterator routeIterator, std::vector<am_gatewayID_t>::iterator gatewayIterator);
void listPossibleConnectionFormats(const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_ConnectionFormat_e>& listFormats) const;
void listRestrictedOutputFormatsGateways(const am_gatewayID_t gatewayID, const am_ConnectionFormat_e sinkConnectionFormat, std::vector<am_ConnectionFormat_e>& listFormats) const;
DatabaseHandler* mDatabaseHandler;
diff --git a/AudioManagerDaemon/src/ControlReceiver.cpp b/AudioManagerDaemon/src/ControlReceiver.cpp
index 4900ce7..ac51be7 100644
--- a/AudioManagerDaemon/src/ControlReceiver.cpp
+++ b/AudioManagerDaemon/src/ControlReceiver.cpp
@@ -28,6 +28,7 @@
#include "DatabaseHandler.h"
#include "RoutingSender.h"
#include "CommandSender.h"
+#include "Router.h"
#include <assert.h>
#include <dlt/dlt.h>
@@ -35,26 +36,30 @@ DLT_IMPORT_CONTEXT(AudioManager)
using namespace am;
-ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler) :
+ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, SocketHandler *iSocketHandler, Router* iRouter) :
mDatabaseHandler(iDatabaseHandler), //
mRoutingSender(iRoutingSender), //
mCommandSender(iCommandSender), //
- mSocketHandler(iSocketHandler)
+ mSocketHandler(iSocketHandler), //
+ mRouter(iRouter)
{
assert(mDatabaseHandler!=NULL);
assert(mRoutingSender!=NULL);
assert(mCommandSender!=NULL);
assert(mSocketHandler!=NULL);
+ assert(mRouter!=NULL);
}
-ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender) :
+ControlReceiver::ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, CommandSender *iCommandSender, Router* iRouter) :
mDatabaseHandler(iDatabaseHandler), //
mRoutingSender(iRoutingSender), //
- mCommandSender(iCommandSender)
+ mCommandSender(iCommandSender), //
+ mRouter(iRouter)
{
assert(mDatabaseHandler!=NULL);
assert(mRoutingSender!=NULL);
assert(mCommandSender!=NULL);
+ assert(mRouter!=NULL);
}
ControlReceiver::~ControlReceiver()
@@ -63,7 +68,7 @@ ControlReceiver::~ControlReceiver()
am_Error_e ControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t sourceID, const am_sinkID_t sinkID, std::vector<am_Route_s> & returnList)
{
- //todo: implement routing algorithm
+ mRouter->getRoute(onlyfree,sourceID,sinkID,returnList);
return E_NOT_USED;
}
diff --git a/AudioManagerDaemon/src/DBusWrapper.cpp b/AudioManagerDaemon/src/DBusWrapper.cpp
index 5b81792..94f0788 100644
--- a/AudioManagerDaemon/src/DBusWrapper.cpp
+++ b/AudioManagerDaemon/src/DBusWrapper.cpp
@@ -254,6 +254,7 @@ dbus_bool_t DBusWrapper::addWatch(DBusWatch *watch, void *userData)
dbus_bool_t DBusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
{
+ (void) userData;
int16_t event = 0;
sh_pollHandle_t handle = 0;
uint flags = dbus_watch_get_flags(watch);
@@ -261,8 +262,10 @@ dbus_bool_t DBusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
/* no watch flags for disabled watches */
if (dbus_watch_get_enabled(watch))
{
- if (flags & DBUS_WATCH_READABLE) event |= POLLIN;
- if (flags & DBUS_WATCH_WRITABLE) event |= POLLOUT;
+ if (flags & DBUS_WATCH_READABLE)
+ event |= POLLIN;
+ if (flags & DBUS_WATCH_WRITABLE)
+ event |= POLLOUT;
}
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::addWatchDelegate entered new watch, fd="), DLT_INT(dbus_watch_get_unix_fd(watch)), DLT_STRING("event flag="), DLT_INT(event));
@@ -274,6 +277,7 @@ dbus_bool_t DBusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
mMapHandleWatch.insert(std::make_pair(watch, handle));
return true;
}DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DBusWrapper::addWatchDelegate entering watch failed"));
+ return (true);
}
void DBusWrapper::removeWatch(DBusWatch *watch, void *userData)
@@ -285,9 +289,11 @@ void DBusWrapper::removeWatch(DBusWatch *watch, void *userData)
void DBusWrapper::removeWatchDelegate(DBusWatch *watch, void *userData)
{
+ (void) userData;
std::map<DBusWatch*, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
iterator = mMapHandleWatch.find(watch);
- if (iterator != mMapHandleWatch.end()) mSocketHandler->removeFDPoll(iterator->second);
+ if (iterator != mMapHandleWatch.end())
+ mSocketHandler->removeFDPoll(iterator->second);
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::removeWatch removed watch with handle"), DLT_INT(iterator->second));
mMapHandleWatch.erase(iterator);
}
@@ -301,18 +307,22 @@ void DBusWrapper::toogleWatch(DBusWatch *watch, void *userData)
void DBusWrapper::toogleWatchDelegate(DBusWatch *watch, void *userData)
{
+ (void) userData;
int16_t event = 0;
- int watchFD = dbus_watch_get_unix_fd(watch);
+ dbus_watch_get_unix_fd(watch);
uint flags = dbus_watch_get_flags(watch);
/* no watch flags for disabled watches */
if (dbus_watch_get_enabled(watch))
{
- if (flags & DBUS_WATCH_READABLE) event |= POLLIN;
- if (flags & DBUS_WATCH_WRITABLE) event |= POLLOUT;
+ if (flags & DBUS_WATCH_READABLE)
+ event |= POLLIN;
+ if (flags & DBUS_WATCH_WRITABLE)
+ event |= POLLOUT;
}
std::map<DBusWatch*, sh_pollHandle_t>::iterator iterator = mMapHandleWatch.begin();
iterator = mMapHandleWatch.find(watch);
- if (iterator != mMapHandleWatch.end()) mSocketHandler->updateEventFlags(iterator->second, event);
+ if (iterator != mMapHandleWatch.end())
+ mSocketHandler->updateEventFlags(iterator->second, event);
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::toogleWatchDelegate watch was toggeled"));
}
@@ -325,7 +335,8 @@ dbus_bool_t DBusWrapper::addTimeout(DBusTimeout *timeout, void* userData)
dbus_bool_t DBusWrapper::addTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
- if (!dbus_timeout_get_enabled(timeout)) return false;
+ if (!dbus_timeout_get_enabled(timeout))
+ return false;
//calculate the timeout in timeval
timespec pollTimeout;
@@ -359,6 +370,7 @@ void DBusWrapper::removeTimeout(DBusTimeout *timeout, void* userData)
void DBusWrapper::removeTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
+ (void) userData;
//get the pointer to the handle and remove the timer
sh_timerHandle_t* handle = (sh_timerHandle_t*) dbus_timeout_get_data(timeout);
mSocketHandler->removeTimer(*handle);
@@ -386,9 +398,12 @@ void DBusWrapper::toggleTimeout(DBusTimeout *timeout, void* userData)
bool am::DBusWrapper::dbusDispatchCallback(const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
bool returnVal = true;
dbus_connection_ref(mDbusConnection);
- if (dbus_connection_dispatch(mDbusConnection) == DBUS_DISPATCH_COMPLETE) returnVal = false;
+ if (dbus_connection_dispatch(mDbusConnection) == DBUS_DISPATCH_COMPLETE)
+ returnVal = false;
dbus_connection_unref(mDbusConnection);
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusDispatchCallback was called"));
return returnVal;
@@ -396,9 +411,12 @@ bool am::DBusWrapper::dbusDispatchCallback(const sh_pollHandle_t handle, void *u
bool am::DBusWrapper::dbusCheckCallback(const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
bool returnVal = false;
dbus_connection_ref(mDbusConnection);
- if (dbus_connection_get_dispatch_status(mDbusConnection) == DBUS_DISPATCH_DATA_REMAINS) returnVal = true;
+ if (dbus_connection_get_dispatch_status(mDbusConnection) == DBUS_DISPATCH_DATA_REMAINS)
+ returnVal = true;
dbus_connection_unref(mDbusConnection);
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusCheckCallback was called"));
return returnVal;
@@ -406,24 +424,31 @@ bool am::DBusWrapper::dbusCheckCallback(const sh_pollHandle_t handle, void *user
void am::DBusWrapper::dbusFireCallback(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
assert(userData!=NULL);
uint flags = 0;
- if (pollfd.revents & POLLIN) flags |= DBUS_WATCH_READABLE;
- if (pollfd.revents & POLLOUT) flags |= DBUS_WATCH_WRITABLE;
- if (pollfd.revents & POLLHUP) flags |= DBUS_WATCH_HANGUP;
- if (pollfd.revents & POLLERR) flags |= DBUS_WATCH_ERROR;
+ if (pollfd.revents & POLLIN)
+ flags |= DBUS_WATCH_READABLE;
+ if (pollfd.revents & POLLOUT)
+ flags |= DBUS_WATCH_WRITABLE;
+ if (pollfd.revents & POLLHUP)
+ flags |= DBUS_WATCH_HANGUP;
+ if (pollfd.revents & POLLERR)
+ flags |= DBUS_WATCH_ERROR;
DBusWatch *watch = (DBusWatch*) userData;
dbus_connection_ref(mDbusConnection);
- bool ok = dbus_watch_handle(watch, flags);
+ dbus_watch_handle(watch, flags);
dbus_connection_unref(mDbusConnection);
DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DBusWrapper::dbusFireCallback was called"));
}
void DBusWrapper::toggleTimeoutDelegate(DBusTimeout *timeout, void* userData)
{
+ (void) userData;
//get the pointer to the handle and remove the timer
sh_timerHandle_t* handle = (sh_timerHandle_t*) dbus_timeout_get_data(timeout);
diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp
index 5c834ee..fb1e5c6 100644
--- a/AudioManagerDaemon/src/DatabaseHandler.cpp
+++ b/AudioManagerDaemon/src/DatabaseHandler.cpp
@@ -2465,7 +2465,7 @@ am_Error_e am::DatabaseHandler::getListSinkConnectionFormats(const am_sinkID_t s
am_Error_e am::DatabaseHandler::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_ConnectionFormat_e> & listConnectionFormats) const
{
listConnectionFormats.clear();
- sqlite3_stmt* query = NULL, *qConnectionFormat = NULL, *qSoundProperty = NULL, *qMAinSoundProperty = NULL;
+ sqlite3_stmt* qConnectionFormat = NULL;
int eCode = 0;
am_ConnectionFormat_e tempConnectionFormat;
@@ -3109,8 +3109,6 @@ am_Error_e DatabaseHandler::changeConnectionTimingInformation(const am_connectio
}
//now we need to find all mainConnections that use the changed connection and update their timing
- am_timeSync_t tempDelay = 0;
- am_Error_e error;
int tempMainConnectionID;
//first get all route tables for all mainconnections
diff --git a/AudioManagerDaemon/src/DatabaseObserver.cpp b/AudioManagerDaemon/src/DatabaseObserver.cpp
index b09aee8..19e3ea2 100644
--- a/AudioManagerDaemon/src/DatabaseObserver.cpp
+++ b/AudioManagerDaemon/src/DatabaseObserver.cpp
@@ -72,6 +72,7 @@ void DatabaseObserver::newDomain(am_Domain_s domain)
void DatabaseObserver::newGateway(am_Gateway_s gateway)
{
+ (void) gateway;
//todo: implement something
}
@@ -99,6 +100,7 @@ void DatabaseObserver::removeDomain(am_domainID_t domainID)
void DatabaseObserver::removeGateway(am_gatewayID_t gatewayID)
{
+ (void) gatewayID;
//todo: implement something
}
diff --git a/AudioManagerDaemon/src/Router.cpp b/AudioManagerDaemon/src/Router.cpp
index aec487c..30d7f5f 100644
--- a/AudioManagerDaemon/src/Router.cpp
+++ b/AudioManagerDaemon/src/Router.cpp
@@ -113,8 +113,10 @@ am_Error_e Router::getRoute(const bool onlyfree, const am_sourceID_t sourceID, c
//Step through the routes and try to use always the best connectionFormat
std::vector<am_RoutingElement_s>::iterator routingInterator = actualRoutingElement.begin();
gatewayIterator = listGatewayID.begin();
- if (findBestWay(actualRoutingElement, routingInterator, gatewayIterator, 0) != E_OK)
+ if (findBestWay(actualRoutingElement, routingInterator, gatewayIterator) != E_OK)
+ {
continue;
+ }
//add the route to the list of routes...
actualRoute.sourceID = sourceID;
@@ -136,47 +138,61 @@ void Router::listPossibleConnectionFormats(const am_sourceID_t sourceID, const a
std::vector<am_ConnectionFormat_e>::iterator it = listSourceFormats.begin();
}
-am_Error_e Router::findBestWay(std::vector<am_RoutingElement_s> & listRoute, std::vector<am_RoutingElement_s>::iterator routeIterator, std::vector<am_gatewayID_t>::iterator gatewayIterator, int choiceNumber)
+am_Error_e Router::findBestWay(std::vector<am_RoutingElement_s> & listRoute, std::vector<am_RoutingElement_s>::iterator routeIterator, std::vector<am_gatewayID_t>::iterator gatewayIterator)
{
+ am_Error_e returnError = E_NOT_POSSIBLE;
std::vector<am_ConnectionFormat_e> listConnectionFormats;
+ std::vector<am_ConnectionFormat_e> listMergeConnectionFormats;
std::vector<am_ConnectionFormat_e> listPriorityConnectionFormats;
- //get best connection format for the first connection, now
+ std::vector<am_RoutingElement_s>::iterator nextIterator = routeIterator + 1;
+ //get best connection format
listPossibleConnectionFormats(routeIterator->sourceID, routeIterator->sinkID, listConnectionFormats);
- //if we get to the point that no choice makes sense, return ...
- if (choiceNumber >= (int) listConnectionFormats.size())
- return (E_NOT_POSSIBLE);
-
//if we have not just started, we need to take care about the gateways...
if (routeIterator != listRoute.begin())
{
//since we have to deal with Gateways, there are restrictions what connectionFormat we can take. So we need to take the subset of connections that are restricted:
std::vector<am_ConnectionFormat_e> listRestrictedConnectionFormats;
- std::insert_iterator<std::vector<am_ConnectionFormat_e> > inserter(listConnectionFormats, listConnectionFormats.begin());
+ std::insert_iterator<std::vector<am_ConnectionFormat_e> > inserter(listMergeConnectionFormats, listMergeConnectionFormats.begin());
std::vector<am_RoutingElement_s>::iterator tempIterator(routeIterator);
tempIterator--;
listRestrictedOutputFormatsGateways(*gatewayIterator, (tempIterator)->connectionFormat, listRestrictedConnectionFormats);
set_intersection(listConnectionFormats.begin(), listConnectionFormats.end(), listRestrictedConnectionFormats.begin(), listRestrictedConnectionFormats.end(), inserter);
gatewayIterator++;
}
+ else
+ {
+ listMergeConnectionFormats = listConnectionFormats;
+ }
//let the controller decide:
- mControlSender->getConnectionFormatChoice(routeIterator->sourceID, routeIterator->sinkID, listConnectionFormats, listPriorityConnectionFormats);
+ mControlSender->getConnectionFormatChoice(routeIterator->sourceID, routeIterator->sinkID, listMergeConnectionFormats, listPriorityConnectionFormats);
+
+ //we have the list sorted after prios - now we try one after the other with the next part of the route
+ std::vector<am_ConnectionFormat_e>::iterator connectionFormatIterator = listPriorityConnectionFormats.begin();
- //go back one step, if we cannot find a format and take the next best!
- if (listPriorityConnectionFormats.empty())
+ //here we need to check if we are at the end and stop
+ if (nextIterator == listRoute.end())
{
- findBestWay(listRoute, --routeIterator, --gatewayIterator, ++choiceNumber);
+ if (!listPriorityConnectionFormats.empty())
+ {
+ routeIterator->connectionFormat = listPriorityConnectionFormats.front();
+ return E_OK;
+ }
+ else
+ return E_NOT_POSSIBLE;
}
- routeIterator->connectionFormat = listPriorityConnectionFormats.at(choiceNumber);
-
- //ok, we are through and found a way, if not, take the next part of the route and start with toplevel
- if (routeIterator < listRoute.end())
+ for (; connectionFormatIterator != listPriorityConnectionFormats.end(); ++connectionFormatIterator)
{
- findBestWay(listRoute, ++routeIterator, gatewayIterator, 0);
+ routeIterator->connectionFormat = *connectionFormatIterator;
+ if ((returnError = findBestWay(listRoute, nextIterator, gatewayIterator)) == E_OK)
+ {
+ break;
+ }
}
- return (E_OK);
+
+ return (returnError);
}
void Router::listRestrictedOutputFormatsGateways(const am_gatewayID_t gatewayID, const am_ConnectionFormat_e sinkConnectionFormat, std::vector<am_ConnectionFormat_e> & listFormats) const
diff --git a/AudioManagerDaemon/src/RoutingReceiver.cpp b/AudioManagerDaemon/src/RoutingReceiver.cpp
index 9a7263d..a6f35e7 100644
--- a/AudioManagerDaemon/src/RoutingReceiver.cpp
+++ b/AudioManagerDaemon/src/RoutingReceiver.cpp
@@ -319,12 +319,16 @@ am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> &
am_Error_e RoutingReceiver::peekSinkClassID(const std::string name, const am_sinkClass_t& sinkClassID)
{
+ (void) name;
+ (void) sinkClassID;
//todo: implement
return E_NOT_USED;
}
am_Error_e RoutingReceiver::peekSourceClassID(const std::string name, const am_sourceClass_t& sourceClassID)
{
+ (void) name;
+ (void) sourceClassID;
//todo: implement
return E_NOT_USED;
}
diff --git a/AudioManagerDaemon/src/RoutingSender.cpp b/AudioManagerDaemon/src/RoutingSender.cpp
index acdb32f..ac99fb7 100644
--- a/AudioManagerDaemon/src/RoutingSender.cpp
+++ b/AudioManagerDaemon/src/RoutingSender.cpp
@@ -268,7 +268,7 @@ am_Error_e RoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const a
handleData.soundPropery = soundProperty;
handle = createHandle(handleData, H_SETSINKSOUNDPROPERTY);
mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
- return iter->second->asyncSetSinkSoundProperty(handle, soundProperty, sinkID);
+ return iter->second->asyncSetSinkSoundProperty(handle, sinkID, soundProperty);
return (E_NON_EXISTENT);
}
@@ -282,7 +282,7 @@ am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const
handleData.soundPropery = soundProperty;
handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTY);
mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
- return iter->second->asyncSetSourceSoundProperty(handle, soundProperty, sourceID);
+ return iter->second->asyncSetSourceSoundProperty(handle, sourceID, soundProperty);
return (E_NON_EXISTENT);
}
@@ -296,7 +296,7 @@ am_Error_e am::RoutingSender::asyncSetSourceSoundProperties(am_Handle_s& handle,
handleData.soundProperties = new std::vector<am_SoundProperty_s>(listSoundProperties);
handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTIES);
mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
- return iter->second->asyncSetSourceSoundProperties(handle, listSoundProperties, sourceID);
+ return iter->second->asyncSetSourceSoundProperties(handle, sourceID, listSoundProperties);
return (E_NON_EXISTENT);
}
@@ -310,7 +310,7 @@ am_Error_e am::RoutingSender::asyncSetSinkSoundProperties(am_Handle_s& handle, c
handleData.soundProperties = new std::vector<am_SoundProperty_s>(listSoundProperties);
handle = createHandle(handleData, H_SETSINKSOUNDPROPERTIES);
mMapHandleInterface.insert(std::make_pair(handle.handle, iter->second));
- return iter->second->asyncSetSinkSoundProperties(handle, listSoundProperties, sinkID);
+ return iter->second->asyncSetSinkSoundProperties(handle, sinkID, listSoundProperties);
return (E_NON_EXISTENT);
}
diff --git a/AudioManagerDaemon/src/TelnetServer.cpp b/AudioManagerDaemon/src/TelnetServer.cpp
index 36eac28..43fcc46 100644
--- a/AudioManagerDaemon/src/TelnetServer.cpp
+++ b/AudioManagerDaemon/src/TelnetServer.cpp
@@ -113,6 +113,8 @@ TelnetServer::~TelnetServer()
void TelnetServer::connectSocket(const pollfd pfd, const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
//first, accept the connection, create a new filedescriptor
struct sockaddr answer;
socklen_t len = sizeof(answer);
@@ -131,6 +133,8 @@ void TelnetServer::connectSocket(const pollfd pfd, const sh_pollHandle_t handle,
void TelnetServer::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
+ (void)handle;
+ (void)userData;
//initialize buffer
char buffer[100];
//read until buffer is full or no more data is there
@@ -145,6 +149,8 @@ void TelnetServer::receiveData(const pollfd pollfd, const sh_pollHandle_t handle
bool TelnetServer::dispatchData(const sh_pollHandle_t handle, void *userData)
{
+ (void)handle;
+ (void)userData;
std::vector<connection_s>::iterator iterator = mListConnections.begin();
for (; iterator != mListConnections.end(); ++iterator)
{
@@ -173,6 +179,8 @@ bool TelnetServer::dispatchData(const sh_pollHandle_t handle, void *userData)
bool TelnetServer::check(const sh_pollHandle_t handle, void *userData)
{
+ (void)handle;
+ (void)userData;
if (msgList.size() != 0) return true;
return false;
}
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
index ab51cee..48b00a7 100644
--- a/AudioManagerDaemon/src/main.cpp
+++ b/AudioManagerDaemon/src/main.cpp
@@ -34,6 +34,7 @@
//todo: there is a bug in the visible flags of sinks and sources. fix it.
//todo: make sure that iterators have a fixed end to prevent crashed while adding vectors while iterating on critical vectors
//todo: make sure all configurations are tested
+//todo: clean up startup sequences controller, command and routing interfaces----
#include <config.h>
#include <SocketHandler.h>
#ifdef WITH_DBUS_WRAPPER
@@ -87,6 +88,7 @@ std::vector<std::string> listRoutingPluginDirs;
std::string databasePath = std::string(":memory:");
unsigned int telnetport = DEFAULT_TELNETPORT;
unsigned int maxConnections = MAX_TELNETCONNECTIONS;
+int fd0, fd1, fd2;
void daemonize()
{
@@ -126,9 +128,9 @@ void daemonize()
close(i);
}
- int fd0 = open("/dev/null", O_RDONLY);
- int fd1 = open("/dev/null", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
- int fd2 = open("/dev/null", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
+ fd0 = open("/dev/null", O_RDONLY);
+ fd1 = open("/dev/null", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
+ fd2 = open("/dev/null", O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
if (fd0 != STDIN_FILENO || fd1 != STDOUT_FILENO || fd2 != STDERR_FILENO)
{
@@ -259,24 +261,25 @@ int main(int argc, char *argv[])
RoutingSender iRoutingSender(listRoutingPluginDirs);
CommandSender iCommandSender(listCommandPluginDirs);
ControlSender iControlSender(controllerPlugin);
+ Router iRouter(&iDatabaseHandler, &iControlSender);
#ifdef WITH_DBUS_WRAPPER
#ifdef WITH_SOCKETHANDLER_LOOP
CommandReceiver iCommandReceiver(&iDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper);
RoutingReceiver iRoutingReceiver(&iDatabaseHandler, &iRoutingSender, &iControlSender, &iSocketHandler, &iDBusWrapper);
- ControlReceiver iControlReceiver(&iDatabaseHandler, &iRoutingSender, &iCommandSender, &iSocketHandler);
+ ControlReceiver iControlReceiver(&iDatabaseHandler, &iRoutingSender, &iCommandSender, &iSocketHandler, &iRouter);
#ifdef WITH_TELNET
TelnetServer iTelnetServer(&iSocketHandler,&iCommandSender,&iCommandReceiver,&iRoutingSender,&iRoutingReceiver,&iControlSender,&iControlReceiver,&iDatabaseHandler,telnetport,maxConnections);
#endif
#else /*WITH_SOCKETHANDLER_LOOP */
CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iDBusWrapper);
RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iDBusWrapper);
- ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender);
+ ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender, &iRouter);
#endif /*WITH_SOCKETHANDLER_LOOP*/
#else /*WITH_DBUS_WRAPPER*/
CommandReceiver iCommandReceiver(&iDatabaseHandler,&iControlSender,&iSocketHandler);
RoutingReceiver iRoutingReceiver(&iDatabaseHandler,&iRoutingSender,&iControlSender,&iSocketHandler);
- ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler);
+ ControlReceiver iControlReceiver(&iDatabaseHandler,&iRoutingSender,&iCommandSender,&iSocketHandler, &iRouter);
#ifdef WITH_TELNET
TelnetServer iTelnetServer(&iSocketHandler,telnetport,maxConnections);
#endif
@@ -288,8 +291,6 @@ int main(int argc, char *argv[])
DatabaseObserver iObserver(&iCommandSender, &iRoutingSender);
#endif
- Router iRouter(&iDatabaseHandler,&iControlSender);
-
//since the plugins have been loaded by the *Senders before, we can tell the Controller this:
iControlSender.hookAllPluginsLoaded();
@@ -308,6 +309,9 @@ int main(int argc, char *argv[])
#endif/*WITH_SIMPLEDBUS_LOOP*/
#endif /*WITH_DBUS_WRAPPER*/
+ close(fd0);
+ close(fd1);
+ close(fd2);
exit(0);
}
diff --git a/AudioManagerDaemon/test/controlInterface/MockInterfaces.h b/AudioManagerDaemon/test/controlInterface/MockInterfaces.h
index 9ac325f..746d70e 100644
--- a/AudioManagerDaemon/test/controlInterface/MockInterfaces.h
+++ b/AudioManagerDaemon/test/controlInterface/MockInterfaces.h
@@ -53,13 +53,13 @@ class MockRoutingSendInterface : public RoutingSendInterface {
MOCK_METHOD3(asyncSetSourceState,
am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state));
MOCK_METHOD3(asyncSetSinkSoundProperties,
- am_Error_e(const am_Handle_s handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID));
+ am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties));
MOCK_METHOD3(asyncSetSinkSoundProperty,
- am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID));
+ am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty));
MOCK_METHOD3(asyncSetSourceSoundProperties,
- am_Error_e(const am_Handle_s handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID));
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties));
MOCK_METHOD3(asyncSetSourceSoundProperty,
- am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID));
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty));
MOCK_METHOD5(asyncCrossFade,
am_Error_e(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time));
MOCK_METHOD2(setDomainState,
@@ -71,6 +71,7 @@ class MockRoutingSendInterface : public RoutingSendInterface {
};
+
class MockControlSendInterface : public ControlSendInterface {
public:
MOCK_METHOD1(startupController,
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
index 5d3a4f1..c22f175 100644
--- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.cpp
@@ -42,12 +42,13 @@ controlInterfaceTest::controlInterfaceTest() :
pCommandSender(plistCommandPluginDirs), //
pMockControlInterface(), //
pMockRoutingInterface(), //
- pControlSender(std::string("")), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
pControlInterfaceBackdoor(), //
+ pControlSender(std::string("")), //
+ pRouter(&pDatabaseHandler,&pControlSender), //
pDatabaseObserver(&pCommandSender, &pRoutingSender), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender,&pRouter), //
pRoutingReceiver(&pDatabaseHandler, &pRoutingSender, &pControlSender, pDBusWrapper)
{
pDatabaseHandler.registerObserver(&pDatabaseObserver);
@@ -440,7 +441,7 @@ TEST_F(controlInterfaceTest,ackSetSinkSoundProperty)
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
//change the soundproperty, expect a call on the routinginterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,_,2)).WillOnce(Return(E_OK));
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSinkSoundProperty(_,2,_)).WillOnce(Return(E_OK));
ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sink.sinkID,soundProperty));
//check the list of handles. The handle must be in there and have the right type
@@ -492,7 +493,7 @@ TEST_F(controlInterfaceTest,ackSetSourceSoundProperty)
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
//we trigger the change and wait for a call on the routinginterface
- EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,_,2)).WillOnce(Return(E_OK));
+ EXPECT_CALL(pMockRoutingInterface,asyncSetSourceSoundProperty(_,2,_)).WillOnce(Return(E_OK));
ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,source.sourceID,soundProperty));
//check the list of handles. The handle must be in there and have the right type
diff --git a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
index 1bc3ce8..0029d73 100644
--- a/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
+++ b/AudioManagerDaemon/test/controlInterface/controlInterfaceTest.h
@@ -36,6 +36,7 @@
#include "DatabaseObserver.h"
#include "ControlSender.h"
#include "RoutingSender.h"
+#include "Router.h"
#include "../RoutingInterfaceBackdoor.h"
#include "../CommandInterfaceBackdoor.h"
#include "../ControlInterfaceBackdoor.h"
@@ -57,10 +58,11 @@ public:
CommandSender pCommandSender;
MockControlSendInterface pMockControlInterface;
MockRoutingSendInterface pMockRoutingInterface;
- ControlSender pControlSender;
RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
CommandInterfaceBackdoor pCommandInterfaceBackdoor;
ControlInterfaceBackdoor pControlInterfaceBackdoor;
+ ControlSender pControlSender;
+ Router pRouter;
DatabaseObserver pDatabaseObserver;
ControlReceiver pControlReceiver;
RoutingReceiver pRoutingReceiver;
diff --git a/AudioManagerDaemon/test/database/MockInterfaces.h b/AudioManagerDaemon/test/database/MockInterfaces.h
index 514c7cf..b48c8e8 100644
--- a/AudioManagerDaemon/test/database/MockInterfaces.h
+++ b/AudioManagerDaemon/test/database/MockInterfaces.h
@@ -70,10 +70,9 @@ class MockCommandSendInterface : public CommandSendInterface {
MOCK_METHOD1(cbSystemPropertyChanged,
void(const am_SystemProperty_s& systemProperty));
MOCK_METHOD2(cbTimingInformationChanged,
- void (const am_timeSync_t time, const am_mainConnectionID_t mainConnectionID));
+ void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time));
MOCK_CONST_METHOD0(getInterfaceVersion,
uint16_t());
-
};
diff --git a/AudioManagerDaemon/test/database/databaseTest.cpp b/AudioManagerDaemon/test/database/databaseTest.cpp
index 9913011..064cc05 100644
--- a/AudioManagerDaemon/test/database/databaseTest.cpp
+++ b/AudioManagerDaemon/test/database/databaseTest.cpp
@@ -54,7 +54,9 @@ routingTest::routingTest() :
pMockInterface(), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pControlSender(""),//
+ pRouter(&pDatabaseHandler,&pControlSender), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), //
pObserver(&pCommandSender, &pRoutingSender)
{
pDatabaseHandler.registerObserver(&pObserver);
diff --git a/AudioManagerDaemon/test/database/databaseTest.h b/AudioManagerDaemon/test/database/databaseTest.h
index 0d46b68..466567b 100644
--- a/AudioManagerDaemon/test/database/databaseTest.h
+++ b/AudioManagerDaemon/test/database/databaseTest.h
@@ -41,6 +41,8 @@
#include "ControlSender.h"
#include "DatabaseObserver.h"
#include "RoutingSender.h"
+#include "Router.h"
+#include "ControlSender.h"
#include "../ControlInterfaceBackdoor.h"
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
@@ -61,6 +63,8 @@ public:
MockCommandSendInterface pMockInterface;
RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
CommandInterfaceBackdoor pCommandInterfaceBackdoor;
+ ControlSender pControlSender;
+ Router pRouter;
ControlReceiver pControlReceiver;
DatabaseObserver pObserver;
CommonFunctions pCF;
diff --git a/AudioManagerDaemon/test/routing/MockInterfaces.h b/AudioManagerDaemon/test/routing/MockInterfaces.h
index 9ece31c..ac7b839 100644
--- a/AudioManagerDaemon/test/routing/MockInterfaces.h
+++ b/AudioManagerDaemon/test/routing/MockInterfaces.h
@@ -71,7 +71,7 @@ class MockCommandSendInterface : public CommandSendInterface {
MOCK_METHOD1(cbSystemPropertyChanged,
void(const am_SystemProperty_s& systemProperty));
MOCK_METHOD2(cbTimingInformationChanged,
- void(const am_timeSync_t time, const am_mainConnectionID_t mainConnectionID));
+ void(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time));
MOCK_CONST_METHOD0(getInterfaceVersion,
uint16_t());
};
diff --git a/AudioManagerDaemon/test/routing/routingTest.cpp b/AudioManagerDaemon/test/routing/routingTest.cpp
index 2950255..2ed2c9b 100644
--- a/AudioManagerDaemon/test/routing/routingTest.cpp
+++ b/AudioManagerDaemon/test/routing/routingTest.cpp
@@ -29,6 +29,7 @@
#include "ControlReceiver.h"
#include "ControlSender.h"
#include "DatabaseObserver.h"
+#include "Router.h"
#include "../ControlInterfaceBackdoor.h"
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
@@ -39,13 +40,6 @@ using namespace testing;
DLT_DECLARE_CONTEXT(DLT_CONTEXT)
-//extern int GetRandomNumber(int nLow, int nHigh);
-//extern bool equalSoundProperty (const am_SoundProperty_s a, const am_SoundProperty_s b);
-extern bool equalMainSoundProperty(const am_MainSoundProperty_s a, const am_MainSoundProperty_s b);
-extern bool equalRoutingElement(const am_RoutingElement_s a, const am_RoutingElement_s b);
-extern bool equalClassProperties(const am_ClassProperty_s a, const am_ClassProperty_s b);
-extern std::string int2string(int i);
-
routingTest::routingTest() :
plistRoutingPluginDirs(), //
plistCommandPluginDirs(), //
@@ -59,7 +53,7 @@ routingTest::routingTest() :
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
pControlInterfaceBackdoor(), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), //
pObserver(&pCommandSender, &pRoutingSender)
{
pDatabaseHandler.registerObserver(&pObserver);
@@ -88,18 +82,16 @@ ACTION(returnConnectionFormat)
arg3=arg2;
}
-
-
-//test that checks just 2 domains, one sink one source with only one connection format each
-TEST_F(routingTest,simpleRoute2Domains)
+//test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit.
+TEST_F(routingTest,simpleRoute3DomainsNoConnection)
{
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK)));
//initialize 2 domains
- am_Domain_s domain1, domain2;
- am_domainID_t domainID1, domainID2;
+ am_Domain_s domain1, domain2, domain3;
+ am_domainID_t domainID1, domainID2, domainID3;
domain1.domainID = 0;
domain1.name = "domain1";
@@ -109,52 +101,73 @@ TEST_F(routingTest,simpleRoute2Domains)
domain2.name = "domain2";
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
+ domain3.domainID = 0;
+ domain3.name = "domain3";
+ domain3.busname = "domain3bus";
+ domain3.state = DS_CONTROLLED;
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
- am_Source_s source, gwSource;
- am_sourceID_t sourceID, gwSourceID;
+ am_Source_s source, gwSource, gwSource1;
+ am_sourceID_t sourceID, gwSourceID, gwSourceID1;
source.domainID = domainID1;
source.name = "source1";
source.sourceState = SS_ON;
source.sourceID = 0;
source.sourceClassID = 5;
- source.listConnectionFormats.push_back(CF_ANALOG);
+ source.listConnectionFormats.push_back(CF_MONO);
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
gwSource.sourceState = SS_ON;
gwSource.sourceID = 0;
gwSource.sourceClassID = 5;
- gwSource.listConnectionFormats.push_back(CF_MONO);
+ gwSource.listConnectionFormats.push_back(CF_ANALOG);
+
+ gwSource1.domainID = domainID3;
+ gwSource1.name = "gwsource2";
+ gwSource1.sourceState = SS_ON;
+ gwSource1.sourceID = 0;
+ gwSource1.sourceClassID = 5;
+ gwSource1.listConnectionFormats.push_back(CF_MONO);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
- am_Sink_s sink, gwSink;
- am_sinkID_t sinkID, gwSinkID;
+ am_Sink_s sink, gwSink, gwSink1;
+ am_sinkID_t sinkID, gwSinkID, gwSinkID1;
- sink.domainID = domainID2;
+ sink.domainID = domainID3;
sink.name = "sink1";
sink.sinkID = 0;
sink.sinkClassID = 5;
sink.muteState = MS_MUTED;
- sink.listConnectionFormats.push_back(CF_MONO);
+ sink.listConnectionFormats.push_back(CF_STEREO);
gwSink.domainID = domainID1;
gwSink.name = "gwSink";
gwSink.sinkID = 0;
gwSink.sinkClassID = 5;
gwSink.muteState = MS_MUTED;
- gwSink.listConnectionFormats.push_back(CF_ANALOG);
+ gwSink.listConnectionFormats.push_back(CF_MONO);
+
+ gwSink1.domainID = domainID2;
+ gwSink1.name = "gwSink1";
+ gwSink1.sinkID = 0;
+ gwSink1.sinkClassID = 5;
+ gwSink1.muteState = MS_MUTED;
+ gwSink1.listConnectionFormats.push_back(CF_ANALOG);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
- am_Gateway_s gateway;
- am_gatewayID_t gatewayID;
+ am_Gateway_s gateway, gateway1;
+ am_gatewayID_t gatewayID, gatewayID1;
gateway.controlDomainID = domainID1;
gateway.gatewayID = 0;
@@ -167,25 +180,44 @@ TEST_F(routingTest,simpleRoute2Domains)
gateway.convertionMatrix.push_back(true);
gateway.name = "gateway";
+ gateway1.controlDomainID = domainID2;
+ gateway1.gatewayID = 0;
+ gateway1.sinkID = gwSinkID1;
+ gateway1.sourceID = gwSourceID1;
+ gateway1.domainSourceID = domainID3;
+ gateway1.domainSinkID = domainID2;
+ gateway1.listSinkFormats = gwSink1.listConnectionFormats;
+ gateway1.listSourceFormats = gwSource1.listConnectionFormats;
+ gateway1.convertionMatrix.push_back(true);
+ gateway1.name = "gateway";
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
am_RoutingElement_s hopp1;
am_RoutingElement_s hopp2;
+ am_RoutingElement_s hopp3;
- hopp1.sinkID = gwSinkID;
hopp1.sourceID = sourceID;
+ hopp1.sinkID = gwSinkID;
hopp1.domainID = domainID1;
hopp1.connectionFormat = source.listConnectionFormats[0];
- hopp2.sinkID = sinkID;
hopp2.sourceID = gwSourceID;
+ hopp2.sinkID = gwSinkID1;
hopp2.domainID = domainID2;
- hopp2.connectionFormat = sink.listConnectionFormats[0];
+ hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
+
+ hopp3.sourceID = gwSourceID1;
+ hopp3.sinkID = sinkID;
+ hopp3.domainID = domainID3;
+ hopp3.connectionFormat = sink.listConnectionFormats[0];
listRoutingElements.push_back(hopp1);
listRoutingElements.push_back(hopp2);
+ listRoutingElements.push_back(hopp3);
am_Route_s compareRoute;
compareRoute.route = listRoutingElements;
@@ -193,13 +225,10 @@ TEST_F(routingTest,simpleRoute2Domains)
compareRoute.sourceID = sourceID;
ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(1, listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
-
+ ASSERT_EQ(0, listRoutes.size());
}
-
-//test that checks just 2 domains, one sink one source but the connectionformat of source
-TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats)
+//test that checks just 2 domains, one sink one source with only one connection format each
+TEST_F(routingTest,simpleRoute2Domains)
{
EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
@@ -229,7 +258,7 @@ TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats)
source.sourceState = SS_ON;
source.sourceID = 0;
source.sourceClassID = 5;
- source.listConnectionFormats.push_back(CF_STEREO);
+ source.listConnectionFormats.push_back(CF_ANALOG);
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
@@ -301,19 +330,21 @@ TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats)
compareRoute.sourceID = sourceID;
ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(0, listRoutes.size());
+ ASSERT_EQ(1, listRoutes.size());
+ ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+
}
-//test that checks 3 domains, one sink one source.
-TEST_F(routingTest,simpleRoute3Domains)
+//test that checks just 2 domains, one sink one source but the connectionformat of source
+TEST_F(routingTest,simpleRoute2DomainsNoMatchConnectionFormats)
{
- EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
- EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
+ EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(2);
+ EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(2);
EXPECT_CALL(pMockControlInterface,getConnectionFormatChoice(_,_,_,_)).WillRepeatedly(DoAll(returnConnectionFormat(),Return(E_OK)));
//initialize 2 domains
- am_Domain_s domain1, domain2, domain3;
- am_domainID_t domainID1, domainID2, domainID3;
+ am_Domain_s domain1, domain2;
+ am_domainID_t domainID1, domainID2;
domain1.domainID = 0;
domain1.name = "domain1";
@@ -323,47 +354,34 @@ TEST_F(routingTest,simpleRoute3Domains)
domain2.name = "domain2";
domain2.busname = "domain2bus";
domain2.state = DS_CONTROLLED;
- domain3.domainID = 0;
- domain3.name = "domain3";
- domain3.busname = "domain3bus";
- domain3.state = DS_CONTROLLED;
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain1,domainID1));
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain2,domainID2));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain3,domainID3));
- am_Source_s source, gwSource, gwSource1;
- am_sourceID_t sourceID, gwSourceID, gwSourceID1;
+ am_Source_s source, gwSource;
+ am_sourceID_t sourceID, gwSourceID;
source.domainID = domainID1;
source.name = "source1";
source.sourceState = SS_ON;
source.sourceID = 0;
source.sourceClassID = 5;
- source.listConnectionFormats.push_back(CF_MONO);
+ source.listConnectionFormats.push_back(CF_STEREO);
gwSource.domainID = domainID2;
gwSource.name = "gwsource1";
gwSource.sourceState = SS_ON;
gwSource.sourceID = 0;
gwSource.sourceClassID = 5;
- gwSource.listConnectionFormats.push_back(CF_ANALOG);
-
- gwSource1.domainID = domainID3;
- gwSource1.name = "gwsource2";
- gwSource1.sourceState = SS_ON;
- gwSource1.sourceID = 0;
- gwSource1.sourceClassID = 5;
- gwSource1.listConnectionFormats.push_back(CF_MONO);
+ gwSource.listConnectionFormats.push_back(CF_MONO);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource,gwSourceID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(gwSource1,gwSourceID1));
- am_Sink_s sink, gwSink, gwSink1;
- am_sinkID_t sinkID, gwSinkID, gwSinkID1;
+ am_Sink_s sink, gwSink;
+ am_sinkID_t sinkID, gwSinkID;
- sink.domainID = domainID3;
+ sink.domainID = domainID2;
sink.name = "sink1";
sink.sinkID = 0;
sink.sinkClassID = 5;
@@ -375,21 +393,13 @@ TEST_F(routingTest,simpleRoute3Domains)
gwSink.sinkID = 0;
gwSink.sinkClassID = 5;
gwSink.muteState = MS_MUTED;
- gwSink.listConnectionFormats.push_back(CF_MONO);
-
- gwSink1.domainID = domainID2;
- gwSink1.name = "gwSink1";
- gwSink1.sinkID = 0;
- gwSink1.sinkClassID = 5;
- gwSink1.muteState = MS_MUTED;
- gwSink1.listConnectionFormats.push_back(CF_ANALOG);
+ gwSink.listConnectionFormats.push_back(CF_ANALOG);
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink,gwSinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(gwSink1,gwSinkID1));
- am_Gateway_s gateway, gateway1;
- am_gatewayID_t gatewayID, gatewayID1;
+ am_Gateway_s gateway;
+ am_gatewayID_t gatewayID;
gateway.controlDomainID = domainID1;
gateway.gatewayID = 0;
@@ -402,44 +412,25 @@ TEST_F(routingTest,simpleRoute3Domains)
gateway.convertionMatrix.push_back(true);
gateway.name = "gateway";
- gateway1.controlDomainID = domainID2;
- gateway1.gatewayID = 0;
- gateway1.sinkID = gwSinkID1;
- gateway1.sourceID = gwSourceID1;
- gateway1.domainSourceID = domainID3;
- gateway1.domainSinkID = domainID2;
- gateway1.listSinkFormats = gwSink1.listConnectionFormats;
- gateway1.listSourceFormats = gwSource1.listConnectionFormats;
- gateway1.convertionMatrix.push_back(true);
- gateway1.name = "gateway";
-
ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway,gatewayID));
- ASSERT_EQ(E_OK, pDatabaseHandler.enterGatewayDB(gateway1,gatewayID1));
std::vector<am_Route_s> listRoutes;
std::vector<am_RoutingElement_s> listRoutingElements;
am_RoutingElement_s hopp1;
am_RoutingElement_s hopp2;
- am_RoutingElement_s hopp3;
- hopp1.sourceID = sourceID;
hopp1.sinkID = gwSinkID;
+ hopp1.sourceID = sourceID;
hopp1.domainID = domainID1;
hopp1.connectionFormat = source.listConnectionFormats[0];
+ hopp2.sinkID = sinkID;
hopp2.sourceID = gwSourceID;
- hopp2.sinkID = gwSinkID1;
hopp2.domainID = domainID2;
- hopp2.connectionFormat = gwSink1.listConnectionFormats[0];
-
- hopp3.sourceID = gwSourceID1;
- hopp3.sinkID = sinkID;
- hopp3.domainID = domainID3;
- hopp3.connectionFormat = sink.listConnectionFormats[0];
+ hopp2.connectionFormat = sink.listConnectionFormats[0];
listRoutingElements.push_back(hopp1);
listRoutingElements.push_back(hopp2);
- listRoutingElements.push_back(hopp3);
am_Route_s compareRoute;
compareRoute.route = listRoutingElements;
@@ -447,12 +438,11 @@ TEST_F(routingTest,simpleRoute3Domains)
compareRoute.sourceID = sourceID;
ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(1, listRoutes.size());
- ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
+ ASSERT_EQ(0, listRoutes.size());
}
-//test that checks 3 domains, one sink one source but the connectionformat of third domains do not fit.
-TEST_F(routingTest,simpleRoute3DomainsNoConnection)
+//test that checks 3 domains, one sink one source.
+TEST_F(routingTest,simpleRoute3Domains)
{
EXPECT_CALL(pMockInterface,cbNumberOfSourcesChanged()).Times(3);
EXPECT_CALL(pMockInterface,cbNumberOfSinksChanged()).Times(3);
@@ -515,7 +505,7 @@ TEST_F(routingTest,simpleRoute3DomainsNoConnection)
sink.sinkID = 0;
sink.sinkClassID = 5;
sink.muteState = MS_MUTED;
- sink.listConnectionFormats.push_back(CF_STEREO);
+ sink.listConnectionFormats.push_back(CF_MONO);
gwSink.domainID = domainID1;
gwSink.name = "gwSink";
@@ -594,7 +584,7 @@ TEST_F(routingTest,simpleRoute3DomainsNoConnection)
compareRoute.sourceID = sourceID;
ASSERT_EQ(E_OK, pRouter.getRoute(false,sourceID,sinkID,listRoutes));
- ASSERT_EQ(0, listRoutes.size());
+ ASSERT_EQ(1, listRoutes.size());
ASSERT_TRUE(pCF.compareRoute(compareRoute,listRoutes[0]));
}
diff --git a/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
index 850d90c..6c93507 100644
--- a/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
+++ b/AudioManagerDaemon/test/routingInterface/MockRoutingInterface.h
@@ -53,13 +53,13 @@ class MockRoutingSendInterface : public RoutingSendInterface {
MOCK_METHOD3(asyncSetSourceState,
am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state));
MOCK_METHOD3(asyncSetSinkSoundProperties,
- am_Error_e(const am_Handle_s handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sinkID_t sinkID));
+ am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector<am_SoundProperty_s>& listSoundProperties));
MOCK_METHOD3(asyncSetSinkSoundProperty,
- am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sinkID_t sinkID));
+ am_Error_e(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty));
MOCK_METHOD3(asyncSetSourceSoundProperties,
- am_Error_e(const am_Handle_s handle, const std::vector<am_SoundProperty_s>& listSoundProperties, const am_sourceID_t sourceID));
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector<am_SoundProperty_s>& listSoundProperties));
MOCK_METHOD3(asyncSetSourceSoundProperty,
- am_Error_e(const am_Handle_s handle, const am_SoundProperty_s& soundProperty, const am_sourceID_t sourceID));
+ am_Error_e(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty));
MOCK_METHOD5(asyncCrossFade,
am_Error_e(const am_Handle_s handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time));
MOCK_METHOD2(setDomainState,
@@ -69,7 +69,6 @@ class MockRoutingSendInterface : public RoutingSendInterface {
MOCK_CONST_METHOD0(getInterfaceVersion,
uint16_t());
};
-
} // namespace am
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
index 6ebd99d..5adb863 100644
--- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.cpp
@@ -28,7 +28,7 @@
using namespace am;
using namespace testing;
-DLT_DECLARE_CONTEXT(DLT_CONTEXT);
+DLT_DECLARE_CONTEXT(DLT_CONTEXT)
routingInterfaceTest::routingInterfaceTest() :
plistRoutingPluginDirs(), //
@@ -36,10 +36,12 @@ routingInterfaceTest::routingInterfaceTest() :
pDatabaseHandler(std::string(":memory:")), //
pRoutingSender(plistRoutingPluginDirs), //
pCommandSender(plistCommandPluginDirs), //
+ pControlSender(""), //
+ pRouter(&pDatabaseHandler, &pControlSender), //
pMockInterface(), //
pRoutingInterfaceBackdoor(), //
pCommandInterfaceBackdoor(), //
- pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender), //
+ pControlReceiver(&pDatabaseHandler, &pRoutingSender, &pCommandSender, &pRouter), //
pObserver(&pCommandSender, &pRoutingSender)
{
pDatabaseHandler.registerObserver(&pObserver);
@@ -160,7 +162,7 @@ TEST_F(routingInterfaceTest,setSinkSoundPropertyNoChange)
sink.listSoundProperties.push_back(soundProperty);
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).Times(0);
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,sinkID,_)).Times(0);
ASSERT_EQ(E_NO_CHANGE, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
}
@@ -203,7 +205,7 @@ TEST_F(routingInterfaceTest,setSourceSoundProperty)
source.domainID = 1;
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
- EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,_,sourceID)).WillOnce(Return(E_OK));
+ EXPECT_CALL(pMockInterface,asyncSetSourceSoundProperty(_,sourceID,_)).WillOnce(Return(E_OK));
ASSERT_EQ(E_OK, pControlReceiver.setSourceSoundProperty(handle,sourceID,soundProperty));
ASSERT_NE(handle.handle, 0);
ASSERT_EQ(handle.handleType, H_SETSOURCESOUNDPROPERTY);
@@ -229,7 +231,7 @@ TEST_F(routingInterfaceTest,setSinkSoundProperty)
sink.domainID = 1;
ASSERT_EQ(E_OK, pDatabaseHandler.enterDomainDB(domain,domainID));
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,_,sinkID)).WillOnce(Return(E_OK));
+ EXPECT_CALL(pMockInterface,asyncSetSinkSoundProperty(_,sinkID,_)).WillOnce(Return(E_OK));
ASSERT_EQ(E_OK, pControlReceiver.setSinkSoundProperty(handle,sinkID,soundProperty));
ASSERT_NE(handle.handle, 0);
ASSERT_EQ(handle.handleType, H_SETSINKSOUNDPROPERTY);
diff --git a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
index 4da9643..8ad77eb 100644
--- a/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
+++ b/AudioManagerDaemon/test/routingInterface/routingInterfaceTest.h
@@ -38,6 +38,7 @@
#include "ControlReceiver.h"
#include "ControlSender.h"
#include "DatabaseObserver.h"
+#include "Router.h"
#include "../RoutingInterfaceBackdoor.h"
#include "../CommandInterfaceBackdoor.h"
#include "../CommonFunctions.h"
@@ -55,6 +56,8 @@ public:
DatabaseHandler pDatabaseHandler;
RoutingSender pRoutingSender;
CommandSender pCommandSender;
+ ControlSender pControlSender;
+ Router pRouter;
MockRoutingSendInterface pMockInterface;
RoutingInterfaceBackdoor pRoutingInterfaceBackdoor;
CommandInterfaceBackdoor pCommandInterfaceBackdoor;
diff --git a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
index 5c23789..0ac36fa 100644
--- a/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
+++ b/AudioManagerDaemon/test/sockethandler/sockethandlerTest.cpp
@@ -23,8 +23,6 @@ using namespace am;
DLT_DECLARE_CONTEXT(AudioManager)
-static volatile sig_atomic_t gDispatch = 1; //this global is used to stop the mainloop
-
sockethandlerTest::sockethandlerTest()
{
}
@@ -49,6 +47,8 @@ am::timerCallBack::~timerCallBack()
void am::timerCallBack::timer1Callback(sh_timerHandle_t handle, void* userData)
{
+ (void) handle;
+ (void) userData;
std::cout << "callback1 called" << std::endl;
timespec timeout;
timeout.tv_nsec = 0;
@@ -60,6 +60,8 @@ void am::timerCallBack::timer1Callback(sh_timerHandle_t handle, void* userData)
void am::timerCallBack::timer2Callback(sh_timerHandle_t handle, void* userData)
{
+ (void) handle;
+ (void) userData;
std::cout << "callback2 called" << std::endl;
timespec timeout;
timeout.tv_nsec = 0;
@@ -71,35 +73,40 @@ void am::timerCallBack::timer2Callback(sh_timerHandle_t handle, void* userData)
void am::timerCallBack::timer3Callback(sh_timerHandle_t, void* userData)
{
+ (void) userData;
std::cout << "callback3 called" << std::endl;
}
void am::timerCallBack::timer4Callback(sh_timerHandle_t, void* userData)
{
+ (void) userData;
std::cout << "callback4 called" << std::endl;
mSocketHandler->stop_listening();
}
void* playWithSocketServer(void* data)
{
+ (void) data;
SocketHandler myHandler;
SamplePlugin::sockType_e type = SamplePlugin::INET;
SamplePlugin myplugin(&myHandler, type);
myHandler.start_listenting();
+ return (NULL);
}
void* playWithUnixSocketServer(void* data)
{
+ (void) data;
SocketHandler myHandler;
SamplePlugin::sockType_e type = SamplePlugin::UNIX;
SamplePlugin myplugin(&myHandler, type);
myHandler.start_listenting();
+ return (NULL);
}
TEST(sockethandlerTest,playWithUNIXSockets)
{
pthread_t serverThread;
- char buffer[3000];
struct sockaddr_un servAddr;
int socket_;
@@ -135,7 +142,6 @@ TEST(sockethandlerTest,playWithUNIXSockets)
TEST(sockethandlerTest,playWithSockets)
{
pthread_t serverThread;
- char buffer[3000];
struct sockaddr_in servAddr;
unsigned short servPort = 6060;
struct hostent *host;
@@ -154,7 +160,7 @@ TEST(sockethandlerTest,playWithSockets)
if ((host = (struct hostent*) gethostbyname("localhost")) == 0)
{
std::cout << "ERROR: gethostbyname() failed\n" << std::endl;
-
+ exit(1);
}
memset(&servAddr, 0, sizeof(servAddr));
@@ -229,7 +235,6 @@ am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socket
mReceiveHandle(), //
msgList()
{
- int ret;
int yes = 1;
int socketHandle;
@@ -276,6 +281,8 @@ am::SamplePlugin::SamplePlugin(SocketHandler *mySocketHandler, sockType_e socket
void am::SamplePlugin::connectSocket(const pollfd pollfd1, const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
//first, accept the connection, create a new filedescriptor
std::cout << "Got a connection request !" << std::endl;
struct sockaddr answer;
@@ -293,6 +300,8 @@ void am::SamplePlugin::connectSocket(const pollfd pollfd1, const sh_pollHandle_t
void am::SamplePlugin::receiveData(const pollfd pollfd, const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
//initialize buffer
char buffer[10];
//read until buffer is full or no more data is there
@@ -308,6 +317,8 @@ void am::SamplePlugin::receiveData(const pollfd pollfd, const sh_pollHandle_t ha
bool am::SamplePlugin::dispatchData(const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
//read data from the queue
std::cout << "Data:" << msgList.front() << std::endl;
@@ -318,15 +329,19 @@ bool am::SamplePlugin::dispatchData(const sh_pollHandle_t handle, void *userData
}
//remove the message from the queue and return false if there is no more message to read.
msgList.pop();
- if (msgList.size() != 0) return true;
+ if (msgList.size() != 0)
+ return true;
return false;
}
bool am::SamplePlugin::check(const sh_pollHandle_t handle, void *userData)
{
+ (void) handle;
+ (void) userData;
//checks if there is data to dispatch
std::cout << "check!:" << std::endl;
- if (msgList.size() != 0) return true;
+ if (msgList.size() != 0)
+ return true;
return false;
}