diff options
author | David Robillard <d@drobilla.net> | 2012-08-02 22:12:06 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-08-02 22:12:06 +0000 |
commit | 0bb37e7451f42fe82b28145455a71c56c92174b8 (patch) | |
tree | ade81993e9add2e2fdb64555af7a53a437386a79 | |
parent | 2f49d76d50c658eabd765245b51332924cd62147 (diff) | |
download | suil-0bb37e7451f42fe82b28145455a71c56c92174b8.tar.gz suil-0bb37e7451f42fe82b28145455a71c56c92174b8.tar.bz2 suil-0bb37e7451f42fe82b28145455a71c56c92174b8.zip |
Replace host provided features that match Suil implemented features, rather
than passing UIs duplicate features.
git-svn-id: http://svn.drobilla.net/lad/trunk/suil@4599 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | src/instance.c | 15 | ||||
-rw-r--r-- | src/suil_internal.h | 21 | ||||
-rw-r--r-- | src/x11_in_gtk2.c | 4 | ||||
-rw-r--r-- | src/x11_in_qt4.cpp | 4 | ||||
-rw-r--r-- | wscript | 2 |
6 files changed, 31 insertions, 19 deletions
@@ -1,8 +1,10 @@ suil (9999) unstable; * Gracefully handle UIs with no port_event method + * Replace host provided features that match Suil implemented features, rather + than passing UIs duplicate features - -- David Robillard <d@drobilla.net> Tue, 17 Jul 2012 23:16:19 -0400 + -- David Robillard <d@drobilla.net> Thu, 02 Aug 2012 18:08:43 -0400 suil (0.6.4) stable; diff --git a/src/instance.c b/src/instance.c index ca15ffe..5b53328 100644 --- a/src/instance.c +++ b/src/instance.c @@ -193,30 +193,31 @@ suil_instance_new(SuilHost* host, instance->features[0] = NULL; // Copy user provided features - unsigned n_features = 0; - for (; features && features[n_features]; ++n_features) { - const LV2_Feature* f = features[n_features]; - suil_add_feature(&instance->features, n_features, f->URI, f->data); + const LV2_Feature* const* fi = features; + unsigned n_features = 0; + while (fi && *fi) { + const LV2_Feature* f = *fi++; + suil_add_feature(&instance->features, &n_features, f->URI, f->data); } // Add additional features implemented by SuilHost functions if (host->index_func) { instance->port_map.handle = controller; instance->port_map.port_index = host->index_func; - suil_add_feature(&instance->features, n_features++, + suil_add_feature(&instance->features, &n_features, LV2_UI__portMap, &instance->port_map); } if (host->subscribe_func && host->unsubscribe_func) { instance->port_subscribe.handle = controller; instance->port_subscribe.subscribe = host->subscribe_func; instance->port_subscribe.unsubscribe = host->unsubscribe_func; - suil_add_feature(&instance->features, n_features++, + suil_add_feature(&instance->features, &n_features, LV2_UI__portSubscribe, &instance->port_subscribe); } if (host->touch_func) { instance->touch.handle = controller; instance->touch.touch = host->touch_func; - suil_add_feature(&instance->features, n_features++, + suil_add_feature(&instance->features, &n_features, LV2_UI__touch, &instance->touch); } diff --git a/src/suil_internal.h b/src/suil_internal.h index cca12fa..385dc26 100644 --- a/src/suil_internal.h +++ b/src/suil_internal.h @@ -19,6 +19,7 @@ #include <assert.h> #include <stdlib.h> +#include <string.h> #ifdef _WIN32 #include <windows.h> @@ -101,17 +102,25 @@ suil_dlfunc(void* handle, const char* symbol) /** Add a feature to a (mutable) LV2 feature array. */ static inline void suil_add_feature(LV2_Feature*** features, - unsigned n, + unsigned* n, const char* uri, void* data) { + for (unsigned i = 0; i < *n && (*features)[i]; ++i) { + if (!strcmp((*features)[i]->URI, uri)) { + (*features)[i]->data = data; + return; + } + } + *features = (LV2_Feature**)realloc(*features, - sizeof(LV2_Feature*) * (n + 2)); + sizeof(LV2_Feature*) * (*n + 2)); - (*features)[n] = (LV2_Feature*)malloc(sizeof(LV2_Feature)); - (*features)[n]->URI = uri; - (*features)[n]->data = data; - (*features)[n + 1] = NULL; + (*features)[*n] = (LV2_Feature*)malloc(sizeof(LV2_Feature)); + (*features)[*n]->URI = uri; + (*features)[*n]->data = data; + (*features)[*n + 1] = NULL; + *n += 1; } #endif // SUIL_INTERNAL_H diff --git a/src/x11_in_gtk2.c b/src/x11_in_gtk2.c index 14b0ea2..abb58f6 100644 --- a/src/x11_in_gtk2.c +++ b/src/x11_in_gtk2.c @@ -150,10 +150,10 @@ suil_wrapper_new(SuilHost* host, wrapper->resize.handle = wrap; wrapper->resize.ui_resize = wrapper_resize; - suil_add_feature(features, n_features++, LV2_UI__parent, + suil_add_feature(features, &n_features, LV2_UI__parent, (void*)(intptr_t)gtk_plug_get_id(wrap->plug)); - suil_add_feature(features, n_features++, LV2_UI__resize, + suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize); return wrapper; diff --git a/src/x11_in_qt4.cpp b/src/x11_in_qt4.cpp index dafb384..669c9b4 100644 --- a/src/x11_in_qt4.cpp +++ b/src/x11_in_qt4.cpp @@ -62,10 +62,10 @@ suil_wrapper_new(SuilHost* host, wrapper->resize.handle = ew; wrapper->resize.ui_resize = wrapper_resize; - suil_add_feature(features, n_features++, LV2_UI__parent, + suil_add_feature(features, &n_features, LV2_UI__parent, (void*)(intptr_t)ew->winId()); - suil_add_feature(features, n_features++, LV2_UI__resize, + suil_add_feature(features, &n_features, LV2_UI__resize, &wrapper->resize); return wrapper; @@ -7,7 +7,7 @@ from waflib.extras import autowaf as autowaf import waflib.Options as Options # Version of this package (even if built as a child) -SUIL_VERSION = '0.6.4' +SUIL_VERSION = '0.6.5' SUIL_MAJOR_VERSION = '0' # Library version (UNIX style major, minor, micro) |