summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/Buffer.cpp6
-rw-r--r--src/server/Buffer.hpp2
-rw-r--r--src/server/NodeFactory.cpp2
-rw-r--r--src/server/ingen_lv2.cpp37
4 files changed, 32 insertions, 15 deletions
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 79ec3847..2c990c02 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -91,7 +91,11 @@ Buffer::clear()
_atom->size = _capacity - sizeof(LV2_Atom);
set_block(0, 0, nframes());
} else if (is_sequence()) {
- _atom->size = sizeof(LV2_Atom_Sequence_Body);
+ LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_atom;
+ _atom->type = _factory.uris().atom_Sequence;
+ _atom->size = sizeof(LV2_Atom_Sequence_Body);
+ seq->body.unit = 0;
+ seq->body.pad = 0;
}
}
diff --git a/src/server/Buffer.hpp b/src/server/Buffer.hpp
index fd4151b8..3a06c3fd 100644
--- a/src/server/Buffer.hpp
+++ b/src/server/Buffer.hpp
@@ -130,6 +130,8 @@ public:
LV2_Atom* atom() { return _atom; }
const LV2_Atom* atom() const { return _atom; }
+ void set_capacity(uint32_t capacity) { _capacity = capacity; }
+
inline void ref() { ++_refs; }
inline void deref() {
diff --git a/src/server/NodeFactory.cpp b/src/server/NodeFactory.cpp
index 3f07e534..6683658b 100644
--- a/src/server/NodeFactory.cpp
+++ b/src/server/NodeFactory.cpp
@@ -18,7 +18,6 @@
#include "lilv/lilv.h"
-#include "ingen/Log.hpp"
#include "ingen/World.hpp"
#include "internals/Controller.hpp"
#include "internals/Delay.hpp"
@@ -121,7 +120,6 @@ NodeFactory::load_lv2_plugins()
const Raul::URI uri(lilv_node_as_uri(lilv_plugin_get_uri(lv2_plug)));
if (_plugins.find(uri) != _plugins.end()) {
- _world->log().warn(Raul::fmt("Already discovered <%s>\n") % uri);
continue;
}
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 100e1a4c..69775873 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -102,6 +102,7 @@ public:
, _from_ui(block_length * sizeof(float)) // FIXME: size
, _to_ui(block_length * sizeof(float)) // FIXME: size
, _root_patch(NULL)
+ , _notify_capacity(0)
, _block_length(block_length)
, _sample_rate(sample_rate)
, _frame_time(0)
@@ -165,7 +166,9 @@ public:
context.nframes() * sizeof(float));
} else if (patch_port->is_a(PortType::CONTROL)) {
((float*)buffer)[0] = patch_buf->samples()[0];
- } else {
+ } else if (patch_port->index() != 1) {
+ /* Copy Sequence output to LV2 buffer, except notify output which
+ is written by flush_to_ui() (TODO: merge) */
memcpy(buffer,
patch_buf->atom(),
sizeof(LV2_Atom) + patch_buf->atom()->size);
@@ -175,6 +178,9 @@ public:
void run(uint32_t nframes) {
_engine.process_context().locate(_frame_time, nframes);
+ // Notify buffer is a Chunk with size set to the available space
+ _notify_capacity = ((LV2_Atom_Sequence*)_ports[1]->buffer())->atom.size;
+
for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
pre_process_port(_engine.process_context(), *i);
}
@@ -184,7 +190,7 @@ public:
_main_sem.post();
}
- flush_to_ui();
+ flush_to_ui(_engine.process_context());
for (Ports::iterator i = _ports.begin(); i != _ports.end(); ++i) {
post_process_port(_engine.process_context(), *i);
@@ -211,8 +217,16 @@ public:
return NULL;
}
- /** Unused since LV2 has no dynamic ports. */
- virtual void add_port(ProcessContext& context, EnginePort* port) {}
+ /** This does not have to be real-time since LV2 has no dynamic ports.
+ * It is only called on initial load.
+ */
+ virtual void add_port(ProcessContext& context, EnginePort* port) {
+ const uint32_t index = port->patch_port()->index();
+ if (_ports.size() <= index) {
+ _ports.resize(index + 1);
+ }
+ _ports[index] = port;
+ }
/** Unused since LV2 has no dynamic ports. */
virtual void remove_port(ProcessContext& context, EnginePort* port) {}
@@ -280,18 +294,15 @@ public:
free(buf);
}
- void flush_to_ui() {
+ void flush_to_ui(ProcessContext& context) {
assert(_ports.size() >= 2);
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[1]->buffer();
if (!seq) {
- _engine.log().error("Control out port not connected\n");
+ _engine.log().error("Notify output not connected\n");
return;
}
- // Output port buffer is a Chunk with size set to the available space
- const uint32_t capacity = seq->atom.size;
-
// Initialise output port buffer to an empty Sequence
seq->atom.type = _engine.world()->uris().atom_Sequence;
seq->atom.size = sizeof(LV2_Atom_Sequence_Body);
@@ -304,7 +315,8 @@ public:
break;
}
- if (seq->atom.size + sizeof(LV2_Atom) + atom.size > capacity) {
+ if (seq->atom.size + sizeof(LV2_Atom) + atom.size > _notify_capacity) {
+ std::cerr << "Notify overflow" << std::endl;
break; // Output port buffer full, resume next time
}
@@ -348,6 +360,7 @@ private:
Raul::RingBuffer _from_ui;
Raul::RingBuffer _to_ui;
PatchImpl* _root_patch;
+ uint32_t _notify_capacity;
SampleCount _block_length;
SampleCount _sample_rate;
SampleCount _frame_time;
@@ -576,8 +589,8 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
assert(driver->ports().at(port)->patch_port()->index() == port);
assert(driver->ports().at(port)->buffer() == data);
} else {
- engine->log().warn(Raul::fmt("Connect to non-existent port %1%\n")
- % port);
+ engine->log().error(Raul::fmt("Connect to non-existent port %1%\n")
+ % port);
}
}