diff options
-rw-r--r-- | libs/ardour/audioregion.cc | 2 | ||||
-rw-r--r-- | libs/ardour/globals.cc | 2 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 22 | ||||
-rw-r--r-- | libs/pbd/id.cc | 10 | ||||
-rw-r--r-- | libs/pbd/pbd/id.h | 3 |
5 files changed, 35 insertions, 4 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 6665b8d962..4a8593cd63 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -655,7 +655,7 @@ AudioRegion::state (bool full) for (uint32_t n=0; n < sources.size(); ++n) { snprintf (buf2, sizeof(buf2), "source-%d", n); - sources[n]->id().print (buf2); + sources[n]->id().print (buf); node.add_property (buf2, buf); } diff --git a/libs/ardour/globals.cc b/libs/ardour/globals.cc index 2ade56f8a9..e9fc1ddfaf 100644 --- a/libs/ardour/globals.cc +++ b/libs/ardour/globals.cc @@ -195,6 +195,8 @@ ARDOUR::init (AudioEngine& engine, bool use_vst, bool try_optimization) (void) bindtextdomain(PACKAGE, LOCALEDIR); + ID::init (); + Config = new Configuration; if (Config->load_state ()) { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 9fb20973e2..1e355990b4 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1333,6 +1333,13 @@ Session::state(bool full_state) } } + /* save the ID counter */ + + snprintf (buf, sizeof (buf), "%" PRIu64, ID::counter()); + node->add_property ("id-counter", buf); + + /* various options */ + node->add_child_nocopy (get_options()); child = node->add_child ("Sources"); @@ -1502,6 +1509,21 @@ Session::set_state (const XMLNode& node) if ((prop = node.property ("name")) != 0) { _name = prop->value (); } + + if ((prop = node.property (X_("id-counter"))) != 0) { + uint64_t x; + sscanf (prop->value().c_str(), "%" PRIu64, &x); + ID::init_counter (x); + } else { + /* old sessions used a timebased counter, so fake + the startup ID counter based on a standard + timestamp. + */ + time_t now; + time (&now); + ID::init_counter (now); + } + IO::disable_ports (); IO::disable_connecting (); diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc index f483ff911c..f9afa72c98 100644 --- a/libs/pbd/id.cc +++ b/libs/pbd/id.cc @@ -12,12 +12,18 @@ using namespace std; using namespace PBD; -Glib::Mutex ID::counter_lock; +Glib::Mutex* ID::counter_lock = 0; uint64_t ID::_counter = 0; +void +ID::init () +{ + counter_lock = new Glib::Mutex; +} + ID::ID () { - Glib::Mutex::Lock lm (counter_lock); + Glib::Mutex::Lock lm (*counter_lock); id = _counter++; } diff --git a/libs/pbd/pbd/id.h b/libs/pbd/pbd/id.h index e7e796fdc8..9a3f10478d 100644 --- a/libs/pbd/pbd/id.h +++ b/libs/pbd/pbd/id.h @@ -31,12 +31,13 @@ class ID { static uint64_t counter() { return _counter; } static void init_counter (uint64_t val) { _counter = val; } + static void init (); private: uint64_t id; int string_assign (std::string); - static Glib::Mutex counter_lock; + static Glib::Mutex* counter_lock; static uint64_t _counter; }; |