diff options
author | David Robillard <d@drobilla.net> | 2008-05-20 16:37:41 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-05-20 16:37:41 +0000 |
commit | dfc9f577630309a56a786c78da0bde705a0b2135 (patch) | |
tree | 8d4e73af090dd381440ff0b4f33d37e0cd83a953 | |
parent | 34093b89423e7d195972e68676c73853228d35f6 (diff) | |
download | ingen-dfc9f577630309a56a786c78da0bde705a0b2135.tar.gz ingen-dfc9f577630309a56a786c78da0bde705a0b2135.tar.bz2 ingen-dfc9f577630309a56a786c78da0bde705a0b2135.zip |
Fix Jack MIDI output.
git-svn-id: http://svn.drobilla.net/lad/ingen@1224 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | src/libs/engine/EventBuffer.cpp | 10 | ||||
-rw-r--r-- | src/libs/engine/EventBuffer.hpp | 1 | ||||
-rw-r--r-- | src/libs/engine/JackMidiDriver.cpp | 16 |
3 files changed, 17 insertions, 10 deletions
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<EventBuffer*>(_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) |