summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-06-05 19:47:16 +0000
committerDavid Robillard <d@drobilla.net>2012-06-05 19:47:16 +0000
commit50c492d119b240946f35505a71c7ee2f59ed6b4a (patch)
treef730f095ded4bd9f1293f55665a6e8a6b65df8a8 /src
parent9c07b402fd51ec42a78d00881e70bf2cc284f0d6 (diff)
downloadingen-50c492d119b240946f35505a71c7ee2f59ed6b4a.tar.gz
ingen-50c492d119b240946f35505a71c7ee2f59ed6b4a.tar.bz2
ingen-50c492d119b240946f35505a71c7ee2f59ed6b4a.zip
Use LV2 buf-size extension.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4493 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/server/ingen_lv2.cpp46
-rw-r--r--src/shared/AtomReader.cpp16
2 files changed, 47 insertions, 15 deletions
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 146a9107..c868bf76 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -24,10 +24,11 @@
#include <glibmm/miscutils.h>
#include <glibmm/timer.h>
-#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
+#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
-#include "lv2/lv2plug.in/ns/ext/atom/util.h"
+#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "ingen/Interface.hpp"
#include "ingen/serialisation/Parser.hpp"
@@ -104,17 +105,19 @@ public:
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_buffer;
bool enqueued = false;
Buffer* patch_buf = _patch_port->buffer(0).get();
+ Shared::URIs& uris = _patch_port->bufs().uris();
patch_buf->prepare_write(context);
LV2_ATOM_SEQUENCE_FOREACH(seq, ev) {
if (!patch_buf->append_event(
ev->time.frames, ev->body.size, ev->body.type,
(const uint8_t*)LV2_ATOM_BODY(&ev->body))) {
- Raul::warn("Failed to write to MIDI buffer, events lost!\n");
+ Raul::warn("Failed to write to buffer, event lost!\n");
}
- // TODO: Only enqueue appropriate atoms
- enqueue_message(context, _driver, &ev->body);
- enqueued = true;
+ if (Shared::AtomReader::is_message(uris, &ev->body)) {
+ enqueue_message(context, _driver, &ev->body);
+ enqueued = true;
+ }
}
if (enqueued) {
@@ -145,7 +148,7 @@ private:
typedef std::vector<LV2Port*> Ports;
public:
- LV2Driver(Engine& engine, SampleCount buffer_size, SampleCount sample_rate)
+ LV2Driver(Engine& engine, SampleCount block_length, SampleCount sample_rate)
: _engine(engine)
, _main_sem(0)
, _reader(engine.world()->uri_map(),
@@ -155,10 +158,10 @@ public:
, _writer(engine.world()->uri_map(),
engine.world()->uris(),
*this)
- , _from_ui(buffer_size * sizeof(float)) // FIXME: size
- , _to_ui(buffer_size * sizeof(float)) // FIXME: size
+ , _from_ui(block_length * sizeof(float)) // FIXME: size
+ , _to_ui(block_length * sizeof(float)) // FIXME: size
, _root_patch(NULL)
- , _buffer_size(buffer_size)
+ , _block_length(block_length)
, _sample_rate(sample_rate)
, _frame_time(0)
, _to_ui_overflow_sem(0)
@@ -322,9 +325,9 @@ public:
_to_ui_overflow_sem.post();
}
- virtual SampleCount block_length() const { return _buffer_size; }
+ virtual SampleCount block_length() const { return _block_length; }
virtual SampleCount sample_rate() const { return _sample_rate; }
- virtual SampleCount frame_time() const { return _frame_time;}
+ virtual SampleCount frame_time() const { return _frame_time; }
virtual bool is_realtime() const { return true; }
Shared::AtomReader& reader() { return _reader; }
@@ -340,7 +343,7 @@ private:
Raul::RingBuffer _from_ui;
Raul::RingBuffer _to_ui;
PatchImpl* _root_patch;
- SampleCount _buffer_size;
+ SampleCount _block_length;
SampleCount _sample_rate;
SampleCount _frame_time;
Ports _ports;
@@ -476,16 +479,29 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
return NULL;
}
- IngenPlugin* plugin = new IngenPlugin();
- LV2_URID_Unmap* unmap = NULL;
+ IngenPlugin* plugin = new IngenPlugin();
+ LV2_URID_Unmap* unmap = NULL;
+ LV2_Buf_Size_Access* access = NULL;
for (int i = 0; features[i]; ++i) {
if (!strcmp(features[i]->URI, LV2_URID__map)) {
plugin->map = (LV2_URID_Map*)features[i]->data;
} else if (!strcmp(features[i]->URI, LV2_URID__unmap)) {
unmap = (LV2_URID_Unmap*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_BUF_SIZE__access)) {
+ access = (LV2_Buf_Size_Access*)features[i]->data;
}
}
+ uint32_t block_length = 4096;
+ if (access) {
+ uint32_t min, multiple_of, power_of;
+ access->get_sample_count(
+ access->handle, &min, &block_length, &multiple_of, &power_of);
+ Raul::info(Raul::fmt("Block length: %1% frames\n") % block_length);
+ } else {
+ Raul::warn("Warning: No buffer size access, guessing 4096 frames.\n");
+ }
+
plugin->world = new Ingen::Shared::World(
plugin->argc, plugin->argv, plugin->map, unmap);
if (!plugin->world->load_module("serialisation")) {
diff --git a/src/shared/AtomReader.cpp b/src/shared/AtomReader.cpp
index cd871079..2bdd9fe1 100644
--- a/src/shared/AtomReader.cpp
+++ b/src/shared/AtomReader.cpp
@@ -81,6 +81,22 @@ AtomReader::atom_to_uri(const LV2_Atom* atom)
}
bool
+AtomReader::is_message(URIs& uris, const LV2_Atom* msg)
+{
+ if (msg->type != uris.atom_Blank && msg->type != uris.atom_Resource) {
+ return false;
+ }
+
+ const LV2_Atom_Object* obj = (const LV2_Atom_Object*)msg;
+ return (obj->body.otype == uris.patch_Get ||
+ obj->body.otype == uris.patch_Delete ||
+ obj->body.otype == uris.patch_Put ||
+ obj->body.otype == uris.patch_Patch ||
+ obj->body.otype == uris.patch_Move ||
+ obj->body.otype == uris.patch_Response);
+}
+
+bool
AtomReader::write(const LV2_Atom* msg)
{
if (msg->type != _uris.atom_Blank && msg->type != _uris.atom_Resource) {