From c43d2f869946642e173554923904e6c92881a008 Mon Sep 17 00:00:00 2001 From: Aleksandar Donchev Date: Tue, 18 Nov 2014 16:03:11 +0100 Subject: * Lazy lookup for static registered sources and sinks. Signed-off-by: Christian Linke --- AudioManagerDaemon/include/CAmRoutingReceiver.h | 2 ++ AudioManagerDaemon/src/CAmRoutingReceiver.cpp | 10 +++++++ .../test/MockIAmRoutingReceive.h | 4 +++ .../include/CAmRoutingSenderCAPI.h | 2 ++ .../src/CAmRoutingSenderCAPI.cpp | 32 ++++++++++++++++++++++ .../test/MockIAmRoutingReceive.h | 4 +++ 6 files changed, 54 insertions(+) diff --git a/AudioManagerDaemon/include/CAmRoutingReceiver.h b/AudioManagerDaemon/include/CAmRoutingReceiver.h index bf42f6b..be81529 100644 --- a/AudioManagerDaemon/include/CAmRoutingReceiver.h +++ b/AudioManagerDaemon/include/CAmRoutingReceiver.h @@ -92,6 +92,8 @@ public: void ackSourceNotificationConfiguration(const am_Handle_s handle, const am_Error_e error) ; void hookSinkNotificationDataChange(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload) ; void hookSourceNotificationDataChange(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload) ; + am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID); + am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID); uint16_t getStartupHandle(); //!< returns a startup handle uint16_t getRundownHandle(); //!< returns a rundown handle diff --git a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp index 67bc911..29f7db7 100644 --- a/AudioManagerDaemon/src/CAmRoutingReceiver.cpp +++ b/AudioManagerDaemon/src/CAmRoutingReceiver.cpp @@ -479,6 +479,16 @@ void CAmRoutingReceiver::hookSourceNotificationDataChange(const am_sourceID_t so mpControlSender->hookSourceNotificationDataChanged(sourceID,payload); } +am_Error_e CAmRoutingReceiver::getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t& domainID) +{ + return mpDatabaseHandler->getDomainOfSink(sinkID,domainID); +} + +am_Error_e CAmRoutingReceiver::getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t& domainID) +{ + return mpDatabaseHandler->getDomainOfSource(sourceID,domainID); +} + void am::CAmRoutingReceiver::waitOnRundown(bool rundown) { mWaitRundown = rundown; diff --git a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h index 4d5849c..5bb4f2a 100644 --- a/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h +++ b/PluginRoutingInterfaceAsync/test/MockIAmRoutingReceive.h @@ -124,6 +124,10 @@ public: void(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload)); MOCK_METHOD2(hookSourceNotificationDataChange, void(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload)); + MOCK_METHOD2(getDomainOfSource, + am_Error_e(const am_sourceID_t sourceID, am_domainID_t& domainID)); + MOCK_METHOD2(getDomainOfSink, + am_Error_e(const am_sinkID_t sinkID, am_domainID_t& domainID)); }; } // namespace am diff --git a/PluginRoutingInterfaceCAPI/include/CAmRoutingSenderCAPI.h b/PluginRoutingInterfaceCAPI/include/CAmRoutingSenderCAPI.h index 2c975c7..20e07ac 100644 --- a/PluginRoutingInterfaceCAPI/include/CAmRoutingSenderCAPI.h +++ b/PluginRoutingInterfaceCAPI/include/CAmRoutingSenderCAPI.h @@ -41,6 +41,8 @@ class CAmRoutingSenderCAPI: public IAmRoutingSend IAmRoutingReceive *mpIAmRoutingReceive; ///< pointer to the routing receive interface std::shared_ptr mService; ///< shared pointer to the routing service implementation CAmRoutingSenderCAPI(); + void checkSourceLookup(const am_sourceID_t id); + void checkSinkLookup(const am_sinkID_t id); public: CAmRoutingSenderCAPI(CAmCommonAPIWrapper *aWrapper) ; virtual ~CAmRoutingSenderCAPI(); diff --git a/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp b/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp index 18a80ea..1531613 100644 --- a/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp +++ b/PluginRoutingInterfaceCAPI/src/CAmRoutingSenderCAPI.cpp @@ -137,9 +137,30 @@ void CAmRoutingSenderCAPI::setRoutingRundown(const uint16_t handle) mService->gotRundown(mLookupData.numberOfDomains(),handle); } +void CAmRoutingSenderCAPI::checkSourceLookup(const am_sourceID_t id) +{ + am_domainID_t domainID; + am_Error_e result = mpIAmRoutingReceive->getDomainOfSource(id, domainID); + if(E_OK==result) + mLookupData.addSourceLookup(id, domainID); + else + logError("checkSinkLookup addSourceLookup error:", result); +} + +void CAmRoutingSenderCAPI::checkSinkLookup(const am_sinkID_t id) +{ + am_domainID_t domainID; + am_Error_e result = mpIAmRoutingReceive->getDomainOfSink(id, domainID); + if(E_OK==result) + mLookupData.addSinkLookup(id, domainID); + else + logError("checkSinkLookup addSinkLookup error:", result); +} + am_Error_e CAmRoutingSenderCAPI::asyncAbort(const am_Handle_s handle) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncAbort called"); + return mLookupData.asyncAbort(handle,[](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); }); @@ -148,6 +169,8 @@ am_Error_e CAmRoutingSenderCAPI::asyncAbort(const am_Handle_s handle) am_Error_e CAmRoutingSenderCAPI::asyncConnect(const am_Handle_s handle, const am_connectionID_t connectionID, const am_sourceID_t sourceID, const am_sinkID_t sinkID, const am_CustomConnectionFormat_t connectionFormat) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncConnect called"); + checkSourceLookup(sourceID); + checkSinkLookup(sinkID); return mLookupData.asyncConnect(handle,connectionID, sourceID, sinkID, connectionFormat, [&,handle,connectionID](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -176,6 +199,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncDisconnect(const am_Handle_s handle, const am_Error_e CAmRoutingSenderCAPI::asyncSetSinkVolume(const am_Handle_s handle, const am_sinkID_t sinkID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSinkVolume called"); + checkSinkLookup(sinkID); return mLookupData.asyncSetSinkVolume(handle,sinkID, volume, ramp, time, [&, handle, volume](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -190,6 +214,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSinkVolume(const am_Handle_s handle, co am_Error_e CAmRoutingSenderCAPI::asyncSetSourceVolume(const am_Handle_s handle, const am_sourceID_t sourceID, const am_volume_t volume, const am_CustomRampType_t ramp, const am_time_t time) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSourceVolume called"); + checkSourceLookup(sourceID); return mLookupData.asyncSetSourceVolume(handle,sourceID, volume, ramp, time, [&, handle, volume](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -204,6 +229,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSourceVolume(const am_Handle_s handle, am_Error_e CAmRoutingSenderCAPI::asyncSetSourceState(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SourceState_e state) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSourceState called"); + checkSourceLookup(sourceID); return mLookupData.asyncSetSourceState(handle,sourceID, state,[&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -218,6 +244,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSourceState(const am_Handle_s handle, c am_Error_e CAmRoutingSenderCAPI::asyncSetSinkSoundProperties(const am_Handle_s handle, const am_sinkID_t sinkID, const std::vector& listSoundProperties) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSinkSoundProperties called"); + checkSinkLookup(sinkID); return mLookupData.asyncSetSinkSoundProperties(handle,sinkID, listSoundProperties, [&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -232,6 +259,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSinkSoundProperties(const am_Handle_s h am_Error_e CAmRoutingSenderCAPI::asyncSetSinkSoundProperty(const am_Handle_s handle, const am_sinkID_t sinkID, const am_SoundProperty_s& soundProperty) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSinkSoundProperty called"); + checkSinkLookup(sinkID); return mLookupData.asyncSetSinkSoundProperty(handle, sinkID, soundProperty, [&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -246,6 +274,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSinkSoundProperty(const am_Handle_s han am_Error_e CAmRoutingSenderCAPI::asyncSetSourceSoundProperties(const am_Handle_s handle, const am_sourceID_t sourceID, const std::vector& listSoundProperties) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSourceSoundProperties called"); + checkSourceLookup(sourceID); return mLookupData.asyncSetSourceSoundProperties(handle, sourceID, listSoundProperties, [&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -260,6 +289,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSourceSoundProperties(const am_Handle_s am_Error_e CAmRoutingSenderCAPI::asyncSetSourceSoundProperty(const am_Handle_s handle, const am_sourceID_t sourceID, const am_SoundProperty_s& soundProperty) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSourceSoundProperty called"); + checkSourceLookup(sourceID); return mLookupData.asyncSetSourceSoundProperty(handle, sourceID, soundProperty, [&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -317,6 +347,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetVolumes(const am_Handle_s handle, const am_Error_e CAmRoutingSenderCAPI::asyncSetSinkNotificationConfiguration(const am_Handle_s handle, const am_sinkID_t sinkID, const am_NotificationConfiguration_s& nc) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSinkNotificationConfiguration called"); + checkSinkLookup(sinkID); return mLookupData.asyncSetSinkNotificationConfiguration(handle, sinkID, nc, [&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) @@ -331,6 +362,7 @@ am_Error_e CAmRoutingSenderCAPI::asyncSetSinkNotificationConfiguration(const am_ am_Error_e CAmRoutingSenderCAPI::asyncSetSourceNotificationConfiguration(const am_Handle_s handle, const am_sourceID_t sourceID, const am_NotificationConfiguration_s& nc) { log(&ctxCommandCAPI, DLT_LOG_INFO, "CAmRoutingSenderCAPI::asyncSetSourceNotificationConfiguration called"); + checkSourceLookup(sourceID); return mLookupData.asyncSetSourceNotificationConfiguration(handle, sourceID, nc, [&, handle](const CommonAPI::CallStatus& callStatus){ log(&ctxCommandCAPI, DLT_LOG_INFO, __PRETTY_FUNCTION__, "Response with call status:", static_cast(callStatus)); if (callStatus != CommonAPI::CallStatus::SUCCESS) diff --git a/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h b/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h index 1443219..0638aa4 100644 --- a/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h +++ b/PluginRoutingInterfaceCAPI/test/MockIAmRoutingReceive.h @@ -126,6 +126,10 @@ class MockIAmRoutingReceive : public IAmRoutingReceive { void(const am_sinkID_t sinkID, const am_NotificationPayload_s& payload)); MOCK_METHOD2(hookSourceNotificationDataChange, void(const am_sourceID_t sourceID, const am_NotificationPayload_s& payload)); + MOCK_METHOD2(getDomainOfSource, + am_Error_e(const am_sourceID_t sourceID, am_domainID_t& domainID)); + MOCK_METHOD2(getDomainOfSink, + am_Error_e(const am_sinkID_t sinkID, am_domainID_t& domainID)); }; } // namespace am -- cgit v1.2.1