summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/engine/EventBuffer.cpp10
-rw-r--r--src/libs/engine/EventBuffer.hpp1
-rw-r--r--src/libs/engine/JackMidiDriver.cpp16
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)