summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGENIVI Audio Manager Maintainer <genivi-maint-audiomanager@smtp1.genivi.org>2017-05-02 15:23:36 +0200
committerGitHub <noreply@github.com>2017-05-02 15:23:36 +0200
commit8f2387e42641c7c2b967553a4c578f0e87549fb6 (patch)
tree304e30980de90f791a39f009e67c20dfd82c9b0b
parent71eab93f9cd67b2e0343700552adf988c420f174 (diff)
parentcfe230db3654094c4c098eea2736c71dd97396d0 (diff)
downloadaudiomanager-8f2387e42641c7c2b967553a4c578f0e87549fb6.tar.gz
Merge pull request #15 from JensLorenz/boundary_fix
AMCore Enhancements and Fixes
-rw-r--r--AudioManagerCore/include/CAmDatabaseHandlerMap.h9
-rw-r--r--AudioManagerCore/src/CAmDatabaseHandlerMap.cpp55
-rw-r--r--AudioManagerUtilities/src/CAmDbusWrapper.cpp18
-rw-r--r--AudioManagerUtilities/src/CAmDltWrapper.cpp9
-rwxr-xr-xCMakeLists.txt4
5 files changed, 53 insertions, 42 deletions
diff --git a/AudioManagerCore/include/CAmDatabaseHandlerMap.h b/AudioManagerCore/include/CAmDatabaseHandlerMap.h
index 3909b05..3686027 100644
--- a/AudioManagerCore/include/CAmDatabaseHandlerMap.h
+++ b/AudioManagerCore/include/CAmDatabaseHandlerMap.h
@@ -442,13 +442,12 @@ private:
* A common method implementing the logic for static and dynamic IDs except main connection ID.
*
* @param resultID Pointer to an output variable.
- * @param sourceID Pointer to ID, which will be manipulated.
+ * @param elementID Pointer to ID, which will be manipulated.
* @param desiredStaticID Not 0 for static IDs and 0 for dynamic IDs.
- * Usually the static IDs are in interval [1 , DYNAMIC_ID_BOUNDARY]. Default is 0.
- * @param preferedStaticIDBoundary A limit for a given dynamic ID. Default is DYNAMIC_ID_BOUNDARY.
+ * Usually the static IDs are in interval [1 , DYNAMIC_ID_BOUNDARY-1]. Default is 0.
* @return TRUE on successfully changed ID.
*/
- bool increaseID(int16_t & resultID, AmIdentifier & sourceID, int16_t const desiredStaticID);
+ bool increaseID(int16_t & resultID, AmIdentifier & elementID, int16_t const desiredStaticID);
/**
* \brief Increases the main connection ID.
*
@@ -478,7 +477,7 @@ private:
AmMappedData::print(iter->second, output);
}
private:
- template <typename TMapKey,class TMapObject> bool getNextConnectionID(int16_t & resultID, AmIdentifier & sourceID,
+ template <typename TMapKey,class TMapObject> bool getNextConnectionID(int16_t & resultID, AmIdentifier & connID,
const std::unordered_map<TMapKey, TMapObject> & map);
};
diff --git a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
index 83419b9..48ef37b 100644
--- a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
+++ b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp
@@ -55,6 +55,7 @@
(true)
#endif
+
#define NOTIFY_OBSERVERS(CALL)\
for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
if(nextObserver->CALL)\
@@ -384,17 +385,17 @@ void CAmDatabaseHandlerMap::AmCrossfader::getDescription (std::string & outStrin
outString = fmt.str();
}
-bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t & resultID, AmIdentifier & sourceID,
+bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t & resultID, AmIdentifier & elementID,
int16_t const desiredStaticID = 0)
{
- if( desiredStaticID > 0 && desiredStaticID < sourceID.mMin )
+ if( desiredStaticID > 0 && desiredStaticID < elementID.mMin )
{
resultID = desiredStaticID;
return true;
}
- else if( sourceID.mCurrentValue < sourceID.mMax ) //The last used value is 'limit' - 1. e.g. SHRT_MAX - 1, SHRT_MAX is reserved.
+ else if( elementID.mCurrentValue < elementID.mMax ) //The last used value is 'limit' - 1. e.g. SHRT_MAX - 1, SHRT_MAX is reserved.
{
- resultID = sourceID.mCurrentValue++;
+ resultID = elementID.mCurrentValue++;
return true;
}
else
@@ -402,31 +403,31 @@ bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t & resultID, AmIdent
resultID = -1;
return false;
}
- }
+}
-template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::AmMappedData::getNextConnectionID(int16_t & resultID, AmIdentifier & sourceID,
+template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::AmMappedData::getNextConnectionID(int16_t & resultID, AmIdentifier & connID,
const std::unordered_map<TMapKey, TMapObject> & map)
{
TMapKey nextID;
- int16_t const lastID = sourceID.mCurrentValue;
- if( sourceID.mCurrentValue < sourceID.mMax )
- nextID = sourceID.mCurrentValue++;
+ int16_t const lastID = connID.mCurrentValue;
+ if( connID.mCurrentValue < connID.mMax )
+ nextID = connID.mCurrentValue++;
else
- nextID = sourceID.mCurrentValue = sourceID.mMin;
+ nextID = connID.mCurrentValue = connID.mMin;
bool notFreeIDs = false;
while( existsObjectWithKeyInMap(nextID, map) )
{
- if( sourceID.mCurrentValue < sourceID.mMax )
- nextID = sourceID.mCurrentValue++;
+ if( connID.mCurrentValue < connID.mMax )
+ nextID = connID.mCurrentValue++;
else
{
- sourceID.mCurrentValue = sourceID.mMin;
- nextID = sourceID.mCurrentValue++;
+ connID.mCurrentValue = connID.mMin;
+ nextID = connID.mCurrentValue;
}
- if( sourceID.mCurrentValue == lastID )
+ if( connID.mCurrentValue == lastID )
{
notFreeIDs = true;
break;
@@ -639,7 +640,7 @@ bool CAmDatabaseHandlerMap::insertSinkDB(const am_Sink_s & sinkData, am_sinkID_t
am_Error_e CAmDatabaseHandlerMap::enterSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
{
- if(sinkData.sinkID>DYNAMIC_ID_BOUNDARY)
+ if(sinkData.sinkID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"sinkID must be below:",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -734,7 +735,7 @@ bool CAmDatabaseHandlerMap::insertCrossfaderDB(const am_Crossfader_s & crossfade
am_Error_e CAmDatabaseHandlerMap::enterCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
{
- if(crossfaderData.crossfaderID>DYNAMIC_ID_BOUNDARY)
+ if(crossfaderData.crossfaderID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"crossfaderID must be below:",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -822,7 +823,7 @@ bool CAmDatabaseHandlerMap::insertGatewayDB(const am_Gateway_s & gatewayData, am
am_Error_e CAmDatabaseHandlerMap::enterGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
{
- if(gatewayData.gatewayID>DYNAMIC_ID_BOUNDARY)
+ if(gatewayData.gatewayID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"gatewayID must be below:",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -896,7 +897,7 @@ bool CAmDatabaseHandlerMap::insertConverterDB(const am_Converter_s & converteDat
am_Error_e CAmDatabaseHandlerMap::enterConverterDB(const am_Converter_s & converterData, am_converterID_t & converterID)
{
- if(converterData.converterID>DYNAMIC_ID_BOUNDARY)
+ if(converterData.converterID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"converterID must be below:",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -1003,7 +1004,7 @@ bool CAmDatabaseHandlerMap::insertSourceDB(const am_Source_s & sourceData, am_so
am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
{
- if(sourceData.sourceID>DYNAMIC_ID_BOUNDARY)
+ if(sourceData.sourceID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"sourceID must be below:",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -1136,7 +1137,7 @@ bool CAmDatabaseHandlerMap::insertSinkClassDB(const am_SinkClass_s & sinkClass,
am_Error_e CAmDatabaseHandlerMap::enterSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
{
- if(sinkClass.sinkClassID>DYNAMIC_ID_BOUNDARY)
+ if(sinkClass.sinkClassID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"sinkClassID must be <",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -1200,7 +1201,7 @@ bool CAmDatabaseHandlerMap::insertSourceClassDB(am_sourceClass_t & sourceClassID
am_Error_e CAmDatabaseHandlerMap::enterSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
{
- if(sourceClass.sourceClassID>DYNAMIC_ID_BOUNDARY)
+ if(sourceClass.sourceClassID>=DYNAMIC_ID_BOUNDARY)
{
logError(__METHOD_NAME__,"sourceClassID must be <",DYNAMIC_ID_BOUNDARY);
return (E_NOT_POSSIBLE);
@@ -1505,12 +1506,14 @@ am_Error_e CAmDatabaseHandlerMap::removeMainConnectionDB(const am_mainConnection
return (E_NON_EXISTENT);
}
- mMappedData.mMainConnectionMap.erase(mainConnectionID);
+ DB_COND_UPDATE_INIT;
+ DB_COND_UPDATE(mMappedData.mMainConnectionMap[mainConnectionID].mainConnectionID, CS_DISCONNECTED);
+ if (DB_COND_ISMODIFIED)
+ NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainConnectionID, CS_DISCONNECTED)
+ mMappedData.mMainConnectionMap.erase(mainConnectionID);
logVerbose("DatabaseHandler::removeMainConnectionDB removed:", mainConnectionID);
-
- NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainConnectionID, CS_DISCONNECTED)
- NOTIFY_OBSERVERS1(dboRemovedMainConnection, mainConnectionID)
+ NOTIFY_OBSERVERS1(dboRemovedMainConnection, mainConnectionID)
return (E_OK);
}
diff --git a/AudioManagerUtilities/src/CAmDbusWrapper.cpp b/AudioManagerUtilities/src/CAmDbusWrapper.cpp
index b87d3a5..1f1d5a6 100644
--- a/AudioManagerUtilities/src/CAmDbusWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmDbusWrapper.cpp
@@ -293,18 +293,18 @@ dbus_bool_t CAmDbusWrapper::addWatchDelegate(DBusWatch * watch, void* userData)
event |= POLLIN;
if (flags & DBUS_WATCH_WRITABLE)
event |= POLLOUT;
- }
- logInfo("DBusWrapper::addWatchDelegate entered new watch, fd=", dbus_watch_get_unix_fd(watch), "event flag=", event);
- am_Error_e error = mpSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch), event, &pDbusPrepareCallback, &pDbusFireCallback, &pDbusCheckCallback, &pDbusDispatchCallback, watch, handle);
+ logInfo("DBusWrapper::addWatchDelegate entered new watch, fd=", dbus_watch_get_unix_fd(watch), "event flag=", event);
+ am_Error_e error = mpSocketHandler->addFDPoll(dbus_watch_get_unix_fd(watch), event, &pDbusPrepareCallback, &pDbusFireCallback, &pDbusCheckCallback, &pDbusDispatchCallback, watch, handle);
- //if everything is alright, add the watch and the handle to our map so we know this relationship
- if (error == E_OK && handle != 0)
- {
- mMapHandleWatch.insert(std::make_pair(watch, handle));
- return (true);
+ //if everything is alright, add the watch and the handle to our map so we know this relationship
+ if (error == E_OK && handle != 0)
+ {
+ mMapHandleWatch.insert(std::make_pair(watch, handle));
+ return (true);
+ }
+ logError("DBusWrapper::addWatchDelegate entering watch failed");
}
- logError("DBusWrapper::addWatchDelegate entering watch failed");
return (true);
}
diff --git a/AudioManagerUtilities/src/CAmDltWrapper.cpp b/AudioManagerUtilities/src/CAmDltWrapper.cpp
index dc594af..37a5ff0 100644
--- a/AudioManagerUtilities/src/CAmDltWrapper.cpp
+++ b/AudioManagerUtilities/src/CAmDltWrapper.cpp
@@ -157,6 +157,15 @@ CAmDltWrapper* CAmDltWrapper::instanctiateOnce(const char *appid, const char * d
CAmDltWrapper* CAmDltWrapper::instance()
{
+ if (!mpDLTWrapper)
+ {
+ // an application seems not to use our CAmDltWrapper class therefore create default
+ std::ostringstream description;
+ description << "PID=" << getpid() << " _=" << getenv("_");
+ mpDLTWrapper = new CAmDltWrapper("AMDL", description.str().c_str());
+ std::cerr << "Application doesn't call CAmDltWrapper::instanciateOnce!!!" << std::endl;
+ std::cerr << "-> CAmDltWrapper::instance registers DLT application [ AMDL | " << description.str() << " ]" << std::endl;
+ }
return mpDLTWrapper;
}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4655a23..33433ee 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -67,8 +67,8 @@ set(DBUS_SERVICE_PREFIX "org.genivi.audiomanager"
set(DBUS_SERVICE_OBJECT_PATH "/org/genivi/audiomanager"
CACHE PROPERTY "The service object path of the AM - only changable for legacy dbus")
-set(DYNAMIC_ID_BOUNDARY 100
- CACHE INTEGER "The ID boundary between static and dynamic ID ranges")
+set(DYNAMIC_ID_BOUNDARY 101
+ CACHE INTEGER "The ID boundary defines the starting point of the dynamic ID range")
set(LIB_INSTALL_SUFFIX "audiomanager"
CACHE STRINGS "The suffix used for installation of the plugins")