#define port_engine AudioEngine::instance()->port_engine()
-static bool
-filter_relax (MidiBuffer& in, MidiBuffer& out)
-{
- return false;
-}
-
-static bool
-filter_copy (MidiBuffer& in, MidiBuffer& out)
-{
- out.copy (in);
- return false;
-}
-
-static bool
-filter_notes_only (MidiBuffer& in, MidiBuffer& out)
-{
- for (MidiBuffer::iterator b = in.begin(); b != in.end(); ++b) {
- if ((*b).is_note_on() || (*b).is_note_off()) {
- out.push_back (*b);
- }
- }
- return false;
-}
-
AsyncMIDIPort::AsyncMIDIPort (string const & name, PortFlags flags)
: MidiPort (name, 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)
, _xthread (true)
- , inbound_midi_filter (boost::bind (filter_notes_only, _1, _2))
{
}
}
void
-AsyncMIDIPort::set_timer (boost::function<MIDI::framecnt_t (void)>& f)
+AsyncMIDIPort::set_timer (boost::function<MIDI::samplecnt_t (void)>& f)
{
timer = f;
have_timer = true;
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
if (ARDOUR::Port::receives_input()) {
MidiBuffer& mb (get_midi_buffer (nframes));
- framecnt_t when;
+ samplecnt_t when;
if (have_timer) {
when = timer ();
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 (shadow_port) {
- inbound_midi_filter (mb, shadow_port->get_midi_buffer (nframes));
- } else {
- inbound_midi_filter (mb, mb);
- }
}
}
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.
*/
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);
}
}
void
-AsyncMIDIPort::parse (MIDI::framecnt_t)
+AsyncMIDIPort::parse (MIDI::samplecnt_t)
{
MIDI::byte buf[1];
return pthread_equal (pthread_self(), _process_thread);
}
-int
-AsyncMIDIPort::add_shadow_port (string const & name)
-{
- if (!ARDOUR::Port::receives_input()) {
- return -1;
- }
-
- if (shadow_port) {
- return -2;
- }
-
- /* shadow port is not async. */
-
- if (!(shadow_port = boost::dynamic_pointer_cast<MidiPort> (AudioEngine::instance()->register_output_port (DataType::MIDI, name, false)))) {
- return -3;
- }
-
- return 0;
-}