Ignore cycle-start/end for unregistered ports
authorRobin Gareus <robin@gareus.org>
Thu, 3 Aug 2017 17:16:33 +0000 (19:16 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 3 Aug 2017 17:25:14 +0000 (19:25 +0200)
Should fix a race during Session::destroy(), Port::PortDrop
which unregisters ports with the backend, but the actual port instance
will still exist.

The engine does no longer have a session-pointer and only calls
CycleStart(); CycleEnd() to clear port-buffers. Trying to clear
and already unregistered Port will crash.

libs/ardour/audio_port.cc
libs/ardour/midi_port.cc

index 33e41c10ad49cc309615af9d4778e0d5d426b610..f559578e4e366bc3c93978a609e2248c1c9a1d15 100644 (file)
@@ -58,12 +58,12 @@ AudioPort::cycle_start (pframes_t nframes)
 void
 AudioPort::cycle_end (pframes_t nframes)
 {
-        if (sends_output() && !_buffer->written()) {
-               if (!_buffer->data (0)) {
-                       get_audio_buffer (nframes);
-               }
-               if (_buffer->capacity() >= nframes) {
-                       _buffer->silence (nframes);
+       if (sends_output() && !_buffer->written() && _port_handle) {
+               if (!_buffer->data (0)) {
+                       get_audio_buffer (nframes);
+               }
+               if (_buffer->capacity() >= nframes) {
+                       _buffer->silence (nframes);
                }
        }
 }
index 05d9da59714b4bab1c9d626113d3f9939f761230..9a52aef3c6241c4eb18527b1970afb83f434c234 100644 (file)
@@ -65,7 +65,7 @@ MidiPort::cycle_start (pframes_t nframes)
 
        _buffer->clear ();
 
-       if (sends_output ()) {
+       if (sends_output () && _port_handle) {
                port_engine.midi_clear (port_engine.get_buffer (_port_handle, nframes));
        }