LV2: keep track of supported properties
Register all plugin props that we may be interested in to _property_values, and later intercept all messages for registered properties (not just atom_Path).
This commit is contained in:
parent
cf0f1fd6c3
commit
c313b006cf
@ -2025,6 +2025,8 @@ LV2Plugin::load_supported_properties(PropertyDescriptors& descs)
|
|||||||
load_parameter_descriptor(_world, desc, datatype, prop);
|
load_parameter_descriptor(_world, desc, datatype, prop);
|
||||||
descs.insert(std::make_pair(desc.key, desc));
|
descs.insert(std::make_pair(desc.key, desc));
|
||||||
|
|
||||||
|
_property_values[desc.key] = Variant();
|
||||||
|
|
||||||
lilv_node_free(range);
|
lilv_node_free(range);
|
||||||
}
|
}
|
||||||
lilv_nodes_free(properties);
|
lilv_nodes_free(properties);
|
||||||
@ -2842,14 +2844,15 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||||||
_uri_map.urids.patch_value, &value,
|
_uri_map.urids.patch_value, &value,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (property && value &&
|
if (property && value && property->type == _uri_map.urids.atom_URID) {
|
||||||
property->type == _uri_map.urids.atom_URID &&
|
/* check if it's a property we know or care about */
|
||||||
value->type == _uri_map.urids.atom_Path) {
|
const uint32_t prop_id = ((const LV2_Atom_URID*)property)->body;
|
||||||
/* mark session (and preset) as modified */
|
if (_property_values.find (prop_id) != _property_values.end()) {
|
||||||
Plugin::state_changed ();
|
Plugin::state_changed ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
error << string_compose (_("LV2<%1>: Received unknown message type from UI"), name()) << endmsg;
|
error << string_compose (_("LV2<%1>: Received unknown message type from UI"), name()) << endmsg;
|
||||||
}
|
}
|
||||||
@ -3040,19 +3043,27 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
|
|||||||
_uri_map.urids.patch_value, &value,
|
_uri_map.urids.patch_value, &value,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (property && value &&
|
if (property && value && property->type == _uri_map.urids.atom_URID) {
|
||||||
property->type == _uri_map.urids.atom_URID &&
|
|
||||||
value->type == _uri_map.urids.atom_Path) {
|
|
||||||
const uint32_t prop_id = ((const LV2_Atom_URID*)property)->body;
|
const uint32_t prop_id = ((const LV2_Atom_URID*)property)->body;
|
||||||
|
if (_property_values.find (prop_id) != _property_values.end()) {
|
||||||
|
if (value->type == _uri_map.urids.atom_Path) {
|
||||||
const char* path = (const char*)LV2_ATOM_BODY_CONST(value);
|
const char* path = (const char*)LV2_ATOM_BODY_CONST(value);
|
||||||
|
|
||||||
// Emit PropertyChanged signal for UI
|
|
||||||
// TODO: This should emit the control's Changed signal
|
|
||||||
PropertyChanged(prop_id, Variant(Variant::PATH, path));
|
|
||||||
_property_values[prop_id] = Variant(Variant::PATH, path);
|
_property_values[prop_id] = Variant(Variant::PATH, path);
|
||||||
|
}
|
||||||
|
if (value->type == _uri_map.urids.atom_Float) {
|
||||||
|
const float* val = (float*)LV2_ATOM_BODY_CONST(value);
|
||||||
|
_property_values[prop_id] = Variant(Variant::FLOAT, *val);
|
||||||
|
}
|
||||||
|
// TODO add support for other props (Int, Bool, ..)
|
||||||
|
|
||||||
|
// TODO: This should emit the control's Changed signal
|
||||||
|
PropertyChanged(prop_id, _property_values[prop_id]);
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "warning: patch:Set for unknown property" << std::endl;
|
std::cerr << "warning: patch:Set for unknown property" << std::endl;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
std::cerr << "warning: patch:Set for unsupported property" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user