From 8ba6bb943889bfdd58cf4a971a152041c1199cfe Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 18 Apr 2011 12:47:15 +0000 Subject: Put engine code in new Ingen::Engine namespace. Put core interfaces in Ingen namespace (not Ingen::Shared). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3159 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/ingen_lv2.cpp | 67 +++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 32 deletions(-) (limited to 'src/engine/ingen_lv2.cpp') diff --git a/src/engine/ingen_lv2.cpp b/src/engine/ingen_lv2.cpp index c48e65fa..44ebc52b 100644 --- a/src/engine/ingen_lv2.cpp +++ b/src/engine/ingen_lv2.cpp @@ -63,19 +63,19 @@ public: typedef std::vector< SharedPtr > Patches; - Patches patches; - Ingen::Configuration conf; - int argc; - char** argv; + Patches patches; + Ingen::Shared::Configuration conf; + int argc; + char** argv; }; /** Library state (constructed/destructed on library load/unload) */ Lib lib; namespace Ingen { -namespace LV2 { +namespace Engine { -struct LV2Driver; +class LV2Driver; class LV2Port : public DriverPort { @@ -123,7 +123,7 @@ private: void* _buffer; }; -struct LV2Driver : public Driver { +class LV2Driver : public Ingen::Engine::Driver { private: typedef std::vector Ports; @@ -164,7 +164,8 @@ public: _ports.push_back((LV2Port*)port); } - virtual Raul::Deletable* remove_port(const Raul::Path& path, Ingen::DriverPort** port=NULL) { + virtual Raul::Deletable* remove_port(const Raul::Path& path, + DriverPort** port=NULL) { // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports ThreadManager::assert_thread(THREAD_PROCESS); @@ -179,7 +180,7 @@ public: return NULL; } - virtual bool supports(Shared::PortType port_type, Shared::EventType event_type) { + virtual bool supports(PortType port_type, EventType event_type) { return true; } @@ -215,11 +216,14 @@ private: Ports _ports; }; -} // namespace LV2 +} // namespace Engine } // namespace Ingen extern "C" { +using namespace Ingen; +using namespace Ingen::Engine; + /** LV2 plugin library entry point */ LV2_SYMBOL_EXPORT const LV2_Descriptor* @@ -238,9 +242,6 @@ ingen_instantiate(const LV2_Descriptor* descriptor, const char* bundle_path, const LV2_Feature*const* features) { - using namespace Ingen; - using namespace LV2; - Shared::set_bundle_path(bundle_path); const LV2Patch* patch = NULL; @@ -257,31 +258,32 @@ ingen_instantiate(const LV2_Descriptor* descriptor, } IngenPlugin* plugin = (IngenPlugin*)malloc(sizeof(IngenPlugin)); - plugin->world = new World(&lib.conf, lib.argc, lib.argv); + plugin->world = new Ingen::Shared::World(&lib.conf, lib.argc, lib.argv); if (!plugin->world->load_module("serialisation")) { delete plugin->world; return NULL; } - SharedPtr engine(new Engine(plugin->world)); + SharedPtr engine(new Engine::Engine(plugin->world)); plugin->world->set_local_engine(engine); - SharedPtr interface( - new Ingen::QueuedEngineInterface( + SharedPtr interface( + new Engine::QueuedEngineInterface( *engine.get(), - event_queue_size)); + Engine::event_queue_size)); plugin->world->set_engine(interface); engine->add_event_source(interface); - Raul::Thread::get().set_context(THREAD_PRE_PROCESS); - ThreadManager::single_threaded = true; + Raul::Thread::get().set_context(Engine::THREAD_PRE_PROCESS); + Engine::ThreadManager::single_threaded = true; // FIXME: fixed (or at least maximum) buffer size - engine->set_driver(SharedPtr(new LV2Driver(*engine.get(), rate, 4096))); - + LV2Driver* driver = new LV2Driver(*engine.get(), rate, 4096); + engine->set_driver(SharedPtr(driver)); + engine->activate(); - ThreadManager::single_threaded = true; + Engine::ThreadManager::single_threaded = true; ProcessContext context(*engine.get()); context.locate(0, UINT_MAX, 0); @@ -310,9 +312,11 @@ ingen_instantiate(const LV2_Descriptor* descriptor, static void ingen_connect_port(LV2_Handle instance, uint32_t port, void* data) { - IngenPlugin* me = (IngenPlugin*)instance; - Ingen::Engine* engine = (Ingen::Engine*)me->world->local_engine().get(); - Ingen::LV2::LV2Driver* driver = (Ingen::LV2::LV2Driver*)engine->driver(); + using namespace Ingen::Engine; + + IngenPlugin* me = (IngenPlugin*)instance; + Engine::Engine* engine = (Engine::Engine*)me->world->local_engine().get(); + LV2Driver* driver = (LV2Driver*)engine->driver(); if (port < driver->ports().size()) { driver->ports().at(port)->set_buffer(data); assert(driver->ports().at(port)->patch_port()->index() == port); @@ -331,11 +335,11 @@ ingen_activate(LV2_Handle instance) static void ingen_run(LV2_Handle instance, uint32_t sample_count) { - IngenPlugin* me = (IngenPlugin*)instance; - Ingen::Engine* engine = (Ingen::Engine*)me->world->local_engine().get(); + IngenPlugin* me = (IngenPlugin*)instance; + Engine::Engine* engine = (Engine::Engine*)me->world->local_engine().get(); // FIXME: don't do this every call - Raul::Thread::get().set_context(Ingen::THREAD_PROCESS); - ((Ingen::LV2::LV2Driver*)engine->driver())->run(sample_count); + Raul::Thread::get().set_context(Ingen::Engine::THREAD_PROCESS); + ((LV2Driver*)engine->driver())->run(sample_count); } static void @@ -349,7 +353,7 @@ static void ingen_cleanup(LV2_Handle instance) { IngenPlugin* me = (IngenPlugin*)instance; - me->world->set_local_engine(SharedPtr()); + me->world->set_local_engine(SharedPtr()); me->world->set_engine(SharedPtr()); delete me->world; free(instance); @@ -384,7 +388,6 @@ Lib::Lib() Glib::thread_init(); using namespace Ingen; - using namespace LV2; Ingen::Shared::set_bundle_path_from_code((void*)&lv2_descriptor); -- cgit v1.2.1