Fix portability of test and use temporary test
[ardour.git] / libs / ardour / midi_port.cc
index 0f91dd3e362d5543e047b88901f00c9ff282767a..72150f8cfc852f17471556be65c9131fa5d7eb7d 100644 (file)
@@ -47,8 +47,6 @@ MidiPort::cycle_start (pframes_t nframes)
 
        _buffer->clear ();
 
-       assert (_buffer->size () == 0);
-
        if (sends_output ()) {
                jack_midi_clear_buffer (jack_port_get_buffer (_jack_port, nframes));
        }
@@ -68,8 +66,6 @@ MidiPort::get_midi_buffer (pframes_t nframes)
                        void* jack_buffer = jack_port_get_buffer (_jack_port, nframes);
                        const pframes_t event_count = jack_midi_get_event_count (jack_buffer);
                        
-                       assert (event_count < _buffer->capacity());
-                       
                        /* suck all relevant MIDI events from the JACK MIDI port buffer
                           into our MidiBuffer
                        */
@@ -112,7 +108,6 @@ MidiPort::get_midi_buffer (pframes_t nframes)
        return *_buffer;
 }
 
-
 void
 MidiPort::cycle_end (pframes_t /*nframes*/)
 {
@@ -128,10 +123,9 @@ MidiPort::cycle_split ()
 void
 MidiPort::resolve_notes (void* jack_buffer, MidiBuffer::TimeType when)
 {
-
        for (uint8_t channel = 0; channel <= 0xF; channel++) {
 
-               uint8_t ev[3] = { MIDI_CMD_CONTROL | channel, MIDI_CTL_SUSTAIN, 0 };
+               uint8_t ev[3] = { ((uint8_t) (MIDI_CMD_CONTROL | channel)), MIDI_CTL_SUSTAIN, 0 };
 
                /* we need to send all notes off AND turn the
                 * sustain/damper pedal off to handle synths
@@ -151,7 +145,7 @@ MidiPort::resolve_notes (void* jack_buffer, MidiBuffer::TimeType when)
 }
 
 void
-MidiPort::flush_buffers (pframes_t nframes, framepos_t /*time*/)
+MidiPort::flush_buffers (pframes_t nframes)
 {
        if (sends_output ()) {
 
@@ -171,11 +165,6 @@ MidiPort::flush_buffers (pframes_t nframes, framepos_t /*time*/)
 
                        assert (ev.time() < (nframes + _global_port_buffer_offset + _port_buffer_offset));
 
-                       if (ev.event_type() == LoopEventType) {
-                               resolve_notes (jack_buffer, ev.time());
-                               continue;
-                       }
-
                        if (ev.time() >= _global_port_buffer_offset + _port_buffer_offset) {
                                if (jack_midi_event_write (jack_buffer, (jack_nframes_t) ev.time(), ev.buffer(), ev.size()) != 0) {
                                        cerr << "write failed, drop flushed note off on the floor, time "
@@ -183,12 +172,19 @@ MidiPort::flush_buffers (pframes_t nframes, framepos_t /*time*/)
                                }
                        } else {
                                cerr << "drop flushed event on the floor, time " << ev
-                                    << " to early for " << _global_port_buffer_offset + _port_buffer_offset << endl;
+                                    << " to early for " << _global_port_buffer_offset 
+                                    << " + " << _port_buffer_offset << endl;
                        }
                }
        }
 }
 
+void
+MidiPort::require_resolve ()
+{
+       _resolve_required = true;
+}
+
 void
 MidiPort::transport_stopped ()
 {