diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-05 01:49:32 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2006-10-05 01:49:32 +0000 |
commit | ffdf5ada616d285fafb58f45c2e3d37b212a328a (patch) | |
tree | eb4fa2dcd1db72bcbeffebf86fc40a3cf30cf4be /libs/ardour/control_protocol_manager.cc | |
parent | 5ad68cf2c5a7df68b7cc3a3d5a4f76f03a54c32e (diff) |
Generic MIDI control now saves+restores its state; PBD::ID now requires a buffer size for its print() method
git-svn-id: svn://localhost/ardour2/trunk@949 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/control_protocol_manager.cc')
-rw-r--r-- | libs/ardour/control_protocol_manager.cc | 48 |
1 files changed, 46 insertions, 2 deletions
diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc index 5c02936ba0..7170b45656 100644 --- a/libs/ardour/control_protocol_manager.cc +++ b/libs/ardour/control_protocol_manager.cc @@ -50,7 +50,7 @@ ControlProtocolManager::set_session (Session& s) instantiate (**i); (*i)->requested = false; - if ((*i)->state) { + if ((*i)->protocol && (*i)->state) { (*i)->protocol->set_state (*(*i)->state); } } @@ -93,6 +93,10 @@ ControlProtocolManager::instantiate (ControlProtocolInfo& cpi) Glib::Mutex::Lock lm (protocols_lock); control_protocols.push_back (cpi.protocol); + if (cpi.state) { + cpi.protocol->set_state (*cpi.state); + } + return cpi.protocol; } @@ -154,7 +158,7 @@ ControlProtocolManager::discover_control_protocols (string path) vector<string *> *found; PathScanner scanner; - cerr << "looking for control protocols in " << path << endl; + info << string_compose (_("looking for control protocols in %1"), path) << endmsg; found = scanner (path, protocol_filter, 0, false, true); @@ -261,11 +265,20 @@ ControlProtocolManager::set_state (const XMLNode& node) for (citer = clist.begin(); citer != clist.end(); ++citer) { if ((*citer)->name() == X_("Protocol")) { + prop = (*citer)->property (X_("active")); + if (prop && prop->value() == X_("yes")) { if ((prop = (*citer)->property (X_("name"))) != 0) { ControlProtocolInfo* cpi = cpi_by_name (prop->value()); if (cpi) { + + if (!(*citer)->children().empty()) { + cpi->state = (*citer)->children().front (); + } else { + cpi->state = 0; + } + if (_session) { instantiate (*cpi); } else { @@ -294,3 +307,34 @@ ControlProtocolManager::get_state (void) 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); + } +} |