save+restore VCA counter value across instances

This commit is contained in:
Paul Davis
2016-03-07 16:25:50 -05:00
parent 1132d3f4c8
commit 0dca11cb47
3 changed files with 25 additions and 3 deletions

View 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; }

View 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());
}

View 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)