From cff8a65db2c1dc7c96e9591370d01f8da5b1f324 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 17 Oct 2012 14:36:40 +0000 Subject: forward part the backend part of the generic MIDI control fixes from mb2/a2 git-svn-id: svn://localhost/ardour2/branches/3.0@13297 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/control_protocol_manager.cc | 82 ++++++++++++++------------------- 1 file changed, 35 insertions(+), 47 deletions(-) (limited to 'libs/ardour/control_protocol_manager.cc') diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 8611447a93..64876b1d5f 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -139,6 +139,8 @@ ControlProtocolManager::instantiate (ControlProtocolInfo& cpi) control_protocols.push_back (cpi.protocol); + ProtocolStatusChange (&cpi); + return cpi.protocol; } @@ -173,6 +175,9 @@ ControlProtocolManager::teardown (ControlProtocolInfo& cpi) delete cpi.state; cpi.state = 0; dlclose (cpi.descriptor->module); + + ProtocolStatusChange (&cpi); + return 0; } @@ -326,30 +331,43 @@ ControlProtocolManager::set_state (const XMLNode& node, int /*version*/) for (citer = clist.begin(); citer != clist.end(); ++citer) { if ((*citer)->name() == X_("Protocol")) { - prop = (*citer)->property (X_("active")); - - if (prop && string_is_affirmative (prop->value())) { - if ((prop = (*citer)->property (X_("name"))) != 0) { - ControlProtocolInfo* cpi = cpi_by_name (prop->value()); - - if (cpi) { - - if (cpi->state) { - delete cpi->state; - } + if ((prop = (*citer)->property (X_("active"))) == 0) { + continue; + } - cpi->state = new XMLNode (**citer); + bool active = string_is_affirmative (prop->value()); + + if ((prop = (*citer)->property (X_("name"))) == 0) { + continue; + } - if (_session) { - instantiate (*cpi); - } else { - cpi->requested = true; - } + ControlProtocolInfo* cpi = cpi_by_name (prop->value()); + + if (cpi) { + + if (!(*citer)->children().empty()) { + cpi->state = new XMLNode (*((*citer)->children().front ())); + } else { + cpi->state = 0; + } + + if (active) { + if (_session) { + instantiate (*cpi); + } else { + cpi->requested = true; + } + } else { + if (_session) { + teardown (*cpi); + } else { + cpi->requested = false; } } } } } + return 0; } @@ -382,36 +400,6 @@ ControlProtocolManager::get_state () return *root; } -void -ControlProtocolManager::set_protocol_states (const XMLNode& node) -{ - XMLNodeList nlist; - XMLNodeConstIterator niter; - XMLProperty* prop; - - nlist = node.children(); - - for (niter = nlist.begin(); niter != nlist.end(); ++niter) { - - XMLNode* child = (*niter); - - if ((prop = child->property ("name")) == 0) { - error << _("control protocol XML node has no name property. Ignored.") << endmsg; - continue; - } - - ControlProtocolInfo* cpi = cpi_by_name (prop->value()); - - if (!cpi) { - warning << string_compose (_("control protocol \"%1\" is not known. Ignored"), prop->value()) << endmsg; - continue; - } - - /* copy the node so that ownership is clear */ - - cpi->state = new XMLNode (*child); - } -} ControlProtocolManager& ControlProtocolManager::instance () -- cgit v1.2.3