diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2009-12-24 04:04:01 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2009-12-24 04:04:01 +0000 |
commit | f53cbaede885cd52b8fee59890e33575a4fc11fa (patch) | |
tree | 6db06514b75b029ece4d18fbc376e2e1cc06eb2e /libs | |
parent | defa1fad942e9a33b8fe3f56b26427af069a1b73 (diff) |
clean up editor mixer strip when session is going away; slightly improved boost debugging
git-svn-id: svn://localhost/ardour2/branches/3.0@6397 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/ardour/session_handle.h | 2 | ||||
-rw-r--r-- | libs/ardour/region_factory.cc | 12 | ||||
-rw-r--r-- | libs/ardour/session.cc | 15 | ||||
-rw-r--r-- | libs/ardour/session_handle.cc | 5 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 11 | ||||
-rw-r--r-- | libs/ardour/source_factory.cc | 18 | ||||
-rw-r--r-- | libs/pbd/boost_debug.cc | 54 |
7 files changed, 83 insertions, 34 deletions
diff --git a/libs/ardour/ardour/session_handle.h b/libs/ardour/ardour/session_handle.h index 87de244e42..0331970e5c 100644 --- a/libs/ardour/ardour/session_handle.h +++ b/libs/ardour/ardour/session_handle.h @@ -29,7 +29,7 @@ class SessionHandleRef : public PBD::ScopedConnectionList { public: SessionHandleRef (ARDOUR::Session& s); - virtual ~SessionHandleRef () {} + virtual ~SessionHandleRef (); protected: ARDOUR::Session& _session; diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc index 6399645be1..70ea326230 100644 --- a/libs/ardour/region_factory.cc +++ b/libs/ardour/region_factory.cc @@ -46,7 +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_debug_shared_ptr_mark_interesting (ar, "Region"); boost::shared_ptr<AudioRegion> arp (ar); boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp)); ret->unlock_property_changes (); @@ -79,7 +79,7 @@ RegionFactory::create (boost::shared_ptr<const Region> region) if ((ar = boost::dynamic_pointer_cast<const AudioRegion>(region)) != 0) { AudioRegion* arn = new AudioRegion (ar); - boost_debug_shared_ptr_mark_interesting (arn, typeid (arn).name()); + boost_debug_shared_ptr_mark_interesting (arn, "Region"); boost::shared_ptr<Region> ret (arn); ret->unlock_property_changes (); /* pure copy constructor - no CheckNewRegion emitted */ @@ -118,7 +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_debug_shared_ptr_mark_interesting (ar, "Region"); boost::shared_ptr<AudioRegion> arp (ar); boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp)); ret->unlock_property_changes (); @@ -157,7 +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_debug_shared_ptr_mark_interesting (ar, "Region"); boost::shared_ptr<AudioRegion> arp (ar); boost::shared_ptr<Region> ret (boost::static_pointer_cast<Region> (arp)); ret->unlock_property_changes (); @@ -191,7 +191,7 @@ RegionFactory::create (SourceList& srcs, const XMLNode& node) if (srcs[0]->type() == DataType::AUDIO) { AudioRegion* ar = new AudioRegion (srcs, node); - boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name()); + boost_debug_shared_ptr_mark_interesting (ar, "Region"); boost::shared_ptr<Region> ret (ar); ret->unlock_property_changes (); CheckNewRegion (ret); @@ -214,7 +214,7 @@ RegionFactory::create (boost::shared_ptr<Source> src, nframes_t start, nframes_t if ((as = boost::dynamic_pointer_cast<AudioSource>(src)) != 0) { AudioRegion* ar = new AudioRegion (as, start, length, name, layer, flags); - boost_debug_shared_ptr_mark_interesting (ar, typeid (ar).name()); + boost_debug_shared_ptr_mark_interesting (ar, "Region"); boost::shared_ptr<Region> ret (ar); ret->unlock_property_changes (); if (announce) { diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 2e48ed0215..0bbd1834b4 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -280,8 +280,8 @@ Session::Session (AudioEngine &eng, if (master_out_channels) { ChanCount count(DataType::AUDIO, master_out_channels); Route* rt = new Route (*this, _("master"), Route::MasterOut, DataType::AUDIO); - boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name()); - shared_ptr<Route> r (rt); + boost_debug_shared_ptr_mark_interesting (rt, "Route"); + boost::shared_ptr<Route> r (rt); r->input()->ensure_io (count, false, this); r->output()->ensure_io (count, false, this); r->set_remote_control_id (control_id); @@ -295,7 +295,7 @@ Session::Session (AudioEngine &eng, if (control_out_channels) { ChanCount count(DataType::AUDIO, control_out_channels); Route* rt = new Route (*this, _("monitor"), Route::ControlOut, DataType::AUDIO); - boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name()); + boost_debug_shared_ptr_mark_interesting (rt, "Route"); shared_ptr<Route> r (rt); r->input()->ensure_io (count, false, this); r->output()->ensure_io (count, false, this); @@ -363,7 +363,8 @@ Session::destroy () Stateful::loading_state_version = 0; _butler->terminate_thread (); - + delete _butler; + delete midi_control_ui; if (click_data != default_click) { @@ -424,6 +425,8 @@ Session::destroy () /* writer goes out of scope and updates master */ } routes.flush (); + extern void boost_debug_count_ptrs (); + boost_debug_count_ptrs (); DEBUG_TRACE (DEBUG::Destruction, "delete diskstreams\n"); { @@ -1739,7 +1742,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, "Track"); track = boost::shared_ptr<AudioTrack>(at); if (track->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) { @@ -1930,7 +1933,7 @@ Session::new_audio_route (bool aux, int input_channels, int output_channels, Rou try { Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO); - boost_debug_shared_ptr_mark_interesting (rt, typeid (rt).name()); + boost_debug_shared_ptr_mark_interesting (rt, "Route"); shared_ptr<Route> bus (rt); if (bus->input()->ensure_io (ChanCount(DataType::AUDIO, input_channels), false, this)) { diff --git a/libs/ardour/session_handle.cc b/libs/ardour/session_handle.cc index 36515505ac..14ba994dc3 100644 --- a/libs/ardour/session_handle.cc +++ b/libs/ardour/session_handle.cc @@ -18,6 +18,7 @@ */ #include "pbd/error.h" +#include "pbd/boost_debug.h" #include "ardour/session.h" #include "ardour/session_handle.h" @@ -67,6 +68,10 @@ SessionHandleRef::SessionHandleRef (Session& s) _session.Destroyed.connect_same_thread (*this, boost::bind (&SessionHandleRef::insanity_check, this)); } +SessionHandleRef::~SessionHandleRef () +{ +} + void SessionHandleRef::session_going_away () { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1742feaab1..001954ed44 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1388,16 +1388,17 @@ 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::shared_ptr<Route> ret (at); - return ret; + boost_debug_shared_ptr_mark_interesting (at, "Track"); + return boost::shared_ptr<Route> (at); + } else { boost::shared_ptr<Route> ret (new MidiTrack (*this, node, version)); return ret; } } else { - boost::shared_ptr<Route> ret (new Route (*this, node)); - return ret; + Route* rt = new Route (*this, node); + boost_debug_shared_ptr_mark_interesting (rt, "Route"); + return boost::shared_ptr<Route> (rt); } } diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 9b9a28c698..05e7513da9 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -124,7 +124,7 @@ boost::shared_ptr<Source> SourceFactory::createSilent (Session& s, const XMLNode& node, nframes_t nframes, float sr) { Source* src = new SilentFileSource (s, node, nframes, sr); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); // no analysis data - the file is non-existent SourceCreated (ret); @@ -146,7 +146,7 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) try { Source* src = new SndFileSource (s, node); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); if (setup_peakfile (ret, defer_peaks)) { return boost::shared_ptr<Source>(); @@ -163,7 +163,7 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) /* this is allowed to throw */ Source *src = new CoreAudioSource (s, node); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); if (setup_peakfile (ret, defer_peaks)) { @@ -180,7 +180,7 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) } else if (type == DataType::MIDI) { Source* src = new SMFSource (s, node); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); ret->check_for_analysis_data_on_disk (); SourceCreated (ret); @@ -201,7 +201,7 @@ SourceFactory::createReadable (DataType type, Session& s, const string& path, try { Source* src = new SndFileSource (s, path, chn, flags); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); if (setup_peakfile (ret, defer_peaks)) { @@ -219,7 +219,7 @@ SourceFactory::createReadable (DataType type, Session& s, const string& path, #ifdef USE_COREAUDIO_FOR_FILES Source* src = new CoreAudioSource (s, path, chn, flags); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); if (setup_peakfile (ret, defer_peaks)) { return boost::shared_ptr<Source>(); @@ -242,7 +242,7 @@ SourceFactory::createReadable (DataType type, Session& s, const string& path, } else if (type == DataType::MIDI) { Source* src = new SMFSource (s, path, SMFSource::Flag(0)); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); if (announce) { @@ -270,7 +270,7 @@ SourceFactory::createWritable (DataType type, Session& s, const std::string& pat (destructive ? Source::Flag (SndFileSource::default_writable_flags | Source::Destructive) : SndFileSource::default_writable_flags)); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); if (setup_peakfile (ret, defer_peaks)) { @@ -287,7 +287,7 @@ SourceFactory::createWritable (DataType type, Session& s, const std::string& pat } else if (type == DataType::MIDI) { Source* src = new SMFSource (s, path, Source::Flag(0)); - // boost_debug_shared_ptr_mark_interesting (src, typeid(src).name()); + // boost_debug_shared_ptr_mark_interesting (src, "Source"); boost::shared_ptr<Source> ret (src); // no analysis data - this is a new file diff --git a/libs/pbd/boost_debug.cc b/libs/pbd/boost_debug.cc index 33e7bb3564..9ca2e9bd4a 100644 --- a/libs/pbd/boost_debug.cc +++ b/libs/pbd/boost_debug.cc @@ -146,18 +146,51 @@ boost_debug_shared_ptr_mark_interesting (void* ptr, const char* type) } void -boost_debug_shared_ptr_operator_equals (void const *sp, void const *obj, int) +boost_debug_shared_ptr_operator_equals (void const *sp, void const *old_obj, int old_use_count, void const *obj, int new_use_count) { - if (is_interesting_object (obj)) { - cerr << "sp @ " << sp << " assigned\n"; + if (old_obj == 0 && obj == 0) { + return; + } + + Glib::Mutex::Lock guard (the_lock); + + if (is_interesting_object (old_obj) || is_interesting_object (obj)) { + // cerr << "ASSIGN SWAPS " << old_obj << " & " << obj << endl; + } + + if (is_interesting_object (old_obj)) { + // cerr << "\tlost old sp @ " << sp << " for " << old_obj << " UC = " << old_use_count << " now for " << obj << " UC = " << new_use_count + // << " (total sp's = " << sptrs.size() << ')' << endl; + + PointerMap::iterator x = sptrs.find (sp); + + if (x != sptrs.end()) { + sptrs.erase (x); + // cerr << "\tRemoved (by assigment) sp for " << old_obj << " @ " << sp << " UC = " << old_use_count << " (total sp's = " << sptrs.size() << ')' << endl; + } } + + if (is_interesting_object (obj)) { + + pair<void const*, SPDebug*> newpair; + + newpair.first = sp; + newpair.second = new SPDebug (new Backtrace()); + + sptrs.insert (newpair); + + // cerr << "assignment created sp for " << obj << " @ " << sp << " used to point to " << old_obj << " UC = " << old_use_count + // << " UC = " << new_use_count + // << " (total sp's = " << sptrs.size() << ')' << endl; + + } } void -boost_debug_shared_ptr_reset (void const *sp, void const *obj, int) +boost_debug_shared_ptr_reset (void const *sp, void const *obj, int use_count) { if (is_interesting_object (obj)) { - cerr << "sp @ " << sp << " reset\n"; + // cerr << "reset sp to object @ " << obj << " @ " << sp << " UC was " << use_count << " (total sp's = " << sptrs.size() << ')' << endl; } } @@ -169,7 +202,7 @@ 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; + // cerr << "Removed sp for " << obj << " @ " << sp << " UC = " << use_count << " (total sp's = " << sptrs.size() << ')' << endl; } } @@ -184,11 +217,18 @@ 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; + // cerr << "Stored constructor for " << obj << " @ " << sp << " UC = " << use_count << " (total sp's = " << sptrs.size() << ')' << endl; } } void +boost_debug_count_ptrs () +{ + Glib::Mutex::Lock guard (the_lock); + // cerr << "Tracking " << interesting_pointers.size() << " interesting objects with " << sptrs.size () << " shared ptrs\n"; +} + +void boost_debug_list_ptrs () { Glib::Mutex::Lock guard (the_lock); |