diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-05-20 10:10:28 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-05-20 10:10:28 +0200 |
commit | 975eefe2a6973e2d648326137a3020f05475d008 (patch) | |
tree | 8cf35377f646a937727ddae833d5e63a3ede14f8 | |
parent | a4eebe051bbf32a8821bbb3358d10c80d2da7034 (diff) |
Make jackaudio output module work.
-rw-r--r-- | drumgizmo/output/jackaudio/Makefile.am | 6 | ||||
-rw-r--r-- | drumgizmo/output/jackaudio/jackaudio.cc | 22 | ||||
-rw-r--r-- | src/drumgizmo.cc | 2 |
3 files changed, 22 insertions, 8 deletions
diff --git a/drumgizmo/output/jackaudio/Makefile.am b/drumgizmo/output/jackaudio/Makefile.am index 749e74f..453cad9 100644 --- a/drumgizmo/output/jackaudio/Makefile.am +++ b/drumgizmo/output/jackaudio/Makefile.am @@ -1,6 +1,8 @@ jackaudiosources = \ - jackaudio.cc + jackaudio.cc \ + $(top_srcdir)/src/semaphore.cc \ + $(top_srcdir)/hugin/hugin.c if HAVE_OUTPUT_JACKAUDIO @@ -20,7 +22,7 @@ lib_LTLIBRARIES = $(jackaudioltlibs) libdir = $(OUTPUT_PLUGIN_DIR) -AM_CPPFLAGS = -I$(top_srcdir)/include $(JACK_CFLAGS) +AM_CPPFLAGS = -I$(top_srcdir)/include $(JACK_CFLAGS) -I$(top_srcdir)/hugin -I$(top_srcdir)/src libjackaudio_la_LDFLAGS = $(JACK_LIBS) libjackaudio_la_LIBADD = libjackaudio_la_SOURCES = $(jackaudiobuildsources) diff --git a/drumgizmo/output/jackaudio/jackaudio.cc b/drumgizmo/output/jackaudio/jackaudio.cc index 9410915..385eb48 100644 --- a/drumgizmo/output/jackaudio/jackaudio.cc +++ b/drumgizmo/output/jackaudio/jackaudio.cc @@ -28,6 +28,8 @@ #include <string> #include <audiotypes.h> +#include <semaphore.h> +#include <stdlib.h> #define NOTE_ON 0x90 @@ -56,6 +58,7 @@ private: jack_port_t *output_port[64]; size_t nchannels; sample_t **channels; + Semaphore sem; }; JackAudio::JackAudio() @@ -82,7 +85,7 @@ bool JackAudio::init(int nchannels, char *cnames[]) name.c_str(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0); - channels[i] = (sample_t*)malloc(2048 * sizeof(sample_t)); + channels[i] = (sample_t*)malloc(1024 * sizeof(sample_t)); } return true; } @@ -97,6 +100,7 @@ void JackAudio::setParm(std::string parm, std::string value) bool JackAudio::start() { + //jackclient->activate(); return true; } @@ -109,28 +113,36 @@ void JackAudio::pre(size_t size) } void JackAudio::run(int channel, sample_t* data, size_t size) -{ +{ // Copy engine data to ringbuffer. - for(int i = 0; i < size; i++) { + for(size_t i = 0; i < size; i++) { channels[channel][i] = data[i]; } } void JackAudio::post(size_t size) { + sem.wait(); } void JackAudio::jack_process(jack_nframes_t nframes) { + if(nframes != 1024) { + fprintf(stderr, "jackaudio output module currently only works with a" + " bufferszie of 1024 samples!\n"); + exit(1); + } + printf("o"); fflush(stdout); - for(int c = 0; c < nchannels; c++) { + 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], nframes); - for(int i = 0; i < nframes; i++) { + for(size_t i = 0; i < nframes; i++) { out[i] = channels[c][i]; } } + sem.post(); } extern "C" { diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index cb77fd4..b6ac98f 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -389,7 +389,7 @@ void DrumGizmo::run() oe->start(); size_t pos = 0; - size_t nsamples = 2048; + size_t nsamples = 1024; sample_t samples[nsamples]; while(run(pos, samples, nsamples) == true) { |