Closed abique closed 1 year ago
Below is my suggestion for reworking this extension as I described earlier.
The benefits here is that the API is much simpler than a full dictionary style interface, while still allowing future CLAP versions to add new properties without requiring a new extension. The host also does not need to provide all track information like it would need to in the current draft for this extension.
If hosts want to provide their own third party track information, then they can simply define their own extension in a similar style. Using an enum here makes the implementation and usage simpler than having to compare strings everywhere. Another benefit of this approach is that it makes it very clear to plugins whether this third party track information is being provided or not. Since this API is only a single line get function, I think trying to deduplicate this interface by factoring it out into a generic dictionary style API only makes things more complicated. And with the API as suggested in this PR it's also possible for plugins to modify the track information, which is probably not intended.
After sometime thinking about I see two options:
@robbert-vdh I don't see the benefit of having a property style approach but exclusive to the track-info. It is likely that the properties may be needed for other things later and having a single implementation for properties makes everything uniform (you learn once the interface to query properties, and you implement only once the properties interface. By the way a dictionnary can have read-only properties and reject the set operation on some keys.
I think the property style approach has a weakness:
void*
and size_t
will lead to type error and other problems Something that could be in line with the original approach and what @robbert-vdh proposed:
// This is the initial track info
struct track_info0 {
// attrs
};
// Additionnal info came in a later version of clap
struct track_info1 {
// attrs
};
// Additionnal info came in a later version of clap again
struct track_info2 {
// attrs
};
track_info0 info0;
track_info1 info1;
track_info2 info2;
host_track_info->get(host, 0, &info0);
host_track_info->get(host, 1, &info1);
host_track_info->get(host, 2, &info2);
This avoid doing many low level conversion to int, double, ...
I think the property style approach has a weakness:
* it is complicate and not in line with the "simplicity" we're used to
In my opinion a generic key-value store complicates things even further. The main problems are that you now a) don't know which keys exist, b) third party hosts can and will define their own keys, something CLAP normally would use third party extensions for. This would be the same as the IInfoListener
in VST3 and having used that it complicates the interface a lot. An enum with the possible info types simplifies the interface for both the plugin and the host.
* it opens many questions, what if a int64 is queried with a pointer to 4 bytes, do you implicitly convert to int32 and let the query succeed? * passing `void*` and `size_t` will lead to type error and other problems
The types and sizes are properly documented. That's the reason why I proposed a clap_track_info_type
argument in the first place. That argument adds another layer of verification. If you pass a wrong size and/or the wrong type argument for the property, the host returns an error code. That is in fact exactly the same as the generic dictionary interface from this PR, but with the types and properties determined by enums instead of strings to make it simpler to use and to encourage creating another extension if someone needs more context data. Just like we encourage creating additional factory types when a plugin may need to expose more static data during plugin scanning.
CLAP_INVALID_ID
do the job