summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_track.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-05-29 17:35:21 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-05-29 17:35:21 +0000
commit0a9f5423f5b3faede68fe7c384c5fe32db2e23bf (patch)
tree196c407bb65b8ead7303c8d9483bb8cec5709990 /libs/ardour/midi_track.cc
parent36ccf8304963a7fb9e80ade61df482f122cea39d (diff)
detect buffer "overflow" when delivering immediate events and queue remainder for delivery next time (though without actually requeing - just leave ringbuffer ptrs/indexes where they are. required some deep but minor changes in how MidiRingBuffer::read() works, so that we can detect if we're going to be able to deliver an event before we actually read any of its data. Peek FTW!
git-svn-id: svn://localhost/ardour2/branches/3.0@9629 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/midi_track.cc')
-rw-r--r--libs/ardour/midi_track.cc17
1 files changed, 15 insertions, 2 deletions
diff --git a/libs/ardour/midi_track.cc b/libs/ardour/midi_track.cc
index 47c992466c..07b6d2ac6d 100644
--- a/libs/ardour/midi_track.cc
+++ b/libs/ardour/midi_track.cc
@@ -441,13 +441,26 @@ MidiTrack::push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes)
void
MidiTrack::write_out_of_band_data (BufferSet& bufs, framepos_t /*start*/, framepos_t /*end*/, framecnt_t nframes)
{
- // Append immediate events
MidiBuffer& buf (bufs.get_midi (0));
+
+ // Append immediate events
+
if (_immediate_events.read_space()) {
+
DEBUG_TRACE (DEBUG::MidiIO, string_compose ("%1 has %2 of immediate events to deliver\n",
name(), _immediate_events.read_space()));
+
+ /* write as many of the immediate events as we can, but give "true" as
+ * the last argument ("stop on overflow in destination") so that we'll
+ * ship the rest out next time.
+ *
+ * the (nframes-1) argument puts all these events at the last
+ * possible position of the output buffer, so that we do not
+ * violate monotonicity when writing.
+ */
+
+ _immediate_events.read (buf, 0, 1, nframes-1, true);
}
- _immediate_events.read (buf, 0, 1, nframes-1); // all stamps = 0
// MIDI thru: send incoming data "through" output
if (_midi_thru && _session.transport_speed() != 0.0f && _input->n_ports().n_midi()) {