From 5abcbd805991d1bdfbc735d786b5f5b0e53aaa45 Mon Sep 17 00:00:00 2001 From: christian mueller Date: Mon, 13 Feb 2012 16:26:36 +0100 Subject: [PATCH] * fixed bug in remove connections * added functionality in default ConnectionPlugin --- AudioManagerDaemon/src/DatabaseHandler.cpp | 3 - PluginControlInterface/include/ControlSender.h | 17 ++++ PluginControlInterface/src/ControlSender.cpp | 130 ++++++++++++++++++++----- 3 files changed, 120 insertions(+), 30 deletions(-) diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp index 645da7c..5f7ee1d 100644 --- a/AudioManagerDaemon/src/DatabaseHandler.cpp +++ b/AudioManagerDaemon/src/DatabaseHandler.cpp @@ -1384,11 +1384,8 @@ am_Error_e DatabaseHandler::removeConnection(const am_connectionID_t connectionI assert(connectionID!=0); std::string command = "DELETE from " + std::string(CONNECTION_TABLE) + " WHERE connectionID=" + i2s(connectionID); - std::string command1 = "DROP table SourceClassProperties" + i2s(connectionID); if (!sqQuery(command)) return E_DATABASE_ERROR; - if (!sqQuery(command1)) - return E_DATABASE_ERROR; logInfo("DatabaseHandler::removeConnection removed:", connectionID); return E_OK; } diff --git a/PluginControlInterface/include/ControlSender.h b/PluginControlInterface/include/ControlSender.h index f003222..ace61a6 100644 --- a/PluginControlInterface/include/ControlSender.h +++ b/PluginControlInterface/include/ControlSender.h @@ -94,6 +94,20 @@ private: std::vector listHandleStaus; }; + struct mainVolumeSet + { + am_sinkID_t sinkID; + am_Handle_s handle; + am_mainVolume_t mainVolume; + }; + + struct mainSinkSoundPropertySet + { + am_sinkID_t sinkID; + am_Handle_s handle; + am_MainSoundProperty_s mainSoundProperty; + }; + class findHandle { handleStatus mHandle; @@ -139,6 +153,9 @@ private: }; std::vector mListOpenConnections; + std::vector mListOpenDisconnections; + std::vector mListOpenVolumeChanges; + std::vector mListMainSoundPropertyChanges; }; #endif /* CONTROLSENDER_H_ */ diff --git a/PluginControlInterface/src/ControlSender.cpp b/PluginControlInterface/src/ControlSender.cpp index 161d76b..9df8232 100644 --- a/PluginControlInterface/src/ControlSender.cpp +++ b/PluginControlInterface/src/ControlSender.cpp @@ -41,7 +41,10 @@ extern "C" void destroyControlPluginInterface(ControlSendInterface* controlSendI } ControlSenderPlugin::ControlSenderPlugin() : - mControlReceiveInterface(NULL), mListOpenConnections() + mControlReceiveInterface(NULL), // + mListOpenConnections(), // + mListOpenDisconnections(), // + mListOpenVolumeChanges() { } @@ -105,27 +108,48 @@ am_Error_e ControlSenderPlugin::hookUserConnectionRequest(const am_sourceID_t so am_Error_e ControlSenderPlugin::hookUserDisconnectionRequest(const am_mainConnectionID_t connectionID) { -// //first check if there is a connectionID like that -// std::vector listMainConnections; -// mControlReceiveInterface->getListMainConnections(listMainConnections); -// std::vector::iterator it(listMainConnections.begin()); -// am_MainConnection_s mainConnection; -// mainConnection=connectionID; -// if(listMainConnections.end()==(it=std::find(listMainConnections.begin(),listMainConnections.end(),checkMainConnectionID(mainConnection)))) -// return E_NON_EXISTENT; -// -// std::vector::iterator routeIterator(it->route.route.begin()); -// for(;routeIterator!=it->route.route.end();++routeIterator) -// { -// mControlReceiveInterface->disconnect(handle,routeIterator->) -// } + //first check if there is a connectionID like that + am_MainConnection_s mainConnection; + am_Error_e error; + if ((error = mControlReceiveInterface->getMainConnectionInfoDB(connectionID, mainConnection)) != E_OK) + { + return error; + } + + std::vector::iterator it(mainConnection.listConnectionID.begin()); + std::vector listHandleStaus; + for (; it != mainConnection.listConnectionID.end(); ++it) + { + handleStatus status; + status.status = false; + mControlReceiveInterface->disconnect(status.handle, *it); + listHandleStaus.push_back(status); + } + mainConnectionSet set; + set.connectionID = connectionID; + set.listHandleStaus = listHandleStaus; + mListOpenConnections.push_back(set); + return E_OK; } am_Error_e ControlSenderPlugin::hookUserSetMainSinkSoundProperty(const am_sinkID_t sinkID, const am_MainSoundProperty_s & soundProperty) { - (void) sinkID; - (void) soundProperty; - return E_NOT_USED; + if (sinkID==0) return E_NON_EXISTENT; + + mainSinkSoundPropertySet set; + set.sinkID = sinkID; + set.mainSoundProperty = soundProperty; + am_SoundProperty_s sp; + //I know this is bad - just for the reference, ok? + sp.type = static_cast(soundProperty.type); + sp.value = soundProperty.value; + am_Error_e error; + if ((error = mControlReceiveInterface->setSinkSoundProperty(set.handle, sinkID, sp)) != E_OK) + { + return error; + } + mListMainSoundPropertyChanges.push_back(set); + return E_OK; } am_Error_e ControlSenderPlugin::hookUserSetMainSourceSoundProperty(const am_sourceID_t sourceID, const am_MainSoundProperty_s & soundProperty) @@ -143,16 +167,34 @@ am_Error_e ControlSenderPlugin::hookUserSetSystemProperty(const am_SystemPropert am_Error_e ControlSenderPlugin::hookUserVolumeChange(const am_sinkID_t SinkID, const am_mainVolume_t newVolume) { - (void) SinkID; - (void) newVolume; - return E_NOT_USED; + assert(SinkID!=0); + mainVolumeSet set; + set.sinkID = SinkID; + set.mainVolume = newVolume; + am_Error_e error; + if ((error = mControlReceiveInterface->setSinkVolume(set.handle, SinkID, newVolume, RAMP_DIRECT, 20)) != E_OK) + { + return error; + } + mListOpenVolumeChanges.push_back(set); + return E_OK; } am_Error_e ControlSenderPlugin::hookUserVolumeStep(const am_sinkID_t SinkID, const int16_t increment) { - (void) SinkID; - (void) increment; - return E_NOT_USED; + assert(SinkID!=0); + mainVolumeSet set; + set.sinkID = SinkID; + am_Error_e error; + am_Sink_s sink; + mControlReceiveInterface->getSinkInfoDB(SinkID, sink); + set.mainVolume = sink.volume + increment; + if ((error = mControlReceiveInterface->setSinkVolume(set.handle, SinkID, set.mainVolume, RAMP_DIRECT, 20)) != E_OK) + { + return error; + } + mListOpenVolumeChanges.push_back(set); + return E_OK; } am_Error_e ControlSenderPlugin::hookUserSetSinkMuteState(const am_sinkID_t sinkID, const am_MuteState_e muteState) @@ -307,8 +349,26 @@ void ControlSenderPlugin::cbAckConnect(const am_Handle_s handle, const am_Error_ void ControlSenderPlugin::cbAckDisconnect(const am_Handle_s handle, const am_Error_e errorID) { - (void) handle; (void) errorID; + //\todo:error checking + std::vector::iterator it(mListOpenDisconnections.begin()); + for (; it != mListOpenDisconnections.end(); ++it) + { + std::vector::iterator hit; + handleStatus status; + status.status = true; + status.handle = handle; + hit = std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), findHandle(status)); + if (hit == it->listHandleStaus.end()) + continue; + hit->status = true; + if (it->listHandleStaus.end() == std::find_if(it->listHandleStaus.begin(), it->listHandleStaus.end(), checkHandle(status))) + { + mControlReceiveInterface->removeMainConnectionDB(it->connectionID); + mListOpenDisconnections.erase(it); + break; + } + } } void ControlSenderPlugin::cbAckCrossFade(const am_Handle_s handle, const am_HotSink_e hostsink, const am_Error_e error) @@ -322,7 +382,15 @@ void ControlSenderPlugin::cbAckSetSinkVolumeChange(const am_Handle_s handle, con { (void) error; (void) volume; - (void) handle; + //\todo:error checking + std::vector::iterator it(mListOpenVolumeChanges.begin()); + for (; it != mListOpenVolumeChanges.end(); ++it) + { + if (handle.handle == it->handle.handle) + { + mControlReceiveInterface->changeSinkMainVolumeDB(it->mainVolume, it->sinkID); + } + } } void ControlSenderPlugin::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) @@ -347,7 +415,15 @@ void ControlSenderPlugin::cbAckSetSourceSoundProperty(const am_Handle_s handle, void ControlSenderPlugin::cbAckSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) { (void) error; - (void) handle; + //\todo:error checking + std::vector::iterator it(mListMainSoundPropertyChanges.begin()); + for (; it != mListMainSoundPropertyChanges.end(); ++it) + { + if (handle.handle == it->handle.handle) + { + mControlReceiveInterface->changeMainSinkSoundPropertyDB(it->mainSoundProperty, it->sinkID); + } + } } void ControlSenderPlugin::cbAckSetSourceSoundProperties(const am_Handle_s handle, const am_Error_e error) -- 2.7.4