reload alpha1-6 Pannable XML state so that panning of existing sessions should work...
[ardour.git] / libs / ardour / midi_track.cc
index 47c992466c627327733aafdab7155dbd6c287fd6..52a0cac27e24c8160a83fa66c42e0fbb3455b08f 100644 (file)
@@ -98,7 +98,7 @@ void
 MidiTrack::set_diskstream (boost::shared_ptr<Diskstream> ds)
 {
        Track::set_diskstream (ds);
-       
+
        _diskstream->set_track (this);
        _diskstream->set_destructive (_mode == Destructive);
 
@@ -398,6 +398,19 @@ MidiTrack::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fr
        return ret;
 }
 
+void
+MidiTrack::realtime_locate ()
+{
+       Glib::RWLock::ReaderLock lm (_processor_lock, Glib::TRY_LOCK);
+       if (!lm.locked ()) {
+               return;
+       }
+
+       for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
+               (*i)->realtime_locate ();
+       }
+}
+
 void
 MidiTrack::realtime_handle_transport_stopped ()
 {
@@ -427,7 +440,7 @@ MidiTrack::push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes)
                        const Evoral::MIDIEvent<framepos_t> ev(*e, false);
 
                        /* note on, since for step edit, note length is determined
-                          elsewhere 
+                          elsewhere
                        */
 
                        if (ev.is_note_on()) {
@@ -441,13 +454,26 @@ MidiTrack::push_midi_input_to_step_edit_ringbuffer (framecnt_t nframes)
 void
 MidiTrack::write_out_of_band_data (BufferSet& bufs, framepos_t /*start*/, framepos_t /*end*/, framecnt_t nframes)
 {
-       // Append immediate events
        MidiBuffer& buf (bufs.get_midi (0));
+
+       // Append immediate events
+
        if (_immediate_events.read_space()) {
-               DEBUG_TRACE (DEBUG::MidiIO, string_compose ("%1 has %2 of immediate events to deliver\n", 
+
+               DEBUG_TRACE (DEBUG::MidiIO, string_compose ("%1 has %2 of immediate events to deliver\n",
                                                            name(), _immediate_events.read_space()));
+
+               /* write as many of the immediate events as we can, but give "true" as
+                * the last argument ("stop on overflow in destination") so that we'll
+                * ship the rest out next time.
+                *
+                * the (nframes-1) argument puts all these events at the last
+                * possible position of the output buffer, so that we do not
+                * violate monotonicity when writing.
+                */
+
+               _immediate_events.read (buf, 0, 1, nframes-1, true);
        }
-       _immediate_events.read (buf, 0, 1, nframes-1); // all stamps = 0
 
        // MIDI thru: send incoming data "through" output
        if (_midi_thru && _session.transport_speed() != 0.0f && _input->n_ports().n_midi()) {
@@ -638,7 +664,7 @@ MidiTrack::diskstream_data_recorded (boost::shared_ptr<MidiBuffer> buf, boost::w
 {
        DataRecorded (buf, src); /* EMIT SIGNAL */
 }
-                              
+
 bool
 MidiTrack::should_monitor () const
 {