Make the session watch sources' DropReferences and drop accordingly. Remove a now...
authorCarl Hetherington <carl@carlh.net>
Tue, 1 Mar 2011 02:04:50 +0000 (02:04 +0000)
committerCarl Hetherington <carl@carlh.net>
Tue, 1 Mar 2011 02:04:50 +0000 (02:04 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8998 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/audio_diskstream.cc
libs/ardour/midi_diskstream.cc
libs/ardour/session.cc

index 8a161c3977b2380b447066ed3c934c4b403b8419..2c0dcb3e97a77dcf571d8d4cfa201f6fcad8ea07 100644 (file)
@@ -1404,7 +1404,6 @@ AudioDiskstream::transport_stopped_wallclock (struct tm& when, time_t twhen, boo
 
                                (*chan)->write_source->mark_for_remove ();
                                (*chan)->write_source->drop_references ();
-                                _session.remove_source ((*chan)->write_source);
                                (*chan)->write_source.reset ();
                        }
 
@@ -1963,7 +1962,6 @@ AudioDiskstream::reset_write_sources (bool mark_write_complete, bool /*force*/)
                                 if ((*chan)->write_source->removable()) {
                                         (*chan)->write_source->mark_for_remove ();
                                         (*chan)->write_source->drop_references ();
-                                        _session.remove_source ((*chan)->write_source);
                                 }
                                
                                 (*chan)->write_source.reset ();
index 89a497cf018f208d448837cb483bd1ce01325374..abde4952884f71f8d6e97c77847321dc2edf6472 100644 (file)
@@ -943,6 +943,7 @@ MidiDiskstream::transport_stopped_wallclock (struct tm& /*when*/, time_t /*twhen
 
                if (_write_source) {
                        _write_source->mark_for_remove ();
+                       _write_source->drop_references ();
                        _write_source.reset();
                }
 
index b6b238a398982cbab04026ef41c11a00651c1941..cc791af862ea162ee31d520e22b7cc9b4d80c413 100644 (file)
@@ -2676,6 +2676,8 @@ Session::add_source (boost::shared_ptr<Source> source)
                                Analyser::queue_source_for_analysis (source, false);
                        }
                }
+
+               source->DropReferences.connect_same_thread (*this, boost::bind (&Session::remove_source, this, boost::weak_ptr<Source> (source)));
         }
 }