summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/instance.c72
-rw-r--r--src/suil_internal.h25
-rw-r--r--src/uis.c105
-rw-r--r--suil/suil.h55
-rw-r--r--wscript2
5 files changed, 69 insertions, 190 deletions
diff --git a/src/instance.c b/src/instance.c
index a56a11f..4cb835d 100644
--- a/src/instance.c
+++ b/src/instance.c
@@ -51,8 +51,8 @@ struct _SuilModule {
typedef struct _SuilModule* SuilModule;
static SuilModule
-get_wrap_module(const char* host_type_uri,
- const char* ui_type_uri)
+get_wrap_module(const char* host_type_uri,
+ const char* ui_type_uri)
{
if (!strcmp(host_type_uri, ui_type_uri)) {
return NULL;
@@ -101,32 +101,22 @@ get_wrap_module(const char* host_type_uri,
SUIL_API
SuilInstance
-suil_instance_new(SuilUIs uis,
- const char* type_uri,
+suil_instance_new(const char* plugin_uri,
const char* ui_uri,
+ const char* ui_bundle_path,
+ const char* ui_binary_path,
+ const char* ui_type_uri,
+ const char* host_type_uri,
LV2UI_Write_Function write_function,
LV2UI_Controller controller,
const LV2_Feature* const* features)
{
- // Find the UI to use
- SuilUI ui = NULL;
- if (ui_uri) {
- ui = suil_uis_get(uis, ui_uri);
- } else {
- ui = suil_uis_get_best(uis, type_uri);
- }
- if (!ui) {
- SUIL_ERRORF("No suitable UI found for <%s>\n",
- suil_uis_get_plugin_uri(uis));
- return NULL;
- }
-
// Open UI library
dlerror();
- void* lib = dlopen(ui->binary_path, RTLD_NOW);
+ void* lib = dlopen(ui_binary_path, RTLD_NOW);
if (!lib) {
SUIL_ERRORF("Unable to open UI library %s (%s)\n",
- ui->binary_path, dlerror());
+ ui_binary_path, dlerror());
return NULL;
}
@@ -135,7 +125,7 @@ suil_instance_new(SuilUIs uis,
suil_dlfunc(lib, "lv2ui_descriptor");
if (!df) {
SUIL_ERRORF("Broken LV2 UI %s (no lv2ui_descriptor symbol found)\n",
- ui->binary_path);
+ ui_binary_path);
dlclose(lib);
return NULL;
}
@@ -144,14 +134,14 @@ suil_instance_new(SuilUIs uis,
const LV2UI_Descriptor* descriptor = NULL;
for (uint32_t i = 0; true; ++i) {
const LV2UI_Descriptor* ld = df(i);
- if (!strcmp(ld->URI, ui->uri)) {
+ if (!strcmp(ld->URI, ui_uri)) {
descriptor = ld;
break;
}
}
if (!descriptor) {
SUIL_ERRORF("Failed to find descriptor for <%s> in %s\n",
- ui->uri, ui->binary_path);
+ ui_uri, ui_binary_path);
dlclose(lib);
return NULL;
}
@@ -163,9 +153,9 @@ suil_instance_new(SuilUIs uis,
features = (const LV2_Feature* const*)&local_features;
}
- SuilModule module = get_wrap_module(type_uri, ui->type_uri);
+ SuilModule module = get_wrap_module(host_type_uri, ui_type_uri);
if (module) {
- module->init(type_uri, ui->type_uri, features);
+ module->init(host_type_uri, ui_type_uri, features);
}
// Instantiate UI
@@ -176,8 +166,8 @@ suil_instance_new(SuilUIs uis,
instance->ui_widget = NULL;
instance->handle = descriptor->instantiate(
descriptor,
- uis->plugin_uri,
- ui->bundle_path,
+ plugin_uri,
+ ui_bundle_path,
write_function,
controller,
&instance->ui_widget,
@@ -186,7 +176,7 @@ suil_instance_new(SuilUIs uis,
// Failed to find or instantiate UI
if (!instance || !instance->handle) {
SUIL_ERRORF("Failed to instantiate UI <%s> in %s\n",
- ui->uri, ui->binary_path);
+ ui_uri, ui_binary_path);
free(instance);
dlclose(lib);
return NULL;
@@ -195,15 +185,15 @@ suil_instance_new(SuilUIs uis,
// Got a handle, but failed to create a widget (buggy UI)
if (!instance->ui_widget) {
SUIL_ERRORF("Widget creation failed for UI <%s> in %s\n",
- ui->uri, ui->binary_path);
+ ui_uri, ui_binary_path);
suil_instance_free(instance);
return NULL;
}
if (module) {
- if (module->wrap(type_uri, ui->type_uri, instance)) {
+ if (module->wrap(host_type_uri, ui_type_uri, instance)) {
SUIL_ERRORF("Failed to wrap UI <%s> in type <%s>\n",
- ui->uri, type_uri);
+ ui_uri, host_type_uri);
suil_instance_free(instance);
return NULL;
}
@@ -227,6 +217,20 @@ suil_instance_free(SuilInstance instance)
}
SUIL_API
+const LV2UI_Descriptor*
+suil_instance_get_descriptor(SuilInstance instance)
+{
+ return instance->descriptor;
+}
+
+SUIL_API
+LV2UI_Handle
+suil_instance_get_handle(SuilInstance instance)
+{
+ return instance->handle;
+}
+
+SUIL_API
LV2UI_Widget
suil_instance_get_widget(SuilInstance instance)
{
@@ -247,3 +251,11 @@ suil_instance_port_event(SuilInstance instance,
format,
buffer);
}
+
+SUIL_API
+const void*
+suil_instance_extension_data(SuilInstance instance,
+ const char* uri)
+{
+ return instance->descriptor->extension_data(uri);
+}
diff --git a/src/suil_internal.h b/src/suil_internal.h
index 23de999..26aade6 100644
--- a/src/suil_internal.h
+++ b/src/suil_internal.h
@@ -28,21 +28,6 @@
#define SUIL_ERRORF(fmt, ...) fprintf(stderr, "error: %s: " fmt, \
__func__, __VA_ARGS__)
-struct _SuilUI {
- char* uri;
- char* type_uri;
- char* bundle_path;
- char* binary_path;
-};
-
-typedef struct _SuilUI* SuilUI;
-
-struct _SuilUIs {
- char* plugin_uri;
- SuilUI* uis;
- unsigned n_uis;
-};
-
struct _SuilInstance {
void* lib_handle;
const LV2UI_Descriptor* descriptor;
@@ -51,16 +36,6 @@ struct _SuilInstance {
LV2UI_Widget host_widget;
};
-/** Get the UI with the given URI. */
-SuilUI
-suil_uis_get(SuilUIs uis,
- const char* ui_uri);
-
-/** Get the best UI for the given type. */
-SuilUI
-suil_uis_get_best(SuilUIs uis,
- const char* type_uri);
-
/** Type of a module's suil_wrap_init function.
* This initialisation function must be called before instantiating any
* UI that will need to be wrapped by this wrapper (e.g. it will perform any
diff --git a/src/uis.c b/src/uis.c
deleted file mode 100644
index 2ba234a..0000000
--- a/src/uis.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/* Suil, an LV2 plugin UI hosting library.
- * Copyright 2011 David Robillard <d@drobilla.net>
- *
- * Suil is free software: you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Suil is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
- * License for details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#define _XOPEN_SOURCE 500
-
-#include <string.h>
-
-#include "suil_internal.h"
-
-SUIL_API
-SuilUIs
-suil_uis_new(const char* plugin_uri)
-{
- SuilUIs uis = (SuilUIs)malloc(sizeof(struct _SuilUIs));
- uis->plugin_uri = strdup(plugin_uri);
- uis->uis = malloc(sizeof(SuilUI));
- uis->uis[0] = (SuilUI)NULL;
- uis->n_uis = 0;
- return uis;
-}
-
-SUIL_API
-void
-suil_uis_free(SuilUIs uis)
-{
- free(uis->plugin_uri);
- free(uis);
-}
-
-SUIL_API
-const char*
-suil_uis_get_plugin_uri(SuilUIs uis)
-{
- return uis->plugin_uri;
-}
-
-SUIL_API
-SuilUI
-suil_uis_get(SuilUIs uis,
- const char* ui_uri)
-{
- for (unsigned i = 0; i < uis->n_uis; ++i) {
- if (!strcmp(uis->uis[i]->uri, ui_uri)) {
- return uis->uis[i];
- }
- }
- return NULL;
-}
-
-SUIL_API
-SuilUI
-suil_uis_get_best(SuilUIs uis,
- const char* type_uri)
-{
- // Check for an exact type match
- for (unsigned i = 0; i < uis->n_uis; ++i) {
- if (!strcmp(uis->uis[i]->type_uri, type_uri)) {
- return uis->uis[i];
- }
- }
-
- // No exact match, use the first supported UI
- for (unsigned i = 0; i < uis->n_uis; ++i) {
- if (suil_ui_type_supported(type_uri, uis->uis[i]->type_uri)) {
- return uis->uis[i];
- }
- }
-
- return NULL;
-}
-
-SUIL_API
-void
-suil_uis_add(SuilUIs uis,
- const char* uri,
- const char* type_uri,
- const char* bundle_path,
- const char* binary_path)
-{
- SuilUI ui = (SuilUI)malloc(sizeof(struct _SuilUI));
- ui->uri = strdup(uri);
- ui->type_uri = strdup(type_uri);
- ui->bundle_path = strdup(bundle_path);
- ui->binary_path = strdup(binary_path);
-
- ++uis->n_uis;
- uis->uis = realloc(uis->uis, sizeof(SuilUI) * (uis->n_uis + 1));
- assert(uis->uis[uis->n_uis - 1] == NULL);
- uis->uis[uis->n_uis - 1] = ui;
- uis->uis[uis->n_uis] = NULL;
-}
diff --git a/suil/suil.h b/suil/suil.h
index f5e5584..2e1bb4c 100644
--- a/suil/suil.h
+++ b/suil/suil.h
@@ -53,9 +53,6 @@ extern "C" {
* @{
*/
-/** A set of UIs for a particular LV2 plugin. */
-typedef struct _SuilUIs* SuilUIs;
-
/** An instance of an LV2 plugin UI. */
typedef struct _SuilInstance* SuilInstance;
@@ -69,30 +66,6 @@ bool
suil_ui_type_supported(const char* host_type_uri,
const char* ui_type_uri);
-/** Create a new empty set of UIs for a particular LV2 plugin. */
-SUIL_API
-SuilUIs
-suil_uis_new(const char* plugin_uri);
-
-/** Free @a uis. */
-SUIL_API
-void
-suil_uis_free(SuilUIs uis);
-
-/** Return the URI of the plugin this set of UIs is for. */
-SUIL_API
-const char*
-suil_uis_get_plugin_uri(SuilUIs uis);
-
-/** Add a discovered UI to @a uis. */
-SUIL_API
-void
-suil_uis_add(SuilUIs uis,
- const char* uri,
- const char* type_uri,
- const char* bundle_path,
- const char* binary_path);
-
/** Instantiate a UI for an LV2 plugin.
* @param uis Set of available UIs for the plugin.
* @param type_uri URI of the desired widget type.
@@ -105,9 +78,12 @@ suil_uis_add(SuilUIs uis,
*/
SUIL_API
SuilInstance
-suil_instance_new(SuilUIs uis,
- const char* type_uri,
+suil_instance_new(const char* plugin_uri,
const char* ui_uri,
+ const char* ui_bundle_path,
+ const char* ui_binary_path,
+ const char* ui_type_uri,
+ const char* host_type_uri,
LV2UI_Write_Function write_function,
LV2UI_Controller controller,
const LV2_Feature* const* features);
@@ -120,6 +96,20 @@ SUIL_API
void
suil_instance_free(SuilInstance instance);
+/** Get the LV2UI_Descriptor of a UI instance.
+ * This function should not be needed under normal circumstances.
+ */
+SUIL_API
+const LV2UI_Descriptor*
+suil_instance_get_descriptor(SuilInstance instance);
+
+/** Get the LV2UI_Handle of a UI instance.
+ * This function should not be needed under normal circumstances.
+ */
+SUIL_API
+LV2UI_Handle
+suil_instance_get_handle(SuilInstance instance);
+
/** Get the widget for a UI instance.
* Returns an opaque pointer to a widget, the type of which is defined by the
* corresponding parameter to suil_instantiate. Note this may be a wrapper
@@ -140,6 +130,13 @@ suil_instance_port_event(SuilInstance instance,
uint32_t format,
const void* buffer);
+/** Return a data structure defined by some LV2 extension URI.
+ */
+SUIL_API
+const void*
+suil_instance_extension_data(SuilInstance instance,
+ const char* uri);
+
/** @} */
#ifdef __cplusplus
diff --git a/wscript b/wscript
index ca32446..593c4f9 100644
--- a/wscript
+++ b/wscript
@@ -69,7 +69,7 @@ def build(bld):
# Library
obj = bld(features = 'c cshlib')
obj.export_includes = ['.']
- obj.source = 'src/instance.c src/uis.c'
+ obj.source = 'src/instance.c'
obj.target = 'suil'
obj.includes = ['.']
obj.name = 'libsuil'