diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-12-20 16:54:07 +0100 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2015-12-20 16:54:07 +0100 |
commit | 4c5b1b6713628d91554d934ee72661b83232bbf7 (patch) | |
tree | 21ce6867bb467f47d32af3a64b2c0955082df58a /drumgizmo | |
parent | 89cfec5ae70d3770bc1fb55c658c2551c9a9dd42 (diff) |
Free dlopen resources.
Diffstat (limited to 'drumgizmo')
-rw-r--r-- | drumgizmo/audioinputenginedl.cc | 4 | ||||
-rw-r--r-- | drumgizmo/audioinputenginedl.h | 24 | ||||
-rw-r--r-- | drumgizmo/audiooutputenginedl.cc | 4 | ||||
-rw-r--r-- | drumgizmo/audiooutputenginedl.h | 28 |
4 files changed, 34 insertions, 26 deletions
diff --git a/drumgizmo/audioinputenginedl.cc b/drumgizmo/audioinputenginedl.cc index 93c7079..cba59fa 100644 --- a/drumgizmo/audioinputenginedl.cc +++ b/drumgizmo/audioinputenginedl.cc @@ -41,7 +41,7 @@ AudioInputEngineDL::AudioInputEngineDL(std::string name) is_jack_plugin = strstr(name.c_str(), "jack"); std::string plugin = INPUT_PLUGIN_DIR"/" + name + ".so"; - void *lib = dlopen(plugin.c_str(), RTLD_LAZY); + lib = dlopen(plugin.c_str(), RTLD_LAZY); if(!lib) { printf("Cannot load device: %s\n", dlerror()); return; @@ -124,6 +124,8 @@ AudioInputEngineDL::~AudioInputEngineDL() { i_destroy(ptr); if(is_jack_plugin) close_jack_client(); + dlclose(lib); + lib = nullptr; } bool AudioInputEngineDL::init(Instruments &instruments) diff --git a/drumgizmo/audioinputenginedl.h b/drumgizmo/audioinputenginedl.h index ed1fb27..94bd89d 100644 --- a/drumgizmo/audioinputenginedl.h +++ b/drumgizmo/audioinputenginedl.h @@ -57,19 +57,21 @@ public: void post(); private: - void *ptr; - input_create_func_t i_create; - input_destroy_func_t i_destroy; - input_init_func_t i_init; - input_setparm_func_t i_setparm; - input_start_func_t i_start; - input_stop_func_t i_stop; - input_pre_func_t i_pre; - input_run_func_t i_run; - input_post_func_t i_post; + void *ptr{nullptr}; + input_create_func_t i_create{nullptr}; + input_destroy_func_t i_destroy{nullptr}; + input_init_func_t i_init{nullptr}; + input_setparm_func_t i_setparm{nullptr}; + input_start_func_t i_start{nullptr}; + input_stop_func_t i_stop{nullptr}; + input_pre_func_t i_pre{nullptr}; + input_run_func_t i_run{nullptr}; + input_post_func_t i_post{nullptr}; bool is_jack_plugin; - JackClient *jackclient; + JackClient *jackclient{nullptr}; + + void *lib{nullptr}; }; #endif/*__DRUMGIZMO_AUDIOINPUTENGINEDL_H__*/ diff --git a/drumgizmo/audiooutputenginedl.cc b/drumgizmo/audiooutputenginedl.cc index dad2c5c..042db4a 100644 --- a/drumgizmo/audiooutputenginedl.cc +++ b/drumgizmo/audiooutputenginedl.cc @@ -36,7 +36,7 @@ AudioOutputEngineDL::AudioOutputEngineDL(std::string name) is_jack_plugin = strstr(name.c_str(), "jack"); std::string plugin = OUTPUT_PLUGIN_DIR"/" + name + ".so"; - void *lib = dlopen(plugin.c_str(), RTLD_LAZY); + lib = dlopen(plugin.c_str(), RTLD_LAZY); if(!lib) { printf("Cannot load device: %s\n", dlerror()); return; @@ -132,6 +132,8 @@ AudioOutputEngineDL::~AudioOutputEngineDL() { o_destroy(ptr); if(is_jack_plugin) close_jack_client(); + dlclose(lib); + lib = nullptr; } bool AudioOutputEngineDL::init(Channels channels) diff --git a/drumgizmo/audiooutputenginedl.h b/drumgizmo/audiooutputenginedl.h index 75460f3..4b31015 100644 --- a/drumgizmo/audiooutputenginedl.h +++ b/drumgizmo/audiooutputenginedl.h @@ -68,21 +68,23 @@ public: size_t samplerate(); private: - void *ptr; - output_create_func_t o_create; - output_destroy_func_t o_destroy; - output_init_func_t o_init; - output_setparm_func_t o_setparm; - output_start_func_t o_start; - output_stop_func_t o_stop; - output_pre_func_t o_pre; - output_run_func_t o_run; - output_post_func_t o_post; - output_bufsize_func_t o_bufsize; - output_samplerate_func_t o_samplerate; + void *ptr{nullptr}; + output_create_func_t o_create{nullptr}; + output_destroy_func_t o_destroy{nullptr}; + output_init_func_t o_init{nullptr}; + output_setparm_func_t o_setparm{nullptr}; + output_start_func_t o_start{nullptr}; + output_stop_func_t o_stop{nullptr}; + output_pre_func_t o_pre{nullptr}; + output_run_func_t o_run{nullptr}; + output_post_func_t o_post{nullptr}; + output_bufsize_func_t o_bufsize{nullptr}; + output_samplerate_func_t o_samplerate{nullptr}; bool is_jack_plugin; - JackClient *jackclient; + JackClient *jackclient{nullptr}; + + void* lib{nullptr}; }; #endif/*__DRUMGIZMO_AUDIOOUTPUTENGINEDL_H__*/ |