diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2016-02-29 18:12:13 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2016-05-31 15:30:38 -0400 |
commit | 4d14ae4e23bc58e356dcda387213d0ba4ab6364b (patch) | |
tree | cbc6fe9183a5dfe6deadb66fa1b496301afeec01 /libs/ardour | |
parent | d2c405416c0c86d01f8b701ad2781e53d87410ae (diff) |
mostly restore VCA state on session loading.
This does not restore VCA assignments
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/vca.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/vca_manager.h | 6 | ||||
-rw-r--r-- | libs/ardour/vca.cc | 29 | ||||
-rw-r--r-- | libs/ardour/vca_manager.cc | 44 |
4 files changed, 75 insertions, 8 deletions
diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h index b168a8cef9..a4da21e31f 100644 --- a/libs/ardour/ardour/vca.h +++ b/libs/ardour/ardour/vca.h @@ -25,6 +25,7 @@ #include "pbd/controllable.h" #include "pbd/statefuldestructible.h" +#include "ardour/automatable.h" #include "ardour/session_handle.h" namespace ARDOUR { @@ -32,9 +33,10 @@ namespace ARDOUR { class GainControl; class Route; -class LIBARDOUR_API VCA : public SessionHandleRef, public PBD::StatefulDestructible { +class LIBARDOUR_API VCA : public SessionHandleRef, public PBD::StatefulDestructible, public Automatable { public: VCA (Session& session, const std::string& name, uint32_t num); + VCA (Session& session, XMLNode const&, int version); std::string name() const { return _name; } uint32_t number () const { return _number; } diff --git a/libs/ardour/ardour/vca_manager.h b/libs/ardour/ardour/vca_manager.h index 10e76db860..4e5b54f438 100644 --- a/libs/ardour/ardour/vca_manager.h +++ b/libs/ardour/ardour/vca_manager.h @@ -48,8 +48,7 @@ class VCAManager : public SessionHandleRef, public PBD::StatefulDestructible boost::shared_ptr<VCA> vca_by_number(uint32_t) const; - typedef std::list<boost::shared_ptr<VCA> > VCAS; - VCAS vcas() const; + VCAList vcas() const; PBD::Signal1<void,VCAList&> VCAAdded; PBD::Signal1<void,VCAList&> VCARemoved; @@ -61,8 +60,9 @@ class VCAManager : public SessionHandleRef, public PBD::StatefulDestructible private: mutable Glib::Threads::Mutex lock; - VCAS _vcas; + VCAList _vcas; + void clear (); }; } // namespace diff --git a/libs/ardour/vca.cc b/libs/ardour/vca.cc index f4737e433a..9ae0c5a2dc 100644 --- a/libs/ardour/vca.cc +++ b/libs/ardour/vca.cc @@ -47,10 +47,23 @@ VCA::next_vca_number () VCA::VCA (Session& s, const string& name, uint32_t num) : SessionHandleRef (s) + , Automatable (s) , _number (num) , _name (name) , _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ())) { + add_control (_control); +} + +VCA::VCA (Session& s, XMLNode const & node, int version) + : SessionHandleRef (s) + , Automatable (s) + , _number (0) + , _control (new GainControl (s, Evoral::Parameter (GainAutomation), boost::shared_ptr<AutomationList> ())) +{ + add_control (_control); + + set_state (node, version); } void @@ -90,11 +103,15 @@ VCA::get_state () XMLNode* node = new XMLNode (xml_node_name); node->add_property (X_("name"), _name); node->add_property (X_("number"), _number); + + node->add_child_nocopy (_control->get_state()); + node->add_child_nocopy (get_automation_xml_state()); + return *node; } int -VCA::set_state (XMLNode const& node, int /*version*/) +VCA::set_state (XMLNode const& node, int version) { XMLProperty const* prop; @@ -106,5 +123,15 @@ VCA::set_state (XMLNode const& node, int /*version*/) _number = atoi (prop->value()); } + XMLNodeList const &children (node.children()); + for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { + if ((*i)->name() == Controllable::xml_node_name) { + XMLProperty* prop = (*i)->property ("name"); + if (prop && prop->value() == X_("gaincontrol")) { + _control->set_state (**i, version); + } + } + } + return 0; } diff --git a/libs/ardour/vca_manager.cc b/libs/ardour/vca_manager.cc index 7cef8e932c..a707a9223e 100644 --- a/libs/ardour/vca_manager.cc +++ b/libs/ardour/vca_manager.cc @@ -38,11 +38,17 @@ VCAManager::VCAManager (Session& s) VCAManager::~VCAManager () { + clear (); +} + +void +VCAManager::clear () +{ Mutex::Lock lm (lock); _vcas.clear (); } -VCAManager::VCAS +VCAList VCAManager::vcas () const { Mutex::Lock lm (lock); @@ -99,7 +105,7 @@ VCAManager::vca_by_number (uint32_t n) const { Mutex::Lock lm (lock); - for (VCAS::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) { + for (VCAList::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) { if ((*i)->number() == n) { return *i; } @@ -112,11 +118,43 @@ XMLNode& VCAManager::get_state () { XMLNode* node = new XMLNode (xml_node_name); + + { + Mutex::Lock lm (lock); + + for (VCAList::const_iterator i = _vcas.begin(); i != _vcas.end(); ++i) { + node->add_child_nocopy ((*i)->get_state()); + } + } + return *node; } int -VCAManager::set_state (XMLNode const& node, int /*version*/) +VCAManager::set_state (XMLNode const& node, int version) { + if (node.name() != xml_node_name) { + return -1; + } + + XMLNodeList const & children = node.children(); + VCAList vcal; + + { + + Mutex::Lock lm (lock); + + for (XMLNodeList::const_iterator i = children.begin(); i != children.end(); ++i) { + if ((*i)->name() == VCA::xml_node_name) { + std::cerr << "Adding VCA from XML\n"; + boost::shared_ptr<VCA> vca = boost::shared_ptr<VCA> (new VCA (_session, **i, version)); + _vcas.push_back (vca); + vcal.push_back (vca); + } + } + } + + VCAAdded (vcal); /* EMIT SIGNAL */ + return 0; } |