diff options
-rw-r--r-- | src/host.c | 17 | ||||
-rw-r--r-- | src/instance.c | 32 | ||||
-rw-r--r-- | src/suil_internal.h | 14 |
3 files changed, 33 insertions, 30 deletions
@@ -24,15 +24,12 @@ suil_host_new(SuilPortWriteFunc write_func, SuilPortUnsubscribeFunc unsubscribe_func) { SuilHost* host = malloc(sizeof(struct SuilHostImpl)); - host->write_func = write_func; - host->port_map.handle = host; - host->port_map.port_index = index_func; - host->port_subscribe.handle = host; - host->port_subscribe.subscribe = subscribe_func; - host->port_subscribe.unsubscribe = unsubscribe_func; - host->touch.handle = host; - host->touch.touch = NULL; - host->gtk_lib = NULL; + host->write_func = write_func; + host->index_func = index_func; + host->subscribe_func = subscribe_func; + host->unsubscribe_func = unsubscribe_func; + host->touch_func = NULL; + host->gtk_lib = NULL; return host; } @@ -41,7 +38,7 @@ void suil_host_set_touch_func(SuilHost* host, SuilTouchFunc touch_func) { - host->touch.touch = touch_func; + host->touch_func = touch_func; } SUIL_API diff --git a/src/instance.c b/src/instance.c index 038813e..f6824e8 100644 --- a/src/instance.c +++ b/src/instance.c @@ -175,14 +175,9 @@ suil_instance_new(SuilHost* host, } // Create SuilInstance - SuilInstance* instance = malloc(sizeof(struct SuilInstanceImpl)); - instance->lib_handle = lib; - instance->descriptor = descriptor; - instance->host_widget = NULL; - instance->ui_widget = NULL; - instance->wrapper = NULL; - instance->features = NULL; - instance->handle = NULL; + SuilInstance* instance = calloc(1, sizeof(struct SuilInstanceImpl)); + instance->lib_handle = lib; + instance->descriptor = descriptor; // Make UI features array instance->features = (LV2_Feature**)malloc(sizeof(LV2_Feature**)); @@ -196,17 +191,24 @@ suil_instance_new(SuilHost* host, } // Add additional features implemented by SuilHost functions - if (host->port_map.port_index) { + if (host->index_func) { + instance->port_map.handle = controller; + instance->port_map.port_index = host->index_func; suil_add_feature(&instance->features, n_features++, - LV2_UI__portMap, &host->port_map); + LV2_UI__portMap, &instance->port_map); } - if (host->port_subscribe.subscribe && host->port_subscribe.unsubscribe) { + 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++, - LV2_UI__portSubscribe, &host->port_subscribe); + LV2_UI__portSubscribe, &instance->port_subscribe); } - if (host->touch.touch) { + if (host->touch_func) { + instance->touch.handle = controller; + instance->touch.touch = host->touch_func; suil_add_feature(&instance->features, n_features++, - LV2_UI__touch, &host->touch); + LV2_UI__touch, &instance->touch); } // Open wrapper (this may add additional features) @@ -214,7 +216,7 @@ suil_instance_new(SuilHost* host, host, container_type_uri, ui_type_uri, &instance->features, n_features); // Instantiate UI - instance->handle = descriptor->instantiate( + instance->handle = descriptor->instantiate( descriptor, plugin_uri, ui_bundle_path, diff --git a/src/suil_internal.h b/src/suil_internal.h index 388c8df..cca12fa 100644 --- a/src/suil_internal.h +++ b/src/suil_internal.h @@ -38,11 +38,12 @@ static inline char* dlerror(void) { return "Unknown error"; } __func__, __VA_ARGS__) struct SuilHostImpl { - SuilPortWriteFunc write_func; - LV2UI_Port_Map port_map; - LV2UI_Port_Subscribe port_subscribe; - LV2UI_Touch touch; - void* gtk_lib; + SuilPortWriteFunc write_func; + SuilPortIndexFunc index_func; + SuilPortSubscribeFunc subscribe_func; + SuilPortUnsubscribeFunc unsubscribe_func; + SuilTouchFunc touch_func; + void* gtk_lib; }; struct _SuilWrapper; @@ -66,6 +67,9 @@ struct SuilInstanceImpl { LV2UI_Handle handle; SuilWrapper* wrapper; LV2_Feature** features; + LV2UI_Port_Map port_map; + LV2UI_Port_Subscribe port_subscribe; + LV2UI_Touch touch; SuilWidget ui_widget; SuilWidget host_widget; }; |