diff options
-rw-r--r-- | drumgizmo/audioinputenginedl.cc | 75 | ||||
-rw-r--r-- | drumgizmo/audioinputenginedl.h | 4 | ||||
-rw-r--r-- | drumgizmo/audiooutputenginedl.cc | 5 | ||||
-rw-r--r-- | drumgizmo/audiooutputenginedl.h | 4 | ||||
-rw-r--r-- | drumgizmo/drumgizmoc.cc | 4 | ||||
-rw-r--r-- | drumgizmo/jackclient.cc | 31 | ||||
-rw-r--r-- | drumgizmo/jackclient.h | 7 | ||||
-rw-r--r-- | drumgizmo/output/jackaudio/jackaudio.cc | 1 |
8 files changed, 54 insertions, 77 deletions
diff --git a/drumgizmo/audioinputenginedl.cc b/drumgizmo/audioinputenginedl.cc index 93c7079..7feac55 100644 --- a/drumgizmo/audioinputenginedl.cc +++ b/drumgizmo/audioinputenginedl.cc @@ -174,76 +174,7 @@ void AudioInputEngineDL::post() return i_post(ptr); } -//#include "audioinputenginedummy.h" -//#include "audioinputenginejackmidi.h" -//#include "audioinputenginemidifile.h" - -/* - -typedef Device* (*create_func_t)(void); -typedef void (*destroy_func_t)(Device*); - -struct device_t { - Device* dev; - destroy_func_t destroyer; - void* lib; -}; - -int load_shared_device(device_t &dev, std::string devlib, - std::string devfile, ConfMap devconfmap) { - // load library - dev.lib = dlopen(devlib.c_str(), RTLD_LAZY); - if(!dev.lib ) { - printf("Cannot load device: %s\n", dlerror()); - return -1; - } - - create_func_t create_device = (create_func_t) dlsym(dev.lib, "create"); - const char* dlsym_error = dlerror(); - if(dlsym_error) { - printf("Cannot load symbol create: %s\n", dlsym_error); - return -1; - } - - dev.destroyer = (destroy_func_t) dlsym(dev.lib, "destroy"); - dlsym_error = dlerror(); - if(dlsym_error) { - printf("Cannot load symbol destroy: %s\n", dlsym_error); - return -1; - } - - dev.dev = create_device(); - - // initialize device - DevData devdata = dev.dev->init(devfile, devconfmap); - if(devdata.retval != DevData::VALUE_SUCCESS) { - printf("Error while initializing device: %s\n", devdata.msg.c_str()); - return -1; - } - - return 0; -} - -void unload_shared_device(device_t &dev) { - - dev.destroyer(dev.dev); - dlclose(dev.lib); +void AudioInputEngineDL::setEngine(DrumGizmo* drumgizmo) +{ + jackclient->setEngine(drumgizmo); } -*/ - -#ifdef TEST_AUDIOINPUTENGINEDL -//Additional dependency files -//deps: -//Required cflags (autoconf vars may be used) -//cflags: -//Required link options (autoconf vars may be used) -//libs: -#include "test.h" - -TEST_BEGIN; - -// TODO: Put some testcode here (see test.h for usable macros). - -TEST_END; - -#endif/*TEST_AUDIOINPUTENGINEDL*/ diff --git a/drumgizmo/audioinputenginedl.h b/drumgizmo/audioinputenginedl.h index ed1fb27..7178f75 100644 --- a/drumgizmo/audioinputenginedl.h +++ b/drumgizmo/audioinputenginedl.h @@ -40,6 +40,8 @@ typedef void (*input_pre_func_t)(void*); typedef event_t* (*input_run_func_t)(void*,size_t,size_t,size_t*); typedef void (*input_post_func_t)(void*); +class DrumGizmo; + class AudioInputEngineDL : public AudioInputEngine { public: AudioInputEngineDL(std::string name); @@ -56,6 +58,8 @@ public: event_t *run(size_t pos, size_t len, size_t *nevents); void post(); + void setEngine(DrumGizmo* drumgizmo); + private: void *ptr; input_create_func_t i_create; diff --git a/drumgizmo/audiooutputenginedl.cc b/drumgizmo/audiooutputenginedl.cc index dad2c5c..fc887df 100644 --- a/drumgizmo/audiooutputenginedl.cc +++ b/drumgizmo/audiooutputenginedl.cc @@ -193,3 +193,8 @@ size_t AudioOutputEngineDL::samplerate() if(o_samplerate) return o_samplerate(ptr); return 44100; } + +void AudioOutputEngineDL::setEngine(DrumGizmo* drumgizmo) +{ + jackclient->setEngine(drumgizmo); +} diff --git a/drumgizmo/audiooutputenginedl.h b/drumgizmo/audiooutputenginedl.h index 75460f3..62d94f8 100644 --- a/drumgizmo/audiooutputenginedl.h +++ b/drumgizmo/audiooutputenginedl.h @@ -48,6 +48,8 @@ typedef void (*output_post_func_t)(void*, size_t); typedef size_t (*output_bufsize_func_t)(void*); typedef size_t (*output_samplerate_func_t)(void*); +class DrumGizmo; + class AudioOutputEngineDL : public AudioOutputEngine { public: AudioOutputEngineDL(std::string name); @@ -67,6 +69,8 @@ public: size_t getBufferSize(); size_t samplerate(); + void setEngine(DrumGizmo* drumgizmo); + private: void *ptr; output_create_func_t o_create; diff --git a/drumgizmo/drumgizmoc.cc b/drumgizmo/drumgizmoc.cc index 6111c72..708528c 100644 --- a/drumgizmo/drumgizmoc.cc +++ b/drumgizmo/drumgizmoc.cc @@ -229,7 +229,7 @@ int CliMain::run(int argc, char *argv[]) return 1; } - AudioInputEngine *ie = new AudioInputEngineDL(inputengine); + AudioInputEngineDL *ie = new AudioInputEngineDL(inputengine); if(ie == NULL) { printf("Invalid input engine: %s\n", inputengine.c_str()); @@ -323,6 +323,8 @@ int CliMain::run(int argc, char *argv[]) printf("Using kitfile: %s\n", kitfile.c_str()); DrumGizmo gizmo(oe, ie); + oe->setEngine(&gizmo); + ie->setEngine(&gizmo); gizmo.setFrameSize(oe->getBufferSize()); diff --git a/drumgizmo/jackclient.cc b/drumgizmo/jackclient.cc index e4af141..a24d53a 100644 --- a/drumgizmo/jackclient.cc +++ b/drumgizmo/jackclient.cc @@ -26,20 +26,33 @@ */ #include "jackclient.h" +#include <drumgizmo.h> + extern "C" { - int _wrap_jack_process(jack_nframes_t nframes, void *arg){ - return ((JackClient*)arg)->process(nframes);} + +static int jack_process_callback(jack_nframes_t nframes, void *arg) +{ + return ((JackClient*)arg)->process(nframes); +} + +static void jack_free_wheel_callback(int starting, void *arg) +{ + ((JackClient*)arg)->setFreeWheel(starting); +} + } // extern "C" JackClient::JackClient() : refcnt(0) + , drumgizmo(NULL) { jack_status_t status; jack_client = jack_client_open("DrumGizmo", JackNullOption, &status); - jack_set_process_callback(jack_client, _wrap_jack_process, this); + jack_set_process_callback(jack_client, jack_process_callback, this); + jack_set_freewheel_callback(jack_client, jack_free_wheel_callback, this); active = false; } @@ -79,6 +92,18 @@ int JackClient::process(jack_nframes_t nframes) return 0; } +void JackClient::setFreeWheel(bool freewheel) +{ + if(drumgizmo) { + drumgizmo->setFreeWheel(freewheel); + } +} + +void JackClient::setEngine(DrumGizmo* drumgizmo) +{ + this->drumgizmo = drumgizmo; +} + JackClient *jackclient = NULL; JackClient *init_jack_client() diff --git a/drumgizmo/jackclient.h b/drumgizmo/jackclient.h index f093220..8c5954d 100644 --- a/drumgizmo/jackclient.h +++ b/drumgizmo/jackclient.h @@ -36,6 +36,8 @@ public: virtual void jack_process(jack_nframes_t nframes) = 0; }; +class DrumGizmo; + class JackClient { public: JackClient(); @@ -51,12 +53,17 @@ public: void activate(); int process(jack_nframes_t nframes); + void setFreeWheel(bool freewheel); + jack_client_t *jack_client; + void setEngine(DrumGizmo* drumgizmo); + // Sort of private... int refcnt; private: + DrumGizmo* drumgizmo; std::set<JackProcess *> jack_processes; bool active; }; diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc index 5c04146..7e795ef 100644 --- a/drumgizmo/output/jackaudio/jackaudio.cc +++ b/drumgizmo/output/jackaudio/jackaudio.cc @@ -130,7 +130,6 @@ void JackAudio::post(size_t size) void JackAudio::jack_process(jack_nframes_t nframes) { - //printf("o"); fflush(stdout); for(size_t c = 0; c < nchannels; c++) { jack_default_audio_sample_t *out = (jack_default_audio_sample_t *) jack_port_get_buffer(output_port[c], |