From c024819b9d8c452e970a8702e61c31bd8b319f38 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 6 Mar 2012 05:05:40 +0000 Subject: Use raw type/size/value instead of LilvNode for port values. Remove use of half-baked node_to_serd() and use sratom for port values as well. git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@4023 a436a847-0d15-0410-975c-d299462d15a1 --- src/state.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/state.c b/src/state.c index 2b3be37..ea13007 100644 --- a/src/state.c +++ b/src/state.c @@ -61,15 +61,20 @@ jalv_make_path(LV2_State_Make_Path_Handle handle, return fullpath; } -LilvNode* +const void* get_port_value(const char* port_symbol, - void* user_data) + void* user_data, + uint32_t* size, + uint32_t* type) { Jalv* jalv = (Jalv*)user_data; struct Port* port = jalv_port_by_symbol(jalv, port_symbol); if (port && port->flow == FLOW_INPUT && port->type == TYPE_CONTROL) { - return lilv_new_float(jalv->world, port->control); + *size = sizeof(float); + *type = jalv->forge.Float; + return &port->control; } + *size = *type = 0; return NULL; } @@ -118,9 +123,11 @@ jalv_load_presets(Jalv* jalv, PresetSink sink, void* data) } static void -set_port_value(const char* port_symbol, - const LilvNode* value, - void* user_data) +set_port_value(const char* port_symbol, + void* user_data, + const void* value, + uint32_t size, + uint32_t type) { Jalv* jalv = (Jalv*)user_data; struct Port* port = jalv_port_by_symbol(jalv, port_symbol); @@ -129,13 +136,13 @@ set_port_value(const char* port_symbol, return; } - if (!lilv_node_is_float(value) && !lilv_node_is_int(value)) { - fprintf(stderr, "error: Preset port `%s' value is not a number\n", + if (type != jalv->forge.Float) { + fprintf(stderr, "error: Preset port `%s' value is not a float\n", port_symbol); return; } - const float fvalue = lilv_node_as_float(value); + const float fvalue = *(float*)value; // Send value to plugin jalv_ui_write(jalv, port->index, sizeof(fvalue), 0, &fvalue); -- cgit v1.2.1