From 77f6e9e63ce9ad329b43c92e8a9556aff8e78f2f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Oct 2016 15:51:11 -0400 Subject: Add plugin state saving This only works with a server-side save, so the GUI now uses that if the server is not running remotely, where "remotely" is defined as "via TCP". This isn't perfect, since running ingen via TCP locally is a perfectly valid thing to do, but it will do for now. --- src/server/events/CreateBlock.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/server/events') diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp index 231df4e2..a43a8bf0 100644 --- a/src/server/events/CreateBlock.cpp +++ b/src/server/events/CreateBlock.cpp @@ -29,6 +29,7 @@ #include "PluginImpl.hpp" #include "PortImpl.hpp" #include "PreProcessContext.hpp" +#include "LV2Block.hpp" namespace Ingen { namespace Server { @@ -118,11 +119,22 @@ CreateBlock::pre_process(PreProcessContext& ctx) PluginImpl* const plugin = _engine.block_factory()->plugin(prototype); if (!plugin) { return Event::pre_process_done(Status::PROTOTYPE_NOT_FOUND, prototype); - } else if (!(_block = plugin->instantiate(*_engine.buffer_factory(), - Raul::Symbol(_path.symbol()), - polyphonic, - _graph, - _engine))) { + } + + // Load state from directory if given in properties + LilvState* state = NULL; + Resource::Properties::iterator s = _properties.find(uris.state_state); + if (s != _properties.end() && s->second.type() == uris.forge.Path) { + state = LV2Block::load_state(_engine.world(), s->second.ptr()); + } + + // Instantiate plugin + if (!(_block = plugin->instantiate(*_engine.buffer_factory(), + Raul::Symbol(_path.symbol()), + polyphonic, + _graph, + _engine, + state))) { return Event::pre_process_done(Status::CREATION_FAILED, _path); } } -- cgit v1.2.1