From 4e1426ddbca6953601c6b7fee745e44c0cb34695 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 26 Jan 2013 21:22:47 +0000 Subject: Support state:loadDefaultState. git-svn-id: http://svn.drobilla.net/lad/trunk/jalv@5007 a436a847-0d15-0410-975c-d299462d15a1 --- src/jalv.c | 12 +++++++++++- src/jalv_internal.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/jalv.c b/src/jalv.c index 9668d2c..78623b8 100644 --- a/src/jalv.c +++ b/src/jalv.c @@ -52,6 +52,7 @@ #include "lv2/lv2plug.in/ns/ext/parameters/parameters.h" #include "lv2/lv2plug.in/ns/ext/patch/patch.h" #include "lv2/lv2plug.in/ns/ext/presets/presets.h" +#include "lv2/lv2plug.in/ns/ext/state/state.h" #include "lv2/lv2plug.in/ns/ext/time/time.h" #include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" @@ -133,6 +134,7 @@ static LV2_Feature make_path_feature = { LV2_STATE__makePath, NULL }; static LV2_Feature schedule_feature = { LV2_WORKER__schedule, NULL }; static LV2_Feature log_feature = { LV2_LOG__log, NULL }; static LV2_Feature options_feature = { LV2_OPTIONS__options, NULL }; +static LV2_Feature def_state_feature = { LV2_STATE__loadDefaultState, NULL }; /** These features have no data */ static LV2_Feature buf_size_features[3] = { @@ -140,12 +142,13 @@ static LV2_Feature buf_size_features[3] = { { LV2_BUF_SIZE__fixedBlockLength, NULL }, { LV2_BUF_SIZE__boundedBlockLength, NULL } }; -const LV2_Feature* features[12] = { +const LV2_Feature* features[13] = { &uri_map_feature, &map_feature, &unmap_feature, &make_path_feature, &schedule_feature, &log_feature, &options_feature, + &def_state_feature, &buf_size_features[0], &buf_size_features[1], &buf_size_features[2], @@ -877,6 +880,7 @@ main(int argc, char** argv) jalv.nodes.midi_MidiEvent = lilv_new_uri(world, LV2_MIDI__MidiEvent); jalv.nodes.pset_Preset = lilv_new_uri(world, LV2_PRESETS__Preset); jalv.nodes.rdfs_label = lilv_new_uri(world, LILV_NS_RDFS "label"); + jalv.nodes.state_state = lilv_new_uri(world, LV2_STATE__state); jalv.nodes.work_interface = lilv_new_uri(world, LV2_WORKER__interface); jalv.nodes.work_schedule = lilv_new_uri(world, LV2_WORKER__schedule); jalv.nodes.end = NULL; @@ -931,6 +935,12 @@ main(int argc, char** argv) } lilv_nodes_free(req_feats); + if (!state) { + /* Not restoring state, load the plugin as a preset to get default */ + state = lilv_state_new_from_world( + jalv.world, &jalv.map, lilv_plugin_get_uri(jalv.plugin)); + } + /* Get a plugin UI */ const char* native_ui_type_uri = jalv_native_ui_type(&jalv); if (!jalv.opts.generic_ui && native_ui_type_uri) { diff --git a/src/jalv_internal.h b/src/jalv_internal.h index b8bf649..8859093 100644 --- a/src/jalv_internal.h +++ b/src/jalv_internal.h @@ -127,6 +127,7 @@ typedef struct { LilvNode* midi_MidiEvent; LilvNode* pset_Preset; LilvNode* rdfs_label; + LilvNode* state_state; LilvNode* work_interface; LilvNode* work_schedule; LilvNode* end; ///< NULL terminator for easy freeing of entire structure -- cgit v1.2.1