From 791557b6f7c3efe78aafa20318ef7b90cfdb6e6d Mon Sep 17 00:00:00 2001 From: Christian Linke Date: Tue, 21 Jun 2016 05:09:06 -0700 Subject: some updates of the fix Signed-off-by: Christian Linke --- AudioManagerCore/include/CAmRoutingSender.h | 95 ++++++++++--------- AudioManagerCore/src/CAmControlReceiver.cpp | 19 +--- AudioManagerCore/src/CAmRoutingReceiver.cpp | 8 +- AudioManagerCore/src/CAmRoutingSender.cpp | 105 ++++++++++++--------- .../CAmControlInterfaceTest.cpp | 2 +- .../test/AmMapHandlerTest/CAmMapHandlerTest.cpp | 2 +- .../test/AmRouterMapTest/CAmRouterMapTest.cpp | 2 +- .../test/AmRouterTest/CAmRouterTest.cpp | 2 +- .../CAmRoutingInterfaceTest.cpp | 2 +- AudioManagerDaemon/src/main.cpp | 13 +-- include/IAmControl.h | 5 +- include/audiomanagertypes.h | 2 - 12 files changed, 128 insertions(+), 129 deletions(-) diff --git a/AudioManagerCore/include/CAmRoutingSender.h b/AudioManagerCore/include/CAmRoutingSender.h index 4069920..7bced64 100644 --- a/AudioManagerCore/include/CAmRoutingSender.h +++ b/AudioManagerCore/include/CAmRoutingSender.h @@ -44,7 +44,7 @@ class IAmDatabaseHandler; class CAmRoutingSender { public: - CAmRoutingSender(const std::vector& listOfPluginDirectories); + CAmRoutingSender(const std::vector& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler); ~CAmRoutingSender(); am_Error_e removeHandle(const am_Handle_s& handle); @@ -62,7 +62,7 @@ public: void setRoutingReady(); void setRoutingRundown(); am_Error_e asyncAbort(const am_Handle_s& handle); - am_Error_e asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat); + am_Error_e asyncConnect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat); am_Error_e asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID); am_Error_e asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time); am_Error_e asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time); @@ -90,19 +90,21 @@ public: class handleDataBase { public: - handleDataBase(IAmRoutingSend* interface) : mInterface(interface) {} + handleDataBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler) : mInterface(interface), mpDatabaseHandler(databaseHandler) {} virtual ~handleDataBase() {} - virtual am_Error_e writeDataToDatabase(IAmDatabaseHandler* database)=0; //!< function to write the handle data to the database + virtual am_Error_e writeDataToDatabase()=0; //!< function to write the handle data to the database IAmRoutingSend* returnInterface() {return mInterface;} private: IAmRoutingSend* mInterface; + protected: + IAmDatabaseHandler* mpDatabaseHandler; }; class handleVolumeBase : public handleDataBase { public: - handleVolumeBase(IAmRoutingSend* interface,am_volume_t volume) : - handleDataBase(interface) + handleVolumeBase(IAmRoutingSend* interface, IAmDatabaseHandler* databaseHandler,am_volume_t volume) : + handleDataBase(interface,databaseHandler) ,mVolume(volume) {} virtual ~handleVolumeBase(){} am_volume_t returnVolume() { return mVolume; } @@ -113,12 +115,12 @@ public: class handleSinkSoundProperty : public handleDataBase { public: - handleSinkSoundProperty(IAmRoutingSend* interface,const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) : - handleDataBase(interface) + handleSinkSoundProperty(IAmRoutingSend* interface,const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSinkID(sinkID) ,mSoundProperty(soundProperty) {} ~handleSinkSoundProperty() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sinkID_t mSinkID; am_SoundProperty_s mSoundProperty; @@ -127,12 +129,12 @@ public: class handleSinkSoundProperties : public handleDataBase { public: - handleSinkSoundProperties(IAmRoutingSend* interface,const am_sinkID_t sinkID, const std::vector& listSoundProperties) : - handleDataBase(interface) + handleSinkSoundProperties(IAmRoutingSend* interface,const am_sinkID_t sinkID, const std::vector& listSoundProperties, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSinkID(sinkID) ,mlistSoundProperties(listSoundProperties) {} ~handleSinkSoundProperties() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sinkID_t mSinkID; std::vector mlistSoundProperties; @@ -141,12 +143,12 @@ public: class handleSourceSoundProperty : public handleDataBase { public: - handleSourceSoundProperty(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) : - handleDataBase(interface) + handleSourceSoundProperty(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSourceID(sourceID) ,mSoundProperty(soundProperty) {} ~handleSourceSoundProperty() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sourceID_t mSourceID; am_SoundProperty_s mSoundProperty; @@ -155,12 +157,12 @@ public: class handleSourceSoundProperties : public handleDataBase { public: - handleSourceSoundProperties(IAmRoutingSend* interface,const am_sourceID_t sourceID, const std::vector& listSoundProperties) : - handleDataBase(interface) + handleSourceSoundProperties(IAmRoutingSend* interface,const am_sourceID_t sourceID, const std::vector& listSoundProperties, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSourceID(sourceID) ,mlistSoundProperties(listSoundProperties) {} ~handleSourceSoundProperties(){} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sourceID_t mSourceID; std::vector mlistSoundProperties; @@ -169,12 +171,12 @@ public: class handleSourceState : public handleDataBase { public: - handleSourceState(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SourceState_e& state) : - handleDataBase(interface) + handleSourceState(IAmRoutingSend* interface,const am_sourceID_t sourceID, const am_SourceState_e& state, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSourceID(sourceID) ,mSourceState(state) {} ~handleSourceState() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sourceID_t mSourceID; am_SourceState_e mSourceState; @@ -183,11 +185,11 @@ public: class handleSourceVolume : public handleVolumeBase { public: - handleSourceVolume(IAmRoutingSend* interface, const am_sourceID_t sourceID, const am_volume_t& volume) : - handleVolumeBase(interface,volume) + handleSourceVolume(IAmRoutingSend* interface, const am_sourceID_t sourceID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) : + handleVolumeBase(interface,databaseHandler,volume) ,mSourceID(sourceID) {} ~handleSourceVolume() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sourceID_t mSourceID; }; @@ -195,11 +197,11 @@ public: class handleSinkVolume : public handleVolumeBase { public: - handleSinkVolume(IAmRoutingSend* interface, const am_sinkID_t sinkID, const am_volume_t& volume) : - handleVolumeBase(interface,volume) + handleSinkVolume(IAmRoutingSend* interface, const am_sinkID_t sinkID, IAmDatabaseHandler* databaseHandler,const am_volume_t& volume) : + handleVolumeBase(interface,databaseHandler,volume) ,mSinkID(sinkID) {} ~handleSinkVolume() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sinkID_t mSinkID; }; @@ -207,12 +209,12 @@ public: class handleCrossFader : public handleDataBase { public: - handleCrossFader(IAmRoutingSend* interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e& hotSink) : - handleDataBase(interface) + handleCrossFader(IAmRoutingSend* interface, const am_crossfaderID_t crossfaderID, const am_HotSink_e& hotSink, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mCrossfaderID(crossfaderID) ,mHotSink(hotSink) {} ~handleCrossFader() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_crossfaderID_t mCrossfaderID; am_HotSink_e mHotSink; @@ -221,11 +223,11 @@ public: class handleConnect : public handleDataBase { public: - handleConnect(IAmRoutingSend* interface, const am_connectionID_t connectionID) : - handleDataBase(interface) + handleConnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mConnectionID(connectionID) {} ~handleConnect() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_connectionID_t mConnectionID; }; @@ -233,11 +235,11 @@ public: class handleDisconnect : public handleDataBase { public: - handleDisconnect(IAmRoutingSend* interface, const am_connectionID_t connectionID) : - handleDataBase(interface) + handleDisconnect(IAmRoutingSend* interface, const am_connectionID_t connectionID, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mConnectionID(connectionID) {} ~handleDisconnect() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_connectionID_t mConnectionID; }; @@ -245,11 +247,11 @@ public: class handleSetVolumes : public handleDataBase { public: - handleSetVolumes(IAmRoutingSend* interface, const std::vector listVolumes) : - handleDataBase(interface) + handleSetVolumes(IAmRoutingSend* interface, const std::vector listVolumes, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mlistVolumes(listVolumes) {} ~handleSetVolumes() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: std::vector mlistVolumes; }; @@ -257,12 +259,12 @@ public: class handleSetSinkNotificationConfiguration : public handleDataBase { public: - handleSetSinkNotificationConfiguration(IAmRoutingSend* interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration) : - handleDataBase(interface) + handleSetSinkNotificationConfiguration(IAmRoutingSend* interface, const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSinkID(sinkID) ,mNotificationConfiguration(notificationConfiguration){} ~handleSetSinkNotificationConfiguration() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sinkID_t mSinkID; am_NotificationConfiguration_s mNotificationConfiguration; @@ -271,18 +273,18 @@ public: class handleSetSourceNotificationConfiguration : public handleDataBase { public: - handleSetSourceNotificationConfiguration(IAmRoutingSend* interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration) : - handleDataBase(interface) + handleSetSourceNotificationConfiguration(IAmRoutingSend* interface, const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration, IAmDatabaseHandler* databaseHandler) : + handleDataBase(interface,databaseHandler) ,mSourceID(sourceID) ,mNotificationConfiguration(notificationConfiguration) {} ~handleSetSourceNotificationConfiguration() {} - am_Error_e writeDataToDatabase(IAmDatabaseHandler* database); + am_Error_e writeDataToDatabase(); private: am_sourceID_t mSourceID; am_NotificationConfiguration_s mNotificationConfiguration; }; - am_Error_e writeToDatabaseAndRemove(IAmDatabaseHandler* databasehandler,const am_Handle_s handle); //!< write data to Database and remove handle + am_Error_e writeToDatabaseAndRemove(const am_Handle_s handle); //!< write data to Database and remove handle void checkVolume(const am_Handle_s handle, const am_volume_t volume); bool handleExists(const am_Handle_s handle); //!< returns true if the handle exists @@ -319,6 +321,7 @@ private: SinkInterfaceMap mMapSinkInterface; //!< map of sinks to interfaces SourceInterfaceMap mMapSourceInterface; //!< map of sources to interfaces CAmRoutingReceiver *mpRoutingReceiver; //!< pointer to routing receiver + IAmDatabaseHandler* mpDatabaseHandler; //!< pointer to the databaseHandler }; } diff --git a/AudioManagerCore/src/CAmControlReceiver.cpp b/AudioManagerCore/src/CAmControlReceiver.cpp index 72fe7c7..44ccb96 100644 --- a/AudioManagerCore/src/CAmControlReceiver.cpp +++ b/AudioManagerCore/src/CAmControlReceiver.cpp @@ -61,24 +61,7 @@ am_Error_e CAmControlReceiver::getRoute(const bool onlyfree, const am_sourceID_t am_Error_e CAmControlReceiver::connect(am_Handle_s & handle, am_connectionID_t & connectionID, const am_CustomConnectionFormat_t format, const am_sourceID_t sourceID, const am_sinkID_t sinkID) { - - am_Connection_s tempConnection; - tempConnection.sinkID = sinkID; - tempConnection.sourceID = sourceID; - tempConnection.connectionFormat = format; - tempConnection.connectionID = 0; - tempConnection.delay=-1; - - am_Error_e connError(mDatabaseHandler->enterConnectionDB(tempConnection, connectionID)); - if (connError) - return(connError); - am_Error_e syncError(mRoutingSender->asyncConnect(handle, connectionID, sourceID, sinkID, format)); - if (syncError) - { - logError(__func__,"syncError",syncError); - mDatabaseHandler->removeConnection(connectionID); - } - return(syncError); + return (mRoutingSender->asyncConnect(handle, connectionID, sourceID, sinkID, format)); } am_Error_e CAmControlReceiver::disconnect(am_Handle_s & handle, const am_connectionID_t connectionID) diff --git a/AudioManagerCore/src/CAmRoutingReceiver.cpp b/AudioManagerCore/src/CAmRoutingReceiver.cpp index 895110a..15b0f6a 100644 --- a/AudioManagerCore/src/CAmRoutingReceiver.cpp +++ b/AudioManagerCore/src/CAmRoutingReceiver.cpp @@ -82,7 +82,7 @@ void CAmRoutingReceiver::handleCallback(const am_Handle_s handle, const am_Error { if (error == am_Error_e::E_OK) { - mpRoutingSender->writeToDatabaseAndRemove(mpDatabaseHandler,handle); + mpRoutingSender->writeToDatabaseAndRemove(handle); } else { @@ -95,7 +95,7 @@ void CAmRoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectio logInfo(__func__,"handle=",handle,"connectionID=",connectionID,"error=",error); if (error == am_Error_e::E_OK) { - mpRoutingSender->writeToDatabaseAndRemove(mpDatabaseHandler,handle); + mpRoutingSender->writeToDatabaseAndRemove(handle); } else { @@ -131,7 +131,7 @@ void CAmRoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const if (error== am_Error_e::E_OK || error== am_Error_e::E_ABORTED) { - mpRoutingSender->writeToDatabaseAndRemove(mpDatabaseHandler,handle); + mpRoutingSender->writeToDatabaseAndRemove(handle); } mpRoutingSender->removeHandle(handle); @@ -148,7 +148,7 @@ void CAmRoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, cons if (error== am_Error_e::E_OK || error== am_Error_e::E_ABORTED) { - mpRoutingSender->writeToDatabaseAndRemove(mpDatabaseHandler,handle); + mpRoutingSender->writeToDatabaseAndRemove(handle); } mpRoutingSender->removeHandle(handle); diff --git a/AudioManagerCore/src/CAmRoutingSender.cpp b/AudioManagerCore/src/CAmRoutingSender.cpp index 99f8af3..6dfc00a 100644 --- a/AudioManagerCore/src/CAmRoutingSender.cpp +++ b/AudioManagerCore/src/CAmRoutingSender.cpp @@ -43,7 +43,7 @@ namespace am #define REQUIRED_INTERFACE_VERSION_MAJOR 1 //!< major interface version. All versions smaller than this will be rejected #define REQUIRED_INTERFACE_VERSION_MINOR 0 //!< minor interface version. All versions smaller than this will be rejected -CAmRoutingSender::CAmRoutingSender(const std::vector& listOfPluginDirectories) : +CAmRoutingSender::CAmRoutingSender(const std::vector& listOfPluginDirectories, IAmDatabaseHandler* databaseHandler) : mHandleCount(0), // mlistActiveHandles(), // mListInterfaces(), // @@ -52,12 +52,13 @@ CAmRoutingSender::CAmRoutingSender(const std::vector& listOfPluginD mMapDomainInterface(), // mMapSinkInterface(), // mMapSourceInterface(), // - mpRoutingReceiver() + mpRoutingReceiver(), // + mpDatabaseHandler(databaseHandler) { if (listOfPluginDirectories.empty()) { - logError("CAmRoutingSender::CAmRoutingSender: List of routingplugins is empty"); + logError(__func__,"List of routingplugins is empty"); } std::vector sharedLibraryNameList; @@ -213,7 +214,7 @@ am_Error_e CAmRoutingSender::asyncAbort(const am_Handle_s& handle) return (iter->second->returnInterface()->asyncAbort(handle)); } -am_Error_e CAmRoutingSender::asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat) +am_Error_e CAmRoutingSender::asyncConnect(am_Handle_s& handle, am_connectionID_t& connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat) { auto iter (mMapSinkInterface.find(sinkID)); if (iter == mMapSinkInterface.end()) @@ -236,8 +237,21 @@ am_Error_e CAmRoutingSender::asyncConnect(am_Handle_s& handle, const am_connecti } else { + + am_Connection_s tempConnection; + tempConnection.sinkID = sinkID; + tempConnection.sourceID = sourceID; + tempConnection.connectionFormat = connectionFormat; + tempConnection.connectionID = 0; + tempConnection.delay=-1; + + am_Error_e connError(mpDatabaseHandler->enterConnectionDB(tempConnection, connectionID)); + if (connError) + { + return(connError); + } mMapConnectionInterface.insert(std::make_pair(connectionID, iter->second)); - auto handleData = std::make_shared(iter->second,connectionID); + auto handleData = std::make_shared(iter->second,connectionID,mpDatabaseHandler); handle = createHandle(handleData, am_Handle_e::H_CONNECT); } @@ -247,6 +261,7 @@ am_Error_e CAmRoutingSender::asyncConnect(am_Handle_s& handle, const am_connecti { removeHandle(handle); logError(__func__,"Error while calling connect connectionID:",connectionID,"sourceID:",sourceID,"sinkID:",sinkID,"connectionFormat:",connectionFormat,"handle",handle); + mpDatabaseHandler->removeConnection(connectionID); } return(syncError); } @@ -274,7 +289,7 @@ am_Error_e CAmRoutingSender::asyncDisconnect(am_Handle_s& handle, const am_conne } else { - auto handleData = std::make_shared(iter->second,connectionID); + auto handleData = std::make_shared(iter->second,connectionID,mpDatabaseHandler); handle = createHandle(handleData, am_Handle_e::H_DISCONNECT); } @@ -311,7 +326,7 @@ am_Error_e CAmRoutingSender::asyncSetSinkVolume(am_Handle_s& handle, const am_si } else { - auto handleData = std::make_shared(iter->second,sinkID,volume); + auto handleData = std::make_shared(iter->second,sinkID,mpDatabaseHandler,volume); handle = createHandle(handleData, H_SETSINKVOLUME); } @@ -348,7 +363,7 @@ am_Error_e CAmRoutingSender::asyncSetSourceVolume(am_Handle_s& handle, const am_ } else { - auto handleData = std::make_shared(iter->second,sourceID,volume); + auto handleData = std::make_shared(iter->second,sourceID,mpDatabaseHandler,volume); handle = createHandle(handleData, H_SETSOURCEVOLUME); } @@ -385,7 +400,7 @@ am_Error_e CAmRoutingSender::asyncSetSourceState(am_Handle_s& handle, const am_s } else { - auto handleData = std::make_shared(iter->second,sourceID,state); + auto handleData = std::make_shared(iter->second,sourceID,state,mpDatabaseHandler); handle = createHandle(handleData, H_SETSOURCESTATE); } logInfo(__func__,"sourceID=", sourceID, "state=", state,"handle=",handle); @@ -421,7 +436,7 @@ am_Error_e CAmRoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, cons } else { - auto handleData = std::make_shared(iter->second,sinkID,soundProperty); + auto handleData = std::make_shared(iter->second,sinkID,soundProperty,mpDatabaseHandler); handle = createHandle(handleData, H_SETSINKSOUNDPROPERTY); } @@ -458,7 +473,7 @@ am_Error_e CAmRoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, co } else { - auto handleData = std::make_shared(iter->second,sourceID,soundProperty); + auto handleData = std::make_shared(iter->second,sourceID,soundProperty,mpDatabaseHandler); handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTY); } logInfo(__func__,"sourceID=", sourceID, "soundProperty.Type=", soundProperty.type, "soundProperty.value=", soundProperty.value,"handle=",handle); @@ -494,7 +509,7 @@ am_Error_e CAmRoutingSender::asyncSetSourceSoundProperties(am_Handle_s& handle, } else { - auto handleData = std::make_shared(iter->second,sourceID,listSoundProperties); + auto handleData = std::make_shared(iter->second,sourceID,listSoundProperties,mpDatabaseHandler); handle = createHandle(handleData, H_SETSOURCESOUNDPROPERTIES); } @@ -531,7 +546,7 @@ am_Error_e CAmRoutingSender::asyncSetSinkSoundProperties(am_Handle_s& handle, co } else { - auto handleData = std::make_shared(iter->second,sinkID,listSoundProperties); + auto handleData = std::make_shared(iter->second,sinkID,listSoundProperties,mpDatabaseHandler); handle = createHandle(handleData, H_SETSINKSOUNDPROPERTIES); } @@ -568,7 +583,7 @@ am_Error_e CAmRoutingSender::asyncCrossFade(am_Handle_s& handle, const am_crossf } else { - auto handleData = std::make_shared(iter->second,crossfaderID,hotSink); + auto handleData = std::make_shared(iter->second,crossfaderID,hotSink,mpDatabaseHandler); handle = createHandle(handleData, H_CROSSFADE); } @@ -858,7 +873,7 @@ am_Error_e CAmRoutingSender::asyncSetVolumes(am_Handle_s& handle, const std::vec else return (E_NON_EXISTENT); - auto handleData = std::make_shared(pRoutingInterface,listVolumes); + auto handleData = std::make_shared(pRoutingInterface,listVolumes,mpDatabaseHandler); handle = createHandle(handleData, H_SETVOLUMES); logInfo(__func__, "handle=", handle); @@ -894,7 +909,7 @@ am_Error_e CAmRoutingSender::asyncSetSinkNotificationConfiguration(am_Handle_s& } else { - auto handleData = std::make_shared(iter->second,sinkID,notificationConfiguration); + auto handleData = std::make_shared(iter->second,sinkID,notificationConfiguration,mpDatabaseHandler); handle = createHandle(handleData, H_SETSINKNOTIFICATION); } @@ -931,7 +946,7 @@ am_Error_e CAmRoutingSender::asyncSetSourceNotificationConfiguration(am_Handle_s } else { - auto handleData = std::make_shared(iter->second,sourceID,notificationConfiguration); + auto handleData = std::make_shared(iter->second,sourceID,notificationConfiguration,mpDatabaseHandler); handle = createHandle(handleData, H_SETSOURCENOTIFICATION); } @@ -978,12 +993,12 @@ am_Error_e CAmRoutingSender::resyncConnectionState(const am_domainID_t domainID, return (E_NON_EXISTENT); } -am_Error_e CAmRoutingSender::writeToDatabaseAndRemove(IAmDatabaseHandler* databasehandler,const am_Handle_s handle) +am_Error_e CAmRoutingSender::writeToDatabaseAndRemove(const am_Handle_s handle) { auto it(mlistActiveHandles.find(handle)); if (it!=mlistActiveHandles.end()) { - am_Error_e error(it->second->writeDataToDatabase(databasehandler)); + am_Error_e error(it->second->writeDataToDatabase()); mlistActiveHandles.erase(handle); return (error); } @@ -1016,68 +1031,68 @@ bool CAmRoutingSender::handleExists(const am_Handle_s handle) return (false); } -am_Error_e CAmRoutingSender::handleSinkSoundProperty::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSinkSoundProperty::writeDataToDatabase() { - return (database->changeSinkSoundPropertyDB(mSoundProperty,mSinkID)); + return (mpDatabaseHandler->changeSinkSoundPropertyDB(mSoundProperty,mSinkID)); } -am_Error_e CAmRoutingSender::handleSinkSoundProperties::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSinkSoundProperties::writeDataToDatabase() { std::vector::const_iterator it = mlistSoundProperties.begin(); for (; it != mlistSoundProperties.end(); ++it) { - database->changeSinkSoundPropertyDB(*it, mSinkID); + mpDatabaseHandler->changeSinkSoundPropertyDB(*it, mSinkID); } return (am_Error_e::E_OK); } -am_Error_e CAmRoutingSender::handleSourceSoundProperty::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSourceSoundProperty::writeDataToDatabase() { - return (database->changeSourceSoundPropertyDB(mSoundProperty,mSourceID)); + return (mpDatabaseHandler->changeSourceSoundPropertyDB(mSoundProperty,mSourceID)); } -am_Error_e CAmRoutingSender::handleSourceSoundProperties::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSourceSoundProperties::writeDataToDatabase() { std::vector::const_iterator it = mlistSoundProperties.begin(); for (; it != mlistSoundProperties.end(); ++it) { - database->changeSourceSoundPropertyDB(*it, mSourceID); + mpDatabaseHandler->changeSourceSoundPropertyDB(*it, mSourceID); } return (am_Error_e::E_OK); } -am_Error_e CAmRoutingSender::handleSourceState::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSourceState::writeDataToDatabase() { - return (database->changeSourceState(mSourceID,mSourceState)); + return (mpDatabaseHandler->changeSourceState(mSourceID,mSourceState)); } -am_Error_e CAmRoutingSender::handleSourceVolume::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSourceVolume::writeDataToDatabase() { - return (database->changeSourceVolume(mSourceID,returnVolume())); + return (mpDatabaseHandler->changeSourceVolume(mSourceID,returnVolume())); } -am_Error_e CAmRoutingSender::handleSinkVolume::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSinkVolume::writeDataToDatabase() { - return (database->changeSinkVolume(mSinkID,returnVolume())); + return (mpDatabaseHandler->changeSinkVolume(mSinkID,returnVolume())); } -am_Error_e CAmRoutingSender::handleCrossFader::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleCrossFader::writeDataToDatabase() { - return (database->changeCrossFaderHotSink(mCrossfaderID, mHotSink)); + return (mpDatabaseHandler->changeCrossFaderHotSink(mCrossfaderID, mHotSink)); } -am_Error_e CAmRoutingSender::handleConnect::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleConnect::writeDataToDatabase() { - return (database->changeConnectionFinal(mConnectionID)); + return (mpDatabaseHandler->changeConnectionFinal(mConnectionID)); } -am_Error_e CAmRoutingSender::handleDisconnect::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleDisconnect::writeDataToDatabase() { return E_OK; } -am_Error_e CAmRoutingSender::handleSetVolumes::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSetVolumes::writeDataToDatabase() { std::vector::const_iterator iterator (mlistVolumes.begin()); @@ -1085,23 +1100,23 @@ am_Error_e CAmRoutingSender::handleSetVolumes::writeDataToDatabase(IAmDatabaseHa { if (iterator->volumeType==VT_SINK) { - database->changeSinkVolume(iterator->volumeID.sink,iterator->volume); + mpDatabaseHandler->changeSinkVolume(iterator->volumeID.sink,iterator->volume); } else if (iterator->volumeType==VT_SOURCE) { - database->changeSourceVolume(iterator->volumeID.source,iterator->volume); + mpDatabaseHandler->changeSourceVolume(iterator->volumeID.source,iterator->volume); } } } -am_Error_e CAmRoutingSender::handleSetSinkNotificationConfiguration::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSetSinkNotificationConfiguration::writeDataToDatabase() { - return (database->changeSinkNotificationConfigurationDB(mSinkID,mNotificationConfiguration)); + return (mpDatabaseHandler->changeSinkNotificationConfigurationDB(mSinkID,mNotificationConfiguration)); } -am_Error_e CAmRoutingSender::handleSetSourceNotificationConfiguration::writeDataToDatabase(IAmDatabaseHandler* database) +am_Error_e CAmRoutingSender::handleSetSourceNotificationConfiguration::writeDataToDatabase() { - return (database->changeSourceNotificationConfigurationDB(mSourceID,mNotificationConfiguration)); + return (mpDatabaseHandler->changeSourceNotificationConfigurationDB(mSourceID,mNotificationConfiguration)); } am_Error_e CAmRoutingSender::removeConnectionLookup(const am_connectionID_t connectionID) diff --git a/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp b/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp index be2203a..5386192 100644 --- a/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp +++ b/AudioManagerCore/test/AmControlInterfaceTest/CAmControlInterfaceTest.cpp @@ -50,7 +50,7 @@ CAmControlInterfaceTest::CAmControlInterfaceTest() : plistCommandPluginDirs(), // plistRoutingPluginDirs(), // pDatabaseHandler(), // - pRoutingSender(plistRoutingPluginDirs), //RoutingReceiver + pRoutingSender(plistRoutingPluginDirs,dynamic_cast( &pDatabaseHandler )), //RoutingReceiver pCommandSender(plistCommandPluginDirs), // pMockControlInterface(), // pMockRoutingInterface(), // diff --git a/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp b/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp index 9557b6f..4c91d2a 100644 --- a/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp +++ b/AudioManagerCore/test/AmMapHandlerTest/CAmMapHandlerTest.cpp @@ -51,7 +51,7 @@ CAmMapBasicTest::CAmMapBasicTest() : plistCommandPluginDirs(), // pSocketHandler(),// pDatabaseHandler(), // - pRoutingSender(plistRoutingPluginDirs), // + pRoutingSender(plistRoutingPluginDirs,dynamic_cast( &pDatabaseHandler )), // pCommandSender(plistCommandPluginDirs), // pRoutingInterfaceBackdoor(), // pCommandInterfaceBackdoor(), // diff --git a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp index a99f7d8..465995f 100644 --- a/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp +++ b/AudioManagerCore/test/AmRouterMapTest/CAmRouterMapTest.cpp @@ -40,7 +40,7 @@ CAmRouterMapTest::CAmRouterMapTest() : pControlSender(), // pDatabaseHandler(), pRouter(&pDatabaseHandler, &pControlSender), // - pRoutingSender(plistRoutingPluginDirs), // + pRoutingSender(plistRoutingPluginDirs,dynamic_cast( &pDatabaseHandler )), // pCommandSender(plistCommandPluginDirs), // pMockInterface(), // pMockControlInterface(), // diff --git a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp index 28a5a72..e1acd65 100644 --- a/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp +++ b/AudioManagerCore/test/AmRouterTest/CAmRouterTest.cpp @@ -37,7 +37,7 @@ CAmRouterTest::CAmRouterTest() : pControlSender(), // pDatabaseHandler(), pRouter(&pDatabaseHandler, &pControlSender), // - pRoutingSender(plistRoutingPluginDirs), // + pRoutingSender(plistRoutingPluginDirs,dynamic_cast( &pDatabaseHandler )), // pCommandSender(plistCommandPluginDirs), // pMockInterface(), // pMockControlInterface(), // diff --git a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp index cea44ef..2a166cf 100644 --- a/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp +++ b/AudioManagerCore/test/AmRoutingInterfaceTest/CAmRoutingInterfaceTest.cpp @@ -34,7 +34,7 @@ CAmRoutingInterfaceTest::CAmRoutingInterfaceTest() : plistCommandPluginDirs(), // pSocketHandler(), // pDatabaseHandler(), // - pRoutingSender(plistRoutingPluginDirs), // + pRoutingSender(plistRoutingPluginDirs,dynamic_cast( &pDatabaseHandler )), // pCommandSender(plistCommandPluginDirs), // pControlSender(), // pRouter(&pDatabaseHandler, &pControlSender), // diff --git a/AudioManagerDaemon/src/main.cpp b/AudioManagerDaemon/src/main.cpp index 29cb4c9..ac58ebb 100755 --- a/AudioManagerDaemon/src/main.cpp +++ b/AudioManagerDaemon/src/main.cpp @@ -297,8 +297,11 @@ void mainProgram(int argc, char *argv[]) //in this place, the plugins can get the gloval commandlineparser via CAmCommandLineSingleton::instance() and add their options to the commandline //this must be done in the constructor. //later when the plugins are started, the commandline is already parsed and the objects defined before can be used to get the neccesary information + + CAmDatabaseHandlerMap iDatabaseHandler; + IAmDatabaseHandler *pDatabaseHandler = dynamic_cast( &iDatabaseHandler ); - CAmRoutingSender iRoutingSender(listRoutingPluginDirs); + CAmRoutingSender iRoutingSender(listRoutingPluginDirs,pDatabaseHandler); CAmCommandSender iCommandSender(listCommandPluginDirs); CAmControlSender iControlSender(controllerPlugin.getValue(),&iSocketHandler); @@ -333,13 +336,7 @@ void mainProgram(int argc, char *argv[]) CAmWatchdog iWatchdog(&iSocketHandler); #endif /*WITH_SYSTEMD_WATCHDOG*/ -#ifdef WITH_DATABASE_STORAGE - CAmDatabaseHandlerSQLite iDatabaseHandler(databasePath.getValue()); -#else - CAmDatabaseHandlerMap iDatabaseHandler; -#endif /*WITH_DATABASE_STORAGE*/ - IAmDatabaseHandler *pDatabaseHandler = dynamic_cast( &iDatabaseHandler ); - CAmRouter iRouter(pDatabaseHandler, &iControlSender); +CAmRouter iRouter(pDatabaseHandler, &iControlSender); #ifdef WITH_DBUS_WRAPPER CAmCommandReceiver iCommandReceiver(pDatabaseHandler, &iControlSender, &iSocketHandler, &iDBusWrapper); diff --git a/include/IAmControl.h b/include/IAmControl.h index 1c02d37..9bfab6b 100644 --- a/include/IAmControl.h +++ b/include/IAmControl.h @@ -32,7 +32,7 @@ class CAmSocketHandler; #include "audiomanagertypes.h" -#define ControlVersion "5.0" +#define ControlVersion "5.1" namespace am { /** @@ -49,6 +49,9 @@ namespace am { * implement thread safe by using the deferred-call pattern described on the wiki * which also helps to implement calls that are forbidden.\n * For more information, please check CAmSerializer + * + * All functions that contain handles can be resend when using the same handle. Take care to initialize + * the handles properly to avaid unintended resending. */ class IAmControlReceive { diff --git a/include/audiomanagertypes.h b/include/audiomanagertypes.h index b94c5ee..8651185 100755 --- a/include/audiomanagertypes.h +++ b/include/audiomanagertypes.h @@ -1000,8 +1000,6 @@ public: * the handle as value */ uint16_t handle:10; - - am_Handle_s():handleType(am_Handle_e::H_UNKNOWN),handle(0){ } }; /** -- cgit v1.2.1