From c93019b5c405a61b84a0ba85486167e6241026cc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 28 Jan 2012 18:25:31 +0000 Subject: Implement file state properly. --- plugins/eg-sampler.lv2/sampler.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'plugins/eg-sampler.lv2') diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index b1feef6..5584143 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -361,13 +361,25 @@ save(LV2_Handle instance, uint32_t flags, const LV2_Feature* const* features) { + LV2_State_Map_Path* map_path = NULL; + for (int i = 0; features[i]; ++i) { + if (!strcmp(features[i]->URI, LV2_STATE_MAP_PATH_URI)) { + map_path = (LV2_State_Map_Path*)features[i]->data; + } + } + Sampler* plugin = (Sampler*)instance; + char* apath = map_path->abstract_path(map_path->handle, + plugin->samp->filepath); + store(callback_data, map_uri(plugin, FILENAME_URI), - plugin->samp->filepath, + apath, strlen(plugin->samp->filepath) + 1, plugin->uris.state_path, LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); + + free(apath); } static void @@ -389,7 +401,9 @@ restore(LV2_Handle instance, &size, &type, &valflags); if (value) { - printf("Restored filename %s\n", (const char*)value); + printf("Restoring filename %s\n", (const char*)value); + strncpy(plugin->pending_samp->filepath, value, STRING_BUF); + handle_load_sample(plugin); } } -- cgit v1.2.1