diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-01 13:26:30 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-01 13:26:30 -0500 |
commit | 5153631d70a3bfa9aec2548a1ae33edcffbebfcb (patch) | |
tree | 420c4e8e240bff5e73e572ede04c2623a342ba51 /libs/ardour/async_midi_port.cc | |
parent | d98021624fe879ff42cc4191c4fe02d6aa63331b (diff) |
change API of MIDI::Port::drain() to include a maximum blocking time
Diffstat (limited to 'libs/ardour/async_midi_port.cc')
-rw-r--r-- | libs/ardour/async_midi_port.cc | 8 |
1 files changed, 6 insertions, 2 deletions
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<double> >::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(); } } |