From 851d1fa76a4b9a67b5890ea36380029eaa1fb45f Mon Sep 17 00:00:00 2001 From: Jesse Chappell Date: Thu, 18 Jan 2007 06:39:22 +0000 Subject: [PATCH] Fixed midi controllable state saving/loading git-svn-id: svn://localhost/ardour2/trunk@1356 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/session.h | 1 - libs/ardour/control_protocol_manager.cc | 23 +++++++++++++++++++---- libs/ardour/io.cc | 6 ++++-- libs/ardour/panner.cc | 7 ++++--- libs/ardour/route.cc | 18 ++++++++++++------ libs/ardour/session_state.cc | 14 +------------- 6 files changed, 40 insertions(+), 29 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ae4a64802f..92687c7dc0 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1697,7 +1697,6 @@ class Session : public PBD::StatefulDestructible void config_changed (const char*); - void add_control_protocol (const ControlProtocolInfo* const, XMLNode*); XMLNode& get_control_protocol_state (); }; diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index de177d0e3d..72f56794d7 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -324,10 +324,25 @@ ControlProtocolManager::get_state (void) Glib::Mutex::Lock lm (protocols_lock); for (list::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) { - XMLNode* child = new XMLNode (X_("Protocol")); - child->add_property (X_("name"), (*i)->name); - child->add_property (X_("active"), (*i)->protocol ? "yes" : "no"); - root->add_child_nocopy (*child); + + XMLNode * child; + + if ((*i)->protocol) { + child = &((*i)->protocol->get_state()); + child->add_property (X_("active"), "yes"); + // should we update (*i)->state here? probably. + root->add_child_nocopy (*child); + } + else if ((*i)->state) { + // keep ownership clear + root->add_child_copy (*(*i)->state); + } + else { + child = new XMLNode (X_("Protocol")); + child->add_property (X_("name"), (*i)->name); + child->add_property (X_("active"), "no"); + root->add_child_nocopy (*child); + } } return *root; diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index b4d9db97eb..5e99a14fad 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -1634,8 +1634,10 @@ IO::set_state (const XMLNode& node) set_automation_state (*(*iter)->children().front()); } - if ((*iter)->name() == X_("gaincontrol")) { - _gain_control.set_state (**iter); + if ((*iter)->name() == X_("controllable")) { + if ((prop = (*iter)->property("name")) != 0 && prop->value() == "gaincontrol") { + _gain_control.set_state (**iter); + } } } diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc index 97646d99cd..09974a9529 100644 --- a/libs/ardour/panner.cc +++ b/libs/ardour/panner.cc @@ -534,9 +534,10 @@ EqualPowerStereoPanner::set_state (const XMLNode& node) for (XMLNodeConstIterator iter = node.children().begin(); iter != node.children().end(); ++iter) { - if ((*iter)->name() == X_("panner")) { - - _control.set_state (**iter); + if ((*iter)->name() == X_("controllable")) { + if ((prop = (*iter)->property("name")) != 0 && prop->value() == "panner") { + _control.set_state (**iter); + } } else if ((*iter)->name() == X_("Automation")) { diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index a322c10068..d3097dd776 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -1687,13 +1687,19 @@ Route::_set_state (const XMLNode& node, bool call_base) _comment = cmt->content(); } else if (child->name() == X_("extra")) { + _extra_xml = new XMLNode (*child); - } else if (child->name() == X_("solo")) { - _solo_control.set_state (*child); - _session.add_controllable (&_solo_control); - } else if (child->name() == X_("mute")) { - _mute_control.set_state (*child); - _session.add_controllable (&_mute_control); + + } else if (child->name() == X_("controllable") && (prop = child->property("name")) != 0) { + + if (prop->value() == "solo") { + _solo_control.set_state (*child); + _session.add_controllable (&_solo_control); + } + else if (prop->value() == "mute") { + _mute_control.set_state (*child); + _session.add_controllable (&_mute_control); + } } } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1f8d20e16a..3b66f65cec 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1040,19 +1040,7 @@ XMLNode& Session::get_control_protocol_state () { ControlProtocolManager& cpm (ControlProtocolManager::instance()); - XMLNode* node = new XMLNode (X_("ControlProtocols")); - - cpm.foreach_known_protocol (bind (mem_fun (*this, &Session::add_control_protocol), node)); - - return *node; -} - -void -Session::add_control_protocol (const ControlProtocolInfo* const cpi, XMLNode* node) -{ - if (cpi->protocol) { - node->add_child_nocopy (cpi->protocol->get_state()); - } + return cpm.get_state(); } int