X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fasync_midi_port.cc;h=f7147676b0b5286775e92546af9982be42e8d065;hb=dc4f730ac95837590e8305f69778d1049e4a545e;hp=7614015a2e73ae5c695fd4461175cebe416796f8;hpb=74ae2c6ae60c06b3cb86bcb52f5be23839e8c4ba;p=ardour.git diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc index 7614015a2e..f7147676b0 100644 --- a/libs/ardour/async_midi_port.cc +++ b/libs/ardour/async_midi_port.cc @@ -46,6 +46,7 @@ AsyncMIDIPort::AsyncMIDIPort (string const & name, PortFlags flags) , MIDI::Port (name, MIDI::Port::Flags (0)) , _currently_in_cycle (false) , _last_write_timestamp (0) + , _flush_at_cycle_start (false) , have_timer (false) , output_fifo (2048) , input_fifo (1024) @@ -119,6 +120,9 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes) if (ARDOUR::Port::sends_output()) { flush_output_fifo (nframes); + if (_flush_at_cycle_start) { + flush_buffers (nframes); + } } /* copy incoming data from the port buffer into the input FIFO @@ -139,27 +143,20 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes) if (!have_timer) { when += (*b).time(); } - input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer()); + input_fifo.write (when, Evoral::NO_EVENT, (*b).size(), (*b).buffer()); } if (!mb.empty()) { _xthread.wakeup (); } - if (inbound_midi_filter) { - inbound_midi_filter (mb, mb); - } - - if (shadow_port) { - shadow_midi_filter (mb, shadow_port->get_midi_buffer (nframes)); - } } } void AsyncMIDIPort::cycle_end (MIDI::pframes_t nframes) { - if (ARDOUR::Port::sends_output()) { + if (ARDOUR::Port::sends_output() && !_flush_at_cycle_start) { /* move any additional data from output FIFO into the port buffer. */ @@ -244,14 +241,14 @@ AsyncMIDIPort::write (const MIDI::byte * msg, size_t msglen, MIDI::timestamp_t t necessary. */ if (!vec.buf[0]->owns_buffer()) { - vec.buf[0]->set_buffer (0, 0, true); - } + vec.buf[0]->set_buffer (0, 0, true); + } vec.buf[0]->set (msg, msglen, timestamp); } else { /* see comment in previous branch of if() statement */ if (!vec.buf[1]->owns_buffer()) { - vec.buf[1]->set_buffer (0, 0, true); - } + vec.buf[1]->set_buffer (0, 0, true); + } vec.buf[1]->set (msg, msglen, timestamp); } @@ -349,24 +346,3 @@ AsyncMIDIPort::is_process_thread() return pthread_equal (pthread_self(), _process_thread); } -int -AsyncMIDIPort::add_shadow_port (string const & name, MidiFilter mf) -{ - if (!ARDOUR::Port::receives_input()) { - return -1; - } - - if (shadow_port) { - return -2; - } - - shadow_midi_filter = mf; - - /* shadow port is not async. */ - - if (!(shadow_port = boost::dynamic_pointer_cast (AudioEngine::instance()->register_output_port (DataType::MIDI, name, false, PortFlags (Shadow|IsTerminal))))) { - return -3; - } - - return 0; -}