summaryrefslogtreecommitdiff
path: root/libs/ardour/region_factory.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-06-23 20:14:07 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-06-23 20:14:07 +0000
commitf4401c59284258c6aa56707da64e3da32756329f (patch)
tree73679199ae43516347d607adad212c10612f7eb9 /libs/ardour/region_factory.cc
parentcac03dbeb6ebdcd406385dd14a746cb8c51dd5f8 (diff)
midway snapshot of work done on managing Region & Source lifetimes correctly. may fix missing MIDI file bug ; save empty playlists because they may be referred to by the history file ; undo commands auto-delete when objects they refer to die (currently not commands built from XML deserialization); Sources now know how many regions are using them for something, meaning that we know if we can delete the files holding any data for the source
git-svn-id: svn://localhost/ardour2/branches/3.0@7291 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/region_factory.cc')
-rw-r--r--libs/ardour/region_factory.cc43
1 files changed, 43 insertions, 0 deletions
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 5a4b129710..65649ad8f7 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -73,6 +73,7 @@ RegionFactory::create (boost::shared_ptr<const Region> region)
}
if (ret) {
+ cerr << "Pure copy constructor region " << ret << " named " << ret->name() << endl;
map_add (ret);
/* pure copy constructor - no property list */
@@ -124,6 +125,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, b
if (ret) {
ret->set_properties (plist);
+ cerr << "Partial copy constructor region\n";
map_add (ret);
if (announce) {
@@ -163,6 +165,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs,
if (ret) {
ret->set_properties (plist);
+ cerr << "New sources copy constructor region\n";
map_add (ret);
if (announce) {
@@ -208,6 +211,7 @@ RegionFactory::create (const SourceList& srcs, const PropertyList& plist, bool a
if (ret) {
ret->set_properties (plist);
+ cerr << "de-novo constructor region " << ret << " named " << ret->name() << endl;
map_add (ret);
if (announce) {
@@ -281,6 +285,8 @@ RegionFactory::map_add (boost::shared_ptr<Region> r)
boost::bind (&RegionFactory::region_changed, _1, boost::weak_ptr<Region> (r))
);
+ cerr << "Added region with ID = " << r->id() << " named " << r->name() << endl;
+
update_region_name_map (r);
}
@@ -292,7 +298,32 @@ RegionFactory::map_remove (boost::shared_ptr<Region> r)
if (i != region_map.end()) {
region_map.erase (i);
+ cerr << "Removed region with ID = " << r->id() << " named " << r->name() << endl;;
}
+
+}
+
+void
+RegionFactory::map_remove_with_equivalents (boost::shared_ptr<Region> r)
+{
+ Glib::Mutex::Lock lm (region_map_lock);
+
+ for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ) {
+ RegionMap::iterator tmp = i;
+ ++tmp;
+
+ if (r->region_list_equivalent (i->second)) {
+ cerr << "Removed equivalent region " << i->second->name() << '/' << i->first << endl;
+ region_map.erase (i);
+ } else if (r == i->second) {
+ cerr << "Removed actual region " << i->second->name() << '/' << i->first << endl;
+ region_map.erase (i);
+ }
+
+ i = tmp;
+ }
+
+
}
boost::shared_ptr<Region>
@@ -487,3 +518,15 @@ RegionFactory::new_region_name (string old)
error << string_compose (_("cannot create new name for region \"%1\""), old) << endmsg;
return old;
}
+
+void
+RegionFactory::get_regions_using_source (boost::shared_ptr<Source> s, std::set<boost::shared_ptr<Region> >& r)
+{
+ Glib::Mutex::Lock lm (region_map_lock);
+
+ for (RegionMap::iterator i = region_map.begin(); i != region_map.end(); ++i) {
+ if (i->second->uses_source (s)) {
+ r.insert (i->second);
+ }
+ }
+}