commit c960713e9b8430d9b790a7e27ec618356e248478
parent 3b0e211395938637fa647414914d5ec2cedf7093
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date: Fri, 16 Jul 2021 18:29:40 +0200
Add an invalidation mechanism for the plugin entries
Diffstat:
2 files changed, 43 insertions(+), 7 deletions(-)
diff --git a/examples/plugins/clap-entry.cc b/examples/plugins/clap-entry.cc
@@ -37,9 +37,9 @@ static bool clap_init(const char *plugin_path) {
static void clap_deinit(void) { g_plugins.clear(); }
-static int32_t clap_get_plugin_count(void) { return g_plugins.size(); }
+static uint32_t clap_get_plugin_count(void) { return g_plugins.size(); }
-static const clap_plugin_descriptor *clap_get_plugin_descriptor(int32_t index) {
+static const clap_plugin_descriptor *clap_get_plugin_descriptor(uint32_t index) {
if (index < 0 || index >= g_plugins.size()) {
std::ostringstream msg;
msg << "index out of bounds: " << index << " not in 0.." << g_plugins.size();
@@ -56,10 +56,23 @@ static const clap_plugin *clap_create_plugin(const clap_host *host, const char *
return nullptr;
}
+static uint32_t clap_get_invalidation_sources_count(void)
+{
+ return 0;
+}
+
+static const clap_plugin_invalidation_source *get_invalidation_sources(uint32_t index)
+{
+ return nullptr;
+}
+
CLAP_EXPORT const struct clap_plugin_entry clap_plugin_entry = {
+ CLAP_VERSION,
clap_init,
clap_deinit,
clap_get_plugin_count,
clap_get_plugin_descriptor,
clap_create_plugin,
+ clap_get_invalidation_sources_count,
+ get_invalidation_sources,
};
\ No newline at end of file
diff --git a/include/clap/clap.h b/include/clap/clap.h
@@ -208,22 +208,38 @@ typedef struct clap_plugin {
// ENTRY POINT //
/////////////////
-/* This interface is the entry point of the dynamic library.
- *
- * Every methods must be thread-safe. */
+typedef struct clap_plugin_invalidation_source {
+ // Directory containing the file(s) to scan
+ const char *directory;
+
+ // globing pattern, in the form *.dll
+ const char *filename_glob;
+
+ // should the directory be scanned recursively?
+ bool recursive_scan;
+} clap_plugin_invalidation_source;
+
+// This interface is the entry point of the dynamic library.
+// There is an invalidation mechanism for the set of plugins which is based on files.
+// The host can watch the plugin DSO's mtime and a set of files's mtime provided by
+// get_clap_invalidation_source().
+//
+// Every methods must be thread-safe.
struct clap_plugin_entry {
+ clap_version clap_version; // initialized to CLAP_VERSION
+
bool (*init)(const char *plugin_path);
void (*deinit)(void);
/* Get the number of plugins available.
* [thread-safe] */
- int32_t (*get_plugin_count)(void);
+ uint32_t (*get_plugin_count)(void);
/* Retrieves a plugin descriptor by its index.
* Returns null in case of error.
* The descriptor does not need to be freed.
* [thread-safe] */
- const clap_plugin_descriptor *(*get_plugin_descriptor)(int32_t index);
+ const clap_plugin_descriptor *(*get_plugin_descriptor)(uint32_t index);
/* Create a clap_plugin by its plugin_id.
* The returned pointer must be freed by calling plugin->destroy(plugin);
@@ -231,6 +247,13 @@ struct clap_plugin_entry {
* Returns null in case of error.
* [thread-safe] */
const clap_plugin *(*create_plugin)(const clap_host *host, const char *plugin_id);
+
+ // Get the number of invalidation sources.
+ uint32_t (*get_invalidation_sources_count)(void);
+
+ // Get the invalidation source by its index.
+ // [thread-safe]
+ const clap_plugin_invalidation_source *(*get_invalidation_sources)(uint32_t index);
};
/* Entry point */