aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-01-28 18:25:31 +0000
committerDavid Robillard <d@drobilla.net>2012-01-28 18:25:31 +0000
commitc93019b5c405a61b84a0ba85486167e6241026cc (patch)
tree35d67b9669c4450437815eb266b6f9c44f4b1321
parent0e254ca7ce3fa2a1a9ec746127e00661326799d0 (diff)
downloadlv2-c93019b5c405a61b84a0ba85486167e6241026cc.tar.xz
Implement file state properly.
-rw-r--r--plugins/eg-sampler.lv2/sampler.c18
1 files changed, 16 insertions, 2 deletions
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);
}
}