summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2009-11-28 00:49:04 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2009-11-28 00:49:04 +0000
commit51693a3a5835a7c2deb16242d14d73fbb7881382 (patch)
tree2c576e25b2f1b945be6bdcf30cd9245b27d93d90
parentc5db9a21b990b55e1b515a65a99bdc504d0af89c (diff)
tracing and small fixes to improve object destruction pathways
git-svn-id: svn://localhost/ardour2/branches/3.0@6195 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/audio_diskstream.cc3
-rw-r--r--libs/ardour/audio_playlist.cc6
-rw-r--r--libs/ardour/audiofilesource.cc7
-rw-r--r--libs/ardour/diskstream.cc6
-rw-r--r--libs/ardour/playlist.cc2
-rw-r--r--libs/ardour/region.cc2
-rw-r--r--libs/ardour/region_factory.cc16
-rw-r--r--libs/ardour/route.cc2
-rw-r--r--libs/ardour/session.cc36
-rw-r--r--libs/ardour/session_state.cc2
-rw-r--r--libs/ardour/source.cc2
-rw-r--r--libs/ardour/track.cc2
-rw-r--r--libs/pbd/boost_debug.cc18
13 files changed, 67 insertions, 37 deletions
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index faa4684745..7ef971642d 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -49,6 +49,7 @@
#include "ardour/butler.h"
#include "ardour/configuration.h"
#include "ardour/cycle_timer.h"
+#include "ardour/debug.h"
#include "ardour/io.h"
#include "ardour/playlist_factory.h"
#include "ardour/region_factory.h"
@@ -122,7 +123,7 @@ AudioDiskstream::init (Diskstream::Flag f)
AudioDiskstream::~AudioDiskstream ()
{
- cerr << "AD going away\n";
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("Audio Diskstream %1 destructor\n", _name));
notify_callbacks ();
diff --git a/libs/ardour/audio_playlist.cc b/libs/ardour/audio_playlist.cc
index eb4913e727..30479cf65b 100644
--- a/libs/ardour/audio_playlist.cc
+++ b/libs/ardour/audio_playlist.cc
@@ -351,7 +351,7 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
boost::shared_ptr<AudioRegion> top;
boost::shared_ptr<AudioRegion> bottom;
boost::shared_ptr<Crossfade> xfade;
- RegionList* touched_regions;
+ RegionList* touched_regions = 0;
if (in_set_state || in_partition) {
return;
@@ -401,6 +401,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
OverlapType c = top->coverage (bottom->position(), bottom->last_frame());
+ delete touched_regions;
+
try {
switch (c) {
case OverlapNone:
@@ -509,6 +511,8 @@ AudioPlaylist::check_dependents (boost::shared_ptr<Region> r, bool norefresh)
}
}
+
+ delete touched_regions;
}
void
diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc
index e9eb3641da..f2f09b71fc 100644
--- a/libs/ardour/audiofilesource.cc
+++ b/libs/ardour/audiofilesource.cc
@@ -45,6 +45,7 @@
#include <glibmm/thread.h>
#include "ardour/audiofilesource.h"
+#include "ardour/debug.h"
#include "ardour/sndfile_helpers.h"
#include "ardour/sndfilesource.h"
#include "ardour/session.h"
@@ -99,7 +100,6 @@ AudioFileSource::AudioFileSource (Session& s, const ustring& path, bool embedded
if (init (path, true)) {
throw failed_constructor ();
}
- cerr << "AFS1 created, " << path << endl;
}
/** Constructor used for new internal-to-session files. */
@@ -114,7 +114,6 @@ AudioFileSource::AudioFileSource (Session& s, const ustring& path, bool embedded
if (init (path, false)) {
throw failed_constructor ();
}
- cerr << "AFS2 created, " << path << endl;
}
/** Constructor used for existing internal-to-session files. File must exist. */
@@ -130,14 +129,12 @@ AudioFileSource::AudioFileSource (Session& s, const XMLNode& node, bool must_exi
if (init (_name, must_exist)) {
throw failed_constructor ();
}
- cerr << "AFS3 created, " << path() << endl;
}
AudioFileSource::~AudioFileSource ()
{
- cerr << "AFS " << _name << " destructor, path = " << path() << endl;
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("AudioFileSource destructor %1, removable? %2\n", _path, removable()));
if (removable()) {
- cerr << "\tremoving file\n";
unlink (_path.c_str());
unlink (peakpath.c_str());
}
diff --git a/libs/ardour/diskstream.cc b/libs/ardour/diskstream.cc
index b6cc9d6a04..e2dfc27100 100644
--- a/libs/ardour/diskstream.cc
+++ b/libs/ardour/diskstream.cc
@@ -129,9 +129,11 @@ Diskstream::init (Flag f)
Diskstream::~Diskstream ()
{
- if (_playlist)
- _playlist->release ();
DEBUG_TRACE (DEBUG::Destruction, string_compose ("Diskstream %1 deleted\n", _name));
+
+ if (_playlist) {
+ _playlist->release ();
+ }
}
void
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index f57093ea40..aa41bf65d1 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -32,6 +32,7 @@
#include "pbd/xml++.h"
#include "pbd/stacktrace.h"
+#include "ardour/debug.h"
#include "ardour/playlist.h"
#include "ardour/session.h"
#include "ardour/region.h"
@@ -270,6 +271,7 @@ Playlist::init (bool hide)
Playlist::~Playlist ()
{
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("Playlist %1 destructor\n", _name));
{
RegionLock rl (this);
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index c59a5bb562..cbfd9a9b33 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -339,9 +339,9 @@ Region::Region (boost::shared_ptr<Source> src, const XMLNode& node)
Region::~Region ()
{
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("Region %1 destructor @ %2\n", _name, this));
notify_callbacks ();
GoingAway (); /* EMIT SIGNAL */
- DEBUG_TRACE (DEBUG::Destruction, string_compose ("Region %1 deleted\n", _name));
}
void
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 8b2d30d511..91cc2dbe2a 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -18,6 +18,7 @@
*/
#include "pbd/error.h"
+#include "pbd/boost_debug.h"
#include "ardour/session.h"
@@ -45,6 +46,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, nframes_t start,
if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
AudioRegion* ar = new AudioRegion (other_a, start, length, name, layer, flags);
+ boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name());
boost::shared_ptr<AudioRegion> arp (ar);
boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
ret->unlock_property_changes ();
@@ -76,7 +78,9 @@ RegionFactory::create (boost::shared_ptr<const Region> region)
boost::shared_ptr<const MidiRegion> mr;
if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) {
- boost::shared_ptr<Region> ret (new AudioRegion (ar));
+ AudioRegion* arn = new AudioRegion (ar);
+ boost_debug_shared_ptr_mark_interesting (arn, typeid (arn).name());
+ boost::shared_ptr<Region> ret (arn);
ret->unlock_property_changes ();
/* pure copy constructor - no CheckNewRegion emitted */
return ret;
@@ -114,6 +118,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
if ((other = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
AudioRegion* ar = new AudioRegion (other, srcs, srcs.front()->length(srcs.front()->timeline_position()), name, layer, flags);
+ boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name());
boost::shared_ptr<AudioRegion> arp (ar);
boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
ret->unlock_property_changes ();
@@ -152,6 +157,7 @@ RegionFactory::create (const SourceList& srcs, nframes_t start, nframes_t length
if (srcs[0]->type() == DataType::AUDIO) {
AudioRegion* ar = new AudioRegion (srcs, start, length, name, layer, flags);
+ boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name());
boost::shared_ptr<AudioRegion> arp (ar);
boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp));
ret->unlock_property_changes ();
@@ -184,7 +190,9 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node)
}
if (srcs[0]->type() == DataType::AUDIO) {
- boost::shared_ptr<Region> ret (new AudioRegion (srcs, node));
+ AudioRegion* ar = new AudioRegion (srcs, node);
+ boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name());
+ boost::shared_ptr<Region> ret (ar);
ret->unlock_property_changes ();
CheckNewRegion (ret);
return ret;
@@ -205,7 +213,9 @@ RegionFactory::create (boost::shared_ptr<Source> src, nframes_t start, nframes_t
boost::shared_ptr<MidiSource> ms;
if ((as = boost::dynamic_pointer_cast<AudioSource>(src)) != 0) {
- boost::shared_ptr<Region> ret (new AudioRegion (as, start, length, name, layer, flags));
+ AudioRegion* ar = new AudioRegion (as, start, length, name, layer, flags);
+ boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name());
+ boost::shared_ptr<Region> ret (ar);
ret->unlock_property_changes ();
if (announce) {
CheckNewRegion (ret);
diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc
index 912e80c0ea..1b8dfaec46 100644
--- a/libs/ardour/route.cc
+++ b/libs/ardour/route.cc
@@ -161,6 +161,7 @@ Route::init ()
Route::~Route ()
{
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("route %1 destructor\n", _name));
Metering::disconnect (_meter_connection);
/* don't use clear_processors here, as it depends on the session which may
@@ -170,6 +171,7 @@ Route::~Route ()
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
(*i)->drop_references ();
}
+
_processors.clear ();
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 67f41a906f..f7dfd2111d 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -400,7 +400,7 @@ Session::destroy ()
i = tmp;
}
- DEBUG_TRACE (DEBUG::Destruction, "delete playlists\n");
+ DEBUG_TRACE (DEBUG::Destruction, "delete used playlists\n");
for (PlaylistList::iterator i = playlists.begin(); i != playlists.end(); ) {
PlaylistList::iterator tmp;
@@ -409,11 +409,12 @@ Session::destroy ()
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for used playlist %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count()));
(*i)->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("post-ref = %1\n", (*i).use_count()));
+
i = tmp;
}
+ DEBUG_TRACE (DEBUG::Destruction, "delete unused playlists\n");
for (PlaylistList::iterator i = unused_playlists.begin(); i != unused_playlists.end(); ) {
PlaylistList::iterator tmp;
@@ -422,7 +423,6 @@ Session::destroy ()
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for unused playlist %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count()));
(*i)->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("post-ref = %2\n", (*i).use_count()));
i = tmp;
}
@@ -437,24 +437,28 @@ Session::destroy ()
tmp = i;
++tmp;
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for region %1 ; pre-ref = %2\n", i->second->name(), i->second.use_count()));
+ DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for region %1 (%2); pre-ref = %2\n", i->second->name(), i->second.get(), i->second.use_count()));
i->second->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("\tpost-ref%2\n", i->second.use_count()));
-
+ DEBUG_TRACE(DEBUG::Destruction, string_compose ("region post ref = %1\n", i->second.use_count()));
i = tmp;
}
regions.clear ();
DEBUG_TRACE (DEBUG::Destruction, "delete routes\n");
+
+ /* reset these three references to special routes before we do the usual route delete thing */
+
+ auditioner.reset ();
+ _master_out.reset ();
+ _control_out.reset ();
+
{
RCUWriter<RouteList> writer (routes);
boost::shared_ptr<RouteList> r = writer.get_copy ();
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for route %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count()));
(*i)->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("post-ref = %1\n", (*i).use_count()));
- debug_pointers.push_back ((*i).get());
}
r->clear ();
/* writer goes out of scope and updates master */
@@ -468,7 +472,6 @@ Session::destroy ()
for (DiskstreamList::iterator i = dsl->begin(); i != dsl->end(); ++i) {
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for diskstream %1 ; pre-ref = %2\n", (*i)->name(), (*i).use_count()));
(*i)->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("post-ref = %1\n", (*i).use_count()));
}
dsl->clear ();
}
@@ -483,13 +486,12 @@ Session::destroy ()
DEBUG_TRACE(DEBUG::Destruction, string_compose ("Dropping for source %1 ; pre-ref = %2\n", i->second->path(), i->second.use_count()));
i->second->drop_references ();
- DEBUG_TRACE(DEBUG::Destruction, string_compose ("\tpost-ref%1\n", i->second.use_count()));
i = tmp;
}
- cerr << "Pre source clear, we have " << sources.size() << endl;
+
sources.clear ();
- cerr << "Post source clear, we have " << sources.size() << endl;
+
DEBUG_TRACE (DEBUG::Destruction, "delete route groups\n");
for (list<RouteGroup *>::iterator i = _route_groups.begin(); i != _route_groups.end(); ++i) {
@@ -501,6 +503,8 @@ Session::destroy ()
delete mmc;
boost_debug_list_ptrs ();
+
+ DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
}
void
@@ -1520,8 +1524,6 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
for (i = r->begin(); i != r->end(); ++i) {
- cerr << "\n\n\n CLEAR FED BY for " << (*i)->name() << endl;
-
(*i)->fed_by.clear ();
for (j = r->begin(); j != r->end(); ++j) {
@@ -1785,7 +1787,7 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
try {
AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode);
- boost_debug_shared_ptr_mark_interesting (at, typeid (at).name());
+ // boost_debug_shared_ptr_mark_interesting (at, typeid (at).name());
track = boost::shared_ptr<AudioTrack>(at);
if (track->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) {
@@ -3722,10 +3724,10 @@ void
Session::graph_reordered ()
{
/* don't do this stuff if we are setting up connections
- from a set_state() call or creating new tracks.
+ from a set_state() call or creating new tracks. Ditto for deletion.
*/
- if (_state_of_the_state & InitialConnecting) {
+ if (_state_of_the_state & (InitialConnecting|Deletion)) {
return;
}
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index f53dd7106e..1664b0b9f9 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -1405,7 +1405,7 @@ Session::XMLRouteFactory (const XMLNode& node, int version)
if (has_diskstream) {
if (type == DataType::AUDIO) {
AudioTrack* at = new AudioTrack (*this, node, version);
- boost_debug_shared_ptr_mark_interesting (at, typeid (at).name());
+ // boost_debug_shared_ptr_mark_interesting (at, typeid (at).name());
boost::shared_ptr<Route> ret (at);
return ret;
} else {
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index 10b7ead270..790b7f6c3e 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -75,8 +75,8 @@ Source::Source (Session& s, const XMLNode& node)
Source::~Source ()
{
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("Source %1 destructor\n", _name));
notify_callbacks ();
- DEBUG_TRACE (DEBUG::Destruction, string_compose ("Source %1 deleted\n", _name));
}
diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc
index ce208769f6..01201d38e7 100644
--- a/libs/ardour/track.cc
+++ b/libs/ardour/track.cc
@@ -24,6 +24,7 @@
#include "ardour/audioplaylist.h"
#include "ardour/audioregion.h"
#include "ardour/audiosource.h"
+#include "ardour/debug.h"
#include "ardour/delivery.h"
#include "ardour/diskstream.h"
#include "ardour/io_processor.h"
@@ -62,6 +63,7 @@ Track::Track (Session& sess, const XMLNode& node, DataType default_type)
Track::~Track ()
{
+ DEBUG_TRACE (DEBUG::Destruction, string_compose ("track %1 destructor\n", _name));
}
void
diff --git a/libs/pbd/boost_debug.cc b/libs/pbd/boost_debug.cc
index c9487197e1..33e7bb3564 100644
--- a/libs/pbd/boost_debug.cc
+++ b/libs/pbd/boost_debug.cc
@@ -142,6 +142,7 @@ boost_debug_shared_ptr_mark_interesting (void* ptr, const char* type)
Glib::Mutex::Lock guard (the_lock);
pair<void*,const char*> newpair (ptr, type);
interesting_pointers.insert (newpair);
+ // cerr << "Interesting object @ " << ptr << " of type " << type << endl;
}
void
@@ -168,12 +169,13 @@ boost_debug_shared_ptr_destructor (void const *sp, void const *obj, int use_coun
if (x != sptrs.end()) {
sptrs.erase (x);
+ // cerr << "Removed sp for " << obj << " @ " << sp << endl;
}
}
+
void
boost_debug_shared_ptr_constructor (void const *sp, void const *obj, int use_count)
{
-
if (is_interesting_object (obj)) {
Glib::Mutex::Lock guard (the_lock);
pair<void const*, SPDebug*> newpair;
@@ -182,6 +184,7 @@ boost_debug_shared_ptr_constructor (void const *sp, void const *obj, int use_cou
newpair.second = new SPDebug (new Backtrace());
sptrs.insert (newpair);
+ // cerr << "Stored constructor for " << obj << " @ " << sp << endl;
}
}
@@ -189,10 +192,15 @@ void
boost_debug_list_ptrs ()
{
Glib::Mutex::Lock guard (the_lock);
- for (PointerMap::iterator x = sptrs.begin(); x != sptrs.end(); ++x) {
- cerr << "Shared ptr @ " << x->first << " history: "
- << *x->second
- << endl;
+
+ if (sptrs.empty()) {
+ cerr << "There are no dangling shared ptrs\n";
+ } else {
+ for (PointerMap::iterator x = sptrs.begin(); x != sptrs.end(); ++x) {
+ cerr << "Shared ptr @ " << x->first << " history: "
+ << *x->second
+ << endl;
+ }
}
}