13
0

changes associated with save/restore of AutomationControl id's

git-svn-id: svn://localhost/ardour2/branches/3.0@8111 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2010-11-27 17:43:32 +00:00
parent 979a61eb3f
commit 7cbcf258cc
4 changed files with 25 additions and 8 deletions

View File

@ -36,6 +36,7 @@ PBD::Signal1<void,Controllable*> Controllable::DeleteBinding;
Glib::StaticRWLock Controllable::registry_lock = GLIBMM_STATIC_RW_LOCK_INIT;
Controllable::Controllables Controllable::registry;
PBD::ScopedConnectionList registry_connections;
const std::string Controllable::xml_node_name = X_("Controllable");
Controllable::Controllable (const string& name, Flag f)
: _name (name)
@ -100,13 +101,15 @@ Controllable::by_name (const string& str)
XMLNode&
Controllable::get_state ()
{
XMLNode* node = new XMLNode (X_("Controllable"));
XMLNode* node = new XMLNode (xml_node_name);
char buf[64];
node->add_property (X_("name"), _name); // not reloaded from XML state, just there to look at
_id.print (buf, sizeof (buf));
node->add_property (X_("id"), buf);
node->add_property (X_("flags"), enum_2_string (_flags));
snprintf (buf, sizeof (buf), "%2.12f", get_value());
node->add_property (X_("value"), buf);
return *node;
}
@ -127,6 +130,14 @@ Controllable::set_state (const XMLNode& node, int /*version*/)
if ((prop = node.property (X_("flags"))) != 0) {
_flags = (Flag) string_2_enum (prop->value(), _flags);
}
if ((prop = node.property (X_("value"))) != 0) {
float val;
if (sscanf (prop->value().c_str(), "%f", &val) == 1) {
set_value (val);
}
}
}
void

View File

@ -82,7 +82,7 @@ class Controllable : public PBD::StatefulDestructible {
static Controllable* by_id (const PBD::ID&);
static Controllable* by_name (const std::string&);
static const std::string xml_node_name;
private:
std::string _name;

View File

@ -450,7 +450,7 @@ GenericMidiControlProtocol::get_state ()
node->add_property ("binding", _current_binding);
}
XMLNode* children = new XMLNode (X_("controls"));
XMLNode* children = new XMLNode (X_("Controls"));
node->add_child_nocopy (*children);
@ -504,7 +504,7 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version)
{
Glib::Mutex::Lock lm2 (controllables_lock);
controllables.clear ();
nlist = node.children(); // "controls"
nlist = node.children(); // "Controls"
if (nlist.empty()) {
return 0;
@ -515,13 +515,17 @@ GenericMidiControlProtocol::set_state (const XMLNode& node, int version)
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
if ((prop = (*niter)->property ("id")) != 0) {
cerr << "Looking for MIDI Controllable with ID " << prop->value() << endl;
ID id = prop->value ();
c = session->controllable_by_id (id);
Controllable* c = Controllable::by_id (id);
cerr << "\tresult = " << c << endl;
if (c) {
MIDIControllable* mc = new MIDIControllable (*_input_port, *c, false);
if (mc->set_state (**niter, version) == 0) {
controllables.push_back (mc);
}

View File

@ -430,9 +430,11 @@ MIDIControllable::get_state ()
XMLNode* node = new XMLNode ("MIDIControllable");
if (!_current_uri.empty()) {
if (_current_uri.empty()) {
node->add_property ("id", controllable->id().to_s());
} else {
node->add_property ("uri", _current_uri);
}
}
if (controllable) {
snprintf (buf, sizeof(buf), "0x%x", (int) control_type);