From 06081bbaca9227a94548572f3e19e771558ae2b1 Mon Sep 17 00:00:00 2001 From: ale <ale@incal.net> Date: Fri, 8 Mar 2019 23:01:26 +0000 Subject: [PATCH] Implement synchronous restore --- plugin/plugin.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugin/plugin.c b/plugin/plugin.c index 83ce61d..caf9c7c 100644 --- a/plugin/plugin.c +++ b/plugin/plugin.c @@ -218,8 +218,8 @@ static void handle_event(struct sampler_plugin *plugin, LV2_Atom_Event *ev) { // Sample change, send it to the worker. lv2_log_trace(&plugin->logger, "Scheduling sample change\n"); plugin->schedule->schedule_work(plugin->schedule->handle, - lv2_atom_total_size(&ev->body), - &ev->body); + lv2_atom_total_size(&ev->body), + &ev->body); /* } else if (key == uris->param_gain) { */ /* // Gain change */ /* if (value->type == uris->atom_Float) { */ @@ -324,8 +324,18 @@ static LV2_State_Status restore(LV2_Handle instance, path = paths->absolute_path(paths->handle, (const char *)value); if (!plugin->activated || !schedule) { + struct drumkit *new_kit; + lv2_log_trace(&plugin->logger, "Synchronous restore\n"); + // Do sync restore. + new_kit = drumkit_new(path, plugin->samplerate); + if (!new_kit) { + lv2_log_error(&plugin->logger, "Error loading the drumkit %s\n", path); + return LV2_WORKER_ERR_UNKNOWN; + } + sampler_set_drumkit(plugin->sampler, new_kit); + } else { LV2_Atom_Forge forge; LV2_Atom *buf = (LV2_Atom *)calloc(1, strlen(path) + 128); -- GitLab