summaryrefslogtreecommitdiff
path: root/AudioManagerUtilities
diff options
context:
space:
mode:
authorJens Lorenz <jlorenz@de.adit-jv.com>2017-06-06 10:47:05 +0200
committerJens Lorenz <jlorenz@de.adit-jv.com>2017-09-29 11:42:01 +0200
commit31922cca3a063b2f413967312ae1f927d624a1ed (patch)
tree1fd16a2e86ac87a70db85c1d7043483902e3f9ce /AudioManagerUtilities
parent4bfe4632624bc3ee13fa85f0ffdc23d7618e65e3 (diff)
downloadaudiomanager-31922cca3a063b2f413967312ae1f927d624a1ed.tar.gz
AMUtil: Fix for destroy controller on rundown
On rundown the controller will be unloaded. In case the controller wasn't loaded successfully or the controller doesn't implement the destroy function the rundown of AudioManager crashed. Signed-off-by: Jens Lorenz <jlorenz@de.adit-jv.com>
Diffstat (limited to 'AudioManagerUtilities')
-rw-r--r--AudioManagerUtilities/include/TAmPluginTemplate.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/AudioManagerUtilities/include/TAmPluginTemplate.h b/AudioManagerUtilities/include/TAmPluginTemplate.h
index 8034497..95523f1 100644
--- a/AudioManagerUtilities/include/TAmPluginTemplate.h
+++ b/AudioManagerUtilities/include/TAmPluginTemplate.h
@@ -94,19 +94,25 @@ template<class T> T* getCreateFunction(const std::string& libname, void*& librar
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);
+
+ // get entry point from shared lib
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)
{