summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-03-26 12:25:48 +0200
committerDavid Robillard <d@drobilla.net>2017-03-26 17:02:09 +0200
commitcfb016163227560932044b73407ae9dafa54b4ba (patch)
treec510f0535616bfe776b80021478c5c0be607cec9
parentd70ddd35cc03b35d3b765079d6039fef7a2a19fa (diff)
downloadingen-cfb016163227560932044b73407ae9dafa54b4ba.tar.gz
ingen-cfb016163227560932044b73407ae9dafa54b4ba.tar.bz2
ingen-cfb016163227560932044b73407ae9dafa54b4ba.zip
Remove Node::instance() method
-rw-r--r--ingen/DataAccess.hpp7
-rw-r--r--ingen/EngineBase.hpp7
-rw-r--r--ingen/InstanceAccess.hpp6
-rw-r--r--ingen/Node.hpp4
-rw-r--r--src/server/BlockImpl.hpp2
-rw-r--r--src/server/Engine.cpp11
-rw-r--r--src/server/Engine.hpp1
7 files changed, 33 insertions, 5 deletions
diff --git a/ingen/DataAccess.hpp b/ingen/DataAccess.hpp
index 149daec9..730cf921 100644
--- a/ingen/DataAccess.hpp
+++ b/ingen/DataAccess.hpp
@@ -17,6 +17,7 @@
#ifndef INGEN_ENGINE_DATAACCESS_HPP
#define INGEN_ENGINE_DATAACCESS_HPP
+#include "ingen/EngineBase.hpp"
#include "ingen/LV2Features.hpp"
#include "ingen/Store.hpp"
#include "ingen/World.hpp"
@@ -35,12 +36,16 @@ struct DataAccess : public Ingen::LV2Features::Feature
const char* uri() const { return "http://lv2plug.in/ns/ext/data-access"; }
SPtr<LV2_Feature> feature(World* world, Node* node) {
+ if (!world->engine()) {
+ return SPtr<LV2_Feature>();
+ }
+
Node* store_node = world->store()->get(node->path());
if (!store_node) {
return SPtr<LV2_Feature>();
}
- LilvInstance* inst = store_node->instance();
+ LilvInstance* inst = world->engine()->block_instance(store_node);
if (!inst) {
return SPtr<LV2_Feature>();
}
diff --git a/ingen/EngineBase.hpp b/ingen/EngineBase.hpp
index a57743fe..19f66cb7 100644
--- a/ingen/EngineBase.hpp
+++ b/ingen/EngineBase.hpp
@@ -23,10 +23,12 @@
#include "ingen/ingen.h"
#include "ingen/types.hpp"
+#include "lilv/lilv.h"
namespace Ingen {
class Interface;
+class Node;
/**
The audio engine which executes the graph.
@@ -49,6 +51,11 @@ public:
size_t seq_size) = 0;
/**
+ Return the LV2 instance of a block if possible, or NULL.
+ */
+ virtual LilvInstance* block_instance(Node* node) = 0;
+
+ /**
Activate the engine.
*/
virtual bool activate() = 0;
diff --git a/ingen/InstanceAccess.hpp b/ingen/InstanceAccess.hpp
index 443f5f55..d30ebf1d 100644
--- a/ingen/InstanceAccess.hpp
+++ b/ingen/InstanceAccess.hpp
@@ -28,12 +28,16 @@ struct InstanceAccess : public Ingen::LV2Features::Feature
const char* uri() const { return "http://lv2plug.in/ns/ext/instance-access"; }
SPtr<LV2_Feature> feature(World* world, Node* node) {
+ if (!world->engine()) {
+ return SPtr<LV2_Feature>();
+ }
+
Node* store_node = world->store()->get(node->path());
if (!store_node) {
return SPtr<LV2_Feature>();
}
- LilvInstance* instance = store_node->instance();
+ LilvInstance* instance = world->engine()->block_instance(store_node);
if (!instance) {
return SPtr<LV2_Feature>();
}
diff --git a/ingen/Node.hpp b/ingen/Node.hpp
index 51b000bf..18987749 100644
--- a/ingen/Node.hpp
+++ b/ingen/Node.hpp
@@ -21,7 +21,6 @@
#include "ingen/ingen.h"
#include "ingen/paths.hpp"
#include "ingen/types.hpp"
-#include "lilv/lilv.h"
#include "raul/Path.hpp"
namespace Raul {
@@ -69,8 +68,7 @@ public:
virtual const Resource* plugin() const { return NULL; }
// Plugin blocks only
- virtual LilvInstance* instance() { return NULL; }
- virtual bool save_state(const std::string& dir) const { return false; }
+ virtual bool save_state(const std::string& dir) const { return false; }
// All objects
virtual GraphType graph_type() const = 0;
diff --git a/src/server/BlockImpl.hpp b/src/server/BlockImpl.hpp
index 701e2188..a1ca11b7 100644
--- a/src/server/BlockImpl.hpp
+++ b/src/server/BlockImpl.hpp
@@ -182,6 +182,8 @@ public:
uint32_t num_ports() const { return _ports ? _ports->size() : 0; }
virtual uint32_t polyphony() const { return _polyphony; }
+ virtual LilvInstance* instance() { return nullptr; }
+
/** Mark used during graph compilation */
enum class Mark { UNVISITED, VISITING, VISITED };
Mark get_mark() const { return _mark; }
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index 5f5c53d0..e2fb08af 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -399,6 +399,17 @@ Engine::init(double sample_rate, uint32_t block_length, size_t seq_size)
set_driver(SPtr<Driver>(new DirectDriver(*this, sample_rate, block_length, seq_size)));
}
+LilvInstance*
+Engine::block_instance(Node* node)
+{
+ BlockImpl* const block = dynamic_cast<BlockImpl*>(node);
+ if (!block) {
+ return nullptr;
+ }
+
+ return block->instance();
+}
+
bool
Engine::activate()
{
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index ab69586c..f735aedd 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -77,6 +77,7 @@ public:
// EngineBase methods
virtual void init(double sample_rate, uint32_t block_length, size_t seq_size);
+ virtual LilvInstance* block_instance(Node* node);
virtual bool activate();
virtual void deactivate();
virtual bool pending_events();