diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/BufferFactory.cpp | 6 | ||||
-rw-r--r-- | src/server/BufferFactory.hpp | 2 | ||||
-rw-r--r-- | src/server/LV2Node.cpp | 2 | ||||
-rw-r--r-- | src/server/PortImpl.cpp | 2 | ||||
-rw-r--r-- | src/server/events/CreatePort.cpp | 98 | ||||
-rw-r--r-- | src/server/events/CreatePort.hpp | 7 |
6 files changed, 57 insertions, 60 deletions
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp index 2726d7e3..a11f1c35 100644 --- a/src/server/BufferFactory.cpp +++ b/src/server/BufferFactory.cpp @@ -74,7 +74,7 @@ BufferFactory::audio_buffer_size(SampleCount nframes) } uint32_t -BufferFactory::default_buffer_size(LV2_URID type) +BufferFactory::default_size(LV2_URID type) const { if (type == _uris.atom_Float) { return sizeof(LV2_Atom_Float); @@ -132,14 +132,14 @@ BufferFactory::create(LV2_URID type, uint32_t capacity) Buffer* buffer = NULL; if (capacity == 0) { - capacity = default_buffer_size(type); + capacity = default_size(type); } if (type == _uris.atom_Float) { assert(capacity >= sizeof(LV2_Atom_Float)); buffer = new AudioBuffer(*this, type, capacity); } else if (type == _uris.atom_Sound) { - assert(capacity >= default_buffer_size(_uris.atom_Sound)); + assert(capacity >= default_size(_uris.atom_Sound)); buffer = new AudioBuffer(*this, type, capacity); } else { buffer = new Buffer(*this, type, capacity); diff --git a/src/server/BufferFactory.hpp b/src/server/BufferFactory.hpp index ee6ca5d9..366c2ffa 100644 --- a/src/server/BufferFactory.hpp +++ b/src/server/BufferFactory.hpp @@ -49,7 +49,7 @@ public: ~BufferFactory(); static uint32_t audio_buffer_size(SampleCount nframes); - uint32_t default_buffer_size(LV2_URID type); + uint32_t default_size(LV2_URID type) const; BufferRef get(Context& context, LV2_URID type, diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp index 077c94b2..2e2631ac 100644 --- a/src/server/LV2Node.cpp +++ b/src/server/LV2Node.cpp @@ -251,7 +251,7 @@ LV2Node::instantiate(BufferFactory& bufs) } } - port_buffer_size = bufs.default_buffer_size(buffer_type); + port_buffer_size = bufs.default_size(buffer_type); if (port_type == PortType::ATOM) { // Get default value, and its length diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 8ce8ac91..27d56bfc 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -64,7 +64,7 @@ PortImpl::PortImpl(BufferFactory& bufs, const Ingen::Shared::URIs& uris = bufs.uris(); if (_buffer_size == 0) { - _buffer_size = bufs.default_buffer_size(buffer_type); + _buffer_size = bufs.default_size(buffer_type); } if (_buffer_type == 0) { diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index 9f061238..654f0ba2 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -20,18 +20,15 @@ #include "ingen/shared/URIs.hpp" #include "raul/Array.hpp" #include "raul/Atom.hpp" -#include "raul/Maid.hpp" #include "raul/Path.hpp" #include "Broadcaster.hpp" -#include "ControlBindings.hpp" #include "CreatePort.hpp" #include "Driver.hpp" #include "DuplexPort.hpp" #include "Engine.hpp" #include "EngineStore.hpp" #include "PatchImpl.hpp" -#include "PluginImpl.hpp" #include "PortImpl.hpp" namespace Ingen { @@ -48,7 +45,7 @@ CreatePort::CreatePort(Engine& engine, : Event(engine, client, id, timestamp) , _path(path) , _port_type(PortType::UNKNOWN) - , _buffer_type(0) + , _buf_type(0) , _patch(NULL) , _patch_port(NULL) , _ports_array(NULL) @@ -78,7 +75,7 @@ CreatePort::CreatePort(Engine& engine, const Range buffer_types = properties.equal_range(uris.atom_bufferType); for (Iterator i = buffer_types.first; i != buffer_types.second; ++i) { if (i->second.type() == _engine.world()->forge().URI) { - _buffer_type = _engine.world()->uri_map().map_uri(i->second.get_uri()); + _buf_type = _engine.world()->uri_map().map_uri(i->second.get_uri()); } } } @@ -98,81 +95,78 @@ CreatePort::pre_process() return Event::pre_process_done(PARENT_NOT_FOUND); } - const Ingen::Shared::URIs& uris = _engine.world()->uris(); - - assert(_patch->path() == _path.parent()); + const Shared::URIs& uris = _engine.world()->uris(); + const BufferFactory& buffer_factory = *_engine.buffer_factory(); - size_t buffer_size = _engine.buffer_factory()->default_buffer_size(_buffer_type); + const uint32_t buf_size = buffer_factory.default_size(_buf_type); + const int32_t old_n_ports = _patch->num_ports_non_rt(); - const uint32_t old_num_ports = (_patch->external_ports()) - ? _patch->external_ports()->size() - : 0; + typedef Resource::Properties::const_iterator PropIter; - Resource::Properties::const_iterator index_i = _properties.find(uris.lv2_index); + PropIter index_i = _properties.find(uris.lv2_index); if (index_i == _properties.end()) { + // No index given, append index_i = _properties.insert( std::make_pair(uris.lv2_index, - _engine.world()->forge().make(int32_t(old_num_ports)))); - } else if (index_i->second.type() != uris.forge.Int - || index_i->second.get_int32() != static_cast<int32_t>(old_num_ports)) { + _engine.world()->forge().make(old_n_ports))); + } else if (index_i->second.type() != uris.forge.Int || + index_i->second.get_int32() != old_n_ports) { return Event::pre_process_done(BAD_INDEX); } - Resource::Properties::const_iterator poly_i = _properties.find(uris.ingen_polyphonic); - bool polyphonic = (poly_i != _properties.end() && - poly_i->second.type() == uris.forge.Bool && - poly_i->second.get_bool()); + const PropIter poly_i = _properties.find(uris.ingen_polyphonic); + const bool polyphonic = (poly_i != _properties.end() && + poly_i->second.type() == uris.forge.Bool && + poly_i->second.get_bool()); if (!(_patch_port = _patch->create_port( *_engine.buffer_factory(), _path.symbol(), - _port_type, _buffer_type, buffer_size, _is_output, polyphonic))) { + _port_type, _buf_type, buf_size, _is_output, polyphonic))) { return Event::pre_process_done(CREATION_FAILED); } _patch_port->properties().insert(_properties.begin(), _properties.end()); - assert(index_i->second == _engine.world()->forge().make((int)_patch_port->index())); - - if (_patch_port) { - if (_is_output) - _patch->add_output(new Raul::List<PortImpl*>::Node(_patch_port)); - else - _patch->add_input(new Raul::List<PortImpl*>::Node(_patch_port)); - - if (_patch->external_ports()) - _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, *_patch->external_ports(), NULL); - else - _ports_array = new Raul::Array<PortImpl*>(old_num_ports + 1, NULL); - - _ports_array->at(old_num_ports) = _patch_port; - _engine.engine_store()->add(_patch_port); - - if (!_patch->parent()) { - _engine_port = _engine.driver()->create_port( - dynamic_cast<DuplexPort*>(_patch_port)); - } - - assert(_ports_array->size() == _patch->num_ports_non_rt()); - + _engine.engine_store()->add(_patch_port); + if (_is_output) { + _patch->add_output(new Raul::List<PortImpl*>::Node(_patch_port)); } else { - return Event::pre_process_done(CREATION_FAILED); + _patch->add_input(new Raul::List<PortImpl*>::Node(_patch_port)); + } + + if (!_patch->parent()) { + _engine_port = _engine.driver()->create_port( + dynamic_cast<DuplexPort*>(_patch_port)); } - _update = _patch_port->properties(); + _ports_array = new Raul::Array<PortImpl*>(old_n_ports + 1, NULL); + _update = _patch_port->properties(); + assert(_patch_port->index() == (uint32_t)index_i->second.get_int32()); + assert(_patch->num_ports_non_rt() == (uint32_t)old_n_ports + 1); + assert(_patch_port->index() == (uint32_t)old_n_ports); + assert(_ports_array->size() == _patch->num_ports_non_rt()); + assert(_patch_port->index() < _ports_array->size()); return Event::pre_process_done(SUCCESS); } void CreatePort::execute(ProcessContext& context) { - if (_patch_port) { - _engine.maid()->push(_patch->external_ports()); + if (!_status) { + _old_ports_array = _patch->external_ports(); + if (_old_ports_array) { + for (uint32_t i = 0; i < _old_ports_array->size(); ++i) { + (*_ports_array)[i] = (*_old_ports_array)[i]; + } + } + assert(!(*_ports_array)[_patch_port->index()]); + (*_ports_array)[_patch_port->index()] = _patch_port; _patch->external_ports(_ports_array); - } - if (_engine_port) { - _engine.driver()->add_port(context, _engine_port); + if (_engine_port) { + _engine.driver()->add_port(context, _engine_port); + } } } @@ -183,6 +177,8 @@ CreatePort::post_process() if (!_status) { _engine.broadcaster()->put(_path, _update); } + + delete _old_ports_array; } } // namespace Events diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp index 3952b1b7..9a524c30 100644 --- a/src/server/events/CreatePort.hpp +++ b/src/server/events/CreatePort.hpp @@ -56,11 +56,12 @@ public: private: Raul::Path _path; PortType _port_type; - LV2_URID _buffer_type; + LV2_URID _buf_type; PatchImpl* _patch; PortImpl* _patch_port; - Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports array for Patch - EnginePort* _engine_port; ///< Driver (eg Jack) port if this is a toplevel port + Raul::Array<PortImpl*>* _ports_array; ///< New external port array for Patch + Raul::Array<PortImpl*>* _old_ports_array; + EnginePort* _engine_port; ///< Driver port if on the root Resource::Properties _properties; Resource::Properties _update; bool _is_output; |