13
0

Fix MIDI port offsets.

AudioPort::get_audio_buffer() can offset the buffer simply by offsetting
a pointer. This allows to get an offset buffer for a given port.

For MIDI there's no such concept. A method writing to a MIDI buffer
which is backed by a Port can at best offset it by the global port-buffer
offset (static Port::port_offset), but not by the individual target port's
offset.
This commit is contained in:
Robin Gareus 2017-09-30 05:25:27 +02:00
parent 72fb8a5342
commit 5ada17eba0

View File

@ -272,12 +272,13 @@ MidiPort::flush_buffers (pframes_t nframes)
}
#endif
assert (ev.time() < (nframes + _global_port_buffer_offset + _port_buffer_offset));
assert (ev.time() < (nframes + _global_port_buffer_offset));
if (ev.time() >= _global_port_buffer_offset + _port_buffer_offset) {
if (port_engine.midi_event_put (port_buffer, (pframes_t) ev.time(), ev.buffer(), ev.size()) != 0) {
cerr << "write failed, drop flushed note off on the floor, time "
<< ev.time() << " > " << _global_port_buffer_offset + _port_buffer_offset << endl;
if (ev.time() >= _global_port_buffer_offset) {
if (port_engine.midi_event_put (port_buffer, (pframes_t) ev.time() + _port_buffer_offset, ev.buffer(), ev.size()) != 0) {
cerr << "write failed, dropped event, time "
<< ev.time() << " + " << _port_buffer_offset
<< " > " << _global_port_buffer_offset << endl;
}
} else {
cerr << "drop flushed event on the floor, time " << ev.time()