diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-03-07 16:25:50 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-05-31 15:30:39 -0400 |
commit | 0dca11cb470700399c2e284649ece2ff23332660 (patch) | |
tree | cff266dd9b067de26a4d3c6f7757fe13faf28bd3 | |
parent | 1132d3f4c8871ab15364b442da49acfdfeff1223 (diff) |
save+restore VCA counter value across instances
-rw-r--r-- | libs/ardour/ardour/vca.h | 1 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 13 | ||||
-rw-r--r-- | libs/ardour/vca.cc | 14 |
3 files changed, 25 insertions, 3 deletions
diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h index cca83a13f2..42224eb708 100644 --- a/libs/ardour/ardour/vca.h +++ b/libs/ardour/ardour/vca.h @@ -55,6 +55,7 @@ class LIBARDOUR_API VCA : public Stripable, public Automatable, public boost::en static std::string default_name_template (); static int next_vca_number (); static std::string xml_node_name; + static void set_next_vca_number (uint32_t); virtual boost::shared_ptr<GainControl> gain_control() const { return _gain_control; } virtual boost::shared_ptr<AutomationControl> solo_control() const { return _solo_control; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 819b2949ea..decff17f1e 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1099,6 +1099,11 @@ Session::state (bool full_state) snprintf (buf, sizeof (buf), "%d", Evoral::event_id_counter()); node->add_property ("event-counter", buf); + /* save the VCA counter */ + + snprintf (buf, sizeof (buf), "%" PRIu32, VCA::next_vca_number()); + node->add_property ("vca-counter", buf); + /* various options */ list<XMLNode*> midi_port_nodes = _midi_ports->get_midi_port_states(); @@ -1359,6 +1364,14 @@ Session::set_state (const XMLNode& node, int version) Evoral::init_event_id_counter (atoi (prop->value())); } + if ((prop = node.property (X_("vca-counter"))) != 0) { + uint32_t x; + sscanf (prop->value().c_str(), "%" PRIu32, &x); + VCA::set_next_vca_number (x); + } else { + VCA::set_next_vca_number (1); + } + if ((child = find_named_node (node, "MIDIPorts")) != 0) { _midi_ports->set_midi_port_states (child->children()); } diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc index 6873a29df9..aafb084a40 100644 --- a/libs/ardour/vca.cc +++ b/libs/ardour/vca.cc @@ -31,7 +31,7 @@ using namespace ARDOUR; using namespace PBD; using std::string; -gint VCA::next_number = 0; +gint VCA::next_number = 1; string VCA::xml_node_name (X_("VCA")); string @@ -43,8 +43,16 @@ VCA::default_name_template () int VCA::next_vca_number () { - /* recall that atomic_int_add() returns the value before the add */ - return g_atomic_int_add (&next_number, 1) + 1; + /* recall that atomic_int_add() returns the value before the add. We + * start at one, then next one will be two etc. + */ + return g_atomic_int_add (&next_number, 1); +} + +void +VCA::set_next_vca_number (uint32_t n) +{ + g_atomic_int_set (&next_number, n); } VCA::VCA (Session& s, uint32_t num, const string& name) |