summaryrefslogtreecommitdiff
path: root/AudioManagerDaemon/src
diff options
context:
space:
mode:
authorChristian Mueller <christian@lmuc329619u.(none)>2011-12-08 18:43:48 +0100
committerChristian Mueller <christian@lmuc329619u.(none)>2011-12-08 18:43:48 +0100
commit5773404eb801e27179b7c3c7803a990145d6e94a (patch)
tree4bb9db13fbfb3f72479fd7e6ce342768f299d073 /AudioManagerDaemon/src
parent9826492b0066d47cfa9ba68d6efe737cc3c317a3 (diff)
downloadaudiomanager-5773404eb801e27179b7c3c7803a990145d6e94a.tar.gz
total rework
no more QT
Diffstat (limited to 'AudioManagerDaemon/src')
-rw-r--r--AudioManagerDaemon/src/CommandReceiver.cpp136
-rw-r--r--AudioManagerDaemon/src/CommandSender.cpp233
-rw-r--r--AudioManagerDaemon/src/ControlLoader.cpp42
-rw-r--r--AudioManagerDaemon/src/ControlReceiver.cpp409
-rw-r--r--AudioManagerDaemon/src/DBusWrapper.cpp182
-rw-r--r--AudioManagerDaemon/src/DatabaseHandler.cpp2840
-rw-r--r--AudioManagerDaemon/src/RoutingReceiver.cpp213
-rw-r--r--AudioManagerDaemon/src/RoutingSender.cpp352
-rw-r--r--AudioManagerDaemon/src/main.cpp74
9 files changed, 4481 insertions, 0 deletions
diff --git a/AudioManagerDaemon/src/CommandReceiver.cpp b/AudioManagerDaemon/src/CommandReceiver.cpp
new file mode 100644
index 0000000..b5294bd
--- /dev/null
+++ b/AudioManagerDaemon/src/CommandReceiver.cpp
@@ -0,0 +1,136 @@
+/*
+ * CommandReceiver.cpp
+ *
+ * Created on: Oct 24, 2011
+ * Author: christian
+ */
+
+#include "CommandReceiver.h"
+
+CommandReceiver::CommandReceiver(DatabaseHandler* iDatabaseHandler, DBusWrapper* iDBusWrapper)
+: mDatabaseHandler(iDatabaseHandler), mDBusWrapper(iDBusWrapper)
+{
+}
+
+CommandReceiver::~CommandReceiver()
+{
+}
+
+am_Error_e CommandReceiver::connect(const am_sourceID_t sourceID, const am_sinkID_t sinkID, am_mainConnectionID_t & mainConnectionID)
+{
+ mainConnectionID=4;
+ return E_OK;
+}
+
+
+
+am_Error_e CommandReceiver::disconnect(const am_mainConnectionID_t mainConnectionID)
+{
+}
+
+
+
+am_Error_e CommandReceiver::setVolume(const am_sinkID_t sinkID, const am_mainVolume_t volume)
+{
+}
+
+
+
+am_Error_e CommandReceiver::volumeStep(const am_sinkID_t sinkID, const int16_t volumeStep)
+{
+}
+
+
+
+am_Error_e CommandReceiver::setSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+}
+
+
+
+am_Error_e CommandReceiver::setMainSinkSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+{
+}
+
+
+
+am_Error_e CommandReceiver::setMainSourceSoundProperty(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+{
+}
+
+
+
+am_Error_e CommandReceiver::setSystemProperty(const am_SystemProperty_s & property)
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
+{
+ mDatabaseHandler->getListVisibleMainConnections(listConnections);
+
+}
+
+
+
+am_Error_e CommandReceiver::getListMainSinks(std::vector<am_SinkType_s>& listMainSinks) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListMainSources(std::vector<am_SourceType_s>& listMainSources) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const
+{
+}
+
+
+
+am_Error_e CommandReceiver::getDBusConnectionWrapper(DBusWrapper*& dbusConnectionWrapper) const
+{
+ dbusConnectionWrapper=mDBusWrapper;
+ return E_OK;
+}
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/CommandSender.cpp b/AudioManagerDaemon/src/CommandSender.cpp
new file mode 100644
index 0000000..113ea2b
--- /dev/null
+++ b/AudioManagerDaemon/src/CommandSender.cpp
@@ -0,0 +1,233 @@
+/*
+ * CommandSender.cpp
+ *
+ * Created on: Oct 26, 2011
+ * Author: christian
+ */
+
+#include "CommandSender.h"
+#include "command/CommandSendInterface.h"
+#include "pluginTemplate.h"
+using namespace am;
+
+#define CALL_ALL_INTERFACES(...) \
+ std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin(); \
+ std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end(); \
+ for (; iter<iterEnd;++iter) \
+ { \
+ (*iter)->__VA_ARGS__; \
+ }
+
+
+const char* commandPluginDirectories[] = { "/home/christian/workspace/gitserver/build/plugins/command"};
+uint16_t commandPluginDirectoriesCount = sizeof(commandPluginDirectories) / sizeof(commandPluginDirectories[0]);
+
+CommandSender::CommandSender()
+{
+ std::vector<std::string> sharedLibraryNameList;
+
+ // search communicator plugins in configured directories
+ for (uint16_t dirIndex = 0; dirIndex < commandPluginDirectoriesCount; dirIndex++)
+ {
+ const char* directoryName = commandPluginDirectories[dirIndex];
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Searching for HookPlugins in"),DLT_STRING(directoryName));
+ DIR *directory = opendir(directoryName);
+
+ if (!directory)
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Error opening directory "),DLT_STRING(dirName.c_str()));
+ }
+
+ // iterate content of directory
+ struct dirent *itemInDirectory = 0;
+ while ((itemInDirectory = readdir(directory)))
+ {
+ unsigned char entryType = itemInDirectory->d_type;
+ std::string entryName = itemInDirectory->d_name;
+
+ bool regularFile = (entryType == DT_REG);
+ bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
+
+ if (regularFile && sharedLibExtension)
+ {
+ // DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("PluginSearch adding file "),DLT_STRING(entryName.c_str()));
+ std::string name(directoryName);
+ sharedLibraryNameList.push_back(name + "/" + entryName);
+ }
+ else
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("PluginSearch ignoring file "),DLT_STRING(entryName.c_str()));
+ }
+ }
+
+ closedir(directory);
+ }
+
+ // iterate all communicator plugins and start them
+ std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
+ std::vector<std::string>::iterator iterEnd = sharedLibraryNameList.end();
+
+ for (; iter < iterEnd; ++iter)
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Loading Hook plugin"),DLT_STRING(iter->c_str()));
+ CommandSendInterface* (*createFunc)();
+ createFunc = getCreateFunction<CommandSendInterface*()>(*iter);
+
+ if (!createFunc)
+ {
+ // DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of Communicator not found"));
+ continue;
+ }
+
+ CommandSendInterface* commander = createFunc();
+
+ if (!commander)
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("HookPlugin initialization failed. Entry Function not callable"));
+ continue;
+ }
+
+ mListInterfaces.push_back(commander);
+ }
+}
+
+CommandSender::~CommandSender()
+{
+}
+
+
+am_Error_e CommandSender::stopInterface()
+{
+ am_Error_e returnError=E_OK;
+
+ std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin();
+ std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end();
+ for (; iter<iterEnd;++iter)
+ {
+ am_Error_e error=(*iter)->stopInterface();
+ if (error!= E_OK)
+ {
+ returnError=error;
+ }
+ }
+ return returnError;
+}
+
+
+am_Error_e CommandSender::startupInterface(CommandReceiveInterface *commandreceiveinterface)
+{
+ am_Error_e returnError=E_OK;
+
+ std::vector<CommandSendInterface*>::iterator iter = mListInterfaces.begin();
+ std::vector<CommandSendInterface*>::iterator iterEnd = mListInterfaces.end();
+ for (; iter<iterEnd;++iter)
+ {
+ am_Error_e error=(*iter)->startupInterface(commandreceiveinterface);
+ if (error!= E_OK)
+ {
+ returnError=error;
+ }
+ }
+ return returnError;
+}
+
+
+void CommandSender::cbCommunicationReady()
+{
+ CALL_ALL_INTERFACES(cbCommunicationReady())
+}
+
+void CommandSender::cbCommunicationRundown()
+{
+ CALL_ALL_INTERFACES(cbCommunicationRundown())
+}
+
+void CommandSender::cbNumberOfMainConnectionsChanged()
+{
+ CALL_ALL_INTERFACES(cbNumberOfMainConnectionsChanged())
+}
+
+void CommandSender::cbNumberOfSinksChanged()
+{
+ CALL_ALL_INTERFACES(cbNumberOfSinksChanged())
+}
+
+void CommandSender::cbNumberOfSourcesChanged()
+{
+ CALL_ALL_INTERFACES(cbNumberOfSourcesChanged())
+}
+
+void CommandSender::cbNumberOfSinkClassesChanged()
+{
+ CALL_ALL_INTERFACES(cbNumberOfSinkClassesChanged())
+}
+
+void CommandSender::cbNumberOfSourceClassesChanged()
+{
+ CALL_ALL_INTERFACES(cbNumberOfSourceClassesChanged())
+}
+
+
+void CommandSender::cbMainConnectionStateChanged(const am_mainConnectionID_t connectionID, const am_ConnectionState_e connectionState)
+{
+ CALL_ALL_INTERFACES(cbMainConnectionStateChanged(connectionID,connectionState))
+}
+
+
+
+void CommandSender::cbMainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s SoundProperty)
+{
+ CALL_ALL_INTERFACES(cbMainSinkSoundPropertyChanged(sinkID,SoundProperty))
+}
+
+
+
+void CommandSender::cbMainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
+{
+ CALL_ALL_INTERFACES(cbMainSourceSoundPropertyChanged(sourceID,SoundProperty))
+}
+
+
+
+void CommandSender::cbSinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+ CALL_ALL_INTERFACES(cbSinkAvailabilityChanged(sinkID,availability))
+}
+
+
+
+void CommandSender::cbSourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+ CALL_ALL_INTERFACES(cbSourceAvailabilityChanged(sourceID,availability))
+}
+
+
+
+void CommandSender::cbVolumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
+{
+ CALL_ALL_INTERFACES(cbVolumeChanged(sinkID,volume))
+}
+
+
+
+void CommandSender::cbSinkMuteStateChanged(const am_sinkID_t sinkID, const am_MuteState_e muteState)
+{
+ CALL_ALL_INTERFACES(cbSinkMuteStateChanged(sinkID,muteState))
+}
+
+
+
+void CommandSender::cbSystemPropertyChanged(const am_SystemProperty_s & SystemProperty)
+{
+ CALL_ALL_INTERFACES(cbSystemPropertyChanged(SystemProperty))
+}
+
+
+
+void CommandSender::cbTimingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
+{
+ CALL_ALL_INTERFACES(cbTimingInformationChanged(mainConnection,time))
+}
+
+
+
diff --git a/AudioManagerDaemon/src/ControlLoader.cpp b/AudioManagerDaemon/src/ControlLoader.cpp
new file mode 100644
index 0000000..8f5e5ea
--- /dev/null
+++ b/AudioManagerDaemon/src/ControlLoader.cpp
@@ -0,0 +1,42 @@
+/*
+ * ControlLoader.cpp
+ *
+ * Created on: Oct 25, 2011
+ * Author: christian
+ */
+
+#include "ControlLoader.h"
+#include "pluginTemplate.h"
+#include <string>
+
+ControlLoader::ControlLoader()
+{
+ ControlSendInterface* (*createFunc)();
+ std::string libPath="/home/christian/workspace/gitserver/build/plugins/control/libPluginControlInterface.so";
+ createFunc = getCreateFunction<ControlSendInterface*()>(libPath);
+
+ if (!createFunc) {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of Communicator not found"));
+ }
+
+ //mControler = createFunc();
+
+ if (!mControler) {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("RoutingPlugin initialization failed. Entry Function not callable"));
+ }
+
+}
+
+
+
+ControlLoader::~ControlLoader()
+{
+}
+
+
+
+ControlSendInterface *ControlLoader::returnControl()
+{
+ return mControler;
+}
+
diff --git a/AudioManagerDaemon/src/ControlReceiver.cpp b/AudioManagerDaemon/src/ControlReceiver.cpp
new file mode 100644
index 0000000..d841144
--- /dev/null
+++ b/AudioManagerDaemon/src/ControlReceiver.cpp
@@ -0,0 +1,409 @@
+/*
+ * ContronlReceiver.cpp
+ *
+ * Created on: Oct 24, 2011
+ * Author: christian
+ */
+
+#include "ControlReceiver.h"
+
+ControlReceiver::ControlReceiver(DatabaseHandler* iDatabaseHandler) : mDatabaseHandler(iDatabaseHandler)
+{
+}
+
+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)
+{
+}
+
+
+
+am_Error_e ControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_ConnectionFormat_e format, const am_sourceID_t sourceID, const am_sinkID_t sinkID)
+{
+}
+
+
+
+am_Error_e ControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID)
+{
+}
+
+
+
+am_Error_e ControlReceiver::crossfade(am_Handle_s & handle, const am_HotSink_e hotSource, const am_crossfaderID_t crossfaderID, const am_RampType_e rampType, const am_time_t rampTime)
+{
+}
+
+
+
+am_Error_e ControlReceiver::setSourceState(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SourceState_e state)
+{
+}
+
+
+
+am_Error_e ControlReceiver::setSinkVolume(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 ControlReceiver::setSourceVolume(am_Handle_s & handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e rampType, const am_time_t time)
+{
+}
+
+
+
+am_Error_e ControlReceiver::setSinkSoundProperty(am_Handle_s & handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
+{
+}
+
+
+
+am_Error_e ControlReceiver::setSourceSoundProperty(am_Handle_s & handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
+{
+}
+
+
+
+am_Error_e ControlReceiver::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
+{
+}
+
+
+
+am_Error_e ControlReceiver::abortAction(const am_Handle_s handle)
+{
+}
+
+
+
+am_Error_e ControlReceiver::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
+{
+ return mDatabaseHandler->enterDomainDB(domainData,domainID);
+}
+
+
+
+am_Error_e ControlReceiver::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
+{
+ return mDatabaseHandler->enterMainConnectionDB(mainConnectionData,connectionID);
+}
+
+
+
+am_Error_e ControlReceiver::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+{
+ return mDatabaseHandler->enterSinkDB(sinkData,sinkID);
+}
+
+
+
+am_Error_e ControlReceiver::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+{
+ return mDatabaseHandler->enterCrossfaderDB(crossfaderData,crossfaderID);
+}
+
+
+
+am_Error_e ControlReceiver::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+{
+ return mDatabaseHandler->enterGatewayDB(gatewayData,gatewayID);
+}
+
+
+
+am_Error_e ControlReceiver::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+{
+ return mDatabaseHandler->enterSourceDB(sourceData,sourceID);
+}
+
+am_Error_e ControlReceiver::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
+{
+ return mDatabaseHandler->enterSinkClassDB(sinkClass,sinkClassID);
+}
+
+am_Error_e ControlReceiver::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
+{
+ return mDatabaseHandler->enterSourceClassDB(sourceClassID,sourceClass);
+}
+
+
+am_Error_e ControlReceiver::enterSystemPropertiesListDB(const std::vector<am_SystemProperty_s> & listSystemProperties)
+{
+ return mDatabaseHandler->enterSystemProperties(listSystemProperties);
+}
+
+
+am_Error_e ControlReceiver::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s & route)
+{
+ return mDatabaseHandler->changeMainConnectionRouteDB(mainconnectionID,route);
+}
+
+
+
+am_Error_e ControlReceiver::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
+{
+ return mDatabaseHandler->changeMainConnectionStateDB(mainconnectionID,connectionState);
+}
+
+
+
+am_Error_e ControlReceiver::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
+{
+ return mDatabaseHandler->changeSinkMainVolumeDB(mainVolume,sinkID);
+}
+
+
+
+am_Error_e ControlReceiver::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
+{
+ return mDatabaseHandler->changeSinkAvailabilityDB(availability,sinkID);
+}
+
+
+
+am_Error_e ControlReceiver::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
+{
+ return mDatabaseHandler->changDomainStateDB(domainState,domainID);
+}
+
+
+
+am_Error_e ControlReceiver::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
+{
+ return mDatabaseHandler->changeSinkMuteStateDB(muteState,sinkID);
+}
+
+
+
+am_Error_e ControlReceiver::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+{
+ return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty,sinkID);
+}
+
+
+
+am_Error_e ControlReceiver::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+{
+ return mDatabaseHandler->changeMainSinkSoundPropertyDB(soundProperty,sourceID);
+}
+
+
+
+am_Error_e ControlReceiver::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
+{
+ return mDatabaseHandler->changeSourceAvailabilityDB(availability,sourceID);
+}
+
+
+
+am_Error_e ControlReceiver::changeSystemPropertyDB(const am_SystemProperty_s & property)
+{
+ return mDatabaseHandler->changeSystemPropertyDB(property);
+}
+
+
+
+am_Error_e ControlReceiver::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
+{
+ return mDatabaseHandler->removeMainConnectionDB(mainConnectionID);
+}
+
+
+
+am_Error_e ControlReceiver::removeSinkDB(const am_sinkID_t sinkID)
+{
+ return mDatabaseHandler->removeSinkDB(sinkID);
+}
+
+
+
+am_Error_e ControlReceiver::removeSourceDB(const am_sourceID_t sourceID)
+{
+ return mDatabaseHandler->removeSourceDB(sourceID);
+}
+
+
+
+am_Error_e ControlReceiver::removeGatewayDB(const am_gatewayID_t gatewayID)
+{
+ return mDatabaseHandler->removeGatewayDB(gatewayID);
+}
+
+
+
+am_Error_e ControlReceiver::removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
+{
+ return mDatabaseHandler->removeCrossfaderDB(crossfaderID);
+}
+
+
+
+am_Error_e ControlReceiver::removeDomainDB(const am_domainID_t domainID)
+{
+ return mDatabaseHandler->removeDomainDB(domainID);
+}
+
+
+
+am_Error_e ControlReceiver::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
+{
+ return mDatabaseHandler->getSourceClassInfoDB(sourceID,classInfo);
+}
+
+
+am_Error_e ControlReceiver::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
+{
+ return mDatabaseHandler->getSinkClassInfoDB(sinkID,sinkClass);
+}
+
+
+
+am_Error_e ControlReceiver::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
+{
+ return mDatabaseHandler->getGatewayInfoDB(gatewayID,gatewayData);
+}
+
+
+
+am_Error_e ControlReceiver::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
+{
+ return mDatabaseHandler->getCrossfaderInfoDB(crossfaderID,crossfaderData);
+}
+
+
+
+am_Error_e ControlReceiver::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
+{
+ return mDatabaseHandler->getListSinksOfDomain(domainID,listSinkID);
+}
+
+
+
+am_Error_e ControlReceiver::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
+{
+ return mDatabaseHandler->getListSourcesOfDomain(domainID,listSourceID);
+}
+
+
+
+am_Error_e ControlReceiver::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
+{
+ return mDatabaseHandler->getListCrossfadersOfDomain(domainID,listGatewaysID);
+}
+
+
+
+am_Error_e ControlReceiver::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
+{
+ return mDatabaseHandler->getListGatewaysOfDomain(domainID,listGatewaysID);
+}
+
+
+
+am_Error_e ControlReceiver::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
+{
+ return mDatabaseHandler->getListMainConnections(listMainConnections);
+}
+
+
+
+am_Error_e ControlReceiver::getListDomains(std::vector<am_Domain_s> & listDomains) const
+{
+ return mDatabaseHandler->getListDomains(listDomains);
+}
+
+
+
+am_Error_e ControlReceiver::getListConnections(std::vector<am_Connection_s> & listConnections) const
+{
+ return mDatabaseHandler->getListConnections(listConnections);
+}
+
+
+
+am_Error_e ControlReceiver::getListSinks(std::vector<am_Sink_s> & listSinks) const
+{
+ return mDatabaseHandler->getListSinks(listSinks);
+}
+
+
+
+am_Error_e ControlReceiver::getListSources(std::vector<am_Source_s> & listSources) const
+{
+ return mDatabaseHandler->getListSources(listSources);
+}
+
+
+
+am_Error_e ControlReceiver::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
+{
+ return mDatabaseHandler->getListSourceClasses(listSourceClasses);
+}
+
+
+
+am_Error_e ControlReceiver::getListHandles(std::vector<am_Handle_s> & listHandles) const
+{
+ //todo: implement getListHandles
+}
+
+
+
+am_Error_e ControlReceiver::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
+{
+ return mDatabaseHandler->getListCrossfaders(listCrossfaders);
+}
+
+
+
+am_Error_e ControlReceiver::getListGateways(std::vector<am_Gateway_s> & listGateways) const
+{
+ return mDatabaseHandler->getListGateways(listGateways);
+}
+
+
+
+am_Error_e ControlReceiver::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
+{
+ return mDatabaseHandler->getListSinkClasses(listSinkClasses);
+}
+
+
+am_Error_e ControlReceiver::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
+{
+ return mDatabaseHandler->getListSystemProperties(listSystemProperties);
+}
+
+
+void ControlReceiver::setRoutingReady()
+{
+}
+
+
+am_Error_e ControlReceiver::changeSinkClassInfoDB(const am_SinkClass_s & classInfo)
+{
+}
+
+am_Error_e ControlReceiver::changeSourceClassInfoDB(const am_SourceClass_s & classInfo)
+{
+}
+
+am_Error_e ControlReceiver::removeSinkClassDB(const am_sinkClass_t sinkClassID)
+{
+}
+
+am_Error_e ControlReceiver::removeSourceClassDB(const am_sourceClass_t sourceClassID)
+{
+}
+
+void ControlReceiver::setCommandReady()
+{
+}
+
+
+
diff --git a/AudioManagerDaemon/src/DBusWrapper.cpp b/AudioManagerDaemon/src/DBusWrapper.cpp
new file mode 100644
index 0000000..f614aab
--- /dev/null
+++ b/AudioManagerDaemon/src/DBusWrapper.cpp
@@ -0,0 +1,182 @@
+/**
+* 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 "DBusWrapper.h"
+#include <dlt/dlt.h>
+#include <fstream>
+#include <sstream>
+#include <string>
+
+DLT_IMPORT_CONTEXT(AudioManager);
+
+
+#define ROOT_INTROSPECT_XML \
+DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
+"<node>" \
+"<interface name='org.freedesktop.DBus.Introspectable'>" \
+"<method name='Introspect'>" \
+" <arg name='xml_data' type='s' direction='out'/>" \
+"</method>" \
+"</interface>" \
+
+DBusWrapper* DBusWrapper::mReference = NULL;
+
+
+DBusWrapper::DBusWrapper()
+ : mDbusConnection(0),
+ mDBusError(),
+ mNodesList()
+{
+ dbus_error_init(&mDBusError);
+
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::DBusWrapper Opening DBus connection"));
+
+ mDbusConnection=dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
+ if (dbus_error_is_set(&mDBusError))
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Error while getting the DBus"));
+ dbus_error_free(&mDBusError);
+ }
+ if (NULL == mDbusConnection)
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper DBus Connection is null"));
+ }
+
+ mObjectPathVTable.message_function=DBusWrapper::cbRootIntrospection;
+ dbus_connection_register_object_path(mDbusConnection,DBUS_SERVICE_OBJECT_PATH , &mObjectPathVTable, this);
+ int ret = dbus_bus_request_name(mDbusConnection,DBUS_SERVICE_PREFIX,DBUS_NAME_FLAG_DO_NOT_QUEUE, &mDBusError);
+ if (dbus_error_is_set(&mDBusError))
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Name Error"),DLT_STRING(mDBusError.message));
+ dbus_error_free(&mDBusError);
+ }
+ if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret)
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::DBusWrapper Wrapper is not the Primary Owner"), DLT_INT(ret));
+ }
+}
+
+DBusWrapper::~DBusWrapper()
+{
+ //close the connection again
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~DBusWrapper Closing DBus connection"));
+ dbus_connection_close(mDbusConnection);
+}
+
+void DBusWrapper::registerCallback(const DBusObjectPathVTable* vtable, const std::string& path, void* userdata)
+{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~registerCallback register callback:"),DLT_STRING(path.c_str()));
+
+ std::string completePath=std::string(DBUS_SERVICE_OBJECT_PATH)+"/"+path;
+ dbus_error_init(&mDBusError);
+ mDbusConnection=dbus_bus_get(DBUS_BUS_SESSION, &mDBusError);
+ dbus_connection_register_object_path(mDbusConnection,completePath.c_str(), vtable, userdata);
+ if (dbus_error_is_set(&mDBusError))
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::registerCallack error: "),DLT_STRING(mDBusError.message));
+ dbus_error_free(&mDBusError);
+ }
+ mNodesList.push_back(path);
+}
+
+DBusHandlerResult DBusWrapper::cbRootIntrospection(DBusConnection *conn, DBusMessage *msg, void *reference)
+{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~cbRootIntrospection called:"));
+
+ mReference=(DBusWrapper*)reference;
+ std::list<std::string>nodesList=mReference->mNodesList;
+ DBusMessage * reply;
+ DBusMessageIter args;
+ dbus_uint32_t serial = 0;
+ if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
+ {
+ std::list<std::string>::iterator nodeIter=nodesList.begin();
+ const char *xml=ROOT_INTROSPECT_XML;
+ std::stringstream introspect;
+ introspect << std::string(xml);
+ for(;nodeIter!=nodesList.end();++nodeIter)
+ {
+ introspect<<"<node name='"<<nodeIter->c_str()<<"'/>";
+ }
+ introspect<<"</node>";
+
+ reply = dbus_message_new_method_return(msg);
+ std::string s = introspect.str();
+ const char* string=s.c_str();
+
+ // add the arguments to the reply
+ dbus_message_iter_init_append(reply, &args);
+ if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string))
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!"));
+ }
+
+ // send the reply && flush the connection
+ if (!dbus_connection_send(conn, reply, &serial))
+ {
+ DLT_LOG(AudioManager,DLT_LOG_ERROR, DLT_STRING("DBusWrapper::~cbRootIntrospection DBUS Out Of Memory!"));
+ }
+ dbus_connection_flush(conn);
+ // free the reply
+ dbus_message_unref(reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+ }
+ else
+ {
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+}
+
+void DBusWrapper::dbusMainLoop()
+{
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("DBusWrapper::~dbusMainLoop Entering MainLoop"));
+
+ while (dbus_connection_read_write_dispatch(mDbusConnection, -1))
+ {
+
+ }
+}
+
+void DBusWrapper::getDBusConnection(DBusConnection *& connection) const
+{
+ connection=mDbusConnection;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp
new file mode 100644
index 0000000..948ff94
--- /dev/null
+++ b/AudioManagerDaemon/src/DatabaseHandler.cpp
@@ -0,0 +1,2840 @@
+/*
+ * DatabaseHandler.cpp
+ *
+ * Created on: Oct 24, 2011
+ * Author: christian
+ */
+
+#include "DatabaseHandler.h"
+#include <dlt/dlt.h>
+#include <assert.h>
+#include <stdint.h>
+#include <fstream>
+#include <sstream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+
+DLT_IMPORT_CONTEXT(AudioManager);
+
+//#define DATABASE_PATH "/tmp/audiomanager.sqlite"
+#define DATABASE_PATH ":memory:"
+
+#define DOMAIN_TABLE "Domains"
+#define SOURCE_CLASS_TABLE "SourceClasses"
+#define SINK_CLASS_TABLE "SinkClasses"
+#define SOURCE_TABLE "Sources"
+#define SINK_TABLE "Sinks"
+#define GATEWAY_TABLE "Gateways"
+#define CONNECTION_TABLE "Connections"
+#define MAINCONNECTION_TABLE "MainConnections"
+#define INTERRUPT_TABLE "Interrupts"
+#define MAIN_TABLE "MainTable"
+#define SYSTEM_TABLE "SystemProperties"
+
+const std::string databaseTables[]={
+ " Domains (domainID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), busname VARCHAR(50), nodename VARCHAR(50), early BOOL, complete BOOL, state INTEGER);",
+ " SourceClasses (sourceClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
+ " SinkClasses (sinkClassID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50));",
+ " Sources (sourceID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, domainID INTEGER, name VARCHAR(50), sourceClassID INTEGER, sourceState INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, interruptState INTEGER);",
+ " Sinks (sinkID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), domainID INTEGER, sinkClassID INTEGER, volume INTEGER, visible BOOL, availability INTEGER, availabilityReason INTEGER, muteState INTEGER, mainVolume INTEGER);",
+ " Gateways (gatewayID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, name VARCHAR(50), sinkID INTEGER, sourceID INTEGER, domainSinkID INTEGER, domainSourceID INTEGER, controlDomainID INTEGER);",
+ " Connections (connectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, delay INTEGER, connectionFormat INTEGER );",
+ " MainConnections (mainConnectionID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, sourceID INTEGER, sinkID INTEGER, connectionState INTEGER, delay INTEGER);",
+ " SystemProperties (type INTEGER PRIMARY KEY, value INTEGER);"
+};
+
+/**
+ * template to converts T to std::string
+ * @param i the value to be converted
+ * @return the string
+ */
+
+std::string int2string(int i) {
+ std::stringstream out;
+ out << i;
+ return out.str();
+}
+
+
+DatabaseHandler::DatabaseHandler()
+ : mDatabase(NULL),
+ mPath(DATABASE_PATH),
+ mFirstStaticSink(true),
+ mFirstStaticSource(true),
+ mFirstStaticGateway(true),
+ mFirstStaticSinkClass(true),
+ mFirstStaticSourceClass(true),
+ mListConnectionFormat()
+{
+
+ /**
+ *\todo: this erases the database. just for testing!
+ */
+ std::ifstream infile(mPath.c_str());
+
+ if (infile)
+ {
+ remove(mPath.c_str());
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::DatabaseHandler Knocked down database"));
+ }
+
+ bool dbOpen=openDatabase();
+ if (!dbOpen)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::DatabaseHandler problems opening the database!"));
+ assert(!dbOpen);
+ }
+
+ createTables();
+}
+
+
+
+DatabaseHandler::~DatabaseHandler()
+{
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("Closed Database"));
+ sqlite3_close(mDatabase);
+}
+
+
+
+am_Error_e DatabaseHandler::enterDomainDB(const am_Domain_s & domainData, am_domainID_t & domainID)
+{
+ assert(domainData.domainID==0);
+ assert(!domainData.name.empty());
+ assert(!domainData.busname.empty());
+ assert(domainData.state>=DS_CONTROLLED && domainData.state<=DS_INDEPENDENT_RUNDOWN);
+
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command= "INSERT INTO " + std::string(DOMAIN_TABLE) + "(name, busname, nodename, early, complete, state) VALUES (?,?,?,?,?,?)";
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, domainData.name.c_str(),domainData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_text(query,2, domainData.busname.c_str(),domainData.busname.size(),SQLITE_STATIC);
+ sqlite3_bind_text(query,3, domainData.nodename.c_str(),domainData.nodename.size(),SQLITE_STATIC);
+ sqlite3_bind_int(query,4, domainData.early);
+ sqlite3_bind_int(query,5, domainData.complete);
+ sqlite3_bind_int(query,6, domainData.state);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterDomainDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ domainID=sqlite3_last_insert_rowid(mDatabase);
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterDomainDB entered new domain with name"), DLT_STRING(domainData.name.c_str()),
+ DLT_STRING("busname:"),DLT_STRING(domainData.busname.c_str()),
+ DLT_STRING("nodename:"),DLT_STRING(domainData.nodename.c_str()),
+ DLT_STRING("early:"), DLT_BOOL(domainData.early),
+ DLT_STRING("complete:"),DLT_BOOL(domainData.complete),
+ DLT_STRING("state:"),DLT_INT(domainData.state),
+ DLT_STRING("assigned ID:"),DLT_INT16(domainID));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::enterMainConnectionDB(const am_MainConnection_s & mainConnectionData, am_mainConnectionID_t & connectionID)
+{
+ assert(mainConnectionData.connectionID==0);
+ assert(mainConnectionData.connectionState>=CS_CONNECTING && mainConnectionData.connectionState<=CS_SUSPENDED);
+ assert(mainConnectionData.route.sinkID!=0);
+ assert(mainConnectionData.route.sourceID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command= "INSERT INTO " + std::string(MAINCONNECTION_TABLE) + "(sourceID, sinkID, connectionState) VALUES (?,?,?)";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, mainConnectionData.route.sourceID);
+ sqlite3_bind_int(query,2, mainConnectionData.route.sinkID);
+ sqlite3_bind_int(query,3, mainConnectionData.connectionState);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ connectionID=sqlite3_last_insert_rowid(mDatabase);
+
+ //now check the connectionTabel for all connections in the route. IF a particular route is not found, we return with error
+ std::vector<uint16_t> listOfConnections;
+ int16_t delay=0;
+ command="SELECT connectionID, delay FROM "+std::string(CONNECTION_TABLE)+(" WHERE sourceID=? AND sinkID=? AND connectionFormat=?");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_RoutingElement_s>::const_iterator elementIterator=mainConnectionData.route.route.begin();
+ for (;elementIterator<mainConnectionData.route.route.end();++elementIterator)
+ {
+ sqlite3_bind_int(query,1, elementIterator->sourceID);
+ sqlite3_bind_int(query,2, elementIterator->sinkID);
+ sqlite3_bind_int(query,3, elementIterator->connectionFormat);
+
+ if((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ listOfConnections.push_back(sqlite3_column_int(query,0));
+ int16_t temp_delay=sqlite3_column_int(query,1);
+ if (temp_delay!=-1 && delay!=-1) delay+=temp_delay;
+ else delay=-1;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB did not find route for MainConnection:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //now we create a table with references to the connections;
+ command="CREATE TABLE MainConnectionRoute" + int2string(connectionID) + std::string("(connectionID INTEGER)");
+ assert(this->sqQuery(command));
+
+ command= "INSERT INTO MainConnectionRoute" + int2string(connectionID) + "(connectionID) VALUES (?)";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<uint16_t>::iterator listConnectionIterator=listOfConnections.begin();
+ for(;listConnectionIterator<listOfConnections.end();++listConnectionIterator)
+ {
+ sqlite3_bind_int(query,1, *listConnectionIterator);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterMainConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterMainConnectionDB entered new mainConnection with sourceID"), DLT_INT(mainConnectionData.route.sourceID),
+ DLT_STRING("sinkID:"),DLT_INT16(mainConnectionData.route.sinkID),
+ DLT_STRING("delay:"),DLT_INT16(delay),
+ DLT_STRING("assigned ID:"),DLT_INT16(connectionID));
+
+ //finally, we update the delay value for the maintable
+ if (delay==0) delay=-1;
+ return changeDelayMainConnection(delay,connectionID);
+}
+
+
+
+am_Error_e DatabaseHandler::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+{
+ assert(sinkData.sinkID<DYNAMIC_ID_BOUNDARY);
+ assert(sinkData.domainID!=0);
+ assert(!sinkData.name.empty());
+ assert(sinkData.sinkClassID!=0); // \todo: need to check if class exists?
+ assert(!sinkData.listConnectionFormats.empty());
+ assert(sinkData.muteState>=MS_MUTED && sinkData.muteState<=MS_UNMUTED);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sinkData.sinkID==0 && !mFirstStaticSink)
+ {
+ command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume) VALUES (?,?,?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if(existSink(sinkData.sinkID)) return E_ALREADY_EXISTS;
+ command= "INSERT INTO " + std::string(SINK_TABLE) + "(name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, sinkData.name.c_str(),sinkData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(query,2, sinkData.domainID);
+ sqlite3_bind_int(query,3, sinkData.sinkClassID);
+ sqlite3_bind_int(query,4, sinkData.volume);
+ sqlite3_bind_int(query,5, sinkData.visible);
+ sqlite3_bind_int(query,6, sinkData.available.availability);
+ sqlite3_bind_int(query,7, sinkData.available.availabilityReason);
+ sqlite3_bind_int(query,8, sinkData.muteState);
+ sqlite3_bind_int(query,9, sinkData.mainVolume);
+
+ //if the ID is not created, we add it to the query
+ if(sinkData.sinkID!=0)
+ {
+ sqlite3_bind_int(query,10, sinkData.sinkID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if(mFirstStaticSink)
+ {
+ sqlite3_bind_int(query,10, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSink=false;
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sinkID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
+
+ //now we need to create the additional tables:
+ command="CREATE TABLE SinkConnectionFormat" + int2string(sinkID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+ command="CREATE TABLE SinkMainSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+ command="CREATE TABLE SinkSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command="INSERT INTO SinkConnectionFormat" + int2string(sinkID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=sinkData.listConnectionFormats.begin();
+ for(;connectionFormatIterator<sinkData.listConnectionFormats.end();++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query,1, *connectionFormatIterator);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill MainSinkSoundProperties
+ command="INSERT INTO SinkMainSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator=sinkData.listMainSoundProperties.begin();
+ for(;mainSoundPropertyIterator<sinkData.listMainSoundProperties.end();++mainSoundPropertyIterator)
+ {
+ sqlite3_bind_int(query,1, mainSoundPropertyIterator->type);
+ sqlite3_bind_int(query,2, mainSoundPropertyIterator->value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill SinkSoundProperties
+ command="INSERT INTO SinkSoundProperty" + int2string(sinkID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator=sinkData.listSoundProperties.begin();
+ for(;SoundPropertyIterator<sinkData.listSoundProperties.end();++SoundPropertyIterator)
+ {
+ sqlite3_bind_int(query,1, SoundPropertyIterator->type);
+ sqlite3_bind_int(query,2, SoundPropertyIterator->value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkDB entered new sink with name"), DLT_STRING(sinkData.name.c_str()),
+ DLT_STRING("domainID:"),DLT_INT(sinkData.domainID),
+ DLT_STRING("classID:"),DLT_INT(sinkData.sinkClassID),
+ DLT_STRING("volume:"),DLT_INT(sinkData.volume),
+ DLT_STRING("visible:"),DLT_BOOL(sinkData.visible),
+ DLT_STRING("available.availability:"),DLT_INT(sinkData.available.availability),
+ DLT_STRING("available.availabilityReason:"),DLT_INT(sinkData.available.availabilityReason),
+ DLT_STRING("muteState:"),DLT_INT(sinkData.muteState),
+ DLT_STRING("mainVolume:"),DLT_INT(sinkData.mainVolume),
+ DLT_STRING("assigned ID:"),DLT_INT16(sinkID));
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+{
+ //todo: implement crossfader
+ (void)crossfaderData;
+ (void)crossfaderID;
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e DatabaseHandler::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+{
+ assert(gatewayData.gatewayID<DYNAMIC_ID_BOUNDARY);
+ assert(gatewayData.sinkID!=0);
+ assert(gatewayData.sourceID!=0);
+ assert(gatewayData.controlDomainID!=0);
+ assert(gatewayData.domainSinkID!=0);
+ assert(gatewayData.domainSourceID!=0);
+ assert(!gatewayData.name.empty());
+ assert(!gatewayData.convertionMatrix.empty());
+ assert(!gatewayData.listSinkFormats.empty());
+ assert(!gatewayData.listSourceFormats.empty());
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (gatewayData.gatewayID==0 && !mFirstStaticGateway)
+ {
+ command= "INSERT INTO " + std::string(GATEWAY_TABLE) + "(name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID) VALUES (?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existGateway(gatewayData.gatewayID)) return E_ALREADY_EXISTS;
+ command= "INSERT INTO " + std::string(GATEWAY_TABLE) + "(name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID) VALUES (?,?,?,?,?,?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, gatewayData.name.c_str(),gatewayData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(query,2, gatewayData.sinkID);
+ sqlite3_bind_int(query,3, gatewayData.sourceID);
+ sqlite3_bind_int(query,4, gatewayData.domainSinkID);
+ sqlite3_bind_int(query,5, gatewayData.domainSourceID);
+ sqlite3_bind_int(query,6, gatewayData.controlDomainID);
+
+ //if the ID is not created, we add it to the query
+ if(gatewayData.gatewayID!=0)
+ {
+ sqlite3_bind_int(query,7, gatewayData.gatewayID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if(mFirstStaticGateway)
+ {
+ sqlite3_bind_int(query,7, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticGateway=false;
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ gatewayID=sqlite3_last_insert_rowid(mDatabase);
+
+ //now the convertion matrix todo: change the map implementation sometimes to blob in sqlite
+ mListConnectionFormat.insert(std::make_pair(gatewayID,gatewayData.convertionMatrix));
+
+ command="CREATE TABLE GatewaySourceFormat" + int2string(gatewayID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+ command="CREATE TABLE GatewaySinkFormat" + int2string(gatewayID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command="INSERT INTO GatewaySourceFormat" + int2string(gatewayID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=gatewayData.listSourceFormats.begin();
+ for(;connectionFormatIterator<gatewayData.listSourceFormats.end();++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query,1, *connectionFormatIterator);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ command="INSERT INTO GatewaySinkFormat" + int2string(gatewayID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ connectionFormatIterator=gatewayData.listSinkFormats.begin();
+ for(;connectionFormatIterator<gatewayData.listSinkFormats.end();++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query,1, *connectionFormatIterator);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterGatewayDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterGatewayDB entered new gateway with name"), DLT_STRING(gatewayData.name.c_str()),
+ DLT_STRING("sourceID:"),DLT_INT(gatewayData.sourceID),
+ DLT_STRING("sinkID:"),DLT_INT(gatewayData.sinkID),
+ DLT_STRING("domainSinkID:"),DLT_INT(gatewayData.domainSinkID),
+ DLT_STRING("domainSourceID:"),DLT_BOOL(gatewayData.domainSourceID),
+ DLT_STRING("controlDomainID:"),DLT_INT(gatewayData.controlDomainID),
+ DLT_STRING("assigned ID:"),DLT_INT16(gatewayID));
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+{
+ assert(sourceData.sourceID<DYNAMIC_ID_BOUNDARY);
+ assert(sourceData.domainID!=0);
+ assert(!sourceData.name.empty());
+ assert(sourceData.sourceClassID!=0); // \todo: need to check if class exists?
+ assert(!sourceData.listConnectionFormats.empty());
+ assert(sourceData.sourceState>=SS_ON && sourceData.sourceState<=SS_PAUSED);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sourceData.sourceID==0 && !mFirstStaticSource)
+ {
+ command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState) VALUES (?,?,?,?,?,?,?,?,?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if (existSource(sourceData.sourceID)) return E_ALREADY_EXISTS;
+ else command= "INSERT INTO " + std::string(SOURCE_TABLE) + "(name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID) VALUES (?,?,?,?,?,?,?,?,?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, sourceData.name.c_str(),sourceData.name.size(),SQLITE_STATIC);
+ sqlite3_bind_int(query,2, sourceData.domainID);
+ sqlite3_bind_int(query,3, sourceData.sourceClassID);
+ sqlite3_bind_int(query,4, sourceData.sourceState);
+ sqlite3_bind_int(query,5, sourceData.volume);
+ sqlite3_bind_int(query,6, sourceData.visible);
+ sqlite3_bind_int(query,7, sourceData.available.availability);
+ sqlite3_bind_int(query,8, sourceData.available.availabilityReason);
+ sqlite3_bind_int(query,9, sourceData.interruptState);
+
+ //if the ID is not created, we add it to the query
+ if(sourceData.sourceID!=0)
+ {
+ sqlite3_bind_int(query,10, sourceData.sourceID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if(mFirstStaticSource)
+ {
+ sqlite3_bind_int(query,10, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSource=false;
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sourceID=sqlite3_last_insert_rowid(mDatabase);
+
+ //now we need to create the additional tables:
+ command="CREATE TABLE SourceConnectionFormat" + int2string(sourceID) + std::string("(soundFormat INTEGER)");
+ assert(this->sqQuery(command));
+ command="CREATE TABLE SourceMainSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+ command="CREATE TABLE SourceSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command="INSERT INTO SourceConnectionFormat" + int2string(sourceID) + std::string("(soundFormat) VALUES (?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ConnectionFormat_e>::const_iterator connectionFormatIterator=sourceData.listConnectionFormats.begin();
+ for(;connectionFormatIterator<sourceData.listConnectionFormats.end();++connectionFormatIterator)
+ {
+ sqlite3_bind_int(query,1, *connectionFormatIterator);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill MainSinkSoundProperties
+ command="INSERT INTO SourceMainSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_MainSoundProperty_s>::const_iterator mainSoundPropertyIterator=sourceData.listMainSoundProperties.begin();
+ for(;mainSoundPropertyIterator<sourceData.listMainSoundProperties.end();++mainSoundPropertyIterator)
+ {
+ sqlite3_bind_int(query,1, mainSoundPropertyIterator->type);
+ sqlite3_bind_int(query,2, mainSoundPropertyIterator->value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ //Fill SinkSoundProperties
+ command="INSERT INTO SourceSoundProperty" + int2string(sourceID) + std::string("(soundPropertyType,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_SoundProperty_s>::const_iterator SoundPropertyIterator=sourceData.listSoundProperties.begin();
+ for(;SoundPropertyIterator<sourceData.listSoundProperties.end();++SoundPropertyIterator)
+ {
+ sqlite3_bind_int(query,1, SoundPropertyIterator->type);
+ sqlite3_bind_int(query,2, SoundPropertyIterator->value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkDB entered new source with name"), DLT_STRING(sourceData.name.c_str()),
+ DLT_STRING("domainID:"),DLT_INT(sourceData.domainID),
+ DLT_STRING("classID:"),DLT_INT(sourceData.sourceClassID),
+ DLT_STRING("volume:"),DLT_INT(sourceData.volume),
+ DLT_STRING("visible:"),DLT_BOOL(sourceData.visible),
+ DLT_STRING("available.availability:"),DLT_INT(sourceData.available.availability),
+ DLT_STRING("available.availabilityReason:"),DLT_INT(sourceData.available.availabilityReason),
+ DLT_STRING("interruptState:"),DLT_INT(sourceData.interruptState),
+ DLT_STRING("assigned ID:"),DLT_INT16(sourceID));
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const am_Route_s & route)
+{
+ assert(mainconnectionID!=0);
+ if(!existMainConnection(mainconnectionID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ std::vector<uint16_t> listOfConnections;
+ int16_t delay=0;
+ command="SELECT connectionID, delay FROM "+std::string(CONNECTION_TABLE)+(" WHERE sourceID=? AND sinkID=? AND connectionFormat=?");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_RoutingElement_s>::const_iterator elementIterator=route.route.begin();
+ for (;elementIterator<route.route.end();++elementIterator)
+ {
+ sqlite3_bind_int(query,1, elementIterator->sourceID);
+ sqlite3_bind_int(query,2, elementIterator->sinkID);
+ sqlite3_bind_int(query,3, elementIterator->connectionFormat);
+
+ if((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ listOfConnections.push_back(sqlite3_column_int(query,0));
+ int16_t temp_delay=sqlite3_column_int(query,1);
+ if (temp_delay!=-1 && delay!=-1) delay+=temp_delay;
+ else delay=-1;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB did not find route for MainConnection:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //now we delete the data in the table
+ command="DELETE from MainConnectionRoute" + int2string(mainconnectionID);
+ assert(this->sqQuery(command));
+
+ command= "INSERT INTO MainConnectionRoute" + int2string(mainconnectionID) + "(connectionID) VALUES (?)";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<uint16_t>::iterator listConnectionIterator=listOfConnections.begin();
+ for(;listConnectionIterator<listOfConnections.end();++listConnectionIterator)
+ {
+ sqlite3_bind_int(query,1, *listConnectionIterator);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionRouteDB entered new route:"),DLT_INT(mainconnectionID));
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
+{
+ assert(mainconnectionID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existMainConnection(mainconnectionID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET connectionState=? WHERE mainConnectionID=" + int2string(mainconnectionID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, connectionState);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainConnectionStateDB changed mainConnectionState of MainConnection:"),DLT_INT(mainconnectionID),DLT_STRING("to:"),DLT_INT(connectionState));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
+{
+ assert(sinkID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET mainVolume=? WHERE sinkID=" + int2string(sinkID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, mainVolume);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMainVolumeDB changed mainVolume of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(mainVolume));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSinkAvailabilityDB(const am_Availability_s & availability, const am_sinkID_t sinkID)
+{
+ assert(sinkID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET availability=?, availabilityReason=? WHERE sinkID=" + int2string(sinkID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, availability.availability);
+ sqlite3_bind_int(query,2, availability.availabilityReason);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ } assert(sinkID!=0);
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkAvailabilityDB changed sinkAvailability of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(availability.availability), DLT_STRING("Reason:"),DLT_INT(availability.availabilityReason));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
+{
+ assert(domainID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(DOMAIN_TABLE) + " SET state=? WHERE domainID=" + int2string(domainID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, domainState);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changDomainStateDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changDomainStateDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changDomainStateDB changed domainState of domain:"),DLT_INT(domainID),DLT_STRING("to:"),DLT_INT(domainState));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
+{
+ assert(sinkID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SINK_TABLE) + " SET muteState=? WHERE sinkID=" + int2string(sinkID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, muteState);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ } assert(sinkID!=0);
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkMuteStateDB changed sinkMuteState of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(muteState));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sinkID_t sinkID)
+{
+ //todo: add checks if soundproperty exists!
+ assert(sinkID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE SinkMainSoundProperty" + int2string(sinkID)+ " SET value=? WHERE soundPropertyType=" + int2string(soundProperty.type);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, soundProperty.value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ } assert(sinkID!=0);
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:"),DLT_INT(sinkID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s & soundProperty, const am_sourceID_t sourceID)
+{
+ //todo: add checks if soundproperty exists!
+ assert(sourceID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE SourceMainSoundProperty" + int2string(sourceID)+ " SET value=? WHERE soundPropertyType=" + int2string(soundProperty.type);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, soundProperty.value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:"),DLT_INT(sourceID),DLT_STRING("type:"),DLT_INT(soundProperty.type),DLT_STRING("to:"),DLT_INT(soundProperty.value));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSourceAvailabilityDB(const am_Availability_s & availability, const am_sourceID_t sourceID)
+{
+ assert(sourceID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ command = "UPDATE " + std::string(SOURCE_TABLE) + " SET availability=?, availabilityReason=? WHERE sourceID=" + int2string(sourceID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, availability.availability);
+ sqlite3_bind_int(query,2, availability.availabilityReason);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceAvailabilityDB changed changeSourceAvailabilityDB of source:"),DLT_INT(sourceID),DLT_STRING("to:"),DLT_INT(availability.availability), DLT_STRING("Reason:"),DLT_INT(availability.availabilityReason));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSystemPropertyDB(const am_SystemProperty_s & property)
+{
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command="UPDATE " + std::string(SYSTEM_TABLE) + " set value=? WHERE type=?";
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, property.value);
+ sqlite3_bind_int(query,2, property.type);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSystemPropertyDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSystemPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSystemPropertyDB changed system property"));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
+{
+ assert(mainConnectionID!=0);
+
+ if (!existMainConnection(mainConnectionID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + int2string(mainConnectionID);
+ std::string command1 = "DROP table MainConnectionRoute" + int2string(mainConnectionID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeMainConnectionDB removed:"),DLT_INT(mainConnectionID));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::removeSinkDB(const am_sinkID_t sinkID)
+{
+ assert(sinkID!=0);
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SINK_TABLE) + " WHERE sinkID=" + int2string(sinkID);
+ std::string command1 = "DROP table SinkConnectionFormat" + int2string(sinkID);
+ std::string command2 = "DROP table SinkMainSoundProperty" + int2string(sinkID);
+ std::string command3 = "DROP table SinkSoundProperty" + int2string(sinkID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ if(!sqQuery(command2)) return E_DATABASE_ERROR;
+ if(!sqQuery(command3)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkDB removed:"),DLT_INT(sinkID));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::removeSourceDB(const am_sourceID_t sourceID)
+{
+ assert(sourceID!=0);
+
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + int2string(sourceID);
+ std::string command1 = "DROP table SourceConnectionFormat" + int2string(sourceID);
+ std::string command2 = "DROP table SourceMainSoundProperty" + int2string(sourceID);
+ std::string command3 = "DROP table SourceSoundProperty" + int2string(sourceID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ if(!sqQuery(command2)) return E_DATABASE_ERROR;
+ if(!sqQuery(command3)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceDB removed:"),DLT_INT(sourceID));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::removeGatewayDB(const am_gatewayID_t gatewayID)
+{
+ assert(gatewayID!=0);
+
+ if (!existGateway(gatewayID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + int2string(gatewayID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeGatewayDB removed:"),DLT_INT(gatewayID));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
+{
+ //todo: implement crossdfader
+ (void)crossfaderID;
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e DatabaseHandler::removeDomainDB(const am_domainID_t domainID)
+{
+ assert(domainID!=0);
+
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + int2string(domainID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeDomainDB removed:"),DLT_INT(domainID));
+
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::removeSinkClassDB(const am_sinkClass_t sinkClassID)
+{
+ assert(sinkClassID!=0);
+
+ if (!existSinkClass(sinkClassID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + int2string(sinkClassID);
+ std::string command1 = "DROP table SinkClassProperties" + int2string(sinkClassID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSinkClassDB removed:"),DLT_INT(sinkClassID));
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::removeSourceClassDB(const am_sourceClass_t sourceClassID)
+{
+ assert(sourceClassID!=0);
+
+ if (!existSourceClass(sourceClassID))
+ {
+ return E_NON_EXISTENT;
+ }
+ std::string command = "DELETE from " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + int2string(sourceClassID);
+ std::string command1 = "DROP table SourceClassProperties" + int2string(sourceClassID);
+ if(!sqQuery(command)) return E_DATABASE_ERROR;
+ if(!sqQuery(command1)) return E_DATABASE_ERROR;
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::removeSourceClassDB removed:"),DLT_INT(sourceClassID));
+ return E_OK;
+}
+
+
+am_Error_e DatabaseHandler::getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s & classInfo) const
+{
+ assert(sourceID!=0);
+
+ if (!existSource(sourceID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_ClassProperty_s propertyTemp;
+ std::string command= "SELECT sourceClassID FROM " + std::string(SOURCE_TABLE)+ " WHERE sourceID=" + (int2string(sourceID));
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ if((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ classInfo.sourceClassID=sqlite3_column_int(query,0);
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ command= "SELECT name FROM " + std::string(SOURCE_CLASS_TABLE)+ " WHERE sourceClassID=" + (int2string(classInfo.sourceClassID));
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ if((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ classInfo.name=std::string((const char*)sqlite3_column_text(query,0));
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out Properties
+ command= "SELECT classProperty, value FROM SourceClassProperties"+ int2string(classInfo.sourceClassID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(query,0);
+ propertyTemp.value=sqlite3_column_int(query,1);
+ classInfo.listClassProperties.push_back(propertyTemp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSourceClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSinkClassInfoDB(const am_SinkClass_s& sinkClass)
+{
+ assert(sinkClass.sinkClassID!=0);
+ assert(!sinkClass.listClassProperties.empty());
+
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+
+ //check if the ID already exists
+ if(!existSinkClass(sinkClass.sinkClassID)) return E_NON_EXISTENT;
+
+ //fill ConnectionFormats
+ std::string command="UPDATE SinkClassProperties" + int2string(sinkClass.sinkClassID) + " set value=? WHERE classProperty=?;";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator=sinkClass.listClassProperties.begin();
+ for(;Iterator<sinkClass.listClassProperties.end();++Iterator)
+ {
+ sqlite3_bind_int(query,1, Iterator->value);
+ sqlite3_bind_int(query,2, Iterator->classProperty);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo"));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::changeSourceClassInfoDB(const am_SourceClass_s& sourceClass)
+{
+ assert(sourceClass.sourceClassID!=0);
+ assert(!sourceClass.listClassProperties.empty());
+
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+
+ //check if the ID already exists
+ if(!existSourceClass(sourceClass.sourceClassID)) return E_NON_EXISTENT;
+
+ //fill ConnectionFormats
+ std::string command="UPDATE SourceClassProperties" + int2string(sourceClass.sourceClassID) + " set value=? WHERE classProperty=?;";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator=sourceClass.listClassProperties.begin();
+ for(;Iterator<sourceClass.listClassProperties.end();++Iterator)
+ {
+ sqlite3_bind_int(query,1, Iterator->value);
+ sqlite3_bind_int(query,2, Iterator->classProperty);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::setSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo"));
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s & sinkClass) const
+{
+ assert(sinkID!=0);
+
+ if (!existSink(sinkID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_ClassProperty_s propertyTemp;
+ std::string command= "SELECT sinkClassID FROM " + std::string(SINK_TABLE)+ " WHERE sinkID=" + (int2string(sinkID));
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ if((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sinkClass.sinkClassID=sqlite3_column_int(query,0);
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ command= "SELECT name FROM " + std::string(SINK_CLASS_TABLE)+ " WHERE sinkClassID=" + (int2string(sinkClass.sinkClassID));
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ if((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ sinkClass.name=std::string((const char*)sqlite3_column_text(query,0));
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out Properties
+ command= "SELECT classProperty, value FROM SinkClassProperties"+ int2string(sinkClass.sinkClassID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(query,0);
+ propertyTemp.value=sqlite3_column_int(query,1);
+ sinkClass.listClassProperties.push_back(propertyTemp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getSinkClassInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s & gatewayData) const
+{
+ assert(gatewayID!=0);
+ if (!existGateway(gatewayID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL, *qSinkConnectionFormat=NULL, *qSourceConnectionFormat=NULL;
+ int eCode=0;
+ am_ConnectionFormat_e tempConnectionFormat;
+ std::string command= "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID="+int2string(gatewayID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ gatewayData.name=std::string((const char*)sqlite3_column_text(query,0));
+ gatewayData.sinkID=sqlite3_column_int(query,1);
+ gatewayData.sourceID=sqlite3_column_int(query,2);
+ gatewayData.domainSinkID=sqlite3_column_int(query,3);
+ gatewayData.domainSourceID=sqlite3_column_int(query,4);
+ gatewayData.controlDomainID=sqlite3_column_int(query,5);
+ gatewayData.gatewayID=sqlite3_column_int(query,6);
+
+ //convertionMatrix:
+ ListConnectionFormat::const_iterator iter=mListConnectionFormat.begin();
+ iter=mListConnectionFormat.find(gatewayData.gatewayID);
+ if (iter == mListConnectionFormat.end())
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB database error with convertionFormat"));
+ return E_DATABASE_ERROR;
+ }
+ gatewayData.convertionMatrix=iter->second;
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + int2string(gatewayData.gatewayID);
+ sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSourceConnectionFormat,NULL);
+ while((eCode=sqlite3_step(qSourceConnectionFormat))==SQLITE_ROW)
+ {
+ tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSourceConnectionFormat,0);
+ gatewayData.listSourceFormats.push_back(tempConnectionFormat);
+ }
+
+ if((eCode=sqlite3_finalize(qSourceConnectionFormat))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + int2string(gatewayData.gatewayID);
+ sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSinkConnectionFormat,NULL);
+ while((eCode=sqlite3_step(qSinkConnectionFormat))==SQLITE_ROW)
+ {
+ tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSinkConnectionFormat,0);
+ gatewayData.listSinkFormats.push_back(tempConnectionFormat);
+ }
+
+ if((eCode=sqlite3_finalize(qSinkConnectionFormat))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getGatewayInfoDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+
+}
+
+
+
+am_Error_e DatabaseHandler::getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s & crossfaderData) const
+{
+ //todo: implement crossfader
+ (void)crossfaderID;
+ (void)crossfaderData;
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
+{
+ assert(domainID!=0);
+ listSinkID.clear();
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_sinkID_t temp;
+ std::string command= "SELECT sinkID FROM " + std::string(SINK_TABLE)+ " WHERE domainID=" + (int2string(domainID));
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp=sqlite3_column_int(query,0);
+ listSinkID.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinksOfDomain SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinksOfDomain SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
+{
+ assert(domainID!=0);
+ listSourceID.clear();
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_sourceID_t temp;
+ std::string command= "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE domainID=" + int2string(domainID);
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp=sqlite3_column_int(query,0);
+ listSourceID.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourcesOfDomain SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourcesOfDomain SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listGatewaysID) const
+{
+ //todo: implement crossfader
+ (void)listGatewaysID;
+ (void)domainID;
+ return E_UNKNOWN;
+
+}
+
+
+
+am_Error_e DatabaseHandler::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
+{
+ assert(domainID!=0);
+ listGatewaysID.clear();
+ if (!existDomain(domainID))
+ {
+ return E_NON_EXISTENT;
+ }
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_gatewayID_t temp;
+
+ std::string command= "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE controlDomainID=" +int2string(domainID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp=sqlite3_column_int(query,0);
+ listGatewaysID.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewaysOfDomain SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGatewaysOfDomain SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
+{
+ listMainConnections.clear();
+ sqlite3_stmt *query=NULL, *query1=NULL, *query2=NULL;
+ int eCode=0, eCode1=0, eCode2=0;
+ am_MainConnection_s temp;
+ am_RoutingElement_s tempRoute;
+
+ std::string command= "SELECT mainConnectionID, sourceID, sinkID, connectionState, delay FROM " + std::string(MAINCONNECTION_TABLE);
+ std::string command1= "SELECT connectionID FROM MainConnectionRoute";
+ std::string command2= "SELECT sourceID, sinkID, connectionFormat FROM " + std::string(CONNECTION_TABLE) + " WHERE connectionID=?";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&query2,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.connectionID=sqlite3_column_int(query,0);
+ temp.route.sourceID=sqlite3_column_int(query,1);
+ temp.route.sinkID=sqlite3_column_int(query,2);
+ temp.connectionState=(am_ConnectionState_e)sqlite3_column_int(query,3);
+ temp.delay=sqlite3_column_int(query,4);
+ std::string statement=command1 + int2string(temp.connectionID);
+ sqlite3_prepare_v2(mDatabase,statement.c_str(),-1,&query1,NULL);
+ while((eCode1=sqlite3_step(query1))==SQLITE_ROW) //todo: check results of eCode1, eCode2
+ {
+ int k=sqlite3_column_int(query1,0);
+ sqlite3_bind_int(query2,1,k);
+ while((eCode2=sqlite3_step(query2))==SQLITE_ROW)
+ {
+ tempRoute.sourceID=sqlite3_column_int(query2,0);
+ tempRoute.sinkID=sqlite3_column_int(query2,1);
+ tempRoute.connectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(query2,2);
+ getDomainOfSource(tempRoute.sourceID,tempRoute.domainID);
+ temp.route.route.push_back(tempRoute);
+ }
+ sqlite3_reset(query2);
+ }
+ listMainConnections.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainConnections SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainConnections SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListDomains(std::vector<am_Domain_s> & listDomains) const
+{
+ listDomains.clear();
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_Domain_s temp;
+ std::string command= "SELECT domainID, name, busname, nodename, early, complete, state FROM " + std::string(DOMAIN_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.domainID=sqlite3_column_int(query,0);
+ temp.name=std::string((const char*)sqlite3_column_text(query,1));
+ temp.busname=std::string((const char*)sqlite3_column_text(query,2));
+ temp.nodename=std::string((const char*)sqlite3_column_text(query,3));
+ temp.early=sqlite3_column_int(query,4);
+ temp.complete=sqlite3_column_int(query,5);
+ temp.state=(am_DomainState_e)sqlite3_column_int(query,6);
+ listDomains.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListDomains SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListDomains SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListConnections(std::vector<am_Connection_s> & listConnections) const
+{
+ listConnections.clear();
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_Connection_s temp;
+ std::string command= "SELECT connectionID, sourceID, sinkID, delay, connectionFormat FROM " + std::string(CONNECTION_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.connectionID=sqlite3_column_int(query,0);
+ temp.sourceID=sqlite3_column_int(query,1);
+ temp.sinkID=sqlite3_column_int(query,2);
+ temp.delay=sqlite3_column_int(query,3);
+ temp.connectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(query,4);
+ listConnections.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListConnections SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListConnections SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSinks(std::vector<am_Sink_s> & listSinks) const
+{
+ listSinks.clear();
+ sqlite3_stmt* query=NULL, *qConnectionFormat=NULL, *qSoundProperty=NULL, *qMAinSoundProperty=NULL;
+ int eCode=0;
+ am_Sink_s temp;
+ am_ConnectionFormat_e tempConnectionFormat;
+ am_SoundProperty_s tempSoundProperty;
+ am_MainSoundProperty_s tempMainSoundProperty;
+ std::string command= "SELECT name, domainID, sinkClassID, volume, visible, availability, availabilityReason, muteState, mainVolume, sinkID FROM " + std::string(SINK_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.name=std::string((const char*)sqlite3_column_text(query,0));
+ temp.domainID=sqlite3_column_int(query,1);
+ temp.sinkClassID=sqlite3_column_int(query,2);
+ temp.volume=sqlite3_column_int(query,3);
+ temp.visible=sqlite3_column_int(query,4);
+ temp.available.availability=(am_Availablility_e)sqlite3_column_int(query,5);
+ temp.available.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,6);
+ temp.muteState=(am_MuteState_e)sqlite3_column_int(query,7);
+ temp.mainVolume=sqlite3_column_int(query,8);
+ temp.sinkID=sqlite3_column_int(query,9);
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat= "SELECT soundFormat FROM SinkConnectionFormat"+ int2string(temp.sinkID);
+ sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
+ while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
+ {
+ tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qConnectionFormat,0);
+ temp.listConnectionFormats.push_back(tempConnectionFormat);
+ }
+
+ if((eCode=sqlite3_finalize(qConnectionFormat))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SinkSoundProperty" + int2string(temp.sinkID);
+ sqlite3_prepare_v2(mDatabase,commandSoundProperty.c_str(),-1,&qSoundProperty,NULL);
+ while((eCode=sqlite3_step(qSoundProperty))==SQLITE_ROW)
+ {
+ tempSoundProperty.type=(am_SoundPropertyType_e)sqlite3_column_int(qSoundProperty,0);
+ tempSoundProperty.value=sqlite3_column_int(qSoundProperty,1);
+ temp.listSoundProperties.push_back(tempSoundProperty);
+ }
+
+ if((eCode=sqlite3_finalize(qSoundProperty))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out MainSoundProperties
+ std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SinkMainSoundProperty"+ int2string(temp.sinkID);
+ sqlite3_prepare_v2(mDatabase,commandMainSoundProperty.c_str(),-1,&qMAinSoundProperty,NULL);
+ while((eCode=sqlite3_step(qMAinSoundProperty))==SQLITE_ROW)
+ {
+ tempMainSoundProperty.type=(am_MainSoundPropertyType_e)sqlite3_column_int(qMAinSoundProperty,0);
+ tempMainSoundProperty.value=sqlite3_column_int(qMAinSoundProperty,1);
+ temp.listMainSoundProperties.push_back(tempMainSoundProperty);
+ }
+
+ if((eCode=sqlite3_finalize(qMAinSoundProperty))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ listSinks.push_back(temp);
+ temp.listConnectionFormats.clear();
+ temp.listMainSoundProperties.clear();
+ temp.listSoundProperties.clear();
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSources(std::vector<am_Source_s> & listSources) const
+{
+ listSources.clear();
+ sqlite3_stmt* query=NULL, *qConnectionFormat=NULL, *qSoundProperty=NULL, *qMAinSoundProperty=NULL;
+ int eCode=0;
+ am_Source_s temp;
+ am_ConnectionFormat_e tempConnectionFormat;
+ am_SoundProperty_s tempSoundProperty;
+ am_MainSoundProperty_s tempMainSoundProperty;
+ std::string command= "SELECT name, domainID, sourceClassID, sourceState, volume, visible, availability, availabilityReason, interruptState, sourceID FROM " + std::string(SOURCE_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.name=std::string((const char*)sqlite3_column_text(query,0));
+ temp.domainID=sqlite3_column_int(query,1);
+ temp.sourceClassID=sqlite3_column_int(query,2);
+ temp.sourceState=(am_SourceState_e)sqlite3_column_int(query,3);
+ temp.volume=sqlite3_column_int(query,4);
+ temp.visible=sqlite3_column_int(query,5);
+ temp.available.availability=(am_Availablility_e)sqlite3_column_int(query,6);
+ temp.available.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,7);
+ temp.interruptState=(am_InterruptState_e)sqlite3_column_int(query,8);
+ temp.sourceID=sqlite3_column_int(query,9);
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat= "SELECT soundFormat FROM SourceConnectionFormat"+ int2string(temp.sourceID);
+ sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qConnectionFormat,NULL);
+ while((eCode=sqlite3_step(qConnectionFormat))==SQLITE_ROW)
+ {
+ tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qConnectionFormat,0);
+ temp.listConnectionFormats.push_back(tempConnectionFormat);
+ }
+
+ if((eCode=sqlite3_finalize(qConnectionFormat))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ std::string commandSoundProperty= "SELECT soundPropertyType, value FROM SourceSoundProperty" + int2string(temp.sourceID);
+ sqlite3_prepare_v2(mDatabase,commandSoundProperty.c_str(),-1,&qSoundProperty,NULL);
+ while((eCode=sqlite3_step(qSoundProperty))==SQLITE_ROW)
+ {
+ tempSoundProperty.type=(am_SoundPropertyType_e)sqlite3_column_int(qSoundProperty,0);
+ tempSoundProperty.value=sqlite3_column_int(qSoundProperty,1);
+ temp.listSoundProperties.push_back(tempSoundProperty);
+ }
+
+ if((eCode=sqlite3_finalize(qSoundProperty))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out MainSoundProperties
+ std::string commandMainSoundProperty= "SELECT soundPropertyType, value FROM SourceMainSoundProperty"+ int2string(temp.sourceID);
+ sqlite3_prepare_v2(mDatabase,commandMainSoundProperty.c_str(),-1,&qMAinSoundProperty,NULL);
+ while((eCode=sqlite3_step(qMAinSoundProperty))==SQLITE_ROW)
+ {
+ tempMainSoundProperty.type=(am_MainSoundPropertyType_e)sqlite3_column_int(qMAinSoundProperty,0);
+ tempMainSoundProperty.value=sqlite3_column_int(qMAinSoundProperty,1);
+ temp.listMainSoundProperties.push_back(tempMainSoundProperty);
+ }
+
+ if((eCode=sqlite3_finalize(qMAinSoundProperty))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ listSources.push_back(temp);
+ temp.listConnectionFormats.clear();
+ temp.listMainSoundProperties.clear();
+ temp.listSoundProperties.clear();
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
+{
+ listSourceClasses.clear();
+
+ sqlite3_stmt* query=NULL, *subQuery=NULL;
+ int eCode=0, eCode1;
+ am_SourceClass_s classTemp;
+ am_ClassProperty_s propertyTemp;
+
+ std::string command= "SELECT sourceClassID, name FROM " + std::string(SOURCE_CLASS_TABLE);
+ std::string command2;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ classTemp.sourceClassID=sqlite3_column_int(query,0);
+ classTemp.name=std::string((const char*)sqlite3_column_text(query,1));
+
+ //read out Properties
+ command2="SELECT classProperty, value FROM SourceClassProperties"+ int2string(classTemp.sourceClassID);
+ sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&subQuery,NULL);
+
+ while((eCode1=sqlite3_step(subQuery))==SQLITE_ROW)
+ {
+ propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(subQuery,0);
+ propertyTemp.value=sqlite3_column_int(subQuery,1);
+ classTemp.listClassProperties.push_back(propertyTemp);
+ }
+
+ if(eCode1!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode1=sqlite3_finalize(subQuery))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode1));
+ return E_DATABASE_ERROR;
+ }
+ listSourceClasses.push_back(classTemp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
+{
+ //todo: implement crossfaders
+ (void)listCrossfaders;
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e DatabaseHandler::getListGateways(std::vector<am_Gateway_s> & listGateways) const
+{
+ listGateways.clear();
+ sqlite3_stmt* query=NULL, *qSinkConnectionFormat=NULL, *qSourceConnectionFormat=NULL;
+ int eCode=0;
+ am_Gateway_s temp;
+ am_ConnectionFormat_e tempConnectionFormat;
+
+ std::string command= "SELECT name, sinkID, sourceID, domainSinkID, domainSourceID, controlDomainID, gatewayID FROM " + std::string(GATEWAY_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.name=std::string((const char*)sqlite3_column_text(query,0));
+ temp.sinkID=sqlite3_column_int(query,1);
+ temp.sourceID=sqlite3_column_int(query,2);
+ temp.domainSinkID=sqlite3_column_int(query,3);
+ temp.domainSourceID=sqlite3_column_int(query,4);
+ temp.controlDomainID=sqlite3_column_int(query,5);
+ temp.gatewayID=sqlite3_column_int(query,6);
+
+ //convertionMatrix:
+ ListConnectionFormat::const_iterator iter=mListConnectionFormat.begin();
+ iter=mListConnectionFormat.find(temp.gatewayID);
+ if (iter == mListConnectionFormat.end())
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways database error with convertionFormat"));
+ return E_DATABASE_ERROR;
+ }
+ temp.convertionMatrix=iter->second;
+
+ //read out the connectionFormats
+ std::string commandConnectionFormat= "SELECT soundFormat FROM GatewaySourceFormat" + int2string(temp.gatewayID);
+ sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSourceConnectionFormat,NULL);
+ while((eCode=sqlite3_step(qSourceConnectionFormat))==SQLITE_ROW)
+ {
+ tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSourceConnectionFormat,0);
+ temp.listSourceFormats.push_back(tempConnectionFormat);
+ }
+
+ if((eCode=sqlite3_finalize(qSourceConnectionFormat))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //read out sound properties
+ commandConnectionFormat= "SELECT soundFormat FROM GatewaySinkFormat" + int2string(temp.gatewayID);
+ sqlite3_prepare_v2(mDatabase,commandConnectionFormat.c_str(),-1,&qSinkConnectionFormat,NULL);
+ while((eCode=sqlite3_step(qSinkConnectionFormat))==SQLITE_ROW)
+ {
+ tempConnectionFormat=(am_ConnectionFormat_e)sqlite3_column_int(qSinkConnectionFormat,0);
+ temp.listSinkFormats.push_back(tempConnectionFormat);
+ }
+
+ if((eCode=sqlite3_finalize(qSinkConnectionFormat))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ listGateways.push_back(temp);
+ temp.listSinkFormats.clear();
+ temp.listSourceFormats.clear();
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListGateways SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
+{
+ listSinkClasses.clear();
+
+ sqlite3_stmt* query=NULL, *subQuery=NULL;
+ int eCode=0;
+ am_SinkClass_s classTemp;
+ am_ClassProperty_s propertyTemp;
+
+ std::string command= "SELECT sinkClassID, name FROM " + std::string(SINK_CLASS_TABLE);
+ std::string command2;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ classTemp.sinkClassID=sqlite3_column_int(query,0);
+ classTemp.name=std::string((const char*)sqlite3_column_text(query,1));
+
+ //read out Properties
+ command2="SELECT classProperty, value FROM SinkClassProperties"+ int2string(classTemp.sinkClassID);
+ sqlite3_prepare_v2(mDatabase,command2.c_str(),-1,&subQuery,NULL);
+
+ while((eCode=sqlite3_step(subQuery))==SQLITE_ROW)
+ {
+ propertyTemp.classProperty=(am_ClassProperty_e)sqlite3_column_int(subQuery,0);
+ propertyTemp.value=sqlite3_column_int(subQuery,1);
+ classTemp.listClassProperties.push_back(propertyTemp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(subQuery))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ listSinkClasses.push_back(classTemp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSourceClasses SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
+{
+ listConnections.clear();
+ sqlite3_stmt *query=NULL;
+ int eCode=0;
+ am_MainConnectionType_s temp;
+
+ std::string command= "SELECT mainConnectionID, sourceID, sinkID, connectionState, delay FROM " + std::string(MAINCONNECTION_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.mainConnectionID=sqlite3_column_int(query,0);
+ temp.sourceID=sqlite3_column_int(query,1);
+ temp.sinkID=sqlite3_column_int(query,2);
+ temp.connectionState=(am_ConnectionState_e)sqlite3_column_int(query,3);
+ temp.delay=sqlite3_column_int(query,4);
+ listConnections.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListVisibleMainConnections SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListVisibleMainConnections SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const
+{
+ listMainSinks.clear();
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_SinkType_s temp;
+
+ std::string command= "SELECT name, sinkID, availability, availabilityReason, muteState, mainVolume, sinkClassID FROM " + std::string(SINK_TABLE) + " WHERE visible=1";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.name=std::string((const char*)sqlite3_column_text(query,0));
+ temp.sinkID=sqlite3_column_int(query,1);
+ temp.availability.availability=(am_Availablility_e)sqlite3_column_int(query,2);
+ temp.availability.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,3);
+ temp.muteState=(am_MuteState_e)sqlite3_column_int(query,4);
+ temp.volume=sqlite3_column_int(query,5);
+ temp.sinkClassID=sqlite3_column_int(query,6);
+ listMainSinks.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSinks SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const
+{
+ listMainSources.clear();
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_SourceType_s temp;
+ std::string command= "SELECT name, sourceClassID, availability, availabilityReason, sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE visible=1";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.name=std::string((const char*)sqlite3_column_text(query,0));
+ temp.sourceClassID=sqlite3_column_int(query,1);
+ temp.availability.availability=(am_Availablility_e)sqlite3_column_int(query,2);
+ temp.availability.availabilityReason=(am_AvailabilityReason_e)sqlite3_column_int(query,3);
+ temp.sourceID=sqlite3_column_int(query,4);
+
+ listMainSources.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSources SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
+{
+ assert(sinkID!=0);
+ if (!existSink(sinkID)) return E_DATABASE_ERROR; // todo: here we could change to non existen, but not shown in sequences
+ listSoundProperties.clear();
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_MainSoundProperty_s temp;
+ std::string command= "SELECT soundPropertyType, value FROM SinkMainSoundProperty" + int2string(sinkID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.type=(am_MainSoundPropertyType_e)sqlite3_column_int(query,0);
+ temp.value=sqlite3_column_int(query,1);
+ listSoundProperties.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
+{
+ assert(sourceID!=0);
+ if (!existSource(sourceID)) return E_DATABASE_ERROR; // todo: here we could change to non existen, but not shown in sequences
+ listSourceProperties.clear();
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_MainSoundProperty_s temp;
+ std::string command= "SELECT soundPropertyType, value FROM SourceMainSoundProperty" + int2string(sourceID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.type=(am_MainSoundPropertyType_e)sqlite3_column_int(query,0);
+ temp.value=sqlite3_column_int(query,1);
+ listSourceProperties.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListMainSinkSoundProperties SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
+{
+ listSystemProperties.clear();
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ am_SystemProperty_s temp;
+ std::string command= "SELECT type, value FROM " + std::string(SYSTEM_TABLE);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ temp.type=(am_SystemPropertyType_e)sqlite3_column_int(query,0);
+ temp.value=sqlite3_column_int(query,1);
+ listSystemProperties.push_back(temp);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSystemProperties SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getListSystemProperties SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ return E_OK;
+}
+
+
+
+am_Error_e DatabaseHandler::getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t & delay) const
+{
+ assert(mainConnectionID!=0);
+ delay=-1;
+ sqlite3_stmt *query=NULL;
+ int eCode=0;
+
+ std::string command= "SELECT delay FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + int2string(mainConnectionID);
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+
+ while((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ delay=sqlite3_column_int(query,0);
+ }
+
+ if(eCode!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getTimingInformation SQLITE error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getTimingInformation SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if (delay==-1) return E_NOT_POSSIBLE;
+
+ return E_OK;
+}
+
+bool DatabaseHandler::sqQuery(const std::string& query)
+{
+ sqlite3_stmt* statement;
+ int eCode=0;
+ if ((eCode=sqlite3_exec(mDatabase,query.c_str(),NULL,&statement,NULL))!= SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::sqQuery SQL Query failed:"), DLT_STRING(query.c_str()), DLT_STRING("error code:"),DLT_INT(eCode));
+ return false;
+ }
+ return true;
+}
+
+bool DatabaseHandler::openDatabase()
+{
+ if (sqlite3_open_v2(mPath.c_str(),&mDatabase,SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, NULL) == SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::openDatabase opened database"));
+ return true;
+ }
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::openDatabase failed to open database"));
+ return false;
+}
+
+am_Error_e DatabaseHandler::changeDelayMainConnection(const am_timeSync_t & delay, const am_mainConnectionID_t & connectionID)
+{
+ assert(connectionID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command="UPDATE " + std::string(MAINCONNECTION_TABLE) + " SET delay=? WHERE mainConnectionID=?;";
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, delay);
+ sqlite3_bind_int(query,2, connectionID);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeDelayMainConnection SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::enterConnectionDB(const am_Connection_s& connection, am_connectionID_t& connectionID)
+{
+ assert(connection.connectionID==0);
+ assert(connection.sinkID!=0);
+ assert(connection.sourceID!=0);
+ //connection format is not checked, because it's project specific
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command= "INSERT INTO " + std::string(CONNECTION_TABLE) + "(sinkID, sourceID, delay, connectionFormat) VALUES (?,?,?,?)";
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, connection.sinkID);
+ sqlite3_bind_int(query,2, connection.sourceID);
+ sqlite3_bind_int(query,3, connection.delay);
+ sqlite3_bind_int(query,4, connection.connectionFormat);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ connectionID=sqlite3_last_insert_rowid(mDatabase);
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterConnectionDB entered new connection sourceID:"), DLT_INT16(connection.sourceID),
+ DLT_STRING("sinkID:"),DLT_INT16(connection.sinkID),
+ DLT_STRING("sourceID:"),DLT_INT16(connection.sourceID),
+ DLT_STRING("delay:"), DLT_INT16(connection.delay),
+ DLT_STRING("connectionFormat:"),DLT_INT16(connection.connectionFormat),
+ DLT_STRING("assigned ID:"),DLT_INT16(connectionID));
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
+{
+ assert(sinkClass.sinkClassID<DYNAMIC_ID_BOUNDARY);
+ assert(!sinkClass.listClassProperties.empty());
+ assert(!sinkClass.name.empty());
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sinkClass.sinkClassID==0 && !mFirstStaticSinkClass)
+ {
+ command= "INSERT INTO " + std::string(SINK_CLASS_TABLE) + "(name) VALUES (?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if(existSinkClass(sinkClass.sinkClassID)) return E_ALREADY_EXISTS;
+ command= "INSERT INTO " + std::string(SINK_CLASS_TABLE) + "(name, sinkClassID) VALUES (?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, sinkClass.name.c_str(),sinkClass.name.size(),SQLITE_STATIC);
+
+ //if the ID is not created, we add it to the query
+ if(sinkClass.sinkClassID!=0)
+ {
+ sqlite3_bind_int(query,2, sinkClass.sinkClassID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if(mFirstStaticSinkClass)
+ {
+ sqlite3_bind_int(query,2, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSinkClass=false;
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sinkClassID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
+
+ //now we need to create the additional tables:
+ command="CREATE TABLE SinkClassProperties" + int2string(sinkClassID) + std::string("(classProperty INTEGER, value INTEGER)");
+ assert(this->sqQuery(command));
+
+ //fill ConnectionFormats
+ command="INSERT INTO SinkClassProperties" + int2string(sinkClassID) + std::string("(classProperty,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator=sinkClass.listClassProperties.begin();
+ for(;Iterator<sinkClass.listClassProperties.end();++Iterator)
+ {
+ sqlite3_bind_int(query,1, Iterator->classProperty);
+ sqlite3_bind_int(query,2, Iterator->value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSinkClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSinkClassDB entered new sinkClass"));
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
+{
+ assert(sourceClass.sourceClassID<DYNAMIC_ID_BOUNDARY);
+ assert(!sourceClass.listClassProperties.empty());
+ assert(!sourceClass.name.empty());
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command;
+
+ //if sinkID is zero and the first Static Sink was already entered, the ID is created
+ if (sourceClass.sourceClassID==0 && !mFirstStaticSourceClass)
+ {
+ command= "INSERT INTO " + std::string(SOURCE_CLASS_TABLE) + "(name) VALUES (?)";
+ }
+ else
+ {
+ //check if the ID already exists
+ if(existSourceClass(sourceClass.sourceClassID)) return E_ALREADY_EXISTS;
+ command= "INSERT INTO " + std::string(SOURCE_CLASS_TABLE) + "(name, sourceClassID) VALUES (?,?)";
+ }
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_text(query,1, sourceClass.name.c_str(),sourceClass.name.size(),SQLITE_STATIC);
+
+ //if the ID is not created, we add it to the query
+ if(sourceClass.sourceClassID!=0)
+ {
+ sqlite3_bind_int(query,2, sourceClass.sourceClassID);
+ }
+
+ //if the first static sink is entered, we need to set it onto the boundary
+ else if(mFirstStaticSourceClass)
+ {
+ sqlite3_bind_int(query,2, DYNAMIC_ID_BOUNDARY);
+ mFirstStaticSourceClass=false;
+ }
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sourceClassID=sqlite3_last_insert_rowid(mDatabase); //todo:change last_insert implementations for mulithread usage...
+
+ //now we need to create the additional tables:
+ command="CREATE TABLE SourceClassProperties" + int2string(sourceClassID) + std::string("(classProperty INTEGER, value INTEGER)");
+ assert(sqQuery(command));
+
+ //fill ConnectionFormats
+ command="INSERT INTO SourceClassProperties" + int2string(sourceClassID) + std::string("(classProperty,value) VALUES (?,?)");
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ std::vector<am_ClassProperty_s>::const_iterator Iterator=sourceClass.listClassProperties.begin();
+ for(;Iterator<sourceClass.listClassProperties.end();++Iterator)
+ {
+ sqlite3_bind_int(query,1, Iterator->classProperty);
+ sqlite3_bind_int(query,2, Iterator->value);
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSourceClassDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSourceClassDB entered new sourceClass"));
+ return E_OK;
+}
+
+am_Error_e DatabaseHandler::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties)
+{
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::vector<am_SystemProperty_s>::const_iterator listIterator =listSystemProperties.begin();
+ std::string command= "DELETE * FROM " + std::string(SYSTEM_TABLE);
+ sqQuery(command);
+
+ command="INSERT INTO " + std::string(SYSTEM_TABLE) + " (type, value) VALUES (?,?)";
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ for(;listIterator<listSystemProperties.end();++listIterator)
+ {
+ sqlite3_bind_int(query,1, listIterator->type);
+ sqlite3_bind_int(query,2, listIterator->value);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSystemProperties SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ sqlite3_reset(query);
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterSystemProperties SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::enterSystemProperties entered system properties"));
+ return E_OK;
+}
+
+bool DatabaseHandler::existMainConnection(const am_mainConnectionID_t mainConnectionID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT mainConnectionID FROM " + std::string(MAINCONNECTION_TABLE) + " WHERE mainConnectionID=" + int2string(mainConnectionID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existMainConnection database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSource(const am_sourceID_t sourceID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sourceID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + int2string(sourceID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSink(const am_sinkID_t sinkID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sinkID FROM " + std::string(SINK_TABLE) + " WHERE sinkID=" + int2string(sinkID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSink database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existDomain(const am_domainID_t domainID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT domainID FROM " + std::string(DOMAIN_TABLE) + " WHERE domainID=" + int2string(domainID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existDomain database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existGateway(const am_gatewayID_t gatewayID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT gatewayID FROM " + std::string(GATEWAY_TABLE) + " WHERE gatewayID=" + int2string(gatewayID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existGateway database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+am_Error_e DatabaseHandler::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t & domainID) const
+{
+ assert(sourceID!=0);
+
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT domainID FROM " + std::string(SOURCE_TABLE) + " WHERE sourceID=" + int2string(sourceID);
+ int eCode=0;
+ am_Error_e returnVal=E_DATABASE_ERROR;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_ROW)
+ {
+ domainID=sqlite3_column_int(query,0);
+ returnVal=E_OK;
+ }
+ else
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::getDomainOfSource database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+
+bool DatabaseHandler::existSinkClass(const am_sinkClass_t sinkClassID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sinkClassID FROM " + std::string(SINK_CLASS_TABLE) + " WHERE sinkClassID=" + int2string(sinkClassID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSinkClass database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+bool DatabaseHandler::existSourceClass(const am_sourceClass_t sourceClassID) const
+{
+ sqlite3_stmt* query=NULL;
+ std::string command = "SELECT sourceClassID FROM " + std::string(SOURCE_CLASS_TABLE) + " WHERE sourceClassID=" + int2string(sourceClassID);
+ int eCode=0;
+ bool returnVal=true;
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ if ((eCode=sqlite3_step(query))==SQLITE_DONE) returnVal=false;
+ else if (eCode!=SQLITE_ROW)
+ {
+ returnVal=false;
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::existSinkClass database error!:"), DLT_INT(eCode))
+ }
+ sqlite3_finalize(query);
+ return returnVal;
+}
+
+am_Error_e DatabaseHandler::changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay)
+{
+ assert(connectionID!=0);
+
+ sqlite3_stmt* query=NULL;
+ int eCode=0;
+ std::string command= "UPDATE " + std::string(CONNECTION_TABLE) + " set delay=? WHERE connectionID=?";
+
+ sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL);
+ sqlite3_bind_int(query,1, delay);
+ sqlite3_bind_int(query,2, connectionID);
+
+ if((eCode=sqlite3_step(query))!=SQLITE_DONE)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Step error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ if((eCode=sqlite3_finalize(query))!=SQLITE_OK)
+ {
+ DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::enterConnectionDB SQLITE Finalize error code:"),DLT_INT(eCode));
+ return E_DATABASE_ERROR;
+ }
+
+ //todo: add DLT Info Message here
+ return E_OK;
+}
+
+void DatabaseHandler::createTables()
+{
+ for(uint16_t i=0;i<sizeof(databaseTables)/sizeof(databaseTables[0]);i++)
+ {
+ assert(sqQuery("CREATE TABLE " + databaseTables[i]));
+ }
+}
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/RoutingReceiver.cpp b/AudioManagerDaemon/src/RoutingReceiver.cpp
new file mode 100644
index 0000000..00567e8
--- /dev/null
+++ b/AudioManagerDaemon/src/RoutingReceiver.cpp
@@ -0,0 +1,213 @@
+/*
+ * RoutingReceiver.cpp
+ *
+ * Created on: Oct 24, 2011
+ * Author: christian
+ */
+
+#include "RoutingReceiver.h"
+
+
+
+RoutingReceiver::RoutingReceiver()
+{
+}
+
+
+
+RoutingReceiver::~RoutingReceiver()
+{
+}
+
+
+
+void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error)
+{
+}
+
+
+
+void RoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume)
+{
+}
+
+
+
+void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::peekDomain(const std::string & name, am_domainID_t & domainID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::registerDomain(const am_Domain_s & domainData, am_domainID_t & domainID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::deregisterDomain(const am_domainID_t domainID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::registerGateway(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::deregisterGateway(const am_gatewayID_t gatewayID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::peekSink(const std::string& name, am_sinkID_t & sinkID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::registerSink(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::deregisterSink(const am_sinkID_t sinkID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::peekSource(const std::string & name, am_sourceID_t & sourceID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::registerSource(const am_Source_s & sourceData, am_sourceID_t & sourceID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::deregisterSource(const am_sourceID_t sourceID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::registerCrossfader(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::deregisterCrossfader(const am_crossfaderID_t crossfaderID)
+{
+}
+
+
+
+void RoutingReceiver::hookInterruptStatusChange(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
+{
+}
+
+
+
+void RoutingReceiver::hookDomainRegistrationComplete(const am_domainID_t domainID)
+{
+}
+
+
+
+void RoutingReceiver::hookSinkAvailablityStatusChange(const am_sinkID_t sinkID, const am_Availability_s & availability)
+{
+}
+
+
+
+void RoutingReceiver::hookSourceAvailablityStatusChange(const am_sourceID_t sourceID, const am_Availability_s & availability)
+{
+}
+
+
+
+void RoutingReceiver::hookDomainStateChange(const am_domainID_t domainID, const am_DomainState_e domainState)
+{
+}
+
+
+
+void RoutingReceiver::hookTimingInformationChanged(const am_connectionID_t connectionID, const am_timeSync_t delay)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::sendChangedData(const std::vector<am_EarlyData_s> & earlyData)
+{
+}
+
+
+
+am_Error_e RoutingReceiver::getDBusConnectionWrapper(DBusWrapper *dbusConnectionWrapper) const
+{
+}
+
+
+
+am_Error_e RoutingReceiver::registerDbusNode(const std::string & nodeName)
+{
+}
+
diff --git a/AudioManagerDaemon/src/RoutingSender.cpp b/AudioManagerDaemon/src/RoutingSender.cpp
new file mode 100644
index 0000000..945fefa
--- /dev/null
+++ b/AudioManagerDaemon/src/RoutingSender.cpp
@@ -0,0 +1,352 @@
+/*
+ * RoutingSender.cpp
+ *
+ * Created on: Oct 26, 2011
+ * Author: christian
+ */
+
+#include "RoutingSender.h"
+#include <utility>
+using namespace am;
+
+#define CALL_ALL_INTERFACES(...) \
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin(); \
+ std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end(); \
+ for (; iter<iterEnd;++iter) \
+ { \
+ (*iter).routingInterface->__VA_ARGS__; \
+ }
+
+const char* routingPluginDirectories[] = { "/home/christian/workspace/gitserver/build/plugins/routing"};
+uint16_t routingPluginDirectoriesCount = sizeof(routingPluginDirectories) / sizeof(routingPluginDirectories[0]);
+
+RoutingSender::RoutingSender()
+{
+ std::vector<std::string> sharedLibraryNameList;
+
+ // search communicator plugins in configured directories
+ for (uint16_t dirIndex = 0; dirIndex < routingPluginDirectoriesCount; dirIndex++)
+ {
+ const char* directoryName = routingPluginDirectories[dirIndex];
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Searching for HookPlugins in"),DLT_STRING(directoryName));
+ DIR *directory = opendir(directoryName);
+
+ if (!directory)
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Error opening directory "),DLT_STRING(dirName.c_str()));
+ }
+
+ // iterate content of directory
+ struct dirent *itemInDirectory = 0;
+ while ((itemInDirectory = readdir(directory)))
+ {
+ unsigned char entryType = itemInDirectory->d_type;
+ std::string entryName = itemInDirectory->d_name;
+
+ bool regularFile = (entryType == DT_REG);
+ bool sharedLibExtension = ("so" == entryName.substr(entryName.find_last_of(".") + 1));
+
+ if (regularFile && sharedLibExtension)
+ {
+ // DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("PluginSearch adding file "),DLT_STRING(entryName.c_str()));
+ std::string name(directoryName);
+ sharedLibraryNameList.push_back(name + "/" + entryName);
+ }
+ else
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("PluginSearch ignoring file "),DLT_STRING(entryName.c_str()));
+ }
+ }
+
+ closedir(directory);
+ }
+
+ // iterate all communicator plugins and start them
+ std::vector<std::string>::iterator iter = sharedLibraryNameList.begin();
+ std::vector<std::string>::iterator iterEnd = sharedLibraryNameList.end();
+
+ for (; iter != iterEnd; ++iter)
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Loading Hook plugin"),DLT_STRING(iter->c_str()));
+
+ RoutingSendInterface* (*createFunc)();
+ createFunc = getCreateFunction<RoutingSendInterface*()>(*iter);
+
+ if (!createFunc)
+ {
+ // DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Entry point of Communicator not found"));
+ continue;
+ }
+
+ RoutingSendInterface* router = createFunc();
+
+ if (!router)
+ {
+ //DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("HookPlugin initialization failed. Entry Function not callable"));
+ continue;
+ }
+
+ InterfaceNamePairs routerInterface;
+ routerInterface.routingInterface = router;
+ router->returnBusName(routerInterface.busName);
+ mListInterfaces.push_back(routerInterface);
+ }
+}
+
+RoutingSender::~RoutingSender()
+{
+}
+
+void RoutingSender::routingInterfacesReady()
+{
+ CALL_ALL_INTERFACES(routingInterfacesReady())
+}
+
+void RoutingSender::routingInterfacesRundown()
+{
+ CALL_ALL_INTERFACES(routingInterfacesRundown())
+}
+
+void RoutingSender::startupRoutingInterface(RoutingReceiveInterface *routingreceiveinterface)
+{
+ CALL_ALL_INTERFACES(startupRoutingInterface(routingreceiveinterface))
+}
+
+am_Error_e RoutingSender::asyncAbort(const am_Handle_s handle)
+{
+ //Todo: map handle to RoutingInterface via Database.
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e RoutingSender::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)
+{
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ mMapSinkInterface.find(sinkID);
+ if (iter != mMapSinkInterface.end())
+ {
+ return iter->second->asyncConnect(handle,connectionID,sourceID,sinkID,connectionFormat);
+ mMapConnectionInterface.insert(std::make_pair(connectionID,iter->second));
+ }
+
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::asyncDisconnect(const am_Handle_s handle, const am_connectionID_t connectionID)
+{
+ ConnectionInterfaceMap::iterator iter = mMapConnectionInterface.begin();
+ mMapConnectionInterface.find(connectionID);
+ if (iter != mMapConnectionInterface.end())
+ {
+ return iter->second->asyncDisconnect(handle,connectionID);
+ mMapConnectionInterface.erase(iter);
+ }
+
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::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)
+{
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ mMapSinkInterface.find(sinkID);
+ if (iter != mMapSinkInterface.end())
+ return iter->second->asyncSetSinkVolume(handle,sinkID,volume,ramp,time);
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::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)
+{
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ mMapSourceInterface.find(sourceID);
+ if (iter != mMapSourceInterface.end())
+ return iter->second->asyncSetSourceVolume(handle,sourceID,volume,ramp,time);
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state)
+{
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ mMapSourceInterface.find(sourceID);
+ if (iter != mMapSourceInterface.end())
+ return iter->second->asyncSetSourceState(handle,sourceID,state);
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty)
+{
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ mMapSinkInterface.find(sinkID);
+ if (iter != mMapSinkInterface.end())
+ return iter->second->asyncSetSinkSoundProperty(handle,soundProperty,sinkID);
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty)
+{
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ mMapSourceInterface.find(sourceID);
+ if (iter != mMapSourceInterface.end())
+ return iter->second->asyncSetSourceSoundProperty(handle,soundProperty,sourceID);
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::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)
+{
+ CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
+ mMapCrossfaderInterface.find(crossfaderID);
+ if (iter != mMapCrossfaderInterface.end())
+ return iter->second->asyncCrossFade(handle,crossfaderID,hotSink,rampType,time);
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::setDomainState(const am_domainID_t domainID, const am_DomainState_e domainState)
+{
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ mMapDomainInterface.find(domainID);
+ if (iter != mMapDomainInterface.end())
+ return iter->second->setDomainState(domainID,domainState);
+ return E_NON_EXISTENT;
+}
+
+am_Error_e RoutingSender::addDomainLookup(const am_Domain_s& domainData)
+{
+ std::vector<InterfaceNamePairs>::iterator iter = mListInterfaces.begin();
+ std::vector<InterfaceNamePairs>::iterator iterEnd = mListInterfaces.end();
+ for (; iter<iterEnd;++iter)
+ {
+ if((*iter).busName.compare(domainData.busname) == 0)
+ {
+ mMapDomainInterface.insert(std::make_pair(domainData.domainID,(*iter).routingInterface));
+ return E_OK;
+ }
+ }
+
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e RoutingSender::addSourceLookup(const am_Source_s& sourceData)
+{
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ mMapDomainInterface.find(sourceData.domainID);
+ if (iter != mMapDomainInterface.end())
+ {
+ mMapSourceInterface.insert(std::make_pair(sourceData.sourceID,iter->second));
+ return E_OK;
+ }
+
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e RoutingSender::addSinkLookup(const am_Sink_s& sinkData)
+{
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ mMapDomainInterface.find(sinkData.domainID);
+ if (iter != mMapDomainInterface.end())
+ {
+ mMapSinkInterface.insert(std::make_pair(sinkData.sinkID,iter->second));
+ return E_OK;
+ }
+
+ return E_UNKNOWN;
+}
+
+
+
+am_Error_e RoutingSender::addCrossfaderLookup(const am_Crossfader_s& crossfaderData)
+{
+ DomainInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ mMapSourceInterface.find(crossfaderData.sourceID);
+ if (iter != mMapSourceInterface.end())
+ {
+ mMapSourceInterface.insert(std::make_pair(crossfaderData.crossfaderID,iter->second));
+ return E_OK;
+ }
+
+ return E_UNKNOWN;
+}
+
+am_Error_e RoutingSender::removeDomainLookup(const am_domainID_t domainID)
+{
+ DomainInterfaceMap::iterator iter = mMapDomainInterface.begin();
+ mMapDomainInterface.find(domainID);
+ if (iter != mMapDomainInterface.end())
+ {
+ mMapDomainInterface.erase(iter);
+ return E_OK;
+ }
+
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::removeSourceLookup(const am_sourceID_t sourceID)
+{
+ SourceInterfaceMap::iterator iter = mMapSourceInterface.begin();
+ mMapSourceInterface.find(sourceID);
+ if (iter != mMapSourceInterface.end())
+ {
+ mMapSourceInterface.erase(iter);
+ return E_OK;
+ }
+
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::removeSinkLookup(const am_sinkID_t sinkID)
+{
+ SinkInterfaceMap::iterator iter = mMapSinkInterface.begin();
+ mMapSinkInterface.find(sinkID);
+ if (iter != mMapSinkInterface.end())
+ {
+ mMapSinkInterface.erase(iter);
+ return E_OK;
+ }
+
+ return E_NON_EXISTENT;
+}
+
+
+
+am_Error_e RoutingSender::removeCrossfaderLookup(const am_crossfaderID_t crossfaderID)
+{
+ CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin();
+ mMapCrossfaderInterface.find(crossfaderID);
+ if (iter != mMapCrossfaderInterface.end())
+ {
+ mMapCrossfaderInterface.erase(iter);
+ return E_OK;
+ }
+
+ return E_NON_EXISTENT;
+}
+
+
+
+
+
+
+
diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp
new file mode 100644
index 0000000..ef5da21
--- /dev/null
+++ b/AudioManagerDaemon/src/main.cpp
@@ -0,0 +1,74 @@
+/*
+ * main.cpp
+ *
+ * Created on: Oct 24, 2011
+ * Author: christian
+ */
+
+//todo: add debug commandline option to allow to use other than memory database
+#include "RoutingReceiver.h"
+#include "CommandReceiver.h"
+#include "ControlReceiver.h"
+#include "DatabaseHandler.h"
+#include "control/ControlSendInterface.h"
+#include "DBusWrapper.h"
+#include "ControlLoader.h"
+#include "CommandSender.h"
+#include "RoutingSender.h"
+#include <dbus/dbus.h>
+#include <dlt/dlt.h>
+
+DLT_DECLARE_CONTEXT(AudioManager);
+
+using namespace am;
+
+int main(int argc, char *argv[])
+{
+ DLT_REGISTER_APP("AudioManagerDeamon","AudioManagerDeamon");
+ DLT_REGISTER_CONTEXT(AudioManager,"Main","Main Context");
+ DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("The AudioManager is started "));
+
+ DatabaseHandler iDatabaseHandler;
+ DBusWrapper iDBusWrapper;
+ CommandReceiver iCommandReceiver(&iDatabaseHandler,&iDBusWrapper);
+ RoutingReceiver iRoutingReceiver;
+ ControlReceiver iControlReceiver(&iDatabaseHandler);
+ RoutingSender iRoutingSender;
+ CommandSender iCommandSender;
+
+ am_Connection_s lowCon;
+ am_connectionID_t cID;
+ lowCon.connectionID=0;
+ lowCon.sinkID=2;
+ lowCon.sourceID=3;
+ lowCon.connectionFormat=CF_ANALOG;
+ lowCon.delay=-1;
+ iDatabaseHandler.enterConnectionDB(lowCon,cID);
+
+ am_RoutingElement_s re;
+ re.connectionFormat=CF_ANALOG;
+ re.domainID=1;
+ re.sinkID=2;
+ re.sourceID=3;
+
+ am_MainConnection_s con;
+ am_mainConnectionID_t mainC;
+ con.connectionID=0;
+ con.connectionState=CS_CONNECTING;
+ con.route.sinkID=2;
+ con.route.sourceID=3;
+ con.route.route.push_back(re);
+ iControlReceiver.enterMainConnectionDB(con,mainC);
+ //ControlLoader iControlLoader;
+// ControlSendInterface* iControlSender =iControlLoader.returnControl();
+
+
+ iCommandSender.startupInterface(&iCommandReceiver);
+
+ iDBusWrapper.dbusMainLoop();
+
+}
+
+
+
+