From 066c3f7f16ef69e80376942e8d6b8c4944b8ed08 Mon Sep 17 00:00:00 2001 From: Martin Koch Date: Fri, 19 Jun 2020 16:01:19 +0200 Subject: Add support for announcement and handling of pre-established audio connections through routing side As the complete initialization of the cockpit system takes some time, a few use-cases exist where information needs to be audible (or visible) right before the system is fully started. Here we mainly have: - system alerts + door open + seat belt missing + engine faults - parking assistant warnings + rear view camera screen + beeps if distance goes below limit Both routing- and control-side are extended to allow notifying about such connections Signed-off-by: Martin Koch --- AudioManagerCore/src/CAmDatabaseHandlerMap.cpp | 74 ++++++++++++++++++++------ 1 file changed, 57 insertions(+), 17 deletions(-) (limited to 'AudioManagerCore/src/CAmDatabaseHandlerMap.cpp') diff --git a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp index 6e6e3f9..95d7b1a 100644 --- a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp +++ b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp @@ -611,6 +611,20 @@ am_Error_e CAmDatabaseHandlerMap::enterMainConnectionDB(const am_MainConnection_ return (E_NOT_POSSIBLE); } + // check if we already have this connection + for (auto &mapped : mMappedData.mMainConnectionMap) + { + if ((mapped.second.sourceID != mainConnectionData.sourceID) || (mapped.second.sinkID != mainConnectionData.sinkID)) + { + continue; + } + + connectionID = mapped.second.mainConnectionID; + logWarning(__METHOD_NAME__, "main connection from source", mainConnectionData.sourceID + , "to sink", mainConnectionData.sinkID, "already exists with ID", connectionID); + return E_ALREADY_EXISTS; + } + int16_t delay = 0; int16_t nextID = 0; if (mMappedData.increaseMainConnectionID(nextID)) @@ -1169,6 +1183,20 @@ am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s &conne return (E_NOT_POSSIBLE); } + // check if we already have this connection + for (auto &mapped : mMappedData.mConnectionMap) + { + if ((mapped.second.sourceID != connection.sourceID) || (mapped.second.sinkID != connection.sinkID)) + { + continue; + } + + connectionID = mapped.second.connectionID; + logWarning(__METHOD_NAME__, "connection from source", connection.sourceID + , "to sink", connection.sinkID, "already exists with ID", connectionID); + return E_ALREADY_EXISTS; + } + // connection format is not checked, because it's project specific int16_t nextID = 0; if (mMappedData.increaseConnectionID(nextID)) @@ -1917,54 +1945,66 @@ am_Error_e CAmDatabaseHandlerMap::getSourceClassInfoDB(const am_sourceID_t sourc am_Error_e CAmDatabaseHandlerMap::getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const { - - if (!existSink(sinkID)) + auto iter = mMappedData.mSinkMap.find(sinkID); + if (iter == mMappedData.mSinkMap.end()) { logWarning(__METHOD_NAME__, "sinkID", sinkID, "does not exist"); return (E_NON_EXISTENT); } - am_Sink_Database_s mappedSink = mMappedData.mSinkMap.at(sinkID); - if ( true == mappedSink.reserved ) + sinkData = iter->second; // copy to output parameter even if only ID and name are valid + if ( iter->second.reserved ) { - return (E_NON_EXISTENT); + logWarning(__METHOD_NAME__, "sinkID", sinkID, "reserved for", sinkData.name, "but details are E_UNKNOWN"); + return E_UNKNOWN; } - sinkData = mappedSink; - return (E_OK); } am_Error_e CAmDatabaseHandlerMap::getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const { - - if (!existSource(sourceID)) + auto iter = mMappedData.mSourceMap.find(sourceID); + if (iter == mMappedData.mSourceMap.end()) { logWarning(__METHOD_NAME__, "sourceID", sourceID, "does not exist"); return (E_NON_EXISTENT); } - am_Source_Database_s mappedSource = mMappedData.mSourceMap.at(sourceID); - if ( true == mappedSource.reserved ) + sourceData = iter->second; // copy to output parameter even if only ID and name are valid + if ( true == iter->second.reserved ) { + logWarning(__METHOD_NAME__, "sourceID", sourceID, "reserved for", sourceData.name, "but details are E_UNKNOWN"); + return E_UNKNOWN; + } + + return (E_OK); +} + +am_Error_e am::CAmDatabaseHandlerMap::getConnectionInfoDB(const am_connectionID_t connectionID, am_Connection_s &connectionData) const +{ + auto iter = mMappedData.mConnectionMap.find(connectionID); + if (iter == mMappedData.mConnectionMap.end()) + { + logError(__METHOD_NAME__, "connectionID", connectionID, "does not exist"); return (E_NON_EXISTENT); } - sourceData = mappedSource; + connectionData = iter->second; - return (E_OK); + return E_OK; } am_Error_e am::CAmDatabaseHandlerMap::getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const { - if (!existMainConnection(mainConnectionID)) + auto iter = mMappedData.mMainConnectionMap.find(mainConnectionID); + if (iter == mMappedData.mMainConnectionMap.end()) { - logError(__METHOD_NAME__, "mainConnectionID must exist"); + logError(__METHOD_NAME__, "mainConnectionID", mainConnectionID, "does not exist"); return (E_NON_EXISTENT); } - am_MainConnection_s temp = mMappedData.mMainConnectionMap.at(mainConnectionID); - mainConnectionData = temp; + mainConnectionData = iter->second; return (E_OK); } -- cgit v1.2.1 From efe087370361f5600e82243edfe4dcc64e0144b6 Mon Sep 17 00:00:00 2001 From: Martin Koch Date: Wed, 1 Jul 2020 14:46:52 +0200 Subject: AMCore: correct behavior regarding registration of early connections - modify enterConnectionDB() and enterMainConnectionDB() to accept also connections using reserved (peeked-only) sources and/or sinks Signed-off-by: Martin Koch --- AudioManagerCore/src/CAmDatabaseHandlerMap.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'AudioManagerCore/src/CAmDatabaseHandlerMap.cpp') diff --git a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp index 95d7b1a..fc539bb 100644 --- a/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp +++ b/AudioManagerCore/src/CAmDatabaseHandlerMap.cpp @@ -585,7 +585,7 @@ int16_t CAmDatabaseHandlerMap::calculateDelayForRoute(const std::vectorsecond.reserved && !allowReserved)) { logError(__METHOD_NAME__, "sinkID must be valid!"); return (E_NOT_POSSIBLE); } - if (!existSource(mainConnectionData.sourceID)) + auto itMappedSource = mMappedData.mSourceMap.find(mainConnectionData.sourceID); + if ((itMappedSource == mMappedData.mSourceMap.end()) || (itMappedSource->second.reserved && !allowReserved)) { logError(__METHOD_NAME__, "sourceID must be valid!"); return (E_NOT_POSSIBLE); @@ -1163,7 +1165,7 @@ am_Error_e CAmDatabaseHandlerMap::enterSourceDB(const am_Source_s &sourceData, a return (E_OK); } -am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s &connection, am_connectionID_t &connectionID) +am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s &connection, am_connectionID_t &connectionID, bool allowReserved) { if (connection.connectionID != 0) { @@ -1171,13 +1173,15 @@ am_Error_e CAmDatabaseHandlerMap::enterConnectionDB(const am_Connection_s &conne return (E_NOT_POSSIBLE); } - if (!existSink(connection.sinkID)) + const AmMapSink::const_iterator &itMappedSink = mMappedData.mSinkMap.find(connection.sinkID); + if ((itMappedSink == mMappedData.mSinkMap.end()) || (itMappedSink->second.reserved && !allowReserved)) { logError(__METHOD_NAME__, "sinkID must exist!"); return (E_NOT_POSSIBLE); } - if (!existSource(connection.sourceID)) + const AmMapSource::const_iterator &itMappedSource = mMappedData.mSourceMap.find(connection.sourceID); + if ((itMappedSource == mMappedData.mSourceMap.end()) || (itMappedSource->second.reserved && !allowReserved)) { logError(__METHOD_NAME__, "sourceID must exist!"); return (E_NOT_POSSIBLE); -- cgit v1.2.1