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 | |
parent | d98021624fe879ff42cc4191c4fe02d6aa63331b (diff) |
change API of MIDI::Port::drain() to include a maximum blocking time
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/async_midi_port.h | 2 | ||||
-rw-r--r-- | libs/ardour/async_midi_port.cc | 8 |
2 files changed, 7 insertions, 3 deletions
diff --git a/libs/ardour/ardour/async_midi_port.h b/libs/ardour/ardour/async_midi_port.h index e28c6922d2..96a50ab198 100644 --- a/libs/ardour/ardour/async_midi_port.h +++ b/libs/ardour/ardour/async_midi_port.h @@ -58,7 +58,7 @@ class LIBARDOUR_API AsyncMIDIPort : public ARDOUR::MidiPort, public MIDI::Port { int write (const MIDI::byte *msg, size_t msglen, MIDI::timestamp_t timestamp); int read (MIDI::byte *buf, size_t bufsize); /* waits for output to be cleared */ - void drain (int check_interval_usecs); + void drain (int check_interval_usecs, int total_usecs_to_wait); /* clears async request communication channel */ void clear () { 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(); } } |