summaryrefslogtreecommitdiff
path: root/drumgizmo
diff options
context:
space:
mode:
Diffstat (limited to 'drumgizmo')
-rw-r--r--drumgizmo/audioinputenginedl.cc4
-rw-r--r--drumgizmo/audioinputenginedl.h24
-rw-r--r--drumgizmo/audiooutputenginedl.cc4
-rw-r--r--drumgizmo/audiooutputenginedl.h28
-rw-r--r--drumgizmo/drumgizmoc.cc22
-rw-r--r--drumgizmo/input/jackmidi/Makefile.am3
-rw-r--r--drumgizmo/input/jackmidi/jackmidi.cc4
-rw-r--r--drumgizmo/input/midifile/Makefile.am5
-rw-r--r--drumgizmo/output/alsa/alsa.cc12
-rw-r--r--drumgizmo/output/jackaudio/jackaudio.cc8
-rw-r--r--drumgizmo/output/wavfile/wavfile.cc6
11 files changed, 69 insertions, 51 deletions
diff --git a/drumgizmo/audioinputenginedl.cc b/drumgizmo/audioinputenginedl.cc
index 7feac55..e13bdd1 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 7178f75..1cf2c1d 100644
--- a/drumgizmo/audioinputenginedl.h
+++ b/drumgizmo/audioinputenginedl.h
@@ -61,19 +61,21 @@ public:
void setEngine(DrumGizmo* drumgizmo);
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 fc887df..2e573cd 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 62d94f8..39525fa 100644
--- a/drumgizmo/audiooutputenginedl.h
+++ b/drumgizmo/audiooutputenginedl.h
@@ -72,21 +72,23 @@ public:
void setEngine(DrumGizmo* drumgizmo);
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__*/
diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc
index 708528c..8983aa3 100644
--- a/drumgizmo/drumgizmoc.cc
+++ b/drumgizmo/drumgizmoc.cc
@@ -34,10 +34,6 @@
#include <hugin.hpp>
-#ifndef HUG_FLAG_OUTPUT_TO_STDOUT
-#define HUG_FLAG_OUTPUT_TO_STDOUT 0
-#endif
-
#include "drumgizmo.h"
#include "drumgizmoc.h"
@@ -122,9 +118,10 @@ int CliMain::run(int argc, char *argv[])
{
int c;
+ std::string hugin_filter;
+ unsigned int hugin_flags = 0;
#ifndef DISABLE_HUGIN
- const char *hugin_filter = "+all";
- unsigned int hugin_flags = HUG_FLAG_OUTPUT_TO_STDOUT;
+ hugin_flags = HUG_FLAG_DEFAULT;
#endif/*DISABLE_HUGIN*/
std::string outputengine;
@@ -150,7 +147,7 @@ int CliMain::run(int argc, char *argv[])
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
-
+
c = getopt_long(argc, argv, "hvpo:O:i:I:e:a"
#ifndef DISABLE_HUGIN
"D:"
@@ -217,13 +214,15 @@ int CliMain::run(int argc, char *argv[])
}
hug_status_t status = hug_init(hugin_flags,
- HUG_OPTION_FILTER, hugin_filter,
+ HUG_OPTION_FILTER, hugin_filter.c_str(),
HUG_OPTION_END);
if(status != HUG_STATUS_OK) {
printf("Error: %d\n", status);
return 1;
}
+ DEBUG(drumgizmo, "Debug enabled.");
+
if(inputengine == "") {
printf("Missing input engine\n");
return 1;
@@ -265,6 +264,7 @@ int CliMain::run(int argc, char *argv[])
if(outputengine == "") {
printf("Missing output engine\n");
+ delete ie;
return 1;
}
@@ -309,6 +309,8 @@ int CliMain::run(int argc, char *argv[])
if(kitfile != "") {
printf("Can only handle a single kitfile.\n");
printf(usage_str, argv[0]);
+ delete ie;
+ delete oe;
return 1;
}
kitfile = argv[optind++];
@@ -317,6 +319,8 @@ int CliMain::run(int argc, char *argv[])
} else {
printf("Missing kitfile.\n");
printf(usage_str, argv[0]);
+ delete ie;
+ delete oe;
return 1;
}
@@ -352,6 +356,8 @@ int CliMain::run(int argc, char *argv[])
if(!gizmo.init()) {
printf("Failed init engine.\n");
+ delete ie;
+ delete oe;
return 1;
}
diff --git a/drumgizmo/input/jackmidi/Makefile.am b/drumgizmo/input/jackmidi/Makefile.am
index fd63944..d392f19 100644
--- a/drumgizmo/input/jackmidi/Makefile.am
+++ b/drumgizmo/input/jackmidi/Makefile.am
@@ -26,7 +26,8 @@ libdir = $(INPUT_PLUGIN_DIR)
AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/src -I$(top_srcdir)/hugin
jackmidi_la_LDFLAGS = -module -avoid-version -shared
-jackmidi_la_LIBADD =
+jackmidi_la_LIBADD = $(EXPAT_LIBS)
+jackmidi_la_CXXFLAGS = $(EXPAT_CFLAGS)
jackmidi_la_SOURCES = $(jackmidibuildsources)
install-exec-hook:
diff --git a/drumgizmo/input/jackmidi/jackmidi.cc b/drumgizmo/input/jackmidi/jackmidi.cc
index 5496195..a6b49b7 100644
--- a/drumgizmo/input/jackmidi/jackmidi.cc
+++ b/drumgizmo/input/jackmidi/jackmidi.cc
@@ -60,8 +60,8 @@ public:
private:
void loadMap(std::string map) {}
- JackClient *jackclient;
- jack_port_t *midi_port;
+ JackClient *jackclient{nullptr};
+ jack_port_t *midi_port{nullptr};
size_t pos;
diff --git a/drumgizmo/input/midifile/Makefile.am b/drumgizmo/input/midifile/Makefile.am
index f95a289..9ade475 100644
--- a/drumgizmo/input/midifile/Makefile.am
+++ b/drumgizmo/input/midifile/Makefile.am
@@ -27,8 +27,9 @@ libdir = $(INPUT_PLUGIN_DIR)
AM_CPPFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/include $(SMF_CFLAGS) \
$(EXPAT_CFLAGS) -I$(top_srcdir)/hugin -DWITH_HUG_MUTEX
-midifile_la_LDFLAGS = $(SMF_LIBS) $(EXPAT_LIBS) -module -avoid-version -shared
-midifile_la_LIBADD =
+midifile_la_LDFLAGS = -module -avoid-version -shared
+midifile_la_LIBADD = $(EXPAT_LIBS) $(SMF_LIBS)
+midifile_la_CXXFLAGS =$(EXPAT_CFLAGS)
midifile_la_SOURCES = $(midifilebuildsources)
install-exec-hook:
diff --git a/drumgizmo/output/alsa/alsa.cc b/drumgizmo/output/alsa/alsa.cc
index 0de3cdb..f9a2068 100644
--- a/drumgizmo/output/alsa/alsa.cc
+++ b/drumgizmo/output/alsa/alsa.cc
@@ -53,15 +53,15 @@ public:
size_t samplerate();
private:
- snd_pcm_t *handle;
- snd_pcm_hw_params_t *params;
- sample_t *data;
- size_t channels;
+ snd_pcm_t *handle{nullptr};
+ snd_pcm_hw_params_t *params{nullptr};
+ sample_t *data{nullptr};
+ size_t channels{0};
// Parameters
std::string device;
- unsigned int srate;
- snd_pcm_uframes_t frames;
+ unsigned int srate{0};
+ snd_pcm_uframes_t frames{0};
};
Alsa::Alsa()
diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc
index 7e795ef..e027742 100644
--- a/drumgizmo/output/jackaudio/jackaudio.cc
+++ b/drumgizmo/output/jackaudio/jackaudio.cc
@@ -57,10 +57,10 @@ public:
size_t samplerate();
private:
- JackClient *jackclient;
- jack_port_t *output_port[64];
- size_t nchannels;
- sample_t **channels;
+ JackClient *jackclient{nullptr};
+ jack_port_t *output_port[64] = {};
+ size_t nchannels{0};
+ sample_t **channels{nullptr};
Semaphore sem;
};
diff --git a/drumgizmo/output/wavfile/wavfile.cc b/drumgizmo/output/wavfile/wavfile.cc
index fa4128e..8401f80 100644
--- a/drumgizmo/output/wavfile/wavfile.cc
+++ b/drumgizmo/output/wavfile/wavfile.cc
@@ -28,6 +28,7 @@
#include <audiotypes.h>
#include <string>
+#include <memory.h>
#include <sndfile.h>
@@ -48,8 +49,8 @@ public:
private:
SF_INFO sf_info;
- SNDFILE **fh;
- size_t channels;
+ SNDFILE **fh{nullptr};
+ size_t channels{0};
// Parameters
std::string filename;
@@ -60,6 +61,7 @@ WavFile::WavFile()
fh = NULL;
filename = "output";
+ memset(&sf_info, 0, sizeof(sf_info));
sf_info.channels = 1;//channels;
sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
sf_info.samplerate = 44100;