summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/editor_ops.cc6
-rw-r--r--gtk2_ardour/editor_regions.cc50
-rw-r--r--gtk2_ardour/editor_regions.h7
-rw-r--r--gtk2_ardour/editor_summary.cc6
-rw-r--r--libs/ardour/ardour/region_factory.h18
-rw-r--r--libs/ardour/ardour/session.h20
-rw-r--r--libs/ardour/audio_diskstream.cc2
-rw-r--r--libs/ardour/audio_region_importer.cc4
-rw-r--r--libs/ardour/filter.cc2
-rw-r--r--libs/ardour/midi_diskstream.cc2
-rw-r--r--libs/ardour/playlist.cc18
-rw-r--r--libs/ardour/region.cc2
-rw-r--r--libs/ardour/region_factory.cc198
-rw-r--r--libs/ardour/session.cc188
-rw-r--r--libs/ardour/session_state.cc1
-rw-r--r--libs/ardour/strip_silence.cc2
16 files changed, 207 insertions, 319 deletions
diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc
index f7fe6e7b4a..f9022a04ff 100644
--- a/gtk2_ardour/editor_ops.cc
+++ b/gtk2_ardour/editor_ops.cc
@@ -2668,7 +2668,7 @@ Editor::region_from_selection ()
}
internal_start = start - current->position();
- _session->region_name (new_name, current->name(), true);
+ RegionFactory::region_name (new_name, current->name(), true);
PropertyList plist;
@@ -2708,7 +2708,7 @@ Editor::create_region_from_selection (vector<boost::shared_ptr<Region> >& new_re
}
internal_start = start - current->position();
- _session->region_name (new_name, current->name(), true);
+ RegionFactory::region_name (new_name, current->name(), true);
PropertyList plist;
@@ -5927,7 +5927,7 @@ Editor::split_region_at_points (boost::shared_ptr<Region> r, AnalysisFeatureList
string new_name;
- if (_session->region_name (new_name, r->name())) {
+ if (RegionFactory::region_name (new_name, r->name())) {
break;
}
diff --git a/gtk2_ardour/editor_regions.cc b/gtk2_ardour/editor_regions.cc
index 981ada3eff..c33fc13bf2 100644
--- a/gtk2_ardour/editor_regions.cc
+++ b/gtk2_ardour/editor_regions.cc
@@ -129,48 +129,17 @@ EditorRegions::EditorRegions (Editor* e)
//ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (sigc::mem_fun(*this, &Editor::redisplay_regions));
ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (sigc::mem_fun(*this, &EditorRegions::update_all_rows));
- ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::update_row, this, _1), gui_context());
-
+ ARDOUR::Region::RegionPropertyChanged.connect (region_property_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::region_changed, this, _1, _2), gui_context());
+ ARDOUR::RegionFactory::CheckNewRegion.connect (check_new_region_connection, MISSING_INVALIDATOR, ui_bind (&EditorRegions::add_region, this, _1), gui_context());
}
void
EditorRegions::set_session (ARDOUR::Session* s)
{
EditorComponent::set_session (s);
-
- if (_session) {
- _session->RegionsAdded.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&EditorRegions::handle_new_regions, this, _1), gui_context());
- _session->RegionHiddenChange.connect (_session_connections, MISSING_INVALIDATOR, ui_bind (&EditorRegions::region_hidden, this, _1), gui_context());
- }
-
- redisplay ();
-}
-
-void
-EditorRegions::handle_new_regions (vector<boost::shared_ptr<Region> >& v)
-{
- ENSURE_GUI_THREAD (*this, &EditorRegions::handle_new_regions, v)
- add_regions (v);
-}
-
-void
-EditorRegions::region_hidden_weak (boost::weak_ptr<Region> wr)
-{
- boost::shared_ptr<Region> r (wr.lock());
-
- if (r) {
- region_hidden (r);
- }
-}
-
-void
-EditorRegions::region_hidden (boost::shared_ptr<Region> r)
-{
- ENSURE_GUI_THREAD (*this, &EditorRegions::region_hidden, r)
redisplay ();
}
-
void
EditorRegions::add_regions (vector<boost::shared_ptr<Region> >& regions)
{
@@ -334,18 +303,9 @@ EditorRegions::add_region (boost::shared_ptr<Region> region)
populate_row(region, (*row));
}
-
void
-EditorRegions::region_changed (const PropertyChange& what_changed, boost::weak_ptr<Region> region)
+EditorRegions::region_changed (boost::shared_ptr<Region> r, const PropertyChange& what_changed)
{
- ENSURE_GUI_THREAD (*this, &EditorRegions::region_changed, what_changed, region)
-
- boost::shared_ptr<Region> r = region.lock ();
-
- if (!r) {
- return;
- }
-
if (what_changed.contains (ARDOUR::Properties::name)) {
/* find the region in our model and change its name */
TreeModel::Children rows = _model->children ();
@@ -370,6 +330,10 @@ EditorRegions::region_changed (const PropertyChange& what_changed, boost::weak_p
}
}
+
+ if (what_changed.contains (ARDOUR::Properties::hidden)) {
+ redisplay ();
+ }
}
void
diff --git a/gtk2_ardour/editor_regions.h b/gtk2_ardour/editor_regions.h
index c4ec4a1ba2..54f891950f 100644
--- a/gtk2_ardour/editor_regions.h
+++ b/gtk2_ardour/editor_regions.h
@@ -104,7 +104,7 @@ private:
Columns _columns;
- void region_changed (const PBD::PropertyChange&, boost::weak_ptr<ARDOUR::Region>);
+ void region_changed (boost::shared_ptr<ARDOUR::Region>, PBD::PropertyChange const &);
void selection_changed ();
sigc::connection _change_connection;
bool set_selected_in_subrow (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
@@ -120,12 +120,8 @@ private:
int sorter (Gtk::TreeModel::iterator, Gtk::TreeModel::iterator);
- void handle_new_region (boost::weak_ptr<ARDOUR::Region>);
- void handle_new_regions (std::vector<boost::shared_ptr<ARDOUR::Region> >& );
void add_region (boost::shared_ptr<ARDOUR::Region>);
void add_regions (std::vector<boost::shared_ptr<ARDOUR::Region> > & );
- void region_hidden (boost::shared_ptr<ARDOUR::Region>);
- void region_hidden_weak (boost::weak_ptr<ARDOUR::Region>);
void populate_row (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &);
void update_row (boost::shared_ptr<ARDOUR::Region>);
bool update_subrows (boost::shared_ptr<ARDOUR::Region>, Gtk::TreeModel::Row const &, int);
@@ -149,6 +145,7 @@ private:
bool _no_redisplay;
std::list<boost::shared_ptr<ARDOUR::Region> > tmp_region_list;
PBD::ScopedConnection region_property_connection;
+ PBD::ScopedConnection check_new_region_connection;
bool ignore_region_list_selection_change;
bool ignore_selected_region_change;
};
diff --git a/gtk2_ardour/editor_summary.cc b/gtk2_ardour/editor_summary.cc
index 27cbaefdba..fd4422bc08 100644
--- a/gtk2_ardour/editor_summary.cc
+++ b/gtk2_ardour/editor_summary.cc
@@ -61,8 +61,12 @@ EditorSummary::set_session (Session* s)
set_dirty ();
+ /* Note: the EditorSummary already finds out about new regions from Editor::region_view_added
+ * (which attaches to StreamView::RegionViewAdded), and cut regions by the RegionPropertyChanged
+ * emitted when a cut region is added to the `cutlist' playlist.
+ */
+
if (_session) {
- _session->RegionRemoved.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_dirty, this), gui_context());
_session->StartTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_dirty, this), gui_context());
_session->EndTimeChanged.connect (_session_connections, invalidator (*this), boost::bind (&EditorSummary::set_dirty, this), gui_context());
}
diff --git a/libs/ardour/ardour/region_factory.h b/libs/ardour/ardour/region_factory.h
index 2bff4dd104..ca19f52fec 100644
--- a/libs/ardour/ardour/region_factory.h
+++ b/libs/ardour/ardour/region_factory.h
@@ -83,11 +83,27 @@ class RegionFactory {
static const RegionMap& regions() { return region_map; }
static uint32_t nregions ();
+ static int region_name (std::string &, std::string, bool new_level = false);
+ static std::string new_region_name (std::string);
+
private:
+
+ static boost::shared_ptr<Region> create (boost::shared_ptr<Region>, frameoffset_t offset,
+ bool offset_relative,
+ const PBD::PropertyList&, bool announce = true);
+
+ static void region_changed (PBD::PropertyChange const &, boost::weak_ptr<Region>);
+
static Glib::StaticMutex region_map_lock;
+
static RegionMap region_map;
static void map_add (boost::shared_ptr<Region>);
-
+
+ static Glib::StaticMutex region_name_map_lock;
+
+ static std::map<std::string, uint32_t> region_name_map;
+ static void update_region_name_map (boost::shared_ptr<Region>);
+
static PBD::ScopedConnectionList region_list_connections;
};
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index 36687d5cf1..4af432eeb5 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -261,10 +261,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
void maybe_write_autosave ();
- /* Proxy signal for region hidden changes */
-
- PBD::Signal1<void,boost::shared_ptr<Region> > RegionHiddenChange;
-
/* Emitted when all i/o connections are complete */
PBD::Signal0<void> IOConnectionsComplete;
@@ -314,8 +310,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
int wipe ();
- int remove_region_from_region_list (boost::shared_ptr<Region>);
-
nframes_t get_maximum_extent () const;
nframes_t current_end_frame() const { return end_location->start(); }
nframes_t current_start_frame() const { return start_location->start(); }
@@ -493,13 +487,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
boost::shared_ptr<Region> find_whole_file_parent (boost::shared_ptr<Region const>) const;
- void add_regions (std::vector<boost::shared_ptr<Region> >&);
-
- PBD::Signal1<void,std::vector<boost::shared_ptr<Region> >&> RegionsAdded;
- PBD::Signal1<void,boost::shared_ptr<Region> > RegionRemoved;
-
- int region_name (std::string& result, std::string base = std::string(""), bool newlevel = false);
- std::string new_region_name (std::string);
std::string path_from_region_name (DataType type, std::string name, std::string identifier);
boost::shared_ptr<Region> XMLRegionFactory (const XMLNode&, bool full);
@@ -1241,15 +1228,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
/* REGION MANAGEMENT */
- std::map<std::string,uint32_t> region_name_map;
- void update_region_name_map (boost::shared_ptr<Region>);
-
mutable Glib::Mutex region_lock;
- void add_region (boost::shared_ptr<Region>);
- void region_changed (const PBD::PropertyChange&, boost::weak_ptr<Region>);
- void remove_region (boost::weak_ptr<Region>);
-
int load_regions (const XMLNode& node);
void route_group_changed ();
diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc
index c7194d7495..d832a39e28 100644
--- a/libs/ardour/audio_diskstream.cc
+++ b/libs/ardour/audio_diskstream.cc
@@ -1473,7 +1473,7 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
string region_name;
- _session.region_name (region_name, whole_file_region_name, false);
+ RegionFactory::region_name (region_name, whole_file_region_name, false);
// cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add region " << region_name << endl;
diff --git a/libs/ardour/audio_region_importer.cc b/libs/ardour/audio_region_importer.cc
index ebe4ae5270..7be155b5f5 100644
--- a/libs/ardour/audio_region_importer.cc
+++ b/libs/ardour/audio_region_importer.cc
@@ -176,8 +176,6 @@ AudioRegionImporter::_move ()
if (broken()) {
return;
}
-
- session.add_regions (region);
}
bool
@@ -209,7 +207,7 @@ AudioRegionImporter::parse_xml_region ()
} else if (!prop.compare("name")) {
// rename region if necessary
name = (*it)->value();
- name = session.new_region_name (name);
+ name = RegionFactory::new_region_name (name);
(*it)->set_value (name);
name_ok = true;
} else {
diff --git a/libs/ardour/filter.cc b/libs/ardour/filter.cc
index 2ff93316f3..44e7f11cbd 100644
--- a/libs/ardour/filter.cc
+++ b/libs/ardour/filter.cc
@@ -116,7 +116,7 @@ Filter::finish (boost::shared_ptr<Region> region, SourceList& nsrcs, string regi
/* create a new region */
if (region_name.empty()) {
- region_name = session.new_region_name (region->name());
+ region_name = RegionFactory::new_region_name (region->name());
}
results.clear ();
diff --git a/libs/ardour/midi_diskstream.cc b/libs/ardour/midi_diskstream.cc
index e0d7abe880..dbee0de562 100644
--- a/libs/ardour/midi_diskstream.cc
+++ b/libs/ardour/midi_diskstream.cc
@@ -989,7 +989,7 @@ MidiDiskstream::transport_stopped (struct tm& /*when*/, time_t /*twhen*/, bool a
string region_name;
- _session.region_name (region_name, _write_source->name(), false);
+ RegionFactory::region_name (region_name, _write_source->name(), false);
// cerr << _name << ": based on ci of " << (*ci)->start << " for " << (*ci)->frames << " add a region\n";
diff --git a/libs/ardour/playlist.cc b/libs/ardour/playlist.cc
index 5968f67f21..35b0aedcd8 100644
--- a/libs/ardour/playlist.cc
+++ b/libs/ardour/playlist.cc
@@ -264,7 +264,7 @@ Playlist::Playlist (boost::shared_ptr<const Playlist> other, framepos_t start, f
break;
}
- _session.region_name (new_name, region->name(), false);
+ RegionFactory::region_name (new_name, region->name(), false);
PropertyList plist;
@@ -693,7 +693,7 @@ Playlist::add_region (boost::shared_ptr<Region> region, framepos_t position, flo
if (floor (times) != times) {
length = (framecnt_t) floor (region->length() * (times - floor (times)));
string name;
- _session.region_name (name, region->name(), false);
+ RegionFactory::region_name (name, region->name(), false);
{
PropertyList plist;
@@ -963,7 +963,7 @@ Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, Re
if (!cutting) {
/* "middle" ++++++ */
- _session.region_name (new_name, current->name(), false);
+ RegionFactory::region_name (new_name, current->name(), false);
PropertyList plist;
@@ -982,7 +982,7 @@ Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, Re
/* "end" ====== */
- _session.region_name (new_name, current->name(), false);
+ RegionFactory::region_name (new_name, current->name(), false);
PropertyList plist;
@@ -1020,7 +1020,7 @@ Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, Re
/* end +++++ */
- _session.region_name (new_name, current->name(), false);
+ RegionFactory::region_name (new_name, current->name(), false);
PropertyList plist;
@@ -1063,7 +1063,7 @@ Playlist::partition_internal (framepos_t start, framepos_t end, bool cutting, Re
if (!cutting) {
/* front **** */
- _session.region_name (new_name, current->name(), false);
+ RegionFactory::region_name (new_name, current->name(), false);
PropertyList plist;
@@ -1267,7 +1267,7 @@ Playlist::duplicate (boost::shared_ptr<Region> region, framepos_t position, floa
if (floor (times) != times) {
framecnt_t length = (framecnt_t) floor (region->length() * (times - floor (times)));
string name;
- _session.region_name (name, region->name(), false);
+ RegionFactory::region_name (name, region->name(), false);
{
PropertyList plist;
@@ -1368,7 +1368,7 @@ Playlist::_split_region (boost::shared_ptr<Region> region, framepos_t playlist_p
before = playlist_position - region->position();
after = region->length() - before;
- _session.region_name (before_name, region->name(), false);
+ RegionFactory::region_name (before_name, region->name(), false);
{
PropertyList plist;
@@ -1381,7 +1381,7 @@ Playlist::_split_region (boost::shared_ptr<Region> region, framepos_t playlist_p
left = RegionFactory::create (region, plist);
}
- _session.region_name (after_name, region->name(), false);
+ RegionFactory::region_name (after_name, region->name(), false);
{
PropertyList plist;
diff --git a/libs/ardour/region.cc b/libs/ardour/region.cc
index acd4e1b9dc..bb9338d98d 100644
--- a/libs/ardour/region.cc
+++ b/libs/ardour/region.cc
@@ -486,7 +486,7 @@ Region::first_edit ()
if (_first_edit != EditChangesNothing && pl) {
- _name = _session.new_region_name (_name);
+ _name = RegionFactory::new_region_name (_name);
_first_edit = EditChangesNothing;
send_change (Properties::name);
diff --git a/libs/ardour/region_factory.cc b/libs/ardour/region_factory.cc
index 8a24bc954c..5a4b129710 100644
--- a/libs/ardour/region_factory.cc
+++ b/libs/ardour/region_factory.cc
@@ -17,6 +17,9 @@
*/
+#define __STDC_FORMAT_MACROS
+#include <inttypes.h>
+
#include "pbd/error.h"
#include "pbd/boost_debug.h"
@@ -39,6 +42,8 @@ PBD::Signal1<void,boost::shared_ptr<Region> > RegionFactory::CheckNewRegion;
Glib::StaticMutex RegionFactory::region_map_lock;
RegionFactory::RegionMap RegionFactory::region_map;
PBD::ScopedConnectionList RegionFactory::region_list_connections;
+Glib::StaticMutex RegionFactory::region_name_map_lock;
+std::map<std::string, uint32_t> RegionFactory::region_name_map;
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<const Region> region)
@@ -80,53 +85,25 @@ RegionFactory::create (boost::shared_ptr<const Region> region)
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, const PropertyList& plist, bool announce)
{
- boost::shared_ptr<Region> ret;
- boost::shared_ptr<const AudioRegion> other_a;
- boost::shared_ptr<const MidiRegion> other_m;
-
- if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
-
- AudioRegion* ar = new AudioRegion (other_a, offset, true);
- boost_debug_shared_ptr_mark_interesting (ar, "Region");
-
- boost::shared_ptr<AudioRegion> arp (ar);
- ret = boost::static_pointer_cast<Region> (arp);
-
- } else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
-
- MidiRegion* mr = new MidiRegion (other_m, offset, true);
- boost::shared_ptr<MidiRegion> mrp (mr);
- ret = boost::static_pointer_cast<Region> (mrp);
-
- } else {
- fatal << _("programming error: RegionFactory::create() called with unknown Region type")
- << endmsg;
- /*NOTREACHED*/
- return boost::shared_ptr<Region>();
- }
-
- if (ret) {
- ret->set_properties (plist);
- map_add (ret);
-
- if (announce) {
- CheckNewRegion (ret);
- }
- }
-
- return ret;
+ return create (region, offset, true, plist, announce);
}
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& plist, bool announce)
{
+ return create (region, 0, false, plist, announce);
+}
+
+boost::shared_ptr<Region>
+RegionFactory::create (boost::shared_ptr<Region> region, frameoffset_t offset, bool offset_relative, const PropertyList& plist, bool announce)
+{
boost::shared_ptr<Region> ret;
boost::shared_ptr<const AudioRegion> other_a;
boost::shared_ptr<const MidiRegion> other_m;
if ((other_a = boost::dynamic_pointer_cast<AudioRegion>(region)) != 0) {
- AudioRegion* ar = new AudioRegion (other_a, 0, false);
+ AudioRegion* ar = new AudioRegion (other_a, offset, offset_relative);
boost_debug_shared_ptr_mark_interesting (ar, "Region");
boost::shared_ptr<AudioRegion> arp (ar);
@@ -134,7 +111,7 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
} else if ((other_m = boost::dynamic_pointer_cast<MidiRegion>(region)) != 0) {
- MidiRegion* mr = new MidiRegion (other_m, 0, false);
+ MidiRegion* mr = new MidiRegion (other_m, offset, offset_relative);
boost::shared_ptr<MidiRegion> mrp (mr);
ret = boost::static_pointer_cast<Region> (mrp);
@@ -157,9 +134,6 @@ RegionFactory::create (boost::shared_ptr<Region> region, const PropertyList& pli
return ret;
}
-
-
-
boost::shared_ptr<Region>
RegionFactory::create (boost::shared_ptr<Region> region, const SourceList& srcs, const PropertyList& plist, bool announce)
{
@@ -301,6 +275,13 @@ RegionFactory::map_add (boost::shared_ptr<Region> r)
}
r->DropReferences.connect_same_thread (region_list_connections, boost::bind (&RegionFactory::map_remove, r));
+
+ r->PropertyChanged.connect_same_thread (
+ region_list_connections,
+ boost::bind (&RegionFactory::region_changed, _1, boost::weak_ptr<Region> (r))
+ );
+
+ update_region_name_map (r);
}
void
@@ -369,3 +350,140 @@ RegionFactory::nregions ()
Glib::Mutex::Lock lm (region_map_lock);
return region_map.size ();
}
+
+void
+RegionFactory::update_region_name_map (boost::shared_ptr<Region> region)
+{
+ string::size_type const last_period = region->name().find_last_of ('.');
+
+ if (last_period != string::npos && last_period < region->name().length() - 1) {
+
+ string const base = region->name().substr (0, last_period);
+ string const number = region->name().substr (last_period + 1);
+
+ /* note that if there is no number, we get zero from atoi,
+ which is just fine
+ */
+
+ Glib::Mutex::Lock lm (region_name_map_lock);
+ region_name_map[base] = atoi (number.c_str ());
+ }
+}
+
+void
+RegionFactory::region_changed (PropertyChange const & what_changed, boost::weak_ptr<Region> w)
+{
+ boost::shared_ptr<Region> r = w.lock ();
+ if (!r) {
+ return;
+ }
+
+ if (what_changed.contains (Properties::name)) {
+ update_region_name_map (r);
+ }
+}
+
+int
+RegionFactory::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_name_map_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;
+}
+
+string
+RegionFactory::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 RegionMap& regions (RegionFactory::regions());
+ 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;
+}
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
{
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc
index 4c0dcfd72d..c231f7eb1d 100644
--- a/libs/ardour/session_state.cc
+++ b/libs/ardour/session_state.cc
@@ -270,7 +270,6 @@ Session::first_stage_init (string fullpath, string snapshot_name)
/* These are all static "per-class" signals */
- RegionFactory::CheckNewRegion.connect_same_thread (*this, boost::bind (&Session::add_region, this, _1));
SourceFactory::SourceCreated.connect_same_thread (*this, boost::bind (&Session::add_source, this, _1));
PlaylistFactory::PlaylistCreated.connect_same_thread (*this, boost::bind (&Session::add_playlist, this, _1, _2));
Processor::ProcessorCreated.connect_same_thread (*this, boost::bind (&Session::add_processor, this, _1));
diff --git a/libs/ardour/strip_silence.cc b/libs/ardour/strip_silence.cc
index 21e1ad5450..3952311aa2 100644
--- a/libs/ardour/strip_silence.cc
+++ b/libs/ardour/strip_silence.cc
@@ -113,7 +113,7 @@ StripSilence::run (boost::shared_ptr<Region> r)
copy = boost::dynamic_pointer_cast<AudioRegion> (RegionFactory::create
(region, start, plist));
- copy->set_name (session.new_region_name (region->name ()));
+ copy->set_name (RegionFactory::new_region_name (region->name ()));
std::cerr << "New silent delineated region called " << copy->name()
<< " @ " << copy->start() << " length = " << copy->length() << " pos = " <<