mostly restore VCA state on session loading.
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 29 Feb 2016 23:12:13 +0000 (18:12 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 31 May 2016 19:30:38 +0000 (15:30 -0400)
This does not restore VCA assignments

gtk2_ardour/mixer_strip.cc
gtk2_ardour/mixer_ui.cc
libs/ardour/ardour/vca.h
libs/ardour/ardour/vca_manager.h
libs/ardour/vca.cc
libs/ardour/vca_manager.cc
libs/pbd/controllable.cc

index 591b4f42507f9106060f74d125dd85b7a2c19733..673bce61d1f3548eb79297ff2e6403d72e9fbda4 100644 (file)
@@ -2516,7 +2516,7 @@ MixerStrip::vca_button_release (GdkEventButton* ev, uint32_t which)
                return false;
        }
 
-       VCAManager::VCAS vcas (_session->vca_manager().vcas());
+       VCAList vcas (_session->vca_manager().vcas());
 
        if (vcas.empty()) {
                /* XXX should probably show a message saying "No VCA masters" */
@@ -2527,7 +2527,7 @@ MixerStrip::vca_button_release (GdkEventButton* ev, uint32_t which)
        MenuList& items = menu->items();
        RadioMenuItem::Group group;
 
-       for (VCAManager::VCAS::iterator v = vcas.begin(); v != vcas.end(); ++v) {
+       for (VCAList::iterator v = vcas.begin(); v != vcas.end(); ++v) {
                items.push_back (RadioMenuElem (group, (*v)->name(), sigc::bind (sigc::mem_fun (*this, &MixerStrip::vca_menu_toggle), (*v)->number())));
        }
 
index 3efb1ce0f1e9b1b669eb56fbf7eedcae75dcc323..f847678df809b0130b8d4bbe1179df49ffcf1337 100644 (file)
@@ -1286,6 +1286,8 @@ Mixer_UI::initial_track_display ()
                Unwinder<bool> uw2 (ignore_reorder, true);
 
                track_model->clear ();
+               VCAList vcas = _session->vca_manager().vcas();
+               add_masters (vcas);
                add_strips (copy);
        }
 
index b168a8cef9425798fc3e5dbb9bef97451a6c4bdc..a4da21e31f913d2541851d2ab0c85da923979ecc 100644 (file)
@@ -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; }
index 10e76db860a54cc3f1ea434097acff91d3f280b5..4e5b54f438edaf1b046a948d21338987edc0f45b 100644 (file)
@@ -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
index f4737e433a0e8f262dc94ffff95b3c6b24fe5fe6..9ae0c5a2dcaec879db0a7c2f57b455bdd35fecb1 100644 (file)
@@ -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;
 }
index 7cef8e932c1464af8e25ded54282d45fec0c5c4a..a707a9223e76681f72026250a31bb03a266fe4cd 100644 (file)
@@ -37,12 +37,18 @@ 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;
 }
index 6b92e84926332eebea63d2d7c8c7771e629e81d3..a4c097c3f0c215b994f4d7fed73b711456c7e36b 100644 (file)
@@ -22,6 +22,7 @@
 #include "pbd/xml++.h"
 #include "pbd/error.h"
 #include "pbd/locale_guard.h"
+#include "pbd/stacktrace.h"
 
 #include "i18n.h"
 
@@ -121,6 +122,10 @@ Controllable::get_state ()
 
        node->add_property (X_("name"), _name);
 
+       if (_name == "gaincontrol") {
+               PBD::stacktrace (cerr, 20);
+       }
+
        id().print (buf, sizeof (buf));
        node->add_property (X_("id"), buf);
        node->add_property (X_("flags"), enum_2_string (_flags));