From 79fceb7b387cf45deab770a12f116493a24e5350 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 8 Jan 2011 05:20:34 +0000 Subject: Support "request run" feature from contexts extension. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2791 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/LV2RequestRunFeature.hpp | 82 +++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 src/engine/LV2RequestRunFeature.hpp (limited to 'src/engine/LV2RequestRunFeature.hpp') diff --git a/src/engine/LV2RequestRunFeature.hpp b/src/engine/LV2RequestRunFeature.hpp new file mode 100644 index 00000000..40de2cfb --- /dev/null +++ b/src/engine/LV2RequestRunFeature.hpp @@ -0,0 +1,82 @@ +/* This file is part of Ingen. + * Copyright (C) 2010 David Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_ENGINE_LV2_REQUEST_RUN_FEATURE_HPP +#define INGEN_ENGINE_LV2_REQUEST_RUN_FEATURE_HPP + +#include "lv2/lv2plug.in/ns/ext/contexts/contexts.h" + +#include "raul/log.hpp" + +#include "shared/LV2Features.hpp" + +#include "Driver.hpp" +#include "Engine.hpp" +#include "MessageContext.hpp" +#include "NodeImpl.hpp" +#include "PortImpl.hpp" + +using namespace std; +using namespace Raul; + +namespace Ingen { + +struct RequestRunFeature : public Shared::LV2Features::Feature { + struct Data { + inline Data(Shared::World* w, Shared::Node* n) : world(w), node(n) {} + Shared::World* world; + Shared::Node* node; + }; + + static void request_run(LV2_Contexts_Request_Run_Data data_ptr, + uint32_t context_uri) { + Data* data = reinterpret_cast(data_ptr); + if (!data->world->local_engine()) + return; + + data->world->local_engine()->message_context()->run( + dynamic_cast(data->node), + data->world->local_engine()->driver()->frame_time()); + } + + static void delete_feature(LV2_Feature* feature) { + delete (Data*)feature->data; + free(feature); + } + + SharedPtr feature(Shared::World* world, Shared::Node* n) { + info << "REQUEST RUN FEATURE FOR NODE " << n->path() << endl; + NodeImpl* node = dynamic_cast(n); + if (!node) + return SharedPtr(); + + typedef LV2_Contexts_Request_Run_Feature Feature; + Feature* data = (Feature*)malloc(sizeof(Feature)); + data->data = new Data(world, n); + data->request_run = &request_run; + + LV2_Feature* f = (LV2_Feature*)malloc(sizeof(LV2_Feature)); + f->URI = LV2_CONTEXTS_URI "#RequestRunFeature"; + f->data = data; + + return SharedPtr(f, &delete_feature); + } +}; + +} // namespace Ingen + +#endif // INGEN_ENGINE_LV2_REQUEST_RUN_FEATURE_HPP -- cgit v1.2.1