From 32ed8eb92f194d0cce1b0617d0686147d4be09c0 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 6 Mar 2010 21:15:14 +0000 Subject: Fully load patch in LV2 instantiate method. Actually connect to LV2 buffers. Ingen confirmed working as an LV2 plugin doing audio I/O in lv2_jack_host and Ardour. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2536 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/ingen_lv2.cpp | 49 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-) (limited to 'src/engine/ingen_lv2.cpp') diff --git a/src/engine/ingen_lv2.cpp b/src/engine/ingen_lv2.cpp index 8d14cba7..56d73cdb 100644 --- a/src/engine/ingen_lv2.cpp +++ b/src/engine/ingen_lv2.cpp @@ -25,19 +25,20 @@ #include "raul/log.hpp" #include "raul/Thread.hpp" #include "raul/SharedPtr.hpp" -#include "engine/AudioBuffer.hpp" -#include "engine/Engine.hpp" -#include "engine/ThreadManager.hpp" -#include "engine/Driver.hpp" -#include "engine/ProcessContext.hpp" -#include "engine/PatchImpl.hpp" -#include "engine/QueuedEngineInterface.hpp" +#include "interface/EngineInterface.hpp" #include "module/World.hpp" #include "module/ingen_module.hpp" #include "shared/runtime_paths.hpp" #include "shared/Configuration.hpp" +#include "engine/AudioBuffer.hpp" +#include "engine/Driver.hpp" +#include "engine/Engine.hpp" +#include "engine/PatchImpl.hpp" +#include "engine/PostProcessor.hpp" +#include "engine/ProcessContext.hpp" +#include "engine/QueuedEngineInterface.hpp" +#include "engine/ThreadManager.hpp" #include "serialisation/Parser.hpp" -#include "interface/EngineInterface.hpp" using namespace Ingen; @@ -132,6 +133,8 @@ public: for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) (*i)->pre_process(_context); + _context.engine().process_events(_context); + if (_root_patch) _root_patch->process(_context); @@ -193,6 +196,8 @@ public: virtual bool is_realtime() const { return true; } virtual ProcessContext& context() { return _context; } + Ports& ports() { return _ports; } + private: ProcessContext _context; PatchImpl* _root_patch; @@ -254,27 +259,31 @@ ingen_instantiate(const LV2_Descriptor* descriptor, Raul::Thread::get().set_context(THREAD_PRE_PROCESS); ThreadManager::single_threaded = true; - ProcessContext context(*engine.get()); - // FIXME: fixed (or at least maximum) buffer size engine->set_driver(SharedPtr(new LV2Driver(*engine.get(), rate, 4096))); engine->activate(); ThreadManager::single_threaded = true; + ProcessContext context(*engine.get()); + context.locate(0, UINT_MAX, 0); + + engine->post_processor()->set_end_time(UINT_MAX); + // FIXME: don't load all plugins, only necessary ones plugin->world->engine()->load_plugins(); - engine->process_events(context); + interface->process(*engine->post_processor(), context, false); + engine->post_processor()->process(); plugin->world->parser()->parse_document(plugin->world, plugin->world->engine().get(), patch->filename); - engine->process_events(context); - engine->deactivate(); + while (!interface->empty()) { + interface->process(*engine->post_processor(), context, false); + engine->post_processor()->process(); + } - // Activate and deactivate to create root patch, allocate buffers, etc - //engine->activate(); - //engine->deactivate(); + engine->deactivate(); return (LV2_Handle)plugin; } @@ -283,6 +292,14 @@ ingen_instantiate(const LV2_Descriptor* descriptor, static void ingen_connect_port(LV2_Handle instance, uint32_t port, void* data) { + IngenPlugin* me = (IngenPlugin*)instance; + LV2::LV2Driver* driver = (LV2::LV2Driver*)me->world->local_engine()->driver(); + if (port < driver->ports().size()) { + driver->ports().at(port)->set_buffer(data); + assert(driver->ports().at(port)->patch_port()->index() == port); + } else { + Raul::warn << "Connect to non-existent port " << port << std::endl; + } } -- cgit v1.2.1