13
0

mostly restore VCA state on session loading.

This does not restore VCA assignments
This commit is contained in:
Paul Davis 2016-02-29 18:12:13 -05:00
parent d2c405416c
commit 4d14ae4e23
7 changed files with 84 additions and 10 deletions

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

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

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

View 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

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

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

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