summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandar Donchev <Aleksander.Donchev@partner.bmw.de>2015-03-11 19:10:54 +0100
committerAlexandar Donchev <Aleksander.Donchev@partner.bmw.de>2015-03-11 19:10:54 +0100
commitc628fa5304171cd827f56aa475668d99d26ad28a (patch)
treefda6587626ce2ebfaed367ce767eddc6f3f6d3de
parent3ff140d47796839b0d733d2ec83a638bb5d06bb1 (diff)
downloadaudiomanager-c628fa5304171cd827f56aa475668d99d26ad28a.tar.gz
* Sound property lookup enhancement throught caching . Tests for cached sound properties.
Signed-off-by: Christian Linke <christian.linke@bmw.de> Signed-off-by: Alexandar Donchev <Aleksander.Donchev@partner.bmw.de>>
-rw-r--r--AudioManagerDaemon/include/CAmControlReceiver.h8
-rw-r--r--AudioManagerDaemon/include/CAmDatabaseHandlerMap.h121
-rw-r--r--AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h4
-rw-r--r--AudioManagerDaemon/include/IAmDatabaseHandler.h4
-rw-r--r--AudioManagerDaemon/src/CAmControlReceiver.cpp48
-rw-r--r--AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp156
-rw-r--r--AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp121
-rw-r--r--AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp76
-rw-r--r--AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp105
-rw-r--r--AudioManagerDaemon/test/CAmCommonFunctions.cpp2
-rw-r--r--PluginControlInterface/test/MockIAmControlReceive.h18
-rwxr-xr-xinclude/control/IAmControlReceive.h51
-rw-r--r--include/shared/CAmSerializer.h62
13 files changed, 678 insertions, 98 deletions
diff --git a/AudioManagerDaemon/include/CAmControlReceiver.h b/AudioManagerDaemon/include/CAmControlReceiver.h
index b0a9d1a..7902348 100644
--- a/AudioManagerDaemon/include/CAmControlReceiver.h
+++ b/AudioManagerDaemon/include/CAmControlReceiver.h
@@ -141,6 +141,14 @@ public:
NsmErrorStatus_e unRegisterShutdownClientNSM(const uint32_t shutdownMode) ;
am_Error_e getInterfaceVersionNSM(uint32_t& version) ;
NsmErrorStatus_e sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status) ;
+ am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const;
+ am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const;
+ am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
+ am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
+ am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
private:
IAmDatabaseHandler* mDatabaseHandler; //!< pointer tto the databasehandler
diff --git a/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h b/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h
index 0c97185..89bab75 100644
--- a/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h
+++ b/AudioManagerDaemon/include/CAmDatabaseHandlerMap.h
@@ -126,6 +126,10 @@ public:
am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
+ am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const;
am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const;
am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const;
@@ -200,85 +204,108 @@ public:
* The following structures extend the base structures with the field 'reserved'.
*/
-#define AM_TYPEDEF_SUBCLASS_BEGIN(Subclass, Class) \
- typedef struct Subclass : public Class\
- {\
- Subclass & operator=(const Subclass & anObject) \
- {\
- if (this != &anObject)\
- {\
- Class::operator=(anObject);\
- }\
- return *this;\
- };\
- Subclass & operator=(const Class & anObject)\
- {\
- if (this != &anObject)\
- Class::operator=(anObject);\
- return *this;\
- };\
- void getDescription (std::string & outString) const;\
-
-#define AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(Subclass, Class) \
+#define AM_SUBCLASS_BEGIN(Subclass, Class) \
typedef struct Subclass : public Class\
- {\
- bool reserved;\
- Subclass():Class(), reserved(false)\
- {};\
+ {
+
+#define AM_SUBCLASS_CONSTR(Subclass, Class) \
+ Subclass():Class()
+
+#define AM_SUBCLASS_CONSTR_BODY()\
+ {};
+
+#define AM_SUBCLASS_COPY_OP_START(Subclass, Class) \
Subclass & operator=(const Subclass & anObject)\
{\
if (this != &anObject)\
{\
- Class::operator=(anObject);\
- reserved = anObject.reserved;\
+ Class::operator=(anObject);
+
+#define AM_SUBCLASS_COPY_OP_END()\
}\
return *this;\
- };\
- Subclass & operator=(const Class & anObject)\
- {\
- if (this != &anObject)\
- Class::operator=(anObject);\
- return *this;\
- };\
- void getDescription (std::string & outString) const;\
+ };
+
+#define AM_SUBCLASS_OP(Subclass, Class) \
+ Subclass & operator=(const Class & anObject)\
+ {\
+ if (this != &anObject)\
+ Class::operator=(anObject);\
+ return *this;\
+ };
+
+#define AM_SUBCLASS_END(Typedef) \
+ void getDescription (std::string & outString) const;\
+ } Typedef;
+
+#define AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(Subclass, Class)\
+ AM_SUBCLASS_BEGIN(Subclass, Class)\
+ bool reserved;\
+ AM_SUBCLASS_CONSTR(Subclass, Class)\
+ ,reserved(false)\
+ AM_SUBCLASS_CONSTR_BODY()\
+ AM_SUBCLASS_COPY_OP_START(Subclass, Class)\
+ reserved = anObject.reserved;\
+ AM_SUBCLASS_COPY_OP_END()\
+ AM_SUBCLASS_OP(Subclass, Class)\
+
+#define AM_TYPEDEF_SUBCLASS_SOUND_PROPERTIES_BEGIN(Subclass, Class)\
+ AM_SUBCLASS_BEGIN(Subclass, Class)\
+ bool reserved;\
+ std::unordered_map<am_CustomSoundPropertyType_t, int16_t> cacheSoundProperties;\
+ std::unordered_map<am_CustomMainSoundPropertyType_t, int16_t> cacheMainSoundProperties;\
+ AM_SUBCLASS_CONSTR(Subclass, Class)\
+ ,reserved(false), cacheSoundProperties(), cacheMainSoundProperties()\
+ AM_SUBCLASS_CONSTR_BODY()\
+ AM_SUBCLASS_COPY_OP_START(Subclass, Class)\
+ reserved = anObject.reserved;\
+ cacheSoundProperties = anObject.cacheSoundProperties;\
+ cacheMainSoundProperties = anObject.cacheMainSoundProperties;\
+ AM_SUBCLASS_COPY_OP_END()\
+ AM_SUBCLASS_OP(Subclass, Class)\
+
+#define AM_TYPEDEF_SUBCLASS_BEGIN(Subclass, Class)\
+ AM_SUBCLASS_BEGIN(Subclass, Class)\
+ AM_SUBCLASS_COPY_OP_START(Subclass, Class)\
+ AM_SUBCLASS_COPY_OP_END()\
+ AM_SUBCLASS_OP(Subclass, Class)\
-#define AM_TYPEDEF_SUBCLASS_END(Typedef) } Typedef; \
AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Domain_Database_s,am_Domain_s)
- AM_TYPEDEF_SUBCLASS_END(CAmDomain)
+ AM_SUBCLASS_END(CAmDomain)
- AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Sink_Database_s,am_Sink_s)
+ AM_TYPEDEF_SUBCLASS_SOUND_PROPERTIES_BEGIN(am_Sink_Database_s,am_Sink_s)
void getSinkType(am_SinkType_s & sinkType) const;\
- AM_TYPEDEF_SUBCLASS_END(CAmSink)
+ AM_SUBCLASS_END(CAmSink)
- AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Source_Database_s,am_Source_s)
+ AM_TYPEDEF_SUBCLASS_SOUND_PROPERTIES_BEGIN(am_Source_Database_s,am_Source_s)
void getSourceType(am_SourceType_s & sourceType) const;\
- AM_TYPEDEF_SUBCLASS_END(CAmSource)
+ AM_SUBCLASS_END(CAmSource)
AM_TYPEDEF_SUBCLASS_RESERVED_FLAG_BEGIN(am_Connection_Database_s,am_Connection_s)
- AM_TYPEDEF_SUBCLASS_END(CAmConnection)
+ AM_SUBCLASS_END(CAmConnection)
/**
* The following structures extend the base structures with print capabilities.
*/
AM_TYPEDEF_SUBCLASS_BEGIN(am_MainConnection_Database_s, am_MainConnection_s)
void getMainConnectionType(am_MainConnectionType_s & connectionType) const;\
- AM_TYPEDEF_SUBCLASS_END(CAmMainConnection)
+ AM_SUBCLASS_END(CAmMainConnection)
AM_TYPEDEF_SUBCLASS_BEGIN(am_SourceClass_Database_s, am_SourceClass_s)
- AM_TYPEDEF_SUBCLASS_END(CAmSourceClass)
+ AM_SUBCLASS_END(CAmSourceClass)
AM_TYPEDEF_SUBCLASS_BEGIN(am_SinkClass_Database_s, am_SinkClass_s)
- AM_TYPEDEF_SUBCLASS_END(CAmSinkClass)
+ AM_SUBCLASS_END(CAmSinkClass)
AM_TYPEDEF_SUBCLASS_BEGIN(am_Gateway_Database_s, am_Gateway_s)
- AM_TYPEDEF_SUBCLASS_END(CAmGateway)
+ AM_SUBCLASS_END(CAmGateway)
AM_TYPEDEF_SUBCLASS_BEGIN(am_Converter_Database_s, am_Converter_s)
- AM_TYPEDEF_SUBCLASS_END(CAmConverter)
+ AM_SUBCLASS_END(CAmConverter)
AM_TYPEDEF_SUBCLASS_BEGIN(am_Crossfader_Database_s, am_Crossfader_s)
- AM_TYPEDEF_SUBCLASS_END(CAmCrossfader)
+ AM_SUBCLASS_END(CAmCrossfader)
private:
typedef std::unordered_map<am_domainID_t, CAmDomain> CAmMapDomain;
diff --git a/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h b/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h
index b53bd7f..444ea5c 100644
--- a/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h
+++ b/AudioManagerDaemon/include/CAmDatabaseHandlerSQLite.h
@@ -119,8 +119,12 @@ public:
am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s& mainConnectionData) const;
am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t& volume) const;
am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const;
+ am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const;
am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const;
+ am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
+ am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const;
am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const;
am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const;
am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const;
diff --git a/AudioManagerDaemon/include/IAmDatabaseHandler.h b/AudioManagerDaemon/include/IAmDatabaseHandler.h
index ba387e2..178629d 100644
--- a/AudioManagerDaemon/include/IAmDatabaseHandler.h
+++ b/AudioManagerDaemon/include/IAmDatabaseHandler.h
@@ -113,6 +113,10 @@ public:
virtual am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t& volume) const = 0;
virtual am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const = 0;
virtual am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const = 0;
+ virtual am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
+ virtual am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
+ virtual am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const = 0;
+ virtual am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const = 0;
virtual am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t>& listSinkID) const = 0;
virtual am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t>& listSourceID) const = 0;
virtual am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t>& listGatewaysID) const = 0;
diff --git a/AudioManagerDaemon/src/CAmControlReceiver.cpp b/AudioManagerDaemon/src/CAmControlReceiver.cpp
index f576f5e..6ac7e0a 100644
--- a/AudioManagerDaemon/src/CAmControlReceiver.cpp
+++ b/AudioManagerDaemon/src/CAmControlReceiver.cpp
@@ -695,5 +695,53 @@ NsmErrorStatus_e CAmControlReceiver::sendLifecycleRequestCompleteNSM(const uint3
}
+am_Error_e CAmControlReceiver::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const
+{
+ logInfo("CAmControlReceiver::getListMainSinkSoundProperties was called, sinkID", sinkID);
+ return (mDatabaseHandler->getListMainSinkSoundProperties(sinkID,listSoundproperties));
+}
+
+am_Error_e CAmControlReceiver::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const
+{
+ logInfo("CAmControlReceiver::getListMainSourceSoundProperties was called, sourceID", sourceID);
+ return (mDatabaseHandler->getListMainSourceSoundProperties(sourceID, listSoundproperties));
+}
+
+am_Error_e CAmControlReceiver::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+{
+ logInfo("CAmControlReceiver::getListSinkSoundProperties was called, sinkID", sinkID);
+ return (mDatabaseHandler->getListSinkSoundProperties(sinkID,listSoundproperties));
+}
+
+am_Error_e CAmControlReceiver::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+{
+ logInfo("CAmControlReceiver::getListSourceSoundProperties was called, sourceID", sourceID);
+ return (mDatabaseHandler->getListSourceSoundProperties(sourceID, listSoundproperties));
+}
+
+am_Error_e CAmControlReceiver::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+{
+ logInfo("CAmControlReceiver::getMainSinkSoundPropertyValue was called, sinkID", sinkID);
+ return (mDatabaseHandler->getMainSinkSoundPropertyValue(sinkID,propertyType,value));
+}
+
+am_Error_e CAmControlReceiver::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const
+{
+ logInfo("CAmControlReceiver::getSinkSoundPropertyValue was called, sinkID", sinkID);
+ return (mDatabaseHandler->getSinkSoundPropertyValue(sinkID,propertyType,value));
+}
+
+am_Error_e CAmControlReceiver::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+{
+ logInfo("CAmControlReceiver::getMainSourceSoundPropertyValue was called, sourceID", sourceID);
+ return (mDatabaseHandler->getMainSourceSoundPropertyValue(sourceID,propertyType,value));
+}
+
+am_Error_e CAmControlReceiver::getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const
+{
+ logInfo("CAmControlReceiver::getSourceSoundPropertyValue was called, sourceID", sourceID);
+ return (mDatabaseHandler->getSourceSoundPropertyValue(sourceID,propertyType,value));
+}
+
}
diff --git a/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp b/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp
index 73daef4..864ae8c 100644
--- a/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp
+++ b/AudioManagerDaemon/src/CAmDatabaseHandlerMap.cpp
@@ -1177,12 +1177,17 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSinkSoundPropertyDB(const am_MainSou
{
return (E_NON_EXISTENT);
}
-
- std::vector<am_MainSoundProperty_s>::iterator elementIterator = mMappedData.mSinkMap[sinkID].listMainSoundProperties.begin();
- for (;elementIterator != mMappedData.mSinkMap[sinkID].listMainSoundProperties.end(); ++elementIterator)
+ am_Sink_Database_s & sink = mMappedData.mSinkMap[sinkID];
+ std::vector<am_MainSoundProperty_s>::iterator elementIterator = sink.listMainSoundProperties.begin();
+ for (;elementIterator != sink.listMainSoundProperties.end(); ++elementIterator)
{
if (elementIterator->type == soundProperty.type)
+ {
elementIterator->value = soundProperty.value;
+ if(sink.cacheMainSoundProperties.size())
+ sink.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
+ break;
+ }
}
logInfo("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value);
@@ -1199,12 +1204,17 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainS
{
return (E_NON_EXISTENT);
}
-
- std::vector<am_MainSoundProperty_s>::iterator elementIterator = mMappedData.mSourceMap[sourceID].listMainSoundProperties.begin();
- for (;elementIterator != mMappedData.mSourceMap[sourceID].listMainSoundProperties.end(); ++elementIterator)
+ am_Source_Database_s & source = mMappedData.mSourceMap.at(sourceID);
+ std::vector<am_MainSoundProperty_s>::iterator elementIterator = source.listMainSoundProperties.begin();
+ for (;elementIterator != source.listMainSoundProperties.end(); ++elementIterator)
{
if (elementIterator->type == soundProperty.type)
+ {
elementIterator->value = soundProperty.value;
+ if(source.cacheMainSoundProperties.size())
+ source.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
+ break;
+ }
}
logInfo("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value);
@@ -1867,6 +1877,30 @@ am_Error_e CAmDatabaseHandlerMap::getListMainSourceSoundProperties(const am_sour
return (E_OK);
}
+am_Error_e CAmDatabaseHandlerMap::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+{
+ assert(sinkID!=0);
+ if (!existSink(sinkID))
+ return E_NON_EXISTENT;
+
+ am_Sink_Database_s sink = mMappedData.mSinkMap.at(sinkID);
+ listSoundproperties = sink.listSoundProperties;
+
+ return (E_OK);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+{
+ assert(sourceID!=0);
+ if (!existSource(sourceID))
+ return E_NON_EXISTENT;
+
+ am_Source_Database_s source = mMappedData.mSourceMap.at(sourceID);
+ listSoundproperties = source.listSoundProperties;
+
+ return (E_OK);
+}
+
am_Error_e CAmDatabaseHandlerMap::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
{
listSystemProperties = mMappedData.mSystemProperties;
@@ -2326,17 +2360,20 @@ am_Error_e CAmDatabaseHandlerMap::getSinkSoundPropertyValue(const am_sinkID_t si
{
assert(sinkID!=0);
- am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
- if( NULL!=source )
+ am_Sink_Database_s * pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if( NULL!=pObject )
{
- std::vector<am_SoundProperty_s>::const_iterator iter = source->listSoundProperties.begin();
- for(; iter<source->listSoundProperties.end(); ++iter)
+ if(pObject->listSoundProperties.size()>0 && 0==pObject->cacheSoundProperties.size())
{
- if( propertyType == iter->type )
- {
- value = iter->value;
- return (E_OK);
- }
+ std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
+ for(; iter<pObject->listSoundProperties.end(); ++iter)
+ pObject->cacheSoundProperties[iter->type] = iter->value;
+ }
+ auto it = pObject->cacheSoundProperties.find(propertyType);
+ if(it!=pObject->cacheSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
}
}
value = -1;
@@ -2347,23 +2384,75 @@ am_Error_e CAmDatabaseHandlerMap::getSourceSoundPropertyValue(const am_sourceID_
{
assert(sourceID!=0);
- am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
- if( NULL!=source )
+ am_Source_Database_s * pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if( NULL!=pObject )
{
- std::vector<am_SoundProperty_s>::const_iterator iter = source->listSoundProperties.begin();
- for(; iter<source->listSoundProperties.end(); ++iter)
+ if(pObject->listSoundProperties.size()>0 && 0==pObject->cacheSoundProperties.size())
{
- if( propertyType == iter->type )
- {
- value = iter->value;
- return (E_OK);
- }
+ std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
+ for(; iter<pObject->listSoundProperties.end(); ++iter)
+ pObject->cacheSoundProperties[iter->type] = iter->value;
+ }
+ auto it = pObject->cacheSoundProperties.find(propertyType);
+ if(it!=pObject->cacheSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
+ }
+ }
+ value = -1;
+ return (E_NON_EXISTENT);
+}
+
+am_Error_e CAmDatabaseHandlerMap::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+{
+ assert(sinkID!=0);
+
+ am_Sink_Database_s * pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
+ if( NULL!=pObject )
+ {
+ if(pObject->listMainSoundProperties.size()>0 && 0==pObject->cacheMainSoundProperties.size())
+ {
+ std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
+ for(; iter<pObject->listMainSoundProperties.end(); ++iter)
+ pObject->cacheMainSoundProperties[iter->type] = iter->value;
+ }
+ auto it = pObject->cacheMainSoundProperties.find(propertyType);
+ if(it!=pObject->cacheMainSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
}
}
value = -1;
return (E_NON_EXISTENT);
}
+am_Error_e CAmDatabaseHandlerMap::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+{
+ assert(sourceID!=0);
+
+ am_Source_Database_s * pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
+ if( NULL!=pObject )
+ {
+ if(pObject->listMainSoundProperties.size()>0 && 0==pObject->cacheMainSoundProperties.size())
+ {
+ std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
+ for(; iter<pObject->listMainSoundProperties.end(); ++iter)
+ pObject->cacheMainSoundProperties[iter->type] = iter->value;
+ }
+ auto it = pObject->cacheMainSoundProperties.find(propertyType);
+ if(it!=pObject->cacheMainSoundProperties.end())
+ {
+ value = it->second;
+ return (E_OK);
+ }
+ }
+
+ value = -1;
+ return (E_NON_EXISTENT);
+}
+
am_Error_e CAmDatabaseHandlerMap::getDomainState(const am_domainID_t domainID, am_DomainState_e& state) const
{
assert(domainID!=0);
@@ -2505,12 +2594,15 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceSoundPropertyDB(const am_SoundProp
return (E_NON_EXISTENT);
}
- std::vector<am_SoundProperty_s>::iterator iter = mMappedData.mSourceMap[sourceID].listSoundProperties.begin();
- for(; iter<mMappedData.mSourceMap[sourceID].listSoundProperties.end(); ++iter)
+ am_Source_Database_s & source = mMappedData.mSourceMap[sourceID];
+ std::vector<am_SoundProperty_s>::iterator iter = source.listSoundProperties.begin();
+ for(; iter<source.listSoundProperties.end(); ++iter)
{
if( soundProperty.type == iter->type )
{
iter->value = soundProperty.value;
+ if(source.cacheSoundProperties.size())
+ source.cacheSoundProperties[soundProperty.type] = soundProperty.value;
return (E_OK);
}
}
@@ -2525,13 +2617,15 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkSoundPropertyDB(const am_SoundProper
{
return (E_NON_EXISTENT);
}
-
- std::vector<am_SoundProperty_s>::iterator iter = mMappedData.mSinkMap[sinkID].listSoundProperties.begin();
- for(; iter<mMappedData.mSinkMap[sinkID].listSoundProperties.end(); ++iter)
+ am_Sink_Database_s & sink = mMappedData.mSinkMap[sinkID];
+ std::vector<am_SoundProperty_s>::iterator iter = sink.listSoundProperties.begin();
+ for(; iter<sink.listSoundProperties.end(); ++iter)
{
if( soundProperty.type == iter->type )
{
iter->value = soundProperty.value;
+ if(sink.cacheSoundProperties.size())
+ sink.cacheSoundProperties[soundProperty.type] = soundProperty.value;
return (E_OK);
}
}
@@ -2621,6 +2715,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
if (!listSoundProperties.empty())
{
mMappedData.mSourceMap.at(sourceID).listSoundProperties = listSoundProperties;
+ mMappedData.mSourceMap.at(sourceID).cacheSoundProperties.clear();
}
//check if we have to update the list of connectionformats
@@ -2634,6 +2729,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, c
{
mMappedData.mSourceMap.at(sourceID).listMainSoundProperties = listMainSoundProperties;
+ mMappedData.mSourceMap.at(sourceID).cacheMainSoundProperties.clear();
}
else //read out the properties
{
@@ -2679,6 +2775,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const a
if (!listSoundProperties.empty())
{
mMappedData.mSinkMap.at(sinkID).listSoundProperties = listSoundProperties;
+ mMappedData.mSinkMap.at(sinkID).cacheSoundProperties.clear();
}
//check if we have to update the list of connectionformats
@@ -2691,6 +2788,7 @@ am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const a
if (!listMainSoundProperties.empty() && sinkVisible(sinkID))
{
mMappedData.mSinkMap.at(sinkID).listMainSoundProperties = listMainSoundProperties;
+ mMappedData.mSinkMap.at(sinkID).cacheSoundProperties.clear();
}
else //read out the properties
{
diff --git a/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp b/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp
index cb95ec6..da86386 100644
--- a/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp
+++ b/AudioManagerDaemon/src/CAmDatabaseHandlerSQLite.cpp
@@ -2880,7 +2880,71 @@ am_Error_e CAmDatabaseHandlerSQLite::getListMainSourceSoundProperties(const am_s
if (eCode != SQLITE_DONE)
{
- logError("DatabaseHandler::getListMainSinkSoundProperties SQLITE error code:", eCode);
+ logError("DatabaseHandler::getListMainSourceSoundProperties SQLITE error code:", eCode);
+ MY_SQLITE_FINALIZE(query)
+ return (E_DATABASE_ERROR);
+ }
+
+ MY_SQLITE_FINALIZE(query)
+
+ return (E_OK);
+}
+
+am_Error_e CAmDatabaseHandlerSQLite::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_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_SoundProperty_s temp;
+ std::string command = "SELECT soundPropertyType, value FROM SinkSoundProperty" + i2s(sinkID);
+ MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL)
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.type = (am_CustomMainSoundPropertyType_t) sqlite3_column_int(query, 0);
+ temp.value = sqlite3_column_int(query, 1);
+ listSoundproperties.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ logError("DatabaseHandler::getListSinkSoundProperties SQLITE error code:", eCode);
+ MY_SQLITE_FINALIZE(query)
+ return (E_DATABASE_ERROR);
+ }
+
+ MY_SQLITE_FINALIZE(query)
+
+ return (E_OK);
+}
+
+am_Error_e CAmDatabaseHandlerSQLite::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const
+{
+ assert(sourceID!=0);
+ if (!existSource(sourceID))
+ 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_SoundProperty_s temp;
+ std::string command = "SELECT soundPropertyType, value FROM SourceSoundProperty" + i2s(sourceID);
+ MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL)
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ temp.type = (am_CustomMainSoundPropertyType_t) sqlite3_column_int(query, 0);
+ temp.value = sqlite3_column_int(query, 1);
+ listSoundproperties.push_back(temp);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ logError("DatabaseHandler::getListSourceSoundProperties SQLITE error code:", eCode);
MY_SQLITE_FINALIZE(query)
return (E_DATABASE_ERROR);
}
@@ -4042,6 +4106,61 @@ am_Error_e CAmDatabaseHandlerSQLite::getSourceVolume(const am_sourceID_t sourceI
return (E_OK);
}
+am_Error_e CAmDatabaseHandlerSQLite::getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+{
+ assert(sinkID!=0);
+ if (!existSink(sinkID))
+ return (E_DATABASE_ERROR); // todo: here we could change to non existent, but not shown in sequences
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "SELECT value FROM SinkMainSoundProperty" + i2s(sinkID) + " WHERE soundPropertyType=" + i2s(propertyType);
+ MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL)
+
+ if ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ value = sqlite3_column_int(query, 0);
+ }
+ else
+ {
+ logError("DatabaseHandler::getDomainState database error!:", eCode);
+ MY_SQLITE_FINALIZE(query)
+ return (E_DATABASE_ERROR);
+ }
+
+ MY_SQLITE_FINALIZE(query)
+
+ return (E_OK);
+}
+
+am_Error_e CAmDatabaseHandlerSQLite::getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const
+{
+ assert(sourceID!=0);
+ if (!existSource(sourceID))
+ return (E_DATABASE_ERROR); // todo: here we could change to non existent, but not shown in sequences
+
+ sqlite3_stmt* query = NULL;
+ int eCode = 0;
+ std::string command = "SELECT value FROM SourceMainSoundProperty" + i2s(sourceID) + " WHERE soundPropertyType=" + i2s(propertyType);
+ MY_SQLITE_PREPARE_V2(mpDatabase, command.c_str(), -1, &query, NULL)
+
+ while ((eCode = sqlite3_step(query)) == SQLITE_ROW)
+ {
+ value = sqlite3_column_int(query, 0);
+ }
+
+ if (eCode != SQLITE_DONE)
+ {
+ logError("DatabaseHandler::getSinkSoundPropertyValue SQLITE error code:", eCode);
+ MY_SQLITE_FINALIZE(query)
+ return (E_DATABASE_ERROR);
+ }
+
+ MY_SQLITE_FINALIZE(query)
+
+ return (E_OK);
+}
+
am_Error_e CAmDatabaseHandlerSQLite::getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t & value) const
{
assert(sinkID!=0);
diff --git a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp
index d95a391..85a4c44 100644
--- a/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp
+++ b/AudioManagerDaemon/test/AmDatabaseHandlerTest/CAmDatabaseHandlerTest.cpp
@@ -1120,6 +1120,13 @@ TEST_F(CAmDatabaseHandlerTest, changeSourceMainSoundProperty)
ASSERT_EQ(listIterator->value, property.value);
}
}
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB({property.type, 34},sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, 34);
}
TEST_F(CAmDatabaseHandlerTest, changeSinkMuteState)
@@ -1160,6 +1167,75 @@ TEST_F(CAmDatabaseHandlerTest, changeSinkMainSoundProperty)
ASSERT_EQ(listIterator->value, property.value);
}
}
+
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB({property.type, 34},sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, 34);
+}
+
+TEST_F(CAmDatabaseHandlerTest, changeSourceSoundProperty)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_SoundProperty_s property;
+ property.type = SP_GENIVI_MID;
+ property.value = 33;
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceSoundPropertyDB(property,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+
+ std::vector<am_SoundProperty_s>::iterator listIterator = listSources[0].listSoundProperties.begin();
+ for (; listIterator < listSources[0].listSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceSoundPropertyDB({property.type, 34},sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, 34);
+}
+
+TEST_F(CAmDatabaseHandlerTest, changeSinkSoundProperty)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_SoundProperty_s property;
+ property.type = SP_GENIVI_MID;
+ property.value = 33;
+
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkSoundPropertyDB(property,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ std::vector<am_SoundProperty_s>::iterator listIterator = listSinks[0].listSoundProperties.begin();
+ for (; listIterator < listSinks[0].listSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkSoundPropertyDB({property.type, 34},sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, 34);
}
TEST_F(CAmDatabaseHandlerTest, peekDomain)
diff --git a/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp b/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
index 27dbda7..df72f2d 100644
--- a/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
+++ b/AudioManagerDaemon/test/AmMapHandlerTest/CAmMapHandlerTest.cpp
@@ -1106,6 +1106,21 @@ TEST_F(CAmMapHandlerTest,enterSourcesCorrect)
ASSERT_EQ(true, equal);
}
+TEST_F(CAmMapHandlerTest, changeSinkMuteState)
+{
+ std::vector<am_Sink_s> listSinks;
+ am_Sink_s sink;
+ am_sinkID_t sinkID;
+ pCF.createSink(sink);
+ am_MuteState_e muteState = MS_MUTED;
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
+ ASSERT_EQ(muteState, listSinks[0].muteState);
+}
+
TEST_F(CAmMapHandlerTest, changeSourceMainSoundProperty)
{
std::vector<am_Source_s> listSources;
@@ -1120,54 +1135,116 @@ TEST_F(CAmMapHandlerTest, changeSourceMainSoundProperty)
ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB(property,sourceID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+
std::vector<am_MainSoundProperty_s>::iterator listIterator = listSources[0].listMainSoundProperties.begin();
for (; listIterator < listSources[0].listMainSoundProperties.end(); ++listIterator)
{
if (listIterator->type == property.type)
- {
ASSERT_EQ(listIterator->value, property.value);
- }
}
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSourceSoundPropertyDB({property.type, 34},sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, 34);
+ ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.getMainSourceSoundPropertyValue(sourceID, 1000, value));
}
-TEST_F(CAmMapHandlerTest, changeSinkMuteState)
+TEST_F(CAmMapHandlerTest, changeSinkMainSoundProperty)
{
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
pCF.createSink(sink);
- am_MuteState_e muteState = MS_MUTED;
+ am_MainSoundProperty_s property;
+ property.type = MSP_UNKNOWN;
+ property.value = 33;
+
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkMuteStateDB(muteState,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
- ASSERT_EQ(muteState, listSinks[0].muteState);
+ std::vector<am_MainSoundProperty_s>::iterator listIterator = listSinks[0].listMainSoundProperties.begin();
+ for (; listIterator < listSinks[0].listMainSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB({property.type, 34},sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getMainSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, 34);
+ ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.getMainSinkSoundPropertyValue(sinkID, 1000, value));
}
-TEST_F(CAmMapHandlerTest, changeSinkMainSoundProperty)
+TEST_F(CAmMapHandlerTest, changeSourceSoundProperty)
+{
+ std::vector<am_Source_s> listSources;
+ am_Source_s source;
+ am_sourceID_t sourceID;
+ pCF.createSource(source);
+ am_SoundProperty_s property;
+ property.type = SP_GENIVI_MID;
+ property.value = 33;
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.enterSourceDB(source,sourceID));
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceSoundPropertyDB(property,sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getListSources(listSources));
+
+ std::vector<am_SoundProperty_s>::iterator listIterator = listSources[0].listSoundProperties.begin();
+ for (; listIterator < listSources[0].listSoundProperties.end(); ++listIterator)
+ {
+ if (listIterator->type == property.type)
+ ASSERT_EQ(listIterator->value, property.value);
+ }
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSourceSoundPropertyDB({property.type, 34},sourceID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSourceSoundPropertyValue(sourceID, property.type, value));
+ ASSERT_EQ(value, 34);
+ ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.getSourceSoundPropertyValue(sourceID, 1000, value));
+}
+
+TEST_F(CAmMapHandlerTest, changeSinkSoundProperty)
{
std::vector<am_Sink_s> listSinks;
am_Sink_s sink;
am_sinkID_t sinkID;
pCF.createSink(sink);
- am_MainSoundProperty_s property;
- property.type = MSP_UNKNOWN;
+ am_SoundProperty_s property;
+ property.type = SP_GENIVI_MID;
property.value = 33;
ASSERT_EQ(E_OK, pDatabaseHandler.enterSinkDB(sink,sinkID));
- ASSERT_EQ(E_OK, pDatabaseHandler.changeMainSinkSoundPropertyDB(property,sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkSoundPropertyDB(property,sinkID));
ASSERT_EQ(E_OK, pDatabaseHandler.getListSinks(listSinks));
- std::vector<am_MainSoundProperty_s>::iterator listIterator = listSinks[0].listMainSoundProperties.begin();
- for (; listIterator < listSinks[0].listMainSoundProperties.end(); ++listIterator)
+ std::vector<am_SoundProperty_s>::iterator listIterator = listSinks[0].listSoundProperties.begin();
+ for (; listIterator < listSinks[0].listSoundProperties.end(); ++listIterator)
{
if (listIterator->type == property.type)
- {
ASSERT_EQ(listIterator->value, property.value);
- }
}
+
+ int16_t value;
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, property.value);
+
+ ASSERT_EQ(E_OK, pDatabaseHandler.changeSinkSoundPropertyDB({property.type, 34},sinkID));
+ ASSERT_EQ(E_OK, pDatabaseHandler.getSinkSoundPropertyValue(sinkID, property.type, value));
+ ASSERT_EQ(value, 34);
+ ASSERT_EQ(E_NON_EXISTENT, pDatabaseHandler.getSinkSoundPropertyValue(sinkID, 1000, value));
}
TEST_F(CAmMapHandlerTest, peekDomain)
diff --git a/AudioManagerDaemon/test/CAmCommonFunctions.cpp b/AudioManagerDaemon/test/CAmCommonFunctions.cpp
index e615520..5ab6aef 100644
--- a/AudioManagerDaemon/test/CAmCommonFunctions.cpp
+++ b/AudioManagerDaemon/test/CAmCommonFunctions.cpp
@@ -240,7 +240,7 @@ std::vector<am_MainSoundProperty_s> CAmCommonFunctions::getStandardMainSoundProp
{
std::vector<am_MainSoundProperty_s> mainSoundPropertyList;
am_MainSoundProperty_s mainSoundProperty;
- mainSoundProperty.type = MSP_UNKNOWN;
+ mainSoundProperty.type = MSP_GENIVI_BASS;
mainSoundProperty.value = 23;
mainSoundPropertyList.push_back(mainSoundProperty);
mainSoundProperty.type = MSP_UNKNOWN;
diff --git a/PluginControlInterface/test/MockIAmControlReceive.h b/PluginControlInterface/test/MockIAmControlReceive.h
index 2e9a8df..8e3f51b 100644
--- a/PluginControlInterface/test/MockIAmControlReceive.h
+++ b/PluginControlInterface/test/MockIAmControlReceive.h
@@ -221,8 +221,24 @@ class MockIAmControlReceive : public IAmControlReceive {
am_Error_e(uint32_t& version));
MOCK_METHOD2(sendLifecycleRequestCompleteNSM,
NsmErrorStatus_e(const uint32_t RequestId, const NsmErrorStatus_e status));
+ MOCK_CONST_METHOD2(getListMainSinkSoundProperties,
+ am_Error_e(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties));
+ MOCK_CONST_METHOD2(getListMainSourceSoundProperties,
+ am_Error_e(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties));
+ MOCK_CONST_METHOD2(getListSinkSoundProperties,
+ am_Error_e(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties));
+ MOCK_CONST_METHOD2(getListSourceSoundProperties,
+ am_Error_e(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties));
+ MOCK_CONST_METHOD3(getMainSinkSoundPropertyValue,
+ am_Error_e(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value));
+ MOCK_CONST_METHOD3(getSinkSoundPropertyValue,
+ am_Error_e(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value));
+ MOCK_CONST_METHOD3(getMainSourceSoundPropertyValue,
+ am_Error_e(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value));
+ MOCK_CONST_METHOD3(getSourceSoundPropertyValue,
+ am_Error_e(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value));
};
+} // namespace am
-} // namespace am
#endif
diff --git a/include/control/IAmControlReceive.h b/include/control/IAmControlReceive.h
index 79c0981..9f7bd4e 100755
--- a/include/control/IAmControlReceive.h
+++ b/include/control/IAmControlReceive.h
@@ -20,8 +20,8 @@
* THIS CODE HAS BEEN GENERATED BY ENTERPRISE ARCHITECT GENIVI MODEL.
* PLEASE CHANGE ONLY IN ENTERPRISE ARCHITECT AND GENERATE AGAIN.
*/
-#if !defined(EA_770423FB_365F_4c4b_824E_276D1AE06003__INCLUDED_)
-#define EA_770423FB_365F_4c4b_824E_276D1AE06003__INCLUDED_
+#if !defined(EA_302355E7_3225_415d_AC7F_F0F7468FCCCF__INCLUDED_)
+#define EA_302355E7_3225_415d_AC7F_F0F7468FCCCF__INCLUDED_
#include <vector>
#include <string>
@@ -30,11 +30,11 @@ namespace am {
class CAmSocketHandler;
}
+#include "NodeStateManager.h"
#include "audiomanagertypes.h"
-#include "NodeStateManager.h"
-#define ControlReceiveVersion "3.0"
+#define ControlReceiveVersion "3.1"
namespace am {
/**
@@ -652,7 +652,48 @@ public:
* @return NsmErrorStatus_Ok in case of success
*/
virtual NsmErrorStatus_e sendLifecycleRequestCompleteNSM(const uint32_t RequestId, const NsmErrorStatus_e status) =0;
+ /**
+ * This function retrieves a list of all sink mainsoundproperties with its values
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const =0;
+ /**
+ * This function retrieves a list of all source mainsoundproperties with its
+ * values
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s>& listSoundproperties) const =0;
+ /**
+ * This function retrieves a list of all sink soundproperties with its values
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
+ /**
+ * This function retrieves a list of all sink soundproperties with its values
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const =0;
+ /**
+ * This function retrieves the value of a sink Mainsoundproperty.
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const =0;
+ /**
+ * This function retrieves the value of a sink soundproperty.
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const =0;
+ /**
+ * This function retrieves the value of a source Mainsoundproperty.
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t& value) const =0;
+ /**
+ * This function retrieves the value of a source soundproperty.
+ * @return E_OK when successful, E_DATABASE on error
+ */
+ virtual am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t& value) const =0;
};
}
-#endif // !defined(EA_770423FB_365F_4c4b_824E_276D1AE06003__INCLUDED_)
+#endif // !defined(EA_302355E7_3225_415d_AC7F_F0F7468FCCCF__INCLUDED_)
diff --git a/include/shared/CAmSerializer.h b/include/shared/CAmSerializer.h
index ff131d4..7d6cf80 100644
--- a/include/shared/CAmSerializer.h
+++ b/include/shared/CAmSerializer.h
@@ -745,6 +745,48 @@ private:
};
/**
+ * template for synchronous const calls with three arguments
+ */
+ template<class TClass, typename TretVal, typename TargCall, typename TargCall1, typename TargCall2, typename Targ, typename Targ1, typename Targ2> class CAmSyncThreeArgConstDelegate: public CAmDelegate
+ {
+ private:
+ TClass* mInstance;
+ TretVal (TClass::*mFunction)(TargCall argument, TargCall1 argument1, TargCall2 argument2) const;
+ Targ mArgument;
+ Targ1 mArgument1;
+ Targ2 mArgument2;
+ TretVal mRetval;
+
+ public:
+ CAmSyncThreeArgConstDelegate(TClass* instance, TretVal (TClass::*function)(TargCall argument, TargCall1 argument1, TargCall2 argument2) const, Targ argument, Targ1 argument1, Targ2 argument2) :
+ mInstance(instance), //
+ mFunction(function), //
+ mArgument(argument), //
+ mArgument1(argument1), //
+ mArgument2(argument2), //
+ mRetval()
+ {
+ }
+ ;
+
+ bool call(int* pipe)
+ {
+ mRetval = (*mInstance.*mFunction)(mArgument, mArgument1, mArgument2);
+ write(pipe[1], this, sizeof(this));
+ return (false);
+ }
+ ;
+
+ TretVal returnResults(Targ& argument, Targ1& argument1, Targ2& argument2)
+ {
+ argument = mArgument;
+ argument1 = mArgument1;
+ argument2 = mArgument2;
+ return (mRetval);
+ }
+ };
+
+ /**
* template for synchronous calls with four arguments
*/
template<class TClass, typename TretVal, typename TargCAll, typename TargCall1, typename TargCall2, typename TargCall3, typename Targ, typename Targ1, typename Targ2, typename Targ3> class CAmSyncFourArgDelegate: public CAmDelegate
@@ -1301,6 +1343,26 @@ public:
}
/**
+ * calls a const function with three arguments synchronously threadsafe. for more see syncCall with one argument
+ */
+ template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class Targ, class Targ1, class Targ2>
+ void syncCall(TClass1* instance, TretVal (TClass1::*function)(TargCall, TargCall1, TargCall2) const, TretVal& retVal, Targ& argument, Targ1& argument1, Targ2& argument2)
+ {
+ CAmSyncThreeArgConstDelegate<TClass1, TretVal, TargCall, TargCall1, TargCall2, Targ, Targ1, Targ2>* p(new CAmSyncThreeArgConstDelegate<TClass1, TretVal, TargCall, TargCall1, TargCall2, Targ, Targ1, Targ2>(instance, function, argument, argument1, argument2));
+ send(static_cast<CAmDelegagePtr>(p));
+ int numReads;
+ CAmDelegagePtr ptr;
+ if ((numReads = read(mReturnPipe[0], &ptr, sizeof(ptr))) == -1)
+ {
+ logError("CAmSerializer::receiverCallback could not read pipe!");
+ throw std::runtime_error("CAmSerializer Could not read pipe!");
+ }
+ //working with friend class here is not the finest of all programming stiles but it worCAmTwoArgDelegateks...
+ retVal = p->returnResults(argument, argument1, argument2);
+ delete p;
+ }
+
+ /**
* calls a function with four arguments synchronously threadsafe. for more see syncCall with one argument
*/
template<class TClass1, class TretVal, class TargCall, class TargCall1, class TargCall2, class TargCall3, class Targ, class Targ1, class Targ2, class Targ3>