diff options
author | Christian Mueller <christian@lmuc329619u.(none)> | 2011-12-13 16:30:24 +0100 |
---|---|---|
committer | Christian Mueller <christian@lmuc329619u.(none)> | 2011-12-13 16:30:24 +0100 |
commit | 92c8b837306ff1dcd889f9c075435aec50e9aea3 (patch) | |
tree | 67da5878a6e10aa1372f7567b82c3920d8bb984f /AudioManagerDaemon/src | |
parent | 205595e3d3e6a1d55be3c462ef02c9f828a77feb (diff) | |
download | audiomanager-92c8b837306ff1dcd889f9c075435aec50e9aea3.tar.gz |
.
Diffstat (limited to 'AudioManagerDaemon/src')
-rw-r--r-- | AudioManagerDaemon/src/ControlSender.cpp | 4 | ||||
-rw-r--r-- | AudioManagerDaemon/src/DatabaseHandler.cpp | 161 | ||||
-rw-r--r-- | AudioManagerDaemon/src/RoutingReceiver.cpp | 56 | ||||
-rw-r--r-- | AudioManagerDaemon/src/RoutingSender.cpp | 64 |
4 files changed, 264 insertions, 21 deletions
diff --git a/AudioManagerDaemon/src/ControlSender.cpp b/AudioManagerDaemon/src/ControlSender.cpp index 7f015e1..de2e3b7 100644 --- a/AudioManagerDaemon/src/ControlSender.cpp +++ b/AudioManagerDaemon/src/ControlSender.cpp @@ -259,9 +259,9 @@ void ControlSender::cbAckSetSinkVolumeChange(const am_Handle_s handle, const am_ -void ControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t voulme, const am_Error_e error) +void ControlSender::cbAckSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) { - return mController->cbAckSetSourceVolumeChange(handle,voulme,error); + return mController->cbAckSetSourceVolumeChange(handle,volume,error); } diff --git a/AudioManagerDaemon/src/DatabaseHandler.cpp b/AudioManagerDaemon/src/DatabaseHandler.cpp index 5bfcd37..28fa8db 100644 --- a/AudioManagerDaemon/src/DatabaseHandler.cpp +++ b/AudioManagerDaemon/src/DatabaseHandler.cpp @@ -3322,7 +3322,7 @@ am_Error_e DatabaseHandler::changeSourceState(const am_sourceID_t sourceID, cons { assert(sourceID!=0); sqlite3_stmt* query=NULL; - std::string command = "UPDATE " + std::string(SOURCE_TABLE) +" setsourceState=? WHERE sourceID="+ i2s(sourceID); + std::string command = "UPDATE " + std::string(SOURCE_TABLE) +" SET sourceState=? WHERE sourceID="+ i2s(sourceID); int eCode=0; sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL); sqlite3_bind_int(query,1,sourceState); @@ -3599,6 +3599,165 @@ am_Error_e DatabaseHandler::peekSource(const std::string & name, am_sourceID_t & return E_OK; } +am_Error_e DatabaseHandler::changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume) +{ + 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 volume=? WHERE sinkID=" + i2s(sinkID); + sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL); + sqlite3_bind_int(query,1, volume); + if((eCode=sqlite3_step(query))!=SQLITE_DONE) + { + DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSinkVolume 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::changeSinkVolume SQLITE Finalize error code:"),DLT_INT(eCode)); + return E_DATABASE_ERROR; + } + + DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkVolume changed volume of sink:"),DLT_INT(sinkID),DLT_STRING("to:"),DLT_INT(volume)); + + return E_OK; +} + +am_Error_e DatabaseHandler::changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume) +{ + 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 volume=? WHERE sourceID=" + i2s(sourceID); + sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL); + sqlite3_bind_int(query,1, volume); + if((eCode=sqlite3_step(query))!=SQLITE_DONE) + { + DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeSourceVolume 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::changeSourceVolume SQLITE Finalize error code:"),DLT_INT(eCode)); + return E_DATABASE_ERROR; + } + + DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceVolume changed volume of source=:"),DLT_INT(sourceID),DLT_STRING("to:"),DLT_INT(volume)); + + return E_OK; +} + +am_Error_e DatabaseHandler::changeSourceSoundPropertyDB(const am_SoundProperty_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 SourceSoundProperty" + i2s(sourceID)+ " SET value=? WHERE soundPropertyType=" + i2s(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::changeSourceSoundPropertyDB 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::changeSourceSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode)); + return E_DATABASE_ERROR; + } + + DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSourceSoundPropertyDB changed SourceSoundProperty 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::changeSinkSoundPropertyDB(const am_SoundProperty_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 SinkSoundProperty" + i2s(sinkID)+ " SET value=? WHERE soundPropertyType=" + i2s(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::changeSinkSoundPropertyDB 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::changeSinkSoundPropertyDB SQLITE Finalize error code:"),DLT_INT(eCode)); + return E_DATABASE_ERROR; + } + + DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeSinkSoundPropertyDB 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::changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink) +{ + assert(crossfaderID!=0); + + sqlite3_stmt* query=NULL; + int eCode=0; + std::string command; + + if (!existcrossFader(crossfaderID)) + { + return E_NON_EXISTENT; + } + command = "UPDATE " + std::string(CROSSFADER_TABLE) + " SET hotsink=? WHERE crossfaderID=" + i2s(crossfaderID); + sqlite3_prepare_v2(mDatabase,command.c_str(),-1,&query,NULL); + sqlite3_bind_int(query,1, hotsink); + if((eCode=sqlite3_step(query))!=SQLITE_DONE) + { + DLT_LOG(AudioManager, DLT_LOG_ERROR, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink 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::changeCrossFaderHotSink SQLITE Finalize error code:"),DLT_INT(eCode)); + return E_DATABASE_ERROR; + } + + DLT_LOG(AudioManager, DLT_LOG_INFO, DLT_STRING("DatabaseHandler::changeCrossFaderHotSink changed hotsink of crossfader="),DLT_INT(crossfaderID),DLT_STRING("to:"),DLT_INT(hotsink)); + + return E_OK; +} + void DatabaseHandler::createTables() { for(uint16_t i=0;i<sizeof(databaseTables)/sizeof(databaseTables[0]);i++) diff --git a/AudioManagerDaemon/src/RoutingReceiver.cpp b/AudioManagerDaemon/src/RoutingReceiver.cpp index 9940c6e..b3ccf86 100644 --- a/AudioManagerDaemon/src/RoutingReceiver.cpp +++ b/AudioManagerDaemon/src/RoutingReceiver.cpp @@ -39,7 +39,7 @@ void RoutingReceiver::ackConnect(const am_Handle_s handle, const am_connectionID { mDatabaseHandler->removeConnection(connectionID); } - return mControlSender->cbAckConnect(handle,error); + mControlSender->cbAckConnect(handle,error); } @@ -51,56 +51,106 @@ void RoutingReceiver::ackDisconnect(const am_Handle_s handle, const am_connectio { mDatabaseHandler->removeConnection(connectionID); } - return mControlSender->cbAckConnect(handle,error); + mControlSender->cbAckDisconnect(handle,error); } void RoutingReceiver::ackSetSinkVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) { - + RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle); + if(error==E_OK && handleData.sinkID!=0) + { + //todo: check if volume in handleData is same than volume. React to it. + mDatabaseHandler->changeSinkVolume(handleData.sinkID,volume); + } + mRoutingSender->removeHandle(handle); + mControlSender->cbAckSetSinkVolumeChange(handle,volume,error); } void RoutingReceiver::ackSetSourceVolumeChange(const am_Handle_s handle, const am_volume_t volume, const am_Error_e error) { + RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle); + if(error==E_OK && handleData.sourceID!=0) + { + //todo: check if volume in handleData is same than volume. React to it. + mDatabaseHandler->changeSourceVolume(handleData.sourceID,volume); + } + mRoutingSender->removeHandle(handle); + mControlSender->cbAckSetSourceVolumeChange(handle,volume,error); } void RoutingReceiver::ackSetSourceState(const am_Handle_s handle, const am_Error_e error) { + RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle); + if(error==E_OK && handleData.sourceID!=0) + { + //todo: check if volume in handleData is same than volume. React to it. + mDatabaseHandler->changeSourceState(handleData.sourceID,handleData.sourceState); + } + mRoutingSender->removeHandle(handle); + mControlSender->cbAckSetSourceState(handle,error); } void RoutingReceiver::ackSetSinkSoundProperty(const am_Handle_s handle, const am_Error_e error) { + RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle); + if(error==E_OK && handleData.sinkID!=0) + { + //todo: check if volume in handleData is same than volume. React to it. + mDatabaseHandler->changeSinkSoundPropertyDB(handleData.soundPropery,handleData.sinkID); + } + mRoutingSender->removeHandle(handle); + mControlSender->cbAckSetSinkSoundProperty(handle,error); + } void RoutingReceiver::ackSetSourceSoundProperty(const am_Handle_s handle, const am_Error_e error) { + RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle); + if(error==E_OK && handleData.sourceID!=0) + { + //todo: check if volume in handleData is same than volume. React to it. + mDatabaseHandler->changeSourceSoundPropertyDB(handleData.soundPropery,handleData.sourceID); + } + mRoutingSender->removeHandle(handle); + mControlSender->cbAckSetSourceSoundProperty(handle,error); } void RoutingReceiver::ackCrossFading(const am_Handle_s handle, const am_HotSink_e hotSink, const am_Error_e error) { + RoutingSender::am_handleData_c handleData=mRoutingSender->returnHandleData(handle); + if(error==E_OK && handleData.crossfaderID!=0) + { + //todo: check if volume in handleData is same than volume. React to it. + mDatabaseHandler->changeCrossFaderHotSink(handleData.crossfaderID,hotSink); + } + mRoutingSender->removeHandle(handle); + mControlSender->cbAckCrossFade(handle,hotSink,error); } void RoutingReceiver::ackSourceVolumeTick(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume) { + mControlSender->hookSystemSourceVolumeTick(handle,sourceID,volume); } void RoutingReceiver::ackSinkVolumeTick(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume) { + mControlSender->hookSystemSinkVolumeTick(handle,sinkID,volume); } diff --git a/AudioManagerDaemon/src/RoutingSender.cpp b/AudioManagerDaemon/src/RoutingSender.cpp index d54a986..70aa69f 100644 --- a/AudioManagerDaemon/src/RoutingSender.cpp +++ b/AudioManagerDaemon/src/RoutingSender.cpp @@ -142,11 +142,13 @@ am_Error_e RoutingSender::asyncAbort(const am_Handle_s& handle) am_Error_e RoutingSender::asyncConnect(am_Handle_s& handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_ConnectionFormat_e connectionFormat) { + am_handleData_c handleData; SinkInterfaceMap::iterator iter = mMapSinkInterface.begin(); iter=mMapSinkInterface.find(sinkID); if (iter != mMapSinkInterface.end()) { - handle=createHandle(H_CONNECT); + handleData.connectionID=connectionID; + handle=createHandle(handleData,H_CONNECT); mMapConnectionInterface.insert(std::make_pair(connectionID,iter->second)); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncConnect(handle,connectionID,sourceID,sinkID,connectionFormat); @@ -159,11 +161,13 @@ am_Error_e RoutingSender::asyncConnect(am_Handle_s& handle, const am_connectionI am_Error_e RoutingSender::asyncDisconnect(am_Handle_s& handle, const am_connectionID_t connectionID) { + am_handleData_c handleData; ConnectionInterfaceMap::iterator iter = mMapConnectionInterface.begin(); mMapConnectionInterface.find(connectionID); if (iter != mMapConnectionInterface.end()) { - handle=createHandle(H_DISCONNECT); + handleData.connectionID=connectionID; + handle=createHandle(handleData,H_DISCONNECT); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); am_Error_e returnVal=iter->second->asyncDisconnect(handle,connectionID); mMapConnectionInterface.erase(iter); @@ -177,10 +181,13 @@ am_Error_e RoutingSender::asyncDisconnect(am_Handle_s& handle, const am_connecti am_Error_e RoutingSender::asyncSetSinkVolume(am_Handle_s& handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) { + am_handleData_c handleData; SinkInterfaceMap::iterator iter = mMapSinkInterface.begin(); iter=mMapSinkInterface.find(sinkID); if (iter != mMapSinkInterface.end()) - handle=createHandle(H_SETSINKVOLUME); + handleData.sinkID=sinkID; + handleData.volume=volume; + handle=createHandle(handleData,H_SETSINKVOLUME); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncSetSinkVolume(handle,sinkID,volume,ramp,time); return E_NON_EXISTENT; @@ -190,10 +197,13 @@ am_Error_e RoutingSender::asyncSetSinkVolume(am_Handle_s& handle, const am_sinkI am_Error_e RoutingSender::asyncSetSourceVolume(am_Handle_s& handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_RampType_e ramp, const am_time_t time) { + am_handleData_c handleData; SourceInterfaceMap::iterator iter = mMapSourceInterface.begin(); iter=mMapSourceInterface.find(sourceID); if (iter != mMapSourceInterface.end()) - handle=createHandle(H_SETSOURCEVOLUME); + handleData.sourceID=sourceID; + handleData.volume=volume; + handle=createHandle(handleData,H_SETSOURCEVOLUME); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncSetSourceVolume(handle,sourceID,volume,ramp,time); return E_NON_EXISTENT; @@ -203,10 +213,13 @@ am_Error_e RoutingSender::asyncSetSourceVolume(am_Handle_s& handle, const am_sou am_Error_e RoutingSender::asyncSetSourceState(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SourceState_e state) { + am_handleData_c handleData; SourceInterfaceMap::iterator iter = mMapSourceInterface.begin(); iter=mMapSourceInterface.find(sourceID); if (iter != mMapSourceInterface.end()) - handle=createHandle(H_SETSOURCESTATE); + handleData.sourceID=sourceID; + handleData.sourceState=state; + handle=createHandle(handleData,H_SETSOURCESTATE); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncSetSourceState(handle,sourceID,state); return E_NON_EXISTENT; @@ -216,10 +229,13 @@ am_Error_e RoutingSender::asyncSetSourceState(am_Handle_s& handle, const am_sour am_Error_e RoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const am_sinkID_t sinkID, const am_SoundProperty_s & soundProperty) { + am_handleData_c handleData; SinkInterfaceMap::iterator iter = mMapSinkInterface.begin(); iter=mMapSinkInterface.find(sinkID); if (iter != mMapSinkInterface.end()) - handle=createHandle(H_SETSINKSOUNDPROPERTY); + handleData.sinkID=sinkID; + handleData.soundPropery=soundProperty; + handle=createHandle(handleData,H_SETSINKSOUNDPROPERTY); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncSetSinkSoundProperty(handle,soundProperty,sinkID); return E_NON_EXISTENT; @@ -229,10 +245,13 @@ am_Error_e RoutingSender::asyncSetSinkSoundProperty(am_Handle_s& handle, const a am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const am_sourceID_t sourceID, const am_SoundProperty_s & soundProperty) { + am_handleData_c handleData; SourceInterfaceMap::iterator iter = mMapSourceInterface.begin(); iter=mMapSourceInterface.find(sourceID); if (iter != mMapSourceInterface.end()) - handle=createHandle(H_SETSOURCESOUNDPROPERTY); + handleData.sourceID=sourceID; + handleData.soundPropery=soundProperty; + handle=createHandle(handleData,H_SETSOURCESOUNDPROPERTY); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncSetSourceSoundProperty(handle,soundProperty,sourceID); return E_NON_EXISTENT; @@ -242,10 +261,13 @@ am_Error_e RoutingSender::asyncSetSourceSoundProperty(am_Handle_s& handle, const am_Error_e RoutingSender::asyncCrossFade(am_Handle_s& handle, const am_crossfaderID_t crossfaderID, const am_HotSink_e hotSink, const am_RampType_e rampType, const am_time_t time) { + am_handleData_c handleData; CrossfaderInterfaceMap::iterator iter = mMapCrossfaderInterface.begin(); iter=mMapCrossfaderInterface.find(crossfaderID); if (iter != mMapCrossfaderInterface.end()) - handle=createHandle(H_CROSSFADE); + handleData.crossfaderID=crossfaderID; + handleData.hotSink=hotSink; + handle=createHandle(handleData,H_CROSSFADE); mMapHandleInterface.insert(std::make_pair(handle.handle,iter->second)); return iter->second->asyncCrossFade(handle,crossfaderID,hotSink,rampType,time); return E_NON_EXISTENT; @@ -390,17 +412,29 @@ am_Error_e RoutingSender::removeHandle(const am_Handle_s& handle) am_Error_e RoutingSender::getListHandles(std::vector<am_Handle_s> & listHandles) const { - std::copy(mlistActiveHandles.begin(),mlistActiveHandles.end(),std::back_inserter(listHandles)); + listHandles.clear(); + HandlesMap::const_iterator it=mlistActiveHandles.begin(); + for(;it!=mlistActiveHandles.end();++it) + { + listHandles.push_back(it->first); + } return E_OK; } -am_Handle_s RoutingSender::createHandle(const am_Handle_e handle) +am_Handle_s RoutingSender::createHandle(const am_handleData_c& handleData, const am_Handle_e type) +{ + am_Handle_s handle; + handle.handle=++mHandleCount; //todo: handle overflows here... + handle.handleType=type; + mlistActiveHandles.insert(std::make_pair(handle,handleData)); + return handle; +} + +RoutingSender::am_handleData_c RoutingSender::returnHandleData(am_Handle_s handle) { - am_Handle_s newHandle; - newHandle.handle=++mHandleCount; //todo: handle overflows here... - newHandle.handleType=handle; - mlistActiveHandles.insert(newHandle); - return newHandle; + HandlesMap::iterator it=mlistActiveHandles.begin(); + it=mlistActiveHandles.find(handle); + return (it->second); } void RoutingSender::unloadLibraries(void) |