summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-16 21:50:14 +0000
committerDavid Robillard <d@drobilla.net>2011-04-16 21:50:14 +0000
commitda618852b67d64f5fed686234f5a626c33812c87 (patch)
tree2226d335f85478689a9c0f83f1f58bd9e29d635e
parente867b85118f275a263ef1a3162567d90be62d0ac (diff)
downloadingen-da618852b67d64f5fed686234f5a626c33812c87.tar.gz
ingen-da618852b67d64f5fed686234f5a626c33812c87.tar.bz2
ingen-da618852b67d64f5fed686234f5a626c33812c87.zip
Add EngineBase, a pure virtual public interface for the engine.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3155 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--include/ingen/EngineBase.hpp67
-rw-r--r--src/engine/Engine.hpp5
-rw-r--r--src/engine/LV2RequestRunFeature.hpp5
-rw-r--r--src/engine/ingen_jack.cpp5
-rw-r--r--src/engine/ingen_lv2.cpp18
-rw-r--r--src/engine/ingen_osc.cpp5
-rw-r--r--src/gui/ConnectWindow.cpp2
-rw-r--r--src/shared/World.cpp7
-rw-r--r--src/shared/World.hpp6
9 files changed, 96 insertions, 24 deletions
diff --git a/include/ingen/EngineBase.hpp b/include/ingen/EngineBase.hpp
new file mode 100644
index 00000000..cf3a2e97
--- /dev/null
+++ b/include/ingen/EngineBase.hpp
@@ -0,0 +1,67 @@
+/* This file is part of Ingen.
+ * Copyright 2007-2011 David Robillard <http://drobilla.net>
+ *
+ * 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_BASE_HPP
+#define INGEN_ENGINE_BASE_HPP
+
+#include "raul/SharedPtr.hpp"
+
+namespace Raul { class Maid; }
+
+namespace Ingen {
+
+namespace Shared { class World; }
+
+/**
+ The engine which executes the process graph.
+
+ @ingroup interface
+*/
+class EngineBase
+{
+public:
+ virtual ~EngineBase() {}
+
+ virtual bool activate() = 0;
+
+ virtual void deactivate() = 0;
+
+ /**
+ Indicate that a quit is desired
+
+ This function simply sets a flag which affects the return value of
+ main_iteration, it does not actually force the engine to stop running or
+ block. The code driving the engine is responsible for stopping and
+ cleaning up when main_iteration returns false.
+ */
+ virtual void quit() = 0;
+
+ /**
+ Run a single iteration of the main context.
+
+ The main context post-processes events and performs housekeeping duties
+ like collecting garbage. This should be called regularly, e.g. a few
+ times per second. The return value indicates whether execution should
+ continue; i.e. if false is returned, a quit has been requested and the
+ caller should cease calling main_iteration() and stop the engine.
+ */
+ virtual bool main_iteration() = 0;
+};
+
+} // namespace Ingen
+
+#endif // INGEN_ENGINE_BASE_HPP
diff --git a/src/engine/Engine.hpp b/src/engine/Engine.hpp
index e1854a8b..c9e9229e 100644
--- a/src/engine/Engine.hpp
+++ b/src/engine/Engine.hpp
@@ -25,8 +25,7 @@
#include "raul/SharedPtr.hpp"
-#include "ingen/PortType.hpp"
-#include "ingen/EventType.hpp"
+#include "ingen/EngineBase.hpp"
namespace Raul { class Maid; }
@@ -54,7 +53,7 @@ class ProcessContext;
@ingroup engine
*/
-class Engine : public boost::noncopyable
+class Engine : public boost::noncopyable, public EngineBase
{
public:
explicit Engine(Ingen::Shared::World* world);
diff --git a/src/engine/LV2RequestRunFeature.hpp b/src/engine/LV2RequestRunFeature.hpp
index 9f35d506..6d6b66b3 100644
--- a/src/engine/LV2RequestRunFeature.hpp
+++ b/src/engine/LV2RequestRunFeature.hpp
@@ -48,9 +48,10 @@ struct RequestRunFeature : public Shared::LV2Features::Feature {
if (!data->world->local_engine())
return;
- data->world->local_engine()->message_context()->run(
+ Engine* engine = (Engine*)data->world->local_engine().get();
+ engine->message_context()->run(
dynamic_cast<NodeImpl*>(data->node),
- data->world->local_engine()->driver()->frame_time());
+ engine->driver()->frame_time());
}
static void delete_feature(LV2_Feature* feature) {
diff --git a/src/engine/ingen_jack.cpp b/src/engine/ingen_jack.cpp
index 93119bd8..e8645cb9 100644
--- a/src/engine/ingen_jack.cpp
+++ b/src/engine/ingen_jack.cpp
@@ -25,10 +25,11 @@ using namespace Ingen;
struct IngenJackModule : public Ingen::Shared::Module {
void load(Ingen::Shared::World* world) {
- Ingen::JackDriver* driver = new Ingen::JackDriver(*world->local_engine().get());
+ Ingen::JackDriver* driver = new Ingen::JackDriver(
+ *(Engine*)world->local_engine().get());
driver->attach(world->conf()->option("jack-server").get_string(),
world->conf()->option("jack-client").get_string(), NULL);
- world->local_engine()->set_driver(SharedPtr<Driver>(driver));
+ ((Engine*)world->local_engine().get())->set_driver(SharedPtr<Driver>(driver));
}
};
diff --git a/src/engine/ingen_lv2.cpp b/src/engine/ingen_lv2.cpp
index a6f178ff..69daa7ae 100644
--- a/src/engine/ingen_lv2.cpp
+++ b/src/engine/ingen_lv2.cpp
@@ -267,11 +267,12 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
plugin->world->set_local_engine(engine);
SharedPtr<QueuedEngineInterface> interface(
- new Ingen::QueuedEngineInterface(*plugin->world->local_engine(),
- event_queue_size));
+ new Ingen::QueuedEngineInterface(
+ *engine.get(),
+ event_queue_size));
plugin->world->set_engine(interface);
- plugin->world->local_engine()->add_event_source(interface);
+ engine->add_event_source(interface);
Raul::Thread::get().set_context(THREAD_PRE_PROCESS);
ThreadManager::single_threaded = true;
@@ -309,9 +310,9 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
static void
ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
{
- IngenPlugin* me = (IngenPlugin*)instance;
- SharedPtr<Ingen::Engine> engine = me->world->local_engine();
- Ingen::LV2::LV2Driver* driver = (Ingen::LV2::LV2Driver*)engine->driver();
+ IngenPlugin* me = (IngenPlugin*)instance;
+ Ingen::Engine* engine = (Ingen::Engine*)me->world->local_engine().get();
+ Ingen::LV2::LV2Driver* driver = (Ingen::LV2::LV2Driver*)engine->driver();
if (port < driver->ports().size()) {
driver->ports().at(port)->set_buffer(data);
assert(driver->ports().at(port)->patch_port()->index() == port);
@@ -330,10 +331,11 @@ ingen_activate(LV2_Handle instance)
static void
ingen_run(LV2_Handle instance, uint32_t sample_count)
{
- IngenPlugin* me = (IngenPlugin*)instance;
+ IngenPlugin* me = (IngenPlugin*)instance;
+ Ingen::Engine* engine = (Ingen::Engine*)me->world->local_engine().get();
// FIXME: don't do this every call
Raul::Thread::get().set_context(Ingen::THREAD_PROCESS);
- ((Ingen::LV2::LV2Driver*)me->world->local_engine()->driver())->run(sample_count);
+ ((Ingen::LV2::LV2Driver*)engine->driver())->run(sample_count);
}
static void
diff --git a/src/engine/ingen_osc.cpp b/src/engine/ingen_osc.cpp
index 5e75b756..0a2d6768 100644
--- a/src/engine/ingen_osc.cpp
+++ b/src/engine/ingen_osc.cpp
@@ -27,10 +27,11 @@ using namespace Ingen;
struct IngenOSCModule : public Ingen::Shared::Module {
void load(Ingen::Shared::World* world) {
SharedPtr<OSCEngineReceiver> interface(
- new Ingen::OSCEngineReceiver(*world->local_engine().get(),
+ new Ingen::OSCEngineReceiver(
+ *(Engine*)world->local_engine().get(),
event_queue_size,
world->conf()->option("engine-port").get_int32()));
- world->local_engine()->add_event_source(interface);
+ ((Engine*)world->local_engine().get())->add_event_source(interface);
}
};
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index 9f466e29..8c5a654a 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -246,7 +246,7 @@ ConnectWindow::connect(bool existing)
SharedPtr<SigClientInterface> client(new SigClientInterface());
- if (!world->local_engine()->driver())
+ if (!((Engine*)world->local_engine().get())->driver())
world->load("ingen_jack");
world->local_engine()->activate();
diff --git a/src/shared/World.cpp b/src/shared/World.cpp
index f869dc33..38c08340 100644
--- a/src/shared/World.cpp
+++ b/src/shared/World.cpp
@@ -25,6 +25,7 @@
#endif
#include "raul/log.hpp"
#include "sord/sordmm.hpp"
+#include "ingen/EngineBase.hpp"
#include "shared/runtime_paths.hpp"
#include "shared/LV2Features.hpp"
#include "shared/LV2URIMap.hpp"
@@ -172,7 +173,7 @@ public:
Sord::World* rdf_world;
SharedPtr<LV2URIMap> uris;
SharedPtr<EngineInterface> engine;
- SharedPtr<Engine> local_engine;
+ SharedPtr<EngineBase> local_engine;
SharedPtr<Serialisation::Serialiser> serialiser;
SharedPtr<Serialisation::Parser> parser;
SharedPtr<Store> store;
@@ -191,7 +192,7 @@ World::~World()
delete _impl;
}
-void World::set_local_engine(SharedPtr<Engine> e) { _impl->local_engine = e; }
+void World::set_local_engine(SharedPtr<EngineBase> e) { _impl->local_engine = e; }
void World::set_engine(SharedPtr<EngineInterface> e) { _impl->engine = e; }
void World::set_serialiser(SharedPtr<Serialisation::Serialiser> s) { _impl->serialiser = s; }
void World::set_parser(SharedPtr<Serialisation::Parser> p) { _impl->parser = p; }
@@ -200,7 +201,7 @@ void World::set_conf(Raul::Configuration* c) { _impl->conf
int& World::argc() { return _impl->argc; }
char**& World::argv() { return _impl->argv; }
-SharedPtr<Engine> World::local_engine() { return _impl->local_engine; }
+SharedPtr<EngineBase> World::local_engine() { return _impl->local_engine; }
SharedPtr<EngineInterface> World::engine() { return _impl->engine; }
SharedPtr<Serialisation::Serialiser> World::serialiser() { return _impl->serialiser; }
SharedPtr<Serialisation::Parser> World::parser() { return _impl->parser; }
diff --git a/src/shared/World.hpp b/src/shared/World.hpp
index 233ae83a..4a07d4f6 100644
--- a/src/shared/World.hpp
+++ b/src/shared/World.hpp
@@ -35,7 +35,7 @@ namespace Sord { class World; }
namespace Ingen {
-class Engine;
+class EngineBase;
namespace Serialisation { class Serialiser; class Parser; }
@@ -76,13 +76,13 @@ public:
virtual bool run(const std::string& mime_type,
const std::string& filename);
- virtual void set_local_engine(SharedPtr<Engine> e);
+ virtual void set_local_engine(SharedPtr<EngineBase> e);
virtual void set_engine(SharedPtr<EngineInterface> e);
virtual void set_serialiser(SharedPtr<Serialisation::Serialiser> s);
virtual void set_parser(SharedPtr<Serialisation::Parser> p);
virtual void set_store(SharedPtr<Store> s);
- virtual SharedPtr<Engine> local_engine();
+ virtual SharedPtr<EngineBase> local_engine();
virtual SharedPtr<EngineInterface> engine();
virtual SharedPtr<Serialisation::Serialiser> serialiser();
virtual SharedPtr<Serialisation::Parser> parser();