summaryrefslogtreecommitdiff
path: root/libs/ardour/control_protocol_manager.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-04-24 22:45:19 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-04-24 22:45:19 +0000
commit028e1ebc4a392572cae586d0e9044a32b867cba4 (patch)
tree36d3a748486feb3f41575708bef8b153fef2cad4 /libs/ardour/control_protocol_manager.cc
parent484debb45c5ea45bccf0f9cb05b1239a9c2244a3 (diff)
a) completely refactor abstract UI code
b) single-thread Tranzport implementation c) implement BasicUI to share functionality across multiple controllers d) various minor fixes here and there git-svn-id: svn://localhost/trunk/ardour2@468 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/control_protocol_manager.cc')
-rw-r--r--libs/ardour/control_protocol_manager.cc69
1 files changed, 69 insertions, 0 deletions
diff --git a/libs/ardour/control_protocol_manager.cc b/libs/ardour/control_protocol_manager.cc
index 893124f0f5..ed33d0b6ee 100644
--- a/libs/ardour/control_protocol_manager.cc
+++ b/libs/ardour/control_protocol_manager.cc
@@ -15,6 +15,7 @@ using namespace std;
#include "i18n.h"
ControlProtocolManager* ControlProtocolManager::_instance = 0;
+const string ControlProtocolManager::state_node_name = X_("ControlProtocols");
ControlProtocolManager::ControlProtocolManager ()
{
@@ -42,6 +43,13 @@ ControlProtocolManager::set_session (Session& s)
{
_session = &s;
_session->going_away.connect (mem_fun (*this, &ControlProtocolManager::drop_session));
+
+ for (list<ControlProtocolInfo*>::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) {
+ if ((*i)->requested) {
+ instantiate (**i);
+ (*i)->requested = false;
+ }
+ }
}
void
@@ -122,6 +130,8 @@ ControlProtocolManager::discover_control_protocols (string path)
vector<string *> *found;
PathScanner scanner;
+ cerr << "looking for control protocols in " << path << endl;
+
found = scanner (path, protocol_filter, 0, false, true);
for (vector<string*>::iterator i = found->begin(); i != found->end(); ++i) {
@@ -145,9 +155,12 @@ ControlProtocolManager::control_protocol_discover (string path)
info->name = descriptor->name;
info->path = path;
info->protocol = 0;
+ info->requested = false;
control_protocol_info.push_back (info);
+ cerr << "discovered control surface protocol \"" << info->name << '"' << endl;
+
dlclose (descriptor->module);
}
@@ -195,3 +208,59 @@ ControlProtocolManager::foreach_known_protocol (sigc::slot<void,const ControlPro
method (*i);
}
}
+
+ControlProtocolInfo*
+ControlProtocolManager::cpi_by_name (string name)
+{
+ for (list<ControlProtocolInfo*>::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) {
+ if (name == (*i)->name) {
+ return *i;
+ }
+ }
+ return 0;
+}
+
+int
+ControlProtocolManager::set_state (const XMLNode& node)
+{
+ XMLNodeList clist;
+ XMLNodeConstIterator citer;
+ XMLProperty* prop;
+
+ clist = node.children();
+
+ for (citer = clist.begin(); citer != clist.end(); ++citer) {
+ if ((*citer)->name() == X_("Protocol")) {
+ if ((prop = (*citer)->property (X_("active"))) != 0) {
+ if (prop->value() == X_("yes")) {
+ if ((prop = (*citer)->property (X_("name"))) != 0) {
+ ControlProtocolInfo* cpi = cpi_by_name (prop->value());
+ if (cpi) {
+ if (_session) {
+ instantiate (*cpi);
+ } else {
+ cpi->requested = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+XMLNode&
+ControlProtocolManager::get_state (void)
+{
+ XMLNode* root = new XMLNode (state_node_name);
+ LockMonitor lm (protocols_lock, __LINE__, __FILE__);
+
+ for (list<ControlProtocolInfo*>::iterator i = control_protocol_info.begin(); i != control_protocol_info.end(); ++i) {
+ XMLNode* child = new XMLNode (X_("Protocol"));
+ child->add_property (X_("name"), (*i)->name);
+ child->add_property (X_("active"), (*i)->protocol ? "yes" : "no");
+ root->add_child_nocopy (*child);
+ }
+
+ return *root;
+}