diff options
author | Jacqueline Molz <Jacqueline.Molz@bmw.de> | 2018-08-22 17:26:53 +0200 |
---|---|---|
committer | Jacqueline Molz <Jacqueline.Molz@bmw.de> | 2018-08-22 17:29:36 +0200 |
commit | 9a379652687bacab9a162d89c83829fff411340b (patch) | |
tree | 8168a89885ed3e7b30ad5ac2a449b3b07bc555c1 /AudioManagerCore/src/CAmDatabaseHandlerMap.cpp | |
parent | 4f261b37238d310cc74ca5b1d9ca244ec3c5b70e (diff) | |
download | audiomanager-9a379652687bacab9a162d89c83829fff411340b.tar.gz |
Notifying observers of sound properties only by value changes.genivi_imp
Fix infinite loop in CAmDltWrapper by logging out enum values exceeding the boundaries.
Minor changes: Pull request 36
changed implementation to database macros (review comments)
added option "WITH_DATABASE_CHANGE_CHECK" to audiomanagerconfig.h.in
whitespace cleanup in test/AmMapHandlerTest/CAmMapHandlerTest.cpp
additional cast to uint in DB_UPDATE call in function removeMainConnectionDB to solve error in macro expansion
Diffstat (limited to 'AudioManagerCore/src/CAmDatabaseHandlerMap.cpp')
-rw-r--r-- | AudioManagerCore/src/CAmDatabaseHandlerMap.cpp | 75 |
1 files changed, 52 insertions, 23 deletions
diff --git a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp index 8e5c192..4bc94ee 100644 --- a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp +++ b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp @@ -33,7 +33,8 @@ #include "CAmRouter.h" #include "CAmDltWrapper.h" -#define __METHOD_NAME__ std::string(std::string("CAmDatabaseHandlerMap::") + __func__) +static std::string __am_className__("CAmDatabaseHandlerMap::"); +#define __METHOD_NAME__ std::string(__am_className__ + __func__) #ifdef WITH_DATABASE_CHANGE_CHECK # define DB_COND_UPDATE_RIE(x, y) \ @@ -1492,26 +1493,37 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSinkSoundPropertyDB(const am_MainSou logError(__METHOD_NAME__, "sinkID must exist"); return (E_NON_EXISTENT); } - + DB_COND_UPDATE_INIT; 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) { - DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value); - if (sink.cacheMainSoundProperties.size()) + DB_COND_UPDATE(elementIterator->value, soundProperty.value); + if (DB_COND_ISMODIFIED) { - sink.cacheMainSoundProperties[soundProperty.type] = soundProperty.value; + if (sink.cacheMainSoundProperties.size()) + { + sink.cacheMainSoundProperties[soundProperty.type] = soundProperty.value; + } } break; } } - logVerbose("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value); - NOTIFY_OBSERVERS2(dboMainSinkSoundPropertyChanged, sinkID, soundProperty) - return (E_OK); + if (DB_COND_ISMODIFIED) + { + logVerbose("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value); + NOTIFY_OBSERVERS2(dboMainSinkSoundPropertyChanged, sinkID, soundProperty) + return (E_OK); + } + else + { + logVerbose("DatabaseHandler::changeMainSinkSoundPropertyDB called MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value); + return (E_NO_CHANGE); + } } am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID) @@ -1523,26 +1535,36 @@ am_Error_e CAmDatabaseHandlerMap::changeMainSourceSoundPropertyDB(const am_MainS return (E_NON_EXISTENT); } + DB_COND_UPDATE_INIT; 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) { - DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value); - if (source.cacheMainSoundProperties.size()) + DB_COND_UPDATE(elementIterator->value, soundProperty.value); + if (DB_COND_ISMODIFIED) { - source.cacheMainSoundProperties[soundProperty.type] = soundProperty.value; + if (source.cacheMainSoundProperties.size()) + { + source.cacheMainSoundProperties[soundProperty.type] = soundProperty.value; + } } - break; } } - logVerbose("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value); - - NOTIFY_OBSERVERS2(dboMainSourceSoundPropertyChanged, sourceID, soundProperty) - return (E_OK); + if (DB_COND_ISMODIFIED) + { + logVerbose("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value); + NOTIFY_OBSERVERS2(dboMainSourceSoundPropertyChanged, sourceID, soundProperty) + return (E_OK); + } + else + { + logVerbose("DatabaseHandler::changeMainSourceSoundPropertyDB called MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value); + return (E_NO_CHANGE); + } } am_Error_e CAmDatabaseHandlerMap::changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID) @@ -1573,20 +1595,27 @@ am_Error_e CAmDatabaseHandlerMap::changeSourceAvailabilityDB(const am_Availabili am_Error_e CAmDatabaseHandlerMap::changeSystemPropertyDB(const am_SystemProperty_s &property) { + DB_COND_UPDATE_INIT; std::vector<am_SystemProperty_s>::iterator elementIterator = mMappedData.mSystemProperties.begin(); for (; elementIterator != mMappedData.mSystemProperties.end(); ++elementIterator) { if (elementIterator->type == property.type) { - DB_COND_UPDATE_RIE(elementIterator->value, property.value); + DB_COND_UPDATE(elementIterator->value, property.value); } } - logVerbose("DatabaseHandler::changeSystemPropertyDB changed system property"); - - NOTIFY_OBSERVERS1(dboSystemPropertyChanged, property) - - return (E_OK); + if (DB_COND_ISMODIFIED) + { + logVerbose("DatabaseHandler::changeSystemPropertyDB changed system property ", property.type, " to ", property.value); + NOTIFY_OBSERVERS1(dboSystemPropertyChanged, property) + return (E_OK); + } + else + { + logVerbose("DatabaseHandler::changeSystemPropertyDB called for system property ", property.type); + return (E_NO_CHANGE); + } } am_Error_e CAmDatabaseHandlerMap::removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID) @@ -1599,7 +1628,7 @@ am_Error_e CAmDatabaseHandlerMap::removeMainConnectionDB(const am_mainConnection } DB_COND_UPDATE_INIT; - DB_COND_UPDATE(mMappedData.mMainConnectionMap[mainConnectionID].mainConnectionID, CS_DISCONNECTED); + DB_COND_UPDATE(mMappedData.mMainConnectionMap[mainConnectionID].mainConnectionID, static_cast<uint16_t>(CS_DISCONNECTED)); if (DB_COND_ISMODIFIED) { NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainConnectionID, CS_DISCONNECTED) |