diff options
author | Tim Mayberry <mojofunk@gmail.com> | 2016-08-25 15:55:51 +1000 |
---|---|---|
committer | Tim Mayberry <mojofunk@gmail.com> | 2017-04-19 09:36:49 +1000 |
commit | 74301a50635449a16a0d8f80d0f8880575b92f3b (patch) | |
tree | 1c1a3d9df89b02c1e4b5b052819192ca7f36108f /libs/ardour | |
parent | 070a73c975b40d875d46a749ea67545c8ff2a25c (diff) |
Use XMLNode::get/set_property in ARDOUR::LV2Plugin
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/lv2_plugin.cc | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 76dc734978..00353fb243 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -1298,21 +1298,19 @@ LV2Plugin::add_state(XMLNode* root) const assert(_insert_id != PBD::ID("0")); XMLNode* child; - char buf[32]; LocaleGuard lg; for (uint32_t i = 0; i < parameter_count(); ++i) { if (parameter_is_input(i) && parameter_is_control(i)) { child = new XMLNode("Port"); - child->add_property("symbol", port_symbol(i)); - snprintf(buf, sizeof(buf), "%+f", _shadow_data[i]); - child->add_property("value", string(buf)); + child->set_property("symbol", port_symbol(i)); + child->set_property("value", _shadow_data[i]); root->add_child_nocopy(*child); } } if (!_plugin_state_dir.empty()) { - root->add_property("template-dir", _plugin_state_dir); + root->set_property("template-dir", _plugin_state_dir); } if (_has_state_interface) { @@ -1368,7 +1366,7 @@ LV2Plugin::add_state(XMLNode* root) const saved_state = _state_version; } - root->add_property("state-dir", string_compose("state%1", saved_state)); + root->set_property("state-dir", string_compose("state%1", saved_state)); } } @@ -2004,12 +2002,8 @@ int LV2Plugin::set_state(const XMLNode& node, int version) { XMLNodeList nodes; - XMLProperty const * prop; XMLNodeConstIterator iter; XMLNode* child; - const char* sym; - const char* value; - uint32_t port_id; LocaleGuard lg; if (node.name() != state_node_name()) { @@ -2029,15 +2023,16 @@ LV2Plugin::set_state(const XMLNode& node, int version) child = *iter; - if ((prop = child->property("symbol")) != 0) { - sym = prop->value().c_str(); - } else { + std::string sym; + if (!child->get_property("symbol", sym)) { warning << _("LV2: port has no symbol, ignored") << endmsg; continue; } map<string, uint32_t>::iterator i = _port_indices.find(sym); + uint32_t port_id; + if (i != _port_indices.end()) { port_id = i->second; } else { @@ -2045,31 +2040,32 @@ LV2Plugin::set_state(const XMLNode& node, int version) continue; } - if ((prop = child->property("value")) != 0) { - value = prop->value().c_str(); - } else { + float val; + if (!child->get_property("value", val)) { warning << _("LV2: port has no value, ignored") << endmsg; continue; } - set_parameter(port_id, atof(value)); + set_parameter(port_id, val); } - if ((prop = node.property("template-dir")) != 0) { - set_state_dir (prop->value ()); + std::string template_dir; + if (node.get_property("template-dir", template_dir)) { + set_state_dir (template_dir); } _state_version = 0; - if ((prop = node.property("state-dir")) != 0) { - if (sscanf(prop->value().c_str(), "state%u", &_state_version) != 1) { + std::string state_dir; + if (node.get_property("state-dir", state_dir) != 0) { + if (sscanf(state_dir.c_str(), "state%u", &_state_version) != 1) { error << string_compose( "LV2: failed to parse state version from \"%1\"", - prop->value()) << endmsg; + state_dir) << endmsg; } std::string state_file = Glib::build_filename( plugin_dir(), - Glib::build_filename(prop->value(), "state.ttl")); + Glib::build_filename(state_dir, "state.ttl")); LilvState* state = lilv_state_new_from_file( _world.world, _uri_map.urid_map(), NULL, state_file.c_str()); |