summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-03-25 00:33:10 +0000
committerDavid Robillard <d@drobilla.net>2013-03-25 00:33:10 +0000
commit3c45957cdb38a115d013dd5d96f60b6ee1320229 (patch)
tree775bb0f0d297803c92149ab4fc6e55eb20e148b4
parent52c617694203c9dbc20189f5bae3b6446df87bd9 (diff)
downloadlilv-3c45957cdb38a115d013dd5d96f60b6ee1320229.tar.gz
lilv-3c45957cdb38a115d013dd5d96f60b6ee1320229.tar.bz2
lilv-3c45957cdb38a115d013dd5d96f60b6ee1320229.zip
Allow lilv_state_restore() to be used without passing an instance, for restoring port values via a callback only.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@5100 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--NEWS2
-rw-r--r--lilv/lilv.h20
-rw-r--r--src/state.c4
3 files changed, 14 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index b9aeec4..dd41ff6 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,7 @@
lilv (0.16.1) unstable;
+ * Allow lilv_state_restore() to be used without passing an instance,
+ for restoring port values via a callback only
* lilvmm.hpp: Add wrappers for UI API
-- David Robillard <d@drobilla.net> Tue, 19 Mar 2013 00:01:12 -0400
diff --git a/lilv/lilv.h b/lilv/lilv.h
index f2dd17a..d349fb1 100644
--- a/lilv/lilv.h
+++ b/lilv/lilv.h
@@ -1393,21 +1393,21 @@ typedef void (*LilvSetPortValueFunc)(const char* port_symbol,
/**
Restore a plugin instance from a state snapshot.
@param state The state to restore, which must apply to the correct plugin.
- @param instance An instance of the plugin @c state applies to.
+ @param instance An instance of the plugin @c state applies to, or NULL.
@param set_value A function to set a port value (may be NULL).
@param flags Bitwise OR of LV2_State_Flags values.
@param features Features to pass LV2_State_Interface.restore().
- This will set all the properties of @c instance to the values stored in @c
- state. If @c set_value is provided, it will be called (with the given @c
- user_data) to restore each port value, otherwise the host must restore the
- port values itself (using lilv_state_get_port_value) in order to completely
- restore @c state.
+ This will set all the properties of @c instance, if given, to the values
+ stored in @c state. If @c set_value is provided, it will be called (with
+ the given @c user_data) to restore each port value, otherwise the host must
+ restore the port values itself (using lilv_state_get_port_value) in order to
+ completely restore @c state.
- If the state has properties, this function is in the "instantiation"
- threading class, i.e. it MUST NOT be called simultaneously with any function
- on the same plugin instance. If the state has no properties, only port
- values are set via @c set_value.
+ If the state has properties and @c instance is given, this function is in
+ the "instantiation" threading class, i.e. it MUST NOT be called
+ simultaneously with any function on the same plugin instance. If the state
+ has no properties, only port values are set via @c set_value.
See <a href="http://lv2plug.in/ns/ext/state/state.h">state.h</a> from the
LV2 State extension for details on the @c flags and @c features parameters.
diff --git a/src/state.c b/src/state.c
index 9ab441f..b2953a4 100644
--- a/src/state.c
+++ b/src/state.c
@@ -411,8 +411,8 @@ lilv_state_restore(const LilvState* state,
const LV2_Feature** sfeatures = add_features(features, &map_feature, NULL);
- const LV2_Descriptor* desc = instance->lv2_descriptor;
- const LV2_State_Interface* iface = (desc->extension_data)
+ const LV2_Descriptor* desc = instance ? instance->lv2_descriptor : NULL;
+ const LV2_State_Interface* iface = (desc && desc->extension_data)
? (LV2_State_Interface*)desc->extension_data(LV2_STATE__interface)
: NULL;