From 5153631d70a3bfa9aec2548a1ae33edcffbebfcb Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 1 Feb 2016 13:26:30 -0500 Subject: change API of MIDI::Port::drain() to include a maximum blocking time --- libs/ardour/async_midi_port.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libs/ardour/async_midi_port.cc') diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc index 3dfb5610d9..bbcc0aab85 100644 --- a/libs/ardour/async_midi_port.cc +++ b/libs/ardour/async_midi_port.cc @@ -168,7 +168,7 @@ AsyncMIDIPort::cycle_end (MIDI::pframes_t nframes) * Cannot be called from a processing thread. */ void -AsyncMIDIPort::drain (int check_interval_usecs) +AsyncMIDIPort::drain (int check_interval_usecs, int total_usecs_to_wait) { RingBuffer< Evoral::Event >::rw_vector vec = { { 0, 0 }, { 0, 0} }; @@ -183,12 +183,16 @@ AsyncMIDIPort::drain (int check_interval_usecs) return; } - while (1) { + microseconds_t now = get_microseconds (); + microseconds_t end = now + total_usecs_to_wait; + + while (now < end) { output_fifo.get_write_vector (&vec); if (vec.len[0] + vec.len[1] >= output_fifo.bufsize() - 1) { break; } Glib::usleep (check_interval_usecs); + now = get_microseconds(); } } -- cgit v1.2.3