summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/events/SetPortValueQueuedEvent.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-07-28 21:56:03 +0000
committerDavid Robillard <d@drobilla.net>2008-07-28 21:56:03 +0000
commita6fb6a0289ea47692d87f3e0200532a426f8e60d (patch)
tree0e497255eb8a263ff9cca87b2ed125b71144cacb /src/libs/engine/events/SetPortValueQueuedEvent.cpp
parent8e2ba26101828dcf310e0a43ace7aa68dafd3b16 (diff)
downloadingen-a6fb6a0289ea47692d87f3e0200532a426f8e60d.tar.gz
ingen-a6fb6a0289ea47692d87f3e0200532a426f8e60d.tar.bz2
ingen-a6fb6a0289ea47692d87f3e0200532a426f8e60d.zip
Simply global memory management crap by using shared_ptr in the World struct (it's not C anyway, might as well).
Properly support LV2 events from plugin UIs over OSC and directly (w/ monolithic UI/engine). Fix crashes on node destruction with monolithic UI/engine. Resolves ticket #177. git-svn-id: http://svn.drobilla.net/lad/ingen@1293 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events/SetPortValueQueuedEvent.cpp')
-rw-r--r--src/libs/engine/events/SetPortValueQueuedEvent.cpp57
1 files changed, 38 insertions, 19 deletions
diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
index 28bb6df1..14060134 100644
--- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp
+++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp
@@ -16,6 +16,7 @@
*/
#include <sstream>
+#include <iostream>
#include "SetPortValueQueuedEvent.hpp"
#include "Responder.hpp"
#include "Engine.hpp"
@@ -28,6 +29,8 @@
#include "EventBuffer.hpp"
#include "ProcessContext.hpp"
+using namespace std;
+
namespace Ingen {
@@ -36,16 +39,18 @@ SetPortValueQueuedEvent::SetPortValueQueuedEvent(Engine& engine,
SharedPtr<Responder> responder,
SampleCount timestamp,
const string& port_path,
+ const string& data_type,
uint32_t data_size,
const void* data)
-: QueuedEvent(engine, responder, timestamp),
- _omni(true),
- _voice_num(0),
- _port_path(port_path),
- _data_size(data_size),
- _data(malloc(data_size)),
- _port(NULL),
- _error(NO_ERROR)
+ : QueuedEvent(engine, responder, timestamp)
+ , _omni(true)
+ , _voice_num(0)
+ , _port_path(port_path)
+ , _data_type(data_type)
+ , _data_size(data_size)
+ , _data(malloc(data_size))
+ , _port(NULL)
+ , _error(NO_ERROR)
{
memcpy(_data, data, data_size);
}
@@ -57,16 +62,18 @@ SetPortValueQueuedEvent::SetPortValueQueuedEvent(Engine& engine,
SampleCount timestamp,
uint32_t voice_num,
const string& port_path,
+ const string& data_type,
uint32_t data_size,
const void* data)
-: QueuedEvent(engine, responder, timestamp),
- _omni(false),
- _voice_num(voice_num),
- _port_path(port_path),
- _data_size(data_size),
- _data(malloc(data_size)),
- _port(NULL),
- _error(NO_ERROR)
+ : QueuedEvent(engine, responder, timestamp)
+ , _omni(false)
+ , _voice_num(voice_num)
+ , _port_path(port_path)
+ , _data_type(data_type)
+ , _data_size(data_size)
+ , _data(malloc(data_size))
+ , _port(NULL)
+ , _error(NO_ERROR)
{
memcpy(_data, data, data_size);
}
@@ -112,11 +119,23 @@ SetPortValueQueuedEvent::execute(ProcessContext& context)
}
EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf);
- if (ebuf) {
+ // FIXME: eliminate string comparisons
+ if (ebuf && _data_type == "lv2_midi:MidiEvent") {
+ const LV2Features::Feature* f = _engine.world()->lv2_features->feature(LV2_URI_MAP_URI);
+ LV2URIMap* map = (LV2URIMap*)f->controller;
+ const uint32_t type_id = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent");
const uint32_t frames = std::max((uint32_t)(_time - context.start()), ebuf->latest_frames());
- // FIXME: type
- ebuf->append(frames, 0, 0, _data_size, (const unsigned char*)_data);
+ ebuf->prepare_write(context.nframes());
+ // FIXME: how should this work? binary over OSC, ick
+ // Message is an event:
+ ebuf->append(frames, 0, type_id, _data_size, (const unsigned char*)_data);
+ // Message is an event buffer:
+ //ebuf->append((LV2_Event_Buffer*)_data);
+ _port->raise_set_by_user_flag();
+ return;
}
+
+ cerr << "WARNING: Unknown value type " << _data_type << ", ignoring" << endl;
}
}