diff options
author | David Robillard <d@drobilla.net> | 2008-08-17 01:34:53 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-08-17 01:34:53 +0000 |
commit | 694b31089c8060fc6b908b146b12c0e340d004c7 (patch) | |
tree | 48b0e0195de5e7b297e65be15eda35639585ef8a /src/libs/engine/events | |
parent | 3dc90cc95df35e5c786857336f22856c6373b00f (diff) | |
download | ingen-694b31089c8060fc6b908b146b12c0e340d004c7.tar.gz ingen-694b31089c8060fc6b908b146b12c0e340d004c7.tar.bz2 ingen-694b31089c8060fc6b908b146b12c0e340d004c7.zip |
Cloooser...
Bundling of OSC communication both ways (previous was just engine->client).
Factor out common OSC*Sender functionality (bundling stuff).
Fully type-safe and polyphony-aware port value setting/getting, from RDF through OSC through engine and back again.
git-svn-id: http://svn.drobilla.net/lad/ingen@1409 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine/events')
-rw-r--r-- | src/libs/engine/events/MidiLearnEvent.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/events/RequestPortValueEvent.cpp | 2 | ||||
-rw-r--r-- | src/libs/engine/events/SendPortValueEvent.cpp | 4 | ||||
-rw-r--r-- | src/libs/engine/events/SetPortValueEvent.cpp | 44 | ||||
-rw-r--r-- | src/libs/engine/events/SetPortValueEvent.hpp | 27 |
5 files changed, 37 insertions, 42 deletions
diff --git a/src/libs/engine/events/MidiLearnEvent.cpp b/src/libs/engine/events/MidiLearnEvent.cpp index 45216e70..2f37f30d 100644 --- a/src/libs/engine/events/MidiLearnEvent.cpp +++ b/src/libs/engine/events/MidiLearnEvent.cpp @@ -32,7 +32,7 @@ namespace Ingen { void MidiLearnResponseEvent::post_process() { - _engine.broadcaster()->send_control_change(_port_path, _value); + _engine.broadcaster()->send_port_value(_port_path, _value); } diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp index 20203f88..025d3700 100644 --- a/src/libs/engine/events/RequestPortValueEvent.cpp +++ b/src/libs/engine/events/RequestPortValueEvent.cpp @@ -70,7 +70,7 @@ RequestPortValueEvent::post_process() _responder->respond_error("Unable to find port for get_value responder."); } else if (_responder->client()) { _responder->respond_ok(); - _responder->client()->control_change(_port_path, _value); + _responder->client()->set_port_value(_port_path, _value); } else { _responder->respond_error("Unable to find client to send port value"); } diff --git a/src/libs/engine/events/SendPortValueEvent.cpp b/src/libs/engine/events/SendPortValueEvent.cpp index 89e8c9e0..d3fb0d36 100644 --- a/src/libs/engine/events/SendPortValueEvent.cpp +++ b/src/libs/engine/events/SendPortValueEvent.cpp @@ -32,9 +32,9 @@ SendPortValueEvent::post_process() // FIXME... if (_omni) { - _engine.broadcaster()->send_control_change(_port->path(), _value); + _engine.broadcaster()->send_port_value(_port->path(), _value); } else { - _engine.broadcaster()->send_control_change(_port->path(), _value); + _engine.broadcaster()->send_port_value(_port->path(), _value); } } diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index 01263d2c..f69ba9a3 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -39,21 +39,16 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine, bool queued, SampleCount timestamp, const string& port_path, - const string& data_type, - uint32_t data_size, - const void* data) + const Raul::Atom& value) : QueuedEvent(engine, responder, timestamp) , _queued(queued) , _omni(true) , _voice_num(0) , _port_path(port_path) - , _data_type(data_type) - , _data_size(data_size) - , _data(malloc(data_size)) + , _value(value) , _port(NULL) , _error(NO_ERROR) { - memcpy(_data, data, data_size); } @@ -64,27 +59,21 @@ SetPortValueEvent::SetPortValueEvent(Engine& engine, SampleCount timestamp, uint32_t voice_num, const string& port_path, - const string& data_type, - uint32_t data_size, - const void* data) + const Raul::Atom& value) : QueuedEvent(engine, responder, timestamp) , _queued(queued) , _omni(false) , _voice_num(voice_num) , _port_path(port_path) - , _data_type(data_type) - , _data_size(data_size) - , _data(malloc(data_size)) + , _value(value) , _port(NULL) , _error(NO_ERROR) { - memcpy(_data, data, data_size); } SetPortValueEvent::~SetPortValueEvent() { - free(_data); } @@ -129,13 +118,19 @@ SetPortValueEvent::execute(ProcessContext& context) Buffer* const buf = _port->buffer(0); AudioBuffer* const abuf = dynamic_cast<AudioBuffer*>(buf); if (abuf) { + if (_value.type() != Atom::FLOAT) { + _error = TYPE_MISMATCH; + return; + } + if (_omni) { for (uint32_t i=0; i < _port->poly(); ++i) - ((AudioBuffer*)_port->buffer(i))->set_value(*(float*)_data, context.start(), _time); + ((AudioBuffer*)_port->buffer(i))->set_value( + _value.get_float(), context.start(), _time); } else { if (_voice_num < _port->poly()) ((AudioBuffer*)_port->buffer(_voice_num))->set_value( - *(float*)_data, context.start(), _time); + _value.get_float(), context.start(), _time); else _error = ILLEGAL_VOICE; } @@ -144,7 +139,8 @@ SetPortValueEvent::execute(ProcessContext& context) EventBuffer* const ebuf = dynamic_cast<EventBuffer*>(buf); // FIXME: eliminate string comparisons - if (ebuf && _data_type == "lv2_midi:MidiEvent") { + if (ebuf && _value.type() == Atom::BLOB + && !strcmp(_value.get_blob_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"); @@ -152,14 +148,18 @@ SetPortValueEvent::execute(ProcessContext& context) ebuf->prepare_write(context.start(), 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); + ebuf->append(frames, 0, type_id, _value.data_size(), (const uint8_t*)_value.get_blob()); // 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; + + if (_value.type() == Atom::BLOB) + cerr << "WARNING: Unknown value blob type " << _value.get_blob_type() << endl; + else + cerr << "WARNING: Unknown value type " << (int)_value.type() << endl; } } @@ -170,7 +170,7 @@ SetPortValueEvent::post_process() if (_error == NO_ERROR) { assert(_port != NULL); _responder->respond_ok(); - _engine.broadcaster()->send_control_change(_port_path, *(float*)_data); + _engine.broadcaster()->send_port_value(_port_path, _value); } else if (_error == ILLEGAL_PATH) { string msg = "Illegal port path \""; @@ -189,7 +189,7 @@ SetPortValueEvent::post_process() } else if (_error == NO_SPACE) { std::ostringstream msg("Attempt to write "); - msg << _data_size << " bytes to " << _port_path << ", with capacity " + msg << _value.data_size() << " bytes to " << _port_path << ", with capacity " << _port->buffer_size() << endl; _responder->respond_error(msg.str()); } diff --git a/src/libs/engine/events/SetPortValueEvent.hpp b/src/libs/engine/events/SetPortValueEvent.hpp index a509af33..2fc68d9b 100644 --- a/src/libs/engine/events/SetPortValueEvent.hpp +++ b/src/libs/engine/events/SetPortValueEvent.hpp @@ -45,9 +45,7 @@ public: bool queued, SampleCount timestamp, const string& port_path, - const string& data_type, - uint32_t data_size, - const void* data); + const Raul::Atom& value); SetPortValueEvent(Engine& engine, SharedPtr<Responder> responder, @@ -55,9 +53,7 @@ public: SampleCount timestamp, uint32_t voice_num, const string& port_path, - const string& data_type, - uint32_t data_size, - const void* data); + const Raul::Atom& value); ~SetPortValueEvent(); @@ -66,17 +62,16 @@ public: void post_process(); private: - enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, ILLEGAL_PATH, ILLEGAL_VOICE }; + enum ErrorType { NO_ERROR, PORT_NOT_FOUND, NO_SPACE, + ILLEGAL_PATH, ILLEGAL_VOICE, TYPE_MISMATCH }; - bool _queued; - bool _omni; - uint32_t _voice_num; - const string _port_path; - const string _data_type; - uint32_t _data_size; - void* _data; - PortImpl* _port; - ErrorType _error; + bool _queued; + bool _omni; + uint32_t _voice_num; + const string _port_path; + const Raul::Atom _value; + PortImpl* _port; + ErrorType _error; }; |