summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-10-04 21:01:02 +0000
committerDavid Robillard <d@drobilla.net>2008-10-04 21:01:02 +0000
commit5366cd25f52fca092dcab78c5e589cec4970dd43 (patch)
tree1cb087b489d7573f2fc19046003724eb17aad60a /src
parente7967c58dee37454e8b450052fdd15f1656ae042 (diff)
downloadingen-5366cd25f52fca092dcab78c5e589cec4970dd43.tar.gz
ingen-5366cd25f52fca092dcab78c5e589cec4970dd43.tar.bz2
ingen-5366cd25f52fca092dcab78c5e589cec4970dd43.zip
Apply context extension fixes from kfoltman.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1614 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/engine/LV2Node.cpp26
-rw-r--r--src/engine/LV2Node.hpp5
2 files changed, 19 insertions, 12 deletions
diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp
index 9f3be720..d8b4c29c 100644
--- a/src/engine/LV2Node.cpp
+++ b/src/engine/LV2Node.cpp
@@ -28,7 +28,6 @@
#include "EventBuffer.hpp"
#include "OutputPort.hpp"
#include "ProcessContext.hpp"
-#include "lv2_contexts.h"
using namespace std;
@@ -50,7 +49,7 @@ LV2Node::LV2Node(LV2Plugin* plugin,
, _lv2_plugin(plugin)
, _instances(NULL)
, _prepared_instances(NULL)
- , _message_run(NULL)
+ , _message_funcs(NULL)
{
assert(_lv2_plugin);
}
@@ -150,12 +149,10 @@ LV2Node::instantiate()
const void* ctx_ext = slv2_instance_get_extension_data(
(*_instances)[i], LV2_CONTEXT_MESSAGE);
- if (ctx_ext) {
+ if (i == 0 && ctx_ext) {
cerr << "HAS CONTEXT EXTENSION" << endl;
- if (_message_run == NULL)
- _message_run = new MessageRunFuncs(_polyphony, NULL);
- LV2MessageContext* mc = (LV2MessageContext*)ctx_ext;
- (*_message_run)[i] = mc->message_run;
+ assert(!_message_funcs);
+ _message_funcs = (LV2MessageContext*)ctx_ext;
}
}
@@ -226,6 +223,10 @@ LV2Node::instantiate()
const char* context = slv2_value_as_string(c);
if (!strcmp("http://lv2plug.in/ns/dev/contexts#MessageContext", context)) {
cout << "MESSAGE CONTEXT!" << endl;
+ if (!_message_funcs) {
+ cerr << "Plugin " << _lv2_plugin->name()
+ << " has a message port, but no context extension data." << endl;
+ }
port->set_context(Context::MESSAGE);
} else {
cout << "UNKNOWN CONTEXT: "
@@ -279,8 +280,8 @@ void
LV2Node::message_process(MessageContext& context, uint32_t* output)
{
// FIXME: voice
- if (_message_run)
- (*_message_run)[0]((*_instances)[0], output);
+ if (_message_funcs)
+ (*_message_funcs->message_run)((*_instances)[0], output);
/* MESSAGE PROCESS */
}
@@ -304,6 +305,13 @@ LV2Node::set_port_buffer(uint32_t voice, uint32_t port_num, Buffer* buf)
assert(voice < _polyphony);
slv2_instance_connect_port((*_instances)[voice], port_num, buf->raw_data());
+ if ((*_ports).at(port_num)->context() == Context::MESSAGE) {
+ assert(_message_funcs);
+ assert(_message_funcs->message_connect_port);
+ (*_message_funcs->message_connect_port)((*_instances)[voice], port_num, buf->raw_data());
+ } else {
+ slv2_instance_connect_port((*_instances)[voice], port_num, buf->raw_data());
+ }
}
diff --git a/src/engine/LV2Node.hpp b/src/engine/LV2Node.hpp
index 3187005c..1e821c6e 100644
--- a/src/engine/LV2Node.hpp
+++ b/src/engine/LV2Node.hpp
@@ -20,6 +20,7 @@
#include <string>
#include <slv2/slv2.h>
+#include "lv2_contexts.h"
#include "types.hpp"
#include "NodeBase.hpp"
@@ -63,9 +64,7 @@ protected:
Raul::Array<SLV2Instance>* _instances;
Raul::Array<SLV2Instance>* _prepared_instances;
- typedef bool (*MessageRunFunc)(LV2_Handle, uint32_t*);
- typedef Raul::Array<MessageRunFunc> MessageRunFuncs;
- MessageRunFuncs* _message_run;
+ LV2MessageContext* _message_funcs;
};