From dfc9f577630309a56a786c78da0bde705a0b2135 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 20 May 2008 16:37:41 +0000 Subject: Fix Jack MIDI output. git-svn-id: http://svn.drobilla.net/lad/ingen@1224 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/engine/EventBuffer.cpp | 10 ++++++++++ src/libs/engine/EventBuffer.hpp | 1 + src/libs/engine/JackMidiDriver.cpp | 16 ++++++---------- 3 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src/libs/engine') diff --git a/src/libs/engine/EventBuffer.cpp b/src/libs/engine/EventBuffer.cpp index de15c601..9985e2b7 100644 --- a/src/libs/engine/EventBuffer.cpp +++ b/src/libs/engine/EventBuffer.cpp @@ -146,6 +146,16 @@ EventBuffer::increment() const } +/** + * \return true iff the cursor is valid (ie get_event is safe) + */ +bool +EventBuffer::is_valid() const +{ + return lv2_event_is_valid(&_iter); +} + + /** Append an event to the buffer. * * \a timestamp must be >= the latest event in the buffer, diff --git a/src/libs/engine/EventBuffer.hpp b/src/libs/engine/EventBuffer.hpp index 97ec484c..abb51012 100644 --- a/src/libs/engine/EventBuffer.hpp +++ b/src/libs/engine/EventBuffer.hpp @@ -65,6 +65,7 @@ public: } bool increment() const; + bool is_valid() const; uint32_t latest_frames() const { return _latest_frames; } uint32_t latest_subframes() const { return _latest_subframes; } diff --git a/src/libs/engine/JackMidiDriver.cpp b/src/libs/engine/JackMidiDriver.cpp index d6808fcc..22db1d4b 100644 --- a/src/libs/engine/JackMidiDriver.cpp +++ b/src/libs/engine/JackMidiDriver.cpp @@ -107,18 +107,15 @@ JackMidiPort::post_process(ProcessContext& context) { if (is_input()) return; - - assert(_patch_port->poly() == 1); EventBuffer* patch_buf = dynamic_cast(_patch_port->buffer(0)); + void* jack_buf = jack_port_get_buffer(_jack_port, context.nframes()); + + assert(_patch_port->poly() == 1); assert(patch_buf); - void* jack_buffer = jack_port_get_buffer(_jack_port, context.nframes()); - const jack_nframes_t event_count = patch_buf->event_count(); - patch_buf->prepare_read(context.nframes()); - - jack_midi_clear_buffer(jack_buffer); + jack_midi_clear_buffer(jack_buf); uint32_t frames = 0; uint32_t subframes = 0; @@ -127,10 +124,9 @@ JackMidiPort::post_process(ProcessContext& context) uint8_t* data = NULL; // Copy events from Jack port buffer into patch port buffer - for (jack_nframes_t i=0; i < event_count; ++i) { + for (patch_buf->rewind(); patch_buf->is_valid(); patch_buf->increment()) { patch_buf->get_event(&frames, &subframes, &type, &size, &data); - // FIXME: type - jack_midi_event_write(jack_buffer, frames, data, size); + jack_midi_event_write(jack_buf, frames, data, size); } //if (event_count) -- cgit v1.2.1