save+restore VCA counter value across instances
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 7 Mar 2016 21:25:50 +0000 (16:25 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:39 +0000 (15:30 -0400)
libs/ardour/ardour/vca.h
libs/ardour/session_state.cc
libs/ardour/vca.cc

index cca83a13f2093a9a6a0d98cd79ea5d7a8d03b63d..42224eb7083e4e8fc92bf8627418ec6d55786caf 100644 (file)
@@ -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; }
index 819b2949ea876164182b33b479077ee300b582f6..decff17f1e517f91ad0015f6d473637064514f3c 100644 (file)
@@ -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());
        }
index 6873a29df96bf6729583958d3e0627871fa56e4e..aafb084a40bf614e09d5001277f52c5a4b2ca423 100644 (file)
@@ -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)