diff options
author | David Robillard <d@drobilla.net> | 2012-05-12 06:09:44 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-12 06:09:44 +0000 |
commit | 1d9bb9768f8a7d0c76fa33688051cd8f2715075d (patch) | |
tree | 45aa6f6235fb6d2c4227081eeb7c938db255aab5 /src | |
parent | a53738e05b296b4ab4e0b701ea37d60013a42605 (diff) | |
download | ingen-1d9bb9768f8a7d0c76fa33688051cd8f2715075d.tar.gz ingen-1d9bb9768f8a7d0c76fa33688051cd8f2715075d.tar.bz2 ingen-1d9bb9768f8a7d0c76fa33688051cd8f2715075d.zip |
Use compiler checkable ProcessContext parameter rather than runtime context assertions.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4374 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
31 files changed, 104 insertions, 115 deletions
diff --git a/src/server/Driver.hpp b/src/server/Driver.hpp index e12ae737..c96545b9 100644 --- a/src/server/Driver.hpp +++ b/src/server/Driver.hpp @@ -57,14 +57,16 @@ public: virtual EnginePort* create_port(DuplexPort* patch_port) = 0; /** Return the DriverPort for a particular path, iff one exists. */ - virtual EnginePort* engine_port(const Raul::Path& path) = 0; + virtual EnginePort* engine_port(ProcessContext& context, + const Raul::Path& path) = 0; /** Add a system visible port (e.g. a port on the root patch). */ - virtual void add_port(EnginePort* port) = 0; + virtual void add_port(ProcessContext& context, EnginePort* port) = 0; /** Remove a system visible port. */ - virtual Raul::Deletable* remove_port(const Raul::Path& path, - EnginePort** port=NULL) = 0; + virtual Raul::Deletable* remove_port(ProcessContext& context, + const Raul::Path& path, + EnginePort** port = NULL) = 0; /** Return the audio buffer size in frames */ virtual SampleCount block_length() const = 0; diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 1d3b4024..edd0b4a4 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -243,7 +243,7 @@ Engine::run(uint32_t sample_count) // Process events that came in during the last cycle // (Aiming for jitter-free 1 block event latency, ideally) - process_events(_process_context); + process_events(); // Run root patch if (_root_patch) { @@ -274,9 +274,9 @@ Engine::enqueue_event(Event* ev) } void -Engine::process_events(ProcessContext& context) +Engine::process_events() { - _pre_processor->process(context, *_post_processor); + _pre_processor->process(_process_context, *_post_processor); } void diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index 9600e8a2..c32c398a 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -77,7 +77,7 @@ public: bool pending_events(); void enqueue_event(Event* ev); - void process_events(ProcessContext& context); + void process_events(); Ingen::Shared::World* world() const { return _world; } diff --git a/src/server/GraphObjectImpl.hpp b/src/server/GraphObjectImpl.hpp index 112d0a74..b2fa864e 100644 --- a/src/server/GraphObjectImpl.hpp +++ b/src/server/GraphObjectImpl.hpp @@ -60,8 +60,6 @@ public: GraphObject* graph_parent() const { return _parent; } GraphObjectImpl* parent() const { return _parent; } - //virtual void process(ProcessContext& context) = 0; - /** Rename */ virtual void set_path(const Raul::Path& new_path) { _path = new_path; @@ -91,7 +89,8 @@ public: * \param poly Must be <= the most recent value passed to prepare_poly. * \param maid Any objects no longer needed will be pushed to this */ - virtual bool apply_poly(Raul::Maid& maid, uint32_t poly) = 0; + virtual bool apply_poly( + ProcessContext& context, Raul::Maid& maid, uint32_t poly) = 0; protected: GraphObjectImpl(Ingen::Shared::URIs& uris, diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp index 0d211095..4239ae89 100644 --- a/src/server/InputPort.cpp +++ b/src/server/InputPort.cpp @@ -63,9 +63,9 @@ InputPort::InputPort(BufferFactory& bufs, } bool -InputPort::apply_poly(Raul::Maid& maid, uint32_t poly) +InputPort::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) { - bool ret = PortImpl::apply_poly(maid, poly); + bool ret = PortImpl::apply_poly(context, maid, poly); if (!ret) poly = 1; @@ -120,14 +120,10 @@ InputPort::get_buffers(BufferFactory& bufs, * will audibly take effect. */ void -InputPort::add_edge(EdgeImpl* c) +InputPort::add_edge(ProcessContext& context, EdgeImpl* c) { - ThreadManager::assert_thread(THREAD_PROCESS); - _edges.push_front(*c); - - // Broadcast value/activity of connected input - _broadcast = true; + _broadcast = true; // Broadcast value/activity of connected input } /** Remove a edge. Realtime safe. diff --git a/src/server/InputPort.hpp b/src/server/InputPort.hpp index ea52b15e..2565a48d 100644 --- a/src/server/InputPort.hpp +++ b/src/server/InputPort.hpp @@ -67,11 +67,11 @@ public: boost::intrusive::constant_time_size<false> > Edges; - void add_edge(EdgeImpl* c); + void add_edge(ProcessContext& context, EdgeImpl* c); EdgeImpl* remove_edge(ProcessContext& context, const OutputPort* tail); - bool apply_poly(Raul::Maid& maid, uint32_t poly); + bool apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly); bool get_buffers(BufferFactory& bufs, Raul::Array<BufferRef>* buffers, diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 40644a08..46234af0 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -319,9 +319,8 @@ JackDriver::deactivate() * See create_port() and remove_port(). */ void -JackDriver::add_port(EnginePort* port) +JackDriver::add_port(ProcessContext& context, EnginePort* port) { - ThreadManager::assert_thread(THREAD_PROCESS); assert(dynamic_cast<JackPort*>(port)); _ports.push_back((JackPort*)port); } @@ -335,10 +334,10 @@ JackDriver::add_port(EnginePort* port) * It is the callers responsibility to delete the returned port. */ Raul::Deletable* -JackDriver::remove_port(const Raul::Path& path, EnginePort** port) +JackDriver::remove_port(ProcessContext& context, + const Raul::Path& path, + EnginePort** port) { - ThreadManager::assert_thread(THREAD_PROCESS); - for (Raul::List<JackPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) { if ((*i)->patch_port()->path() == path) { Raul::List<JackPort*>::Node* node = _ports.erase(i); @@ -379,10 +378,9 @@ JackDriver::create_port(DuplexPort* patch_port) } EnginePort* -JackDriver::engine_port(const Raul::Path& path) +JackDriver::engine_port(ProcessContext& context, + const Raul::Path& path) { - ThreadManager::assert_thread(THREAD_PROCESS); - for (Raul::List<JackPort*>::iterator i = _ports.begin(); i != _ports.end(); ++i) if ((*i)->patch_port()->path() == path) return (*i); diff --git a/src/server/JackDriver.hpp b/src/server/JackDriver.hpp index a2da2034..a63b6e6b 100644 --- a/src/server/JackDriver.hpp +++ b/src/server/JackDriver.hpp @@ -99,10 +99,12 @@ public: EnginePort* port(const Raul::Path& path); EnginePort* create_port(DuplexPort* patch_port); - void add_port(EnginePort* port); - EnginePort* engine_port(const Raul::Path& path); + void add_port(ProcessContext& context, EnginePort* port); + EnginePort* engine_port(ProcessContext& context, const Raul::Path& path); - Raul::Deletable* remove_port(const Raul::Path& path, EnginePort** port=NULL); + Raul::Deletable* remove_port(ProcessContext& context, + const Raul::Path& path, + EnginePort** port = NULL); /** Transport state for this frame. * Intended to only be called from the audio thread. */ diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 40e13520..516441f0 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -113,7 +113,7 @@ LV2Node::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly) +LV2Node::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) { if (!_polyphonic) poly = 1; @@ -125,7 +125,7 @@ LV2Node::apply_poly(Raul::Maid& maid, uint32_t poly) } assert(poly <= _instances->size()); - return NodeImpl::apply_poly(maid, poly); + return NodeImpl::apply_poly(context, maid, poly); } /** Instantiate self from LV2 plugin descriptor. @@ -274,6 +274,8 @@ LV2Node::instantiate(BufferFactory& bufs) if (lilv_node_is_int(d)) { size_t size_val = lilv_node_as_int(d); port_buffer_size = size_val; + Raul::info << "Atom port " << path() << " buffer size " + << port_buffer_size << std::endl; } } } diff --git a/src/server/LV2Node.hpp b/src/server/LV2Node.hpp index 6309acf2..b0102772 100644 --- a/src/server/LV2Node.hpp +++ b/src/server/LV2Node.hpp @@ -50,7 +50,7 @@ public: bool instantiate(BufferFactory& bufs); bool prepare_poly(BufferFactory& bufs, uint32_t poly); - bool apply_poly(Raul::Maid& maid, uint32_t poly); + bool apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly); void activate(BufferFactory& bufs); void deactivate(); diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp index f6d57146..1778e277 100644 --- a/src/server/NodeImpl.cpp +++ b/src/server/NodeImpl.cpp @@ -28,6 +28,7 @@ #include "PatchImpl.hpp" #include "PluginImpl.hpp" #include "PortImpl.hpp" +#include "ProcessContext.hpp" #include "ThreadManager.hpp" #include "util.hpp" @@ -133,10 +134,8 @@ NodeImpl::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -NodeImpl::apply_poly(Raul::Maid& maid, uint32_t poly) +NodeImpl::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) { - ThreadManager::assert_thread(THREAD_PROCESS); - if (!_polyphonic) poly = 1; @@ -144,7 +143,7 @@ NodeImpl::apply_poly(Raul::Maid& maid, uint32_t poly) if (_ports) for (size_t i = 0; i < num_ports(); ++i) - _ports->at(i)->apply_poly(maid, poly); + _ports->at(i)->apply_poly(context, maid, poly); return true; } @@ -186,9 +185,8 @@ NodeImpl::process_unlock() } void -NodeImpl::wait_for_input(size_t num_providers) +NodeImpl::wait_for_input(ProcessContext& context, size_t num_providers) { - ThreadManager::assert_thread(THREAD_PROCESS); assert(_process_lock.get() == 1); while ((unsigned)_n_inputs_ready.get() < num_providers) @@ -196,9 +194,8 @@ NodeImpl::wait_for_input(size_t num_providers) } void -NodeImpl::signal_input_ready() +NodeImpl::signal_input_ready(ProcessContext& context) { - ThreadManager::assert_thread(THREAD_PROCESS); ++_n_inputs_ready; _input_ready.post(); } @@ -206,10 +203,8 @@ NodeImpl::signal_input_ready() /** Prepare to run a cycle (in the audio thread) */ void -NodeImpl::pre_process(Context& context) +NodeImpl::pre_process(ProcessContext& context) { - ThreadManager::assert_thread(THREAD_PROCESS); - // Mix down input ports for (uint32_t i = 0; i < num_ports(); ++i) { PortImpl* const port = _ports->at(i); @@ -221,10 +216,8 @@ NodeImpl::pre_process(Context& context) /** Prepare to run a cycle (in the audio thread) */ void -NodeImpl::post_process(Context& context) +NodeImpl::post_process(ProcessContext& context) { - ThreadManager::assert_thread(THREAD_PROCESS); - // Write output ports for (size_t i = 0; _ports && i < _ports->size(); ++i) { _ports->at(i)->post_process(context); diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp index 03b0fcbe..7da07dc2 100644 --- a/src/server/NodeImpl.hpp +++ b/src/server/NodeImpl.hpp @@ -105,14 +105,14 @@ public: /** Parallelism: Wait for signal that input is ready. * Only a thread which successfully called process_lock may call this. */ - virtual void wait_for_input(size_t num_providers); + virtual void wait_for_input(ProcessContext& context, size_t num_providers); /** Parallelism: Signal that input is ready. Realtime safe. * Calling this will wake up the thread which blocked on wait_for_input * if there is one, and otherwise cause it to return true the next call. * \return true if lock was aquired and input is ready, false otherwise */ - virtual void signal_input_ready(); + virtual void signal_input_ready(ProcessContext& context); /** Parallelism: Return the number of providers that have signalled. */ virtual unsigned n_inputs_ready() const { return _n_inputs_ready.get(); } @@ -126,7 +126,7 @@ public: const void* data) {} /** Do whatever needs doing in the process thread before process() is called */ - virtual void pre_process(Context& context); + virtual void pre_process(ProcessContext& context); /** Run the node for @a nframes input/output. * @@ -136,7 +136,7 @@ public: virtual void process(ProcessContext& context) = 0; /** Do whatever needs doing in the process thread after process() is called */ - virtual void post_process(Context& context); + virtual void post_process(ProcessContext& context); /** Set the buffer of a port to a given buffer (e.g. connect plugin to buffer) */ virtual void set_port_buffer(uint32_t voice, @@ -162,7 +162,8 @@ public: virtual void set_polyphonic(bool p) { _polyphonic = p; } virtual bool prepare_poly(BufferFactory& bufs, uint32_t poly); - virtual bool apply_poly(Raul::Maid& maid, uint32_t poly); + virtual bool apply_poly( + ProcessContext& context, Raul::Maid& maid, uint32_t poly); /** Information about the Plugin this Node is an instance of. * Not the best name - not all nodes come from plugins (e.g. Patch) diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index 02b43d02..dd20fbf1 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -91,14 +91,12 @@ PatchImpl::deactivate() } void -PatchImpl::disable() +PatchImpl::disable(ProcessContext& context) { - ThreadManager::assert_thread(THREAD_PROCESS); - _process = false; - - for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) + for (Ports::iterator i = _outputs.begin(); i != _outputs.end(); ++i) { (*i)->clear_buffers(); + } } bool @@ -127,7 +125,7 @@ PatchImpl::apply_internal_poly(ProcessContext& context, // TODO: Subpatch dynamic polyphony (i.e. changing port polyphony) for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) - (*i)->apply_poly(maid, poly); + (*i)->apply_poly(context, maid, poly); for (Nodes::iterator i = _nodes.begin(); i != _nodes.end(); ++i) { for (uint32_t j = 0; j < (*i)->num_ports(); ++j) { @@ -216,7 +214,7 @@ PatchImpl::process_parallel(ProcessContext& context) /* Signal dependants their input is ready */ for (uint32_t i = 0; i < n.dependants().size(); ++i) - n.dependants()[i]->signal_input_ready(); + n.dependants()[i]->signal_input_ready(context); ++num_finished; } else { diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp index 5a0dbc9a..02df6fca 100644 --- a/src/server/PatchImpl.hpp +++ b/src/server/PatchImpl.hpp @@ -150,7 +150,7 @@ public: /** Whether to run this patch's DSP bits in the audio thread */ bool enabled() const { return _process; } void enable() { _process = true; } - void disable(); + void disable(ProcessContext& context); uint32_t internal_poly() const { return _internal_poly; } diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index e18ced10..e9bb39ac 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -98,10 +98,8 @@ PortImpl::supports(const Raul::URI& value_type) const } Raul::Array<BufferRef>* -PortImpl::set_buffers(Raul::Array<BufferRef>* buffers) +PortImpl::set_buffers(ProcessContext& context, Raul::Array<BufferRef>* buffers) { - ThreadManager::assert_thread(THREAD_PROCESS); - Raul::Array<BufferRef>* ret = NULL; if (buffers != _buffers) { ret = _buffers; @@ -146,9 +144,8 @@ PortImpl::prepare_poly_buffers(BufferFactory& bufs) } bool -PortImpl::apply_poly(Raul::Maid& maid, uint32_t poly) +PortImpl::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) { - ThreadManager::assert_thread(THREAD_PROCESS); if (_type != PortType::CONTROL && _type != PortType::CV && _type != PortType::AUDIO) { @@ -164,7 +161,7 @@ PortImpl::apply_poly(Raul::Maid& maid, uint32_t poly) _poly = poly; // Apply a new set of buffers from a preceding call to prepare_poly - maid.push(set_buffers(_prepared_buffers)); + maid.push(set_buffers(context, _prepared_buffers)); assert(_buffers == _prepared_buffers); _prepared_buffers = NULL; diff --git a/src/server/PortImpl.hpp b/src/server/PortImpl.hpp index ddbaa087..da2ba237 100644 --- a/src/server/PortImpl.hpp +++ b/src/server/PortImpl.hpp @@ -61,7 +61,8 @@ public: * Audio thread. Returned value must be freed by caller. * \a buffers must be poly() long */ - Raul::Array<BufferRef>* set_buffers(Raul::Array<BufferRef>* buffers); + Raul::Array<BufferRef>* set_buffers(ProcessContext& context, + Raul::Array<BufferRef>* buffers); /** Prepare for a new (external) polyphony value. * @@ -76,7 +77,8 @@ public: * Audio thread. * \a poly Must be < the most recent value passed to prepare_poly. */ - virtual bool apply_poly(Raul::Maid& maid, uint32_t poly); + virtual bool apply_poly( + ProcessContext& context, Raul::Maid& maid, uint32_t poly); const Raul::Atom& value() const { return _value; } void set_value(const Raul::Atom& v) { _value = v; } diff --git a/src/server/PostProcessor.cpp b/src/server/PostProcessor.cpp index 7a51f5e9..730156cf 100644 --- a/src/server/PostProcessor.cpp +++ b/src/server/PostProcessor.cpp @@ -42,9 +42,8 @@ PostProcessor::~PostProcessor() } void -PostProcessor::append(Event* first, Event* last) +PostProcessor::append(ProcessContext& context, Event* first, Event* last) { - ThreadManager::assert_thread(THREAD_PROCESS); assert(first); assert(last); assert(!last->next()); diff --git a/src/server/PostProcessor.hpp b/src/server/PostProcessor.hpp index 0f99a572..38a7d43d 100644 --- a/src/server/PostProcessor.hpp +++ b/src/server/PostProcessor.hpp @@ -48,7 +48,7 @@ public: /** Push a list of events on to the process queue. realtime-safe, not thread-safe. */ - void append(Event* first, Event* last); + void append(ProcessContext& context, Event* first, Event* last); /** Post-process and delete all pending events */ void process(); diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index 67d53054..e733771c 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -97,7 +97,7 @@ PreProcessor::process(ProcessContext& context, PostProcessor& dest, bool limit) Event* next = (Event*)last->next(); last->next(NULL); assert(!last->next()); - dest.append(_head.get(), last); + dest.append(context, _head.get(), last); _head = next; if (!next) _tail = NULL; diff --git a/src/server/ProcessContext.hpp b/src/server/ProcessContext.hpp index 1af480be..e10bbce8 100644 --- a/src/server/ProcessContext.hpp +++ b/src/server/ProcessContext.hpp @@ -33,8 +33,6 @@ class ProcessSlave; class ProcessContext : public Context { public: - explicit ProcessContext(Engine& engine); - typedef std::vector<ProcessSlave*> Slaves; const Slaves& slaves() const { return _slaves; } @@ -43,6 +41,9 @@ public: void activate(uint32_t parallelism, bool sched_rt); private: + friend class Engine; + explicit ProcessContext(Engine& engine); + Slaves _slaves; }; diff --git a/src/server/ProcessSlave.cpp b/src/server/ProcessSlave.cpp index 6960b5e4..57f45693 100644 --- a/src/server/ProcessSlave.cpp +++ b/src/server/ProcessSlave.cpp @@ -44,13 +44,13 @@ ProcessSlave::_whipped() if (n.node()->process_lock()) { - n.node()->wait_for_input(n.n_providers()); + n.node()->wait_for_input(*_context, n.n_providers()); - n.node()->process(_engine.process_context()); + n.node()->process(*_context); /* Signal dependants their input is ready */ for (size_t i=0; i < n.dependants().size(); ++i) - n.dependants()[i]->signal_input_ready(); + n.dependants()[i]->signal_input_ready(*_context); num_finished = 1; } else { diff --git a/src/server/ProcessSlave.hpp b/src/server/ProcessSlave.hpp index 4bafb1c7..d15ff5af 100644 --- a/src/server/ProcessSlave.hpp +++ b/src/server/ProcessSlave.hpp @@ -38,6 +38,7 @@ class ProcessSlave : protected Raul::Slave { public: ProcessSlave(Engine& engine, bool realtime) : _engine(engine) + , _context(NULL) , _id(_next_id++) , _index(0) , _state(STATE_FINISHED) @@ -65,6 +66,7 @@ public: ProcessContext& context) { assert(_state == STATE_FINISHED); + _context = &context; _index = start_index; _state = STATE_RUNNING; _compiled_patch = compiled_patch; @@ -89,6 +91,7 @@ private: static const int STATE_FINISHED = 2; Engine& _engine; + ProcessContext* _context; uint32_t _id; uint32_t _index; Raul::AtomicInt _state; diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index 7f28c3e6..e0b42424 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -159,9 +159,9 @@ Connect::execute(ProcessContext& context) if (_status == SUCCESS) { // This must be inserted here, since they're actually used by the audio thread - _dst_input_port->add_edge(_edge.get()); + _dst_input_port->add_edge(context, _edge.get()); assert(_buffers); - _engine.maid()->push(_dst_input_port->set_buffers(_buffers)); + _engine.maid()->push(_dst_input_port->set_buffers(context, _buffers)); _dst_input_port->connect_buffers(); _engine.maid()->push(_patch->compiled_patch()); _patch->compiled_patch(_compiled_patch); diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 92121fb8..0098ae6a 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -172,7 +172,7 @@ CreatePort::execute(ProcessContext& context) } if (_engine_port) { - _engine.driver()->add_port(_engine_port); + _engine.driver()->add_port(context, _engine_port); } } diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp index c7e658bc..4df6efb6 100644 --- a/src/server/events/Delete.cpp +++ b/src/server/events/Delete.cpp @@ -155,7 +155,7 @@ Delete::execute(ProcessContext& context) _port->parent_patch()->external_ports(_ports_array); if ( ! _port->parent_patch()->parent()) - _garbage = _engine.driver()->remove_port(_port->path(), &_engine_port); + _garbage = _engine.driver()->remove_port(context, _port->path(), &_engine_port); } if (parent_patch) { diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index 04e3fb93..d6fd999e 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -186,7 +186,7 @@ Disconnect::Impl::execute(ProcessContext& context, bool set_dst_buffers) if (set_dst_buffers) { if (_buffers) { - _engine.maid()->push(_dst_input_port->set_buffers(_buffers)); + _engine.maid()->push(_dst_input_port->set_buffers(context, _buffers)); } else { _dst_input_port->setup_buffers(*_engine.buffer_factory(), _dst_input_port->poly()); diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp index a7273d81..ecfe9508 100644 --- a/src/server/events/Move.cpp +++ b/src/server/events/Move.cpp @@ -103,9 +103,9 @@ Move::execute(ProcessContext& context) SharedPtr<PortImpl> port = PtrCast<PortImpl>(_store_iterator->second); if (port && port->parent()->parent() == NULL) { - EnginePort* engine_port = _engine.driver()->engine_port(_new_path); - if (engine_port) { - engine_port->move(_new_path); + EnginePort* eport = _engine.driver()->engine_port(context, _new_path); + if (eport) { + eport->move(_new_path); } } } diff --git a/src/server/events/SetMetadata.cpp b/src/server/events/SetMetadata.cpp index 7e9c531d..5849269a 100644 --- a/src/server/events/SetMetadata.cpp +++ b/src/server/events/SetMetadata.cpp @@ -303,16 +303,16 @@ SetMetadata::execute(ProcessContext& context) } _patch->enable(); } else { - _patch->disable(); + _patch->disable(context); } break; case POLYPHONIC: { PatchImpl* parent = reinterpret_cast<PatchImpl*>(object->parent()); if (value.get_bool()) - object->apply_poly(*_engine.maid(), parent->internal_poly()); + object->apply_poly(context, *_engine.maid(), parent->internal_poly()); else - object->apply_poly(*_engine.maid(), 1); + object->apply_poly(context, *_engine.maid(), 1); } break; case POLYPHONY: diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index ec91d6fc..b33f412a 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -129,7 +129,7 @@ private: public: LV2Driver(Engine& engine, SampleCount buffer_size, SampleCount sample_rate) - : _context(engine) + : _engine(engine) , _reader(engine.world()->uri_map(), engine.world()->uris(), engine.world()->forge(), @@ -147,20 +147,20 @@ public: {} void run(uint32_t nframes) { - _context.locate(_frame_time, nframes, 0); + _engine.process_context().locate(_frame_time, nframes, 0); for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) - (*i)->pre_process(_context); + (*i)->pre_process(_engine.process_context()); - _context.engine().process_events(_context); + _engine.process_events(); if (_root_patch) - _root_patch->process(_context); + _root_patch->process(_engine.process_context()); flush_to_ui(); for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) - (*i)->post_process(_context); + (*i)->post_process(_engine.process_context()); _frame_time += nframes; } @@ -168,19 +168,17 @@ public: virtual void set_root_patch(PatchImpl* patch) { _root_patch = patch; } virtual PatchImpl* root_patch() { return _root_patch; } - virtual void add_port(EnginePort* port) { + virtual void add_port(ProcessContext& context, EnginePort* port) { // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports - ThreadManager::assert_thread(THREAD_PROCESS); assert(dynamic_cast<LV2Port*>(port)); assert(port->patch_port()->index() == _ports.size()); _ports.push_back((LV2Port*)port); } - virtual Raul::Deletable* remove_port(const Raul::Path& path, - EnginePort** port=NULL) { + virtual Raul::Deletable* remove_port(ProcessContext& context, + const Raul::Path& path, + EnginePort** port = NULL) { // Note this doesn't have to be realtime safe since there's no dynamic LV2 ports - ThreadManager::assert_thread(THREAD_PROCESS); - for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) { if ((*i)->patch_port()->path() == path) { _ports.erase(i); @@ -196,9 +194,8 @@ public: return new LV2Port(this, patch_port); } - virtual EnginePort* engine_port(const Raul::Path& path) { - ThreadManager::assert_thread(THREAD_PROCESS); - + virtual EnginePort* engine_port(ProcessContext& context, + const Raul::Path& path) { for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) if ((*i)->patch_port()->path() == path) return (*i); @@ -230,7 +227,7 @@ public: const uint32_t capacity = seq->atom.size; // Initialise output port buffer to an empty Sequence - seq->atom.type = _context.engine().world()->uris().atom_Sequence; + seq->atom.type = _engine.world()->uris().atom_Sequence; seq->atom.size = sizeof(LV2_Atom_Sequence_Body); const uint32_t read_space = _to_ui.read_space(); @@ -269,14 +266,14 @@ public: virtual SampleCount frame_time() const { return _frame_time;} virtual bool is_realtime() const { return true; } - virtual ProcessContext& context() { return _context; } + //virtual ProcessContext& context() { return _context; } Shared::AtomReader& reader() { return _reader; } Shared::AtomWriter& writer() { return _writer; } Ports& ports() { return _ports; } private: - ProcessContext _context; + Engine& _engine; Shared::AtomReader _reader; Shared::AtomWriter _writer; Raul::RingBuffer _to_ui; @@ -432,11 +429,10 @@ ingen_instantiate(const LV2_Descriptor* descriptor, engine->activate(); Server::ThreadManager::single_threaded = true; - ProcessContext context(*engine.get()); - context.locate(0, UINT_MAX, 0); + engine->process_context().locate(0, UINT_MAX, 0); engine->post_processor()->set_end_time(UINT_MAX); - engine->process_events(context); + engine->process_events(); engine->post_processor()->process(); plugin->world->parser()->parse_file(plugin->world, @@ -444,7 +440,7 @@ ingen_instantiate(const LV2_Descriptor* descriptor, patch->filename); while (engine->pending_events()) { - engine->process_events(context); + engine->process_events(); engine->post_processor()->process(); } diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp index 9e7fbb04..e131fb69 100644 --- a/src/server/internals/Note.cpp +++ b/src/server/internals/Note.cpp @@ -116,9 +116,9 @@ NoteNode::prepare_poly(BufferFactory& bufs, uint32_t poly) } bool -NoteNode::apply_poly(Raul::Maid& maid, uint32_t poly) +NoteNode::apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly) { - if (!NodeImpl::apply_poly(maid, poly)) + if (!NodeImpl::apply_poly(context, maid, poly)) return false; if (_prepared_voices) { diff --git a/src/server/internals/Note.hpp b/src/server/internals/Note.hpp index 687a8871..22aaee7d 100644 --- a/src/server/internals/Note.hpp +++ b/src/server/internals/Note.hpp @@ -50,7 +50,7 @@ public: ~NoteNode(); bool prepare_poly(BufferFactory& bufs, uint32_t poly); - bool apply_poly(Raul::Maid& maid, uint32_t poly); + bool apply_poly(ProcessContext& context, Raul::Maid& maid, uint32_t poly); void process(ProcessContext& context); |