diff options
author | Kapildev Patel <kpatel@jp.adit-jv.com> | 2017-04-24 18:58:31 +0900 |
---|---|---|
committer | Jens Lorenz <jlorenz@de.adit-jv.com> | 2017-09-29 11:42:01 +0200 |
commit | 3e9f7977dc599b6a91e875c8239480f212a4cd3a (patch) | |
tree | 072aeba3a6245eaa6470d7cd21c58afe93d5d051 /AudioManagerUtilities/include | |
parent | f620be8a774f966fbd76ca8892a39ce28037a213 (diff) | |
download | audiomanager-3e9f7977dc599b6a91e875c8239480f212a4cd3a.tar.gz |
AM: Destroy plugin implementation.
With these changes AudioManager would call destroy function of the
controller plugin at the time of shutdown.
Signed-off-by: Kapildev Patel <kpatel@jp.adit-jv.com>
Diffstat (limited to 'AudioManagerUtilities/include')
-rw-r--r-- | AudioManagerUtilities/include/TAmPluginTemplate.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/AudioManagerUtilities/include/TAmPluginTemplate.h b/AudioManagerUtilities/include/TAmPluginTemplate.h index f000fbe..8034497 100644 --- a/AudioManagerUtilities/include/TAmPluginTemplate.h +++ b/AudioManagerUtilities/include/TAmPluginTemplate.h @@ -86,6 +86,40 @@ template<class T> T* getCreateFunction(const std::string& libname, void*& librar return (createFunction); } +/** + * * This template tries to destroy + * @param libname the full path to the library to be loaded + * + */ +template<class T> T* getDestroyFunction(const std::string& libname,void* libraryHandle) +{ + logInfo("destroy : Trying to destroy : ",libname); + // cut off directories + char* fileWithPath = const_cast<char*>(libname.c_str()); + std::string libFileName = basename(fileWithPath); + // cut off "lib" in front and cut off .so end" + std::string destroyFunctionName = "destroy" + libFileName.substr(3, libFileName.length() - 6); + dlerror(); // Clear any existing error + union + { + void* voidPointer; + T* typedPointer; + } functionPointer; + functionPointer.voidPointer = dlsym(libraryHandle, destroyFunctionName.c_str()); + T* destroyFunction = functionPointer.typedPointer; + const char* dlsym_error = dlerror(); + if (!destroyFunction || dlsym_error) + { + logError("getDestroyFunction: Failed to load shared lib entry point function name=", + destroyFunctionName, "error=",dlsym_error); + } + else + { + logInfo("getDestroyFunction: loaded successfully plugin", destroyFunctionName); + } + return (destroyFunction); +} + } #endif /* PLUGINTEMPLATE_H_ */ |