summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/include
diff options
context:
space:
mode:
authorChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
committerChristian Mueller <christian@lmuc329619u.(none)>2011-12-12 21:43:47 +0100
commit205595e3d3e6a1d55be3c462ef02c9f828a77feb (patch)
tree9c1202619c7b9a66ed874ca1a0c81530ae06e426 /AudioManagerDaemon/include
parentd85e69bbf6d8ec6e087c7af579686923c76079cd (diff)
downloadaudiomanager-205595e3d3e6a1d55be3c462ef02c9f828a77feb.tar.gz
some updates, new tests
Diffstat (limited to 'AudioManagerDaemon/include')
-rw-r--r--AudioManagerDaemon/include/CommandReceiver.h29
-rw-r--r--AudioManagerDaemon/include/CommandSender.h10
-rw-r--r--AudioManagerDaemon/include/ControlReceiver.h4
-rw-r--r--AudioManagerDaemon/include/ControlSender.h62
-rw-r--r--AudioManagerDaemon/include/DatabaseHandler.h92
-rw-r--r--AudioManagerDaemon/include/Observer.h45
-rw-r--r--AudioManagerDaemon/include/RoutingReceiver.h13
-rw-r--r--AudioManagerDaemon/include/RoutingSender.h62
-rw-r--r--AudioManagerDaemon/include/pluginTemplate.h7
9 files changed, 292 insertions, 32 deletions
diff --git a/AudioManagerDaemon/include/CommandReceiver.h b/AudioManagerDaemon/include/CommandReceiver.h
index 3f4138a..a49c03d 100644
--- a/AudioManagerDaemon/include/CommandReceiver.h
+++ b/AudioManagerDaemon/include/CommandReceiver.h
@@ -8,16 +8,40 @@
#ifndef COMMANDRECEIVER_H_
#define COMMANDRECEIVER_H_
-
+/**
+* Copyright (C) 2011, BMW AG
+*
+* GeniviAudioMananger AudioManagerDaemon
+*
+* \file DBusWrapper.cpp
+*
+* \date 20-Oct-2011 3:42:04 PM
+* \author Christian Mueller (christian.ei.mueller@bmw.de)
+*
+* \section License
+* GNU Lesser General Public License, version 2.1, with special exception (GENIVI clause)
+* Copyright (C) 2011, BMW AG Christian Mueller Christian.ei.mueller@bmw.de
+*
+* This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License, version 2.1, as published by the Free Software Foundation.
+* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License, version 2.1, for more details.
+* You should have received a copy of the GNU Lesser General Public License, version 2.1, along with this program; if not, see <http://www.gnu.org/licenses/lgpl-2.1.html>.
+* Note that the copyright holders assume that the GNU Lesser General Public License, version 2.1, may also be applicable to programs even in cases in which the program is not a library in the technical sense.
+* Linking AudioManager statically or dynamically with other modules is making a combined work based on AudioManager. You may license such other modules under the GNU Lesser General Public License, version 2.1. If you do not want to license your linked modules under the GNU Lesser General Public License, version 2.1, you may use the program under the following exception.
+* As a special exception, the copyright holders of AudioManager give you permission to combine AudioManager with software programs or libraries that are released under any license unless such a combination is not permitted by the license of such a software program or library. You may copy and distribute such a system following the terms of the GNU Lesser General Public License, version 2.1, including this special exception, for AudioManager and the licenses of the other code concerned.
+* Note that people who make modified versions of AudioManager are not obligated to grant this special exception for their modified versions; it is their choice whether to do so. The GNU Lesser General Public License, version 2.1, gives permission to release a modified version without this exception; this exception also makes it possible to release a modified version which carries forward this exception.
+*
+* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL. PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN
+*/
#include <command/CommandReceiveInterface.h>
#include "DatabaseHandler.h"
#include "DBusWrapper.h"
+#include "ControlSender.h"
using namespace am;
class CommandReceiver: public CommandReceiveInterface {
public:
- CommandReceiver(DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper);
+ CommandReceiver(DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper, ControlSender* iControlSender);
virtual ~CommandReceiver();
am_Error_e connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
am_Error_e disconnect(const am_mainConnectionID_t mainConnectionID) ;
@@ -41,6 +65,7 @@ public:
private:
DatabaseHandler* mDatabaseHandler;
DBusWrapper* mDBusWrapper;
+ ControlSender* mControlSender;
};
#endif /* COMMANDRECEIVER_H_ */
diff --git a/AudioManagerDaemon/include/CommandSender.h b/AudioManagerDaemon/include/CommandSender.h
index 8e604c6..2cd5025 100644
--- a/AudioManagerDaemon/include/CommandSender.h
+++ b/AudioManagerDaemon/include/CommandSender.h
@@ -8,9 +8,12 @@
#ifndef COMMANDSENDER_H_
#define COMMANDSENDER_H_
-#include "pluginTemplate.h"
#include "command/CommandSendInterface.h"
+#ifdef UNIT_TEST
+#include "../test/CommandInterfaceBackdoor.h"
+#endif
+
using namespace am;
class CommandSender {
@@ -35,8 +38,13 @@ public:
void cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
void cbSystemPropertyChanged(const am_SystemProperty_s& SystemProperty) ;
void cbTimingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time) ;
+#ifdef UNIT_TEST
+ friend class CommandInterfaceBackdoor;
+#endif
private:
+ void unloadLibraries(void);
std::vector<CommandSendInterface*> mListInterfaces;
+ std::vector<void*> mListLibraryHandles;
};
#endif /* COMMANDSENDER_H_ */
diff --git a/AudioManagerDaemon/include/ControlReceiver.h b/AudioManagerDaemon/include/ControlReceiver.h
index 722bde1..1b5c072 100644
--- a/AudioManagerDaemon/include/ControlReceiver.h
+++ b/AudioManagerDaemon/include/ControlReceiver.h
@@ -10,12 +10,13 @@
#include <control/ControlReceiveInterface.h>
#include "DatabaseHandler.h"
+#include "RoutingSender.h"
using namespace am;
class ControlReceiver: public ControlReceiveInterface {
public:
- ControlReceiver(DatabaseHandler* iDatabaseHandler);
+ ControlReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender);
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) ;
@@ -81,6 +82,7 @@ public:
private:
DatabaseHandler* mDatabaseHandler;
+ RoutingSender* mRoutingSender;
};
#endif /* CONTRONLRECEIVER_H_ */
diff --git a/AudioManagerDaemon/include/ControlSender.h b/AudioManagerDaemon/include/ControlSender.h
index fde029c..0a490d4 100644
--- a/AudioManagerDaemon/include/ControlSender.h
+++ b/AudioManagerDaemon/include/ControlSender.h
@@ -1,21 +1,71 @@
/*
- * ControlLoader.h
+ * ControlSender.h
*
- * Created on: Oct 25, 2011
+ * Created on: Dec 9, 2011
* Author: christian
*/
-#ifndef CONTROLLOADER_H_
-#define CONTROLLOADER_H_
+#ifndef CONTROLSENDER_H_
+#define CONTROLSENDER_H_
#include "control/ControlSendInterface.h"
+#ifdef UNIT_TEST
+#include "../test/ControlInterfaceBackdoor.h"
+#endif
+
using namespace am;
-class ControlSender : private ControlSendInterface {
+class ControlSender {
public:
ControlSender();
virtual ~ControlSender();
+ am_Error_e startupController(ControlReceiveInterface* controlreceiveinterface) ;
+ am_Error_e stopController() ;
+ void hookAllPluginsLoaded() ;
+ am_Error_e hookUserConnectionRequest(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t& mainConnectionID) ;
+ am_Error_e hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) ;
+ am_Error_e hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s& soundProperty) ;
+ am_Error_e hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s& soundProperty) ;
+ am_Error_e hookUserSetSystemProperty(const am_SystemProperty_s& property) ;
+ am_Error_e hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) ;
+ am_Error_e hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) ;
+ am_Error_e hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
+ am_Error_e hookSystemRegisterDomain(const am_Domain_s& domainData, am_domainID_t& domainID) ;
+ am_Error_e hookSystemDeregisterDomain(const am_domainID_t domainID) ;
+ am_Error_e hookSystemRegisterSink(const am_Sink_s& sinkData, am_sinkID_t& sinkID) ;
+ am_Error_e hookSystemDeregisterSink(const am_sinkID_t sinkID) ;
+ am_Error_e hookSystemRegisterSource(const am_Source_s& sourceData, am_sourceID_t& sourceID) ;
+ am_Error_e hookSystemDeregisterSource(const am_sourceID_t sourceID) ;
+ am_Error_e hookSystemRegisterGateway(const am_Gateway_s& gatewayData, am_gatewayID_t& gatewayID) ;
+ am_Error_e hookSystemDeregisterGateway(const am_gatewayID_t gatewayID) ;
+ am_Error_e hookSystemRegisterCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
+ am_Error_e hookSystemDeregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
+ void hookSystemDomainRegistrationComplete(const am_domainID_t domainID) ;
+ void hookSystemSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) ;
+ void hookSystemSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) ;
+ void hookSystemInterruptStateChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
+ void hookSystemSinkAvailablityStateChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
+ void hookSystemSourceAvailablityStateChange(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
+ void hookSystemDomainStateChange(const am_domainID_t domainID, const am_DomainState_e state) ;
+ void hookSystemReceiveEarlyData(const std::vector<am_EarlyData_s>& data) ;
+ void hookSystemSpeedChange(const am_speed_t speed) ;
+ void hookSystemTimingInformationChanged(const am_mainConnectionID_t mainConnectionID, const am_timeSync_t time) ;
+ void cbAckConnect(const am_Handle_s handle, const am_Error_e errorID) ;
+ void cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) ;
+ void cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) ;
+ void cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) ;
+ void cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) ;
+ void cbAckSetSourceState(const am_Handle_s handle, const am_Error_e error) ;
+ void cbAckSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
+ void cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) ;
+
+#ifdef UNIT_TEST
+ friend class ControlInterfaceBackdoor;
+#endif
+private:
+ ControlSendInterface* mController;
+ void* mlibHandle;
};
-#endif /* CONTROLLOADER_H_ */
+#endif /* CONTROLSENDER_H_ */
diff --git a/AudioManagerDaemon/include/DatabaseHandler.h b/AudioManagerDaemon/include/DatabaseHandler.h
index 5c99719..38c20dd 100644
--- a/AudioManagerDaemon/include/DatabaseHandler.h
+++ b/AudioManagerDaemon/include/DatabaseHandler.h
@@ -8,9 +8,13 @@
#ifndef DATABASEHANDLER_H_
#define DATABASEHANDLER_H_
+#include "Observer.h"
#include "audiomanagertypes.h"
#include <map>
#include <string>
+#include <stdint.h>
+#include <fstream>
+#include <sstream>
#include <vector>
#include <sqlite3.h>
@@ -23,6 +27,9 @@ using namespace am;
//todo: change asserts for dynamic boundary checks into failure answers.#
//todo: check autoincrement boundary and set to 16bit limits
//todo: If the sink is part of a gateway, the listconnectionFormats is copied to the gatewayInformation. Check this statement for sinks & sources
+//todo: exchange last_insert_row id to be more safe
+//todo: create test to ensure uniqueness of names throughout the database
+//todo: enforce the uniqueness of names
class DatabaseHandler {
public:
@@ -52,6 +59,8 @@ public:
am_Error_e changeSinkClassInfoDB(const am_SinkClass_s& sinkClass) ;
am_Error_e changeSourceClassInfoDB(const am_SourceClass_s& sourceClass) ;
am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay) ;
+ am_Error_e changeConnectionFinal(const am_connectionID_t connectionID) ;
+ am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState);
am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) ;
am_Error_e removeSinkDB(const am_sinkID_t sinkID) ;
am_Error_e removeSourceDB(const am_sourceID_t sourceID) ;
@@ -60,10 +69,15 @@ public:
am_Error_e removeDomainDB(const am_domainID_t domainID) ;
am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID) ;
am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID) ;
+ am_Error_e removeConnection(const am_connectionID_t connectionID) ;
am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s& classInfo) const ;
am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s& sinkClass) const ;
am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s& gatewayData) const ;
am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s& crossfaderData) const ;
+ am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const;
+ am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
+ am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_SoundPropertyType_e propertyType, uint16_t& value) const ;
+ am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_SoundPropertyType_e propertyType, uint16_t& value) const ;
am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const ;
am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const ;
am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const ;
@@ -85,8 +99,11 @@ public:
am_Error_e getListSystemProperties(std::vector<am_SystemProperty_s>& listSystemProperties) const ;
am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t& delay) const ;
am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) const;
-
-
+ am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e& sourceState) const;
+ am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e state) const;
+ am_Error_e peekDomain(const std::string& name, am_domainID_t& domainID);
+ am_Error_e peekSink(const std::string& name, am_sinkID_t& sinkID);
+ am_Error_e peekSource(const std::string& name, am_sourceID_t& sourceID);
/**
* checks for a certain mainConnection
* @param mainConnectionID to be checked for
@@ -95,6 +112,27 @@ public:
bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const;
/**
+ * checks if a CrossFader exists
+ * @param crossFaderID the ID of the crossfader to be checked
+ * @return true if exists
+ */
+ bool existcrossFader(const am_crossfaderID_t crossfaderID) const;
+
+ /**
+ * checks if a connection already exists.
+ * Only takes sink, source and format information for search!
+ * @param connection the connection to be checked
+ * @return true if connections exists
+ */
+ bool existConnection(const am_Connection_s connection);
+
+ /**
+ * checks if a connection with the given ID exists
+ * @param connectionID
+ * @return true if connection exits
+ */
+ bool existConnectionID(const am_connectionID_t connectionID);
+ /**
* checks for a certain Source
* @param sourceID to be checked for
* @return true if it exists
@@ -102,6 +140,20 @@ public:
bool existSource(const am_sourceID_t sourceID) const;
/**
+ * checks if a source name or ID exists
+ * @param sourceID the sourceID
+ * @param name the name
+ * @return true if it exits
+ */
+ bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string& name) const;
+
+ /**
+ * checks if a name exits
+ * @param name the name
+ * @return true if it exits
+ */
+ bool existSourceName(const std::string& name) const;
+ /**
* checks for a certain Sink
* @param sinkID to be checked for
* @return true if it exists
@@ -109,6 +161,21 @@ public:
bool existSink(const am_sinkID_t sinkID) const;
/**
+ * checks if a sink with the ID or the name exists
+ * @param sinkID the ID
+ * @param name the name
+ * @return true if it exists.
+ */
+ bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string& name) const;
+
+ /**
+ * checks if a sink with the name exists
+ * @param name the name
+ * @return true if it exists
+ */
+ bool existSinkName(const std::string& name) const;
+
+ /**
* checks for a certain domain
* @param domainID to be checked for
* @return true if it exists
@@ -136,6 +203,26 @@ public:
*/
bool existSourceClass(const am_sourceClass_t sourceClassID) const;
+ /**
+ * registers the Observer at the Database
+ * @param iObserver pointer to the observer
+ */
+ void registerObserver(Observer *iObserver);
+
+ /**
+ * gives information about the visibility of a source
+ * @param sourceID the sourceID
+ * @return true if source is visible
+ */
+ bool sourceVisible(const am_sourceID_t sourceID) const;
+
+ /**
+ * gives information about the visibility of a sink
+ * @param sinkID the sinkID
+ * @return true if source is visible
+ */
+ bool sinkVisible(const am_sinkID_t sinkID) const;
+
private:
am_timeSync_t calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const;
bool connectionPartofMainConnection(const am_connectionID_t connectionID,const am_mainConnectionID_t mainConnectionID) const;
@@ -144,6 +231,7 @@ private:
void createTables();
sqlite3 *mDatabase;
std::string mPath;
+ Observer *mObserver;
bool mFirstStaticSink;
bool mFirstStaticSource;
bool mFirstStaticGateway;
diff --git a/AudioManagerDaemon/include/Observer.h b/AudioManagerDaemon/include/Observer.h
new file mode 100644
index 0000000..f616722
--- /dev/null
+++ b/AudioManagerDaemon/include/Observer.h
@@ -0,0 +1,45 @@
+/*
+ * Observer.h
+ *
+ * Created on: Dec 10, 2011
+ * Author: christian
+ */
+
+#ifndef OBSERVER_H_
+#define OBSERVER_H_
+
+#include "CommandSender.h"
+#include "RoutingSender.h"
+
+class Observer {
+public:
+ Observer(CommandSender *iCommandSender, RoutingSender *iRoutingSender);
+ virtual ~Observer();
+ void numberOfMainConnectionsChanged() ;
+ void numberOfSinkClassesChanged() ;
+ void numberOfSourceClassesChanged() ;
+ void newSink(am_Sink_s sink);
+ void newSource(am_Source_s source);
+ void newDomain(am_Domain_s domain);
+ void newGateway(am_Gateway_s gateway);
+ void newCrossfader(am_Crossfader_s crossfader);
+ void removedSink(am_sinkID_t sinkID);
+ void removedSource(am_sourceID_t sourceID);
+ void removeDomain(am_domainID_t domainID);
+ void removeGateway(am_gatewayID_t gatewayID);
+ void removeCrossfader(am_crossfaderID_t crossfaderID);
+ void mainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState) ;
+ void mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty) ;
+ void mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s& SoundProperty) ;
+ void sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
+ void sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s& availability) ;
+ void volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume) ;
+ void sinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState) ;
+ void systemPropertyChanged(const am_SystemProperty_s& SystemProperty) ;
+ void timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time) ;
+private:
+ CommandSender *mCommandSender;
+ RoutingSender* mRoutingSender;
+};
+
+#endif /* OBSERVER_H_ */
diff --git a/AudioManagerDaemon/include/RoutingReceiver.h b/AudioManagerDaemon/include/RoutingReceiver.h
index 903786a..f2dc405 100644
--- a/AudioManagerDaemon/include/RoutingReceiver.h
+++ b/AudioManagerDaemon/include/RoutingReceiver.h
@@ -9,12 +9,15 @@
#define ROUTINGRECEIVER_H_
#include "routing/RoutingReceiveInterface.h"
+#include "ControlSender.h"
+#include "RoutingSender.h"
+#include "DatabaseHandler.h"
using namespace am;
class RoutingReceiver : public RoutingReceiveInterface {
public:
- RoutingReceiver();
+ RoutingReceiver(DatabaseHandler *iDatabaseHandler, RoutingSender *iRoutingSender, ControlSender *iControlSender);
virtual ~RoutingReceiver();
void ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) ;
void ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error) ;
@@ -39,6 +42,8 @@ public:
am_Error_e deregisterSource(const am_sourceID_t sourceID) ;
am_Error_e registerCrossfader(const am_Crossfader_s& crossfaderData, am_crossfaderID_t& crossfaderID) ;
am_Error_e deregisterCrossfader(const am_crossfaderID_t crossfaderID) ;
+ am_Error_e peekSinkClassID(const std::string& name, am_sourceClass_t& sourceClassID) ;
+ am_Error_e peekSourceClassID(const std::string& name, am_sinkClass_t& sinkClassID) ;
void hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState) ;
void hookDomainRegistrationComplete(const am_domainID_t domainID) ;
void hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s& availability) ;
@@ -47,7 +52,11 @@ public:
void hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay) ;
am_Error_e sendChangedData(const std::vector<am_EarlyData_s>& earlyData) ;
am_Error_e getDBusConnectionWrapper(DBusWrapper* dbusConnectionWrapper) const ;
- am_Error_e registerDbusNode(const std::string& nodeName) ;
+private:
+ DatabaseHandler *mDatabaseHandler;
+ RoutingSender *mRoutingSender;
+ ControlSender *mControlSender;
+
};
#endif /* ROUTINGRECEIVER_H_ */
diff --git a/AudioManagerDaemon/include/RoutingSender.h b/AudioManagerDaemon/include/RoutingSender.h
index 2aac7be..bb3cc53 100644
--- a/AudioManagerDaemon/include/RoutingSender.h
+++ b/AudioManagerDaemon/include/RoutingSender.h
@@ -8,9 +8,14 @@
#ifndef ROUTINGSENDER_H_
#define ROUTINGSENDER_H_
-#include "pluginTemplate.h"
#include "routing/RoutingSendInterface.h"
+
+#ifdef UNIT_TEST //this is needed to test RoutingSender
+#include "../test/RoutingInterfaceBackdoor.h"
+#endif
+
#include <map>
+#include <set>
using namespace am;
@@ -18,6 +23,14 @@ class RoutingSender {
public:
RoutingSender();
virtual ~RoutingSender();
+
+ /**
+ * removes a handle from the list
+ * @param handle to be removed
+ * @return E_OK in case of success
+ */
+ am_Error_e removeHandle(const am_Handle_s& handle);
+
/**
* @author Christian
* this adds the domain to the lookup table of the Router. The data is used to have a quick lookup of the correct pluginInterface.
@@ -65,18 +78,17 @@ public:
void startupRoutingInterface(RoutingReceiveInterface* routingreceiveinterface) ;
void routingInterfacesReady() ;
void routingInterfacesRundown() ;
- am_Error_e asyncAbort(const am_Handle_s handle) ;
- am_Error_e asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) ;
- am_Error_e asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID) ;
- am_Error_e asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
- am_Error_e asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state) ;
- am_Error_e asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ;
- am_Error_e asyncCrossFade(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) ;
+ am_Error_e asyncAbort(const am_Handle_s& handle) ;
+ am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) ;
+ am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID) ;
+ am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
+ am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) ;
+ am_Error_e asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state) ;
+ am_Error_e asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) ;
+ am_Error_e asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) ;
+ am_Error_e asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) ;
am_Error_e setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState) ;
- am_Error_e returnBusName(std::string& BusName) const ;
-private:
+ am_Error_e getListHandles(std::vector<am_Handle_s> & listHandles) const ;
struct InterfaceNamePairs
{
@@ -84,18 +96,40 @@ private:
std::string busName;
};
+#ifdef UNIT_TEST //this is needed to test RoutingSender
+ friend class RoutingInterfaceBackdoor;
+#endif
+private:
+ struct compareHandles
+ {
+ bool operator()(const am_Handle_s& a, const am_Handle_s& b) const
+ {
+ {
+ return (a.handle < b.handle);
+ }
+ }
+ };
+
+ am_Handle_s createHandle(const am_Handle_e handle);
+ void unloadLibraries(void);
+
typedef std::map<am_domainID_t, RoutingSendInterface*> DomainInterfaceMap;
typedef std::map<am_sinkID_t, RoutingSendInterface*> SinkInterfaceMap;
typedef std::map<am_sourceID_t, RoutingSendInterface*> SourceInterfaceMap;
typedef std::map<am_crossfaderID_t, RoutingSendInterface*> CrossfaderInterfaceMap;
typedef std::map<am_connectionID_t, RoutingSendInterface*> ConnectionInterfaceMap;
+ typedef std::map<uint16_t, RoutingSendInterface*> HandleInterfaceMap;
+ int16_t mHandleCount;
+ std::set<am_Handle_s,compareHandles> mlistActiveHandles;
std::vector<InterfaceNamePairs> mListInterfaces;
+ std::vector<void*> mListLibraryHandles;
+ ConnectionInterfaceMap mMapConnectionInterface;
+ CrossfaderInterfaceMap mMapCrossfaderInterface;
DomainInterfaceMap mMapDomainInterface;
SinkInterfaceMap mMapSinkInterface;
SourceInterfaceMap mMapSourceInterface;
- CrossfaderInterfaceMap mMapCrossfaderInterface;
- ConnectionInterfaceMap mMapConnectionInterface;
+ HandleInterfaceMap mMapHandleInterface;
};
#endif /* ROUTINGSENDER_H_ */
diff --git a/AudioManagerDaemon/include/pluginTemplate.h b/AudioManagerDaemon/include/pluginTemplate.h
index 1f6a06b..0054d92 100644
--- a/AudioManagerDaemon/include/pluginTemplate.h
+++ b/AudioManagerDaemon/include/pluginTemplate.h
@@ -35,14 +35,14 @@
#include <string>
#include <dlt/dlt.h>
-DLT_IMPORT_CONTEXT(AudioManager);
+DLT_IMPORT_CONTEXT(AudioManager)
/**
* This template tries to load a library and cast ot to a class
* @param libname the full path to the library to be loaded
* @return returns the pointer to the class to be loaded
*/
-template<class T>T* getCreateFunction(std::string libname) {
+template<class T>T* getCreateFunction(const std::string& libname, void*& libraryHandle) {
DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Trying to load libray with name: "),DLT_STRING(libname.c_str()));
@@ -54,9 +54,8 @@ template<class T>T* getCreateFunction(std::string libname) {
std::string createFunctionName = libFileName.substr(3, libFileName.length() - 6) + "Factory";
// open library
- void *libraryHandle;
dlerror(); // Clear any existing error
- libraryHandle = dlopen(libname.c_str(), RTLD_NOW /*LAZY*/);
+ libraryHandle = dlopen(libname.c_str(), RTLD_LAZY);
const char* dlopen_error = dlerror();
if (!libraryHandle || dlopen_error)
{