Fix some more crashes at session-close
authorRobin Gareus <robin@gareus.org>
Tue, 1 Aug 2017 21:27:34 +0000 (23:27 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 1 Aug 2017 21:27:34 +0000 (23:27 +0200)
PortDrop unregisters backend ports, the backend will return a NULL
buffer-pointer, but the I/O object still exists (Metronome, LTC)

AudioBuffer::_data == 0

#0  msvcrt!memset () from C:\Windows\System32\msvcrt.dll
#1  ARDOUR::AudioBuffer::silence (this=0x2c410710, len=256, offset=0) at ../libs/ardour/audio_buffer.cc:88
#2  ARDOUR::AudioPort::cycle_end (this=0x34918730, nframes=256) at ../libs/ardour/audio_port.cc:66
#3  ARDOUR::PortManager::cycle_end (this=this@entry=0x23342770, nframes=nframes@entry=256)
[process callback w/o session]

libs/ardour/session.cc
libs/ardour/session_ltc.cc

index 2b4fe2b7f1dccf6bb530273a96e290d84fe96b77..62514f6d3656b57a8955c60a0fa2530859201c7f 100644 (file)
@@ -644,6 +644,11 @@ Session::destroy ()
                _slave = 0;
        }
 
+       /* remove I/O objects before unsetting the engine session */
+       _click_io.reset ();
+       _ltc_input.reset ();
+       _ltc_output.reset ();
+
        /* disconnect from any and all signals that we are connected to */
 
        Port::PortSignalDrop (); /* EMIT SIGNAL */
@@ -7071,13 +7076,14 @@ Session::operation_in_progress (GQuark op) const
 boost::shared_ptr<Port>
 Session::ltc_input_port () const
 {
+       assert (_ltc_input);
        return _ltc_input->nth (0);
 }
 
 boost::shared_ptr<Port>
 Session::ltc_output_port () const
 {
-       return _ltc_output->nth (0);
+       return _ltc_output ? _ltc_output->nth (0) : boost::shared_ptr<Port> ();
 }
 
 void
index 87fd47e70ea9543a8ab1402d71d9d4361b932f27..91e11c8a4cde9b3b00cbc3e0f0f3f06489f104d7 100644 (file)
@@ -170,6 +170,12 @@ Session::ltc_tx_send_time_code_for_cycle (framepos_t start_frame, framepos_t end
        pframes_t txf = 0;
        boost::shared_ptr<Port> ltcport = ltc_output_port();
 
+       if (!ltcport) {
+               assert (deletion_in_progress ());
+               return;
+       }
+
+       /* marks buffer as not written */
        Buffer& buf (ltcport->get_buffer (nframes));
 
        if (!ltc_encoder || !ltc_enc_buf) {