diff options
Diffstat (limited to 'libs/ardour/session.cc')
-rw-r--r-- | libs/ardour/session.cc | 188 |
1 files changed, 0 insertions, 188 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 5a34176afe..d7a71ff0c5 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2436,194 +2436,6 @@ Session::diskstream_by_id (const PBD::ID& id) /* Region management */ -string -Session::new_region_name (string old) -{ - string::size_type last_period; - uint32_t number; - string::size_type len = old.length() + 64; - char buf[len]; - - if ((last_period = old.find_last_of ('.')) == string::npos) { - - /* no period present - add one explicitly */ - - old += '.'; - last_period = old.length() - 1; - number = 0; - - } else { - - number = atoi (old.substr (last_period+1).c_str()); - - } - - while (number < (UINT_MAX-1)) { - - const RegionFactory::RegionMap& regions (RegionFactory::regions()); - RegionFactory::RegionMap::const_iterator i; - string sbuf; - - number++; - - snprintf (buf, len, "%s%" PRIu32, old.substr (0, last_period + 1).c_str(), number); - sbuf = buf; - - for (i = regions.begin(); i != regions.end(); ++i) { - if (i->second->name() == sbuf) { - break; - } - } - - if (i == regions.end()) { - break; - } - } - - if (number != (UINT_MAX-1)) { - return buf; - } - - error << string_compose (_("cannot create new name for region \"%1\""), old) << endmsg; - return old; -} - -int -Session::region_name (string& result, string base, bool newlevel) -{ - char buf[16]; - string subbase; - - if (base.find("/") != string::npos) { - base = base.substr(base.find_last_of("/") + 1); - } - - if (base == "") { - - snprintf (buf, sizeof (buf), "%d", RegionFactory::nregions() + 1); - result = "region."; - result += buf; - - } else { - - if (newlevel) { - subbase = base; - } else { - string::size_type pos; - - pos = base.find_last_of ('.'); - - /* pos may be npos, but then we just use entire base */ - - subbase = base.substr (0, pos); - - } - - { - Glib::Mutex::Lock lm (region_lock); - - map<string,uint32_t>::iterator x; - - result = subbase; - - if ((x = region_name_map.find (subbase)) == region_name_map.end()) { - result += ".1"; - region_name_map[subbase] = 1; - } else { - x->second++; - snprintf (buf, sizeof (buf), ".%d", x->second); - - result += buf; - } - } - } - - return 0; -} - -void -Session::add_region (boost::shared_ptr<Region> region) -{ - vector<boost::shared_ptr<Region> > v; - v.push_back (region); - add_regions (v); -} - -void -Session::add_regions (vector<boost::shared_ptr<Region> >& new_regions) -{ - /* mark dirty because something has changed - */ - - set_dirty (); - - for (vector<boost::shared_ptr<Region> >::iterator ii = new_regions.begin(); ii != new_regions.end(); ++ii) { - - boost::shared_ptr<Region> region = *ii; - assert (region); - - region->PropertyChanged.connect_same_thread (*this, boost::bind (&Session::region_changed, this, _1, boost::weak_ptr<Region>(region))); - update_region_name_map (region); - } - - if (!new_regions.empty()) { - RegionsAdded (new_regions); /* EMIT SIGNAL */ - } -} - -void -Session::update_region_name_map (boost::shared_ptr<Region> region) -{ - string::size_type last_period = region->name().find_last_of ('.'); - - if (last_period != string::npos && last_period < region->name().length() - 1) { - - string base = region->name().substr (0, last_period); - string number = region->name().substr (last_period+1); - map<string,uint32_t>::iterator x; - - /* note that if there is no number, we get zero from atoi, - which is just fine - */ - - region_name_map[base] = atoi (number); - } -} - -void -Session::region_changed (const PropertyChange& what_changed, boost::weak_ptr<Region> weak_region) -{ - boost::shared_ptr<Region> region (weak_region.lock ()); - - if (!region) { - return; - } - - if (what_changed.contains (Properties::hidden)) { - /* relay hidden changes */ - RegionHiddenChange (region); - } - - if (what_changed.contains (Properties::name)) { - update_region_name_map (region); - } -} - -void -Session::remove_region (boost::weak_ptr<Region> weak_region) -{ - boost::shared_ptr<Region> region (weak_region.lock ()); - - if (!region) { - return; - } - - RegionFactory::map_remove (region); - set_dirty(); - - RegionRemoved(region); /* EMIT SIGNAL */ -} - boost::shared_ptr<Region> Session::find_whole_file_parent (boost::shared_ptr<Region const> child) const { |