summaryrefslogtreecommitdiffstats
path: root/src/libs/client
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/client
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/client')
-rw-r--r--src/libs/client/DeprecatedLoader.cpp2
-rw-r--r--src/libs/client/OSCClientReceiver.cpp2
-rw-r--r--src/libs/client/OSCEngineSender.cpp59
-rw-r--r--src/libs/client/OSCEngineSender.hpp7
-rw-r--r--src/libs/client/PluginModel.cpp38
-rw-r--r--src/libs/client/PluginUI.cpp28
6 files changed, 72 insertions, 64 deletions
diff --git a/src/libs/client/DeprecatedLoader.cpp b/src/libs/client/DeprecatedLoader.cpp
index 4897137c..77d743eb 100644
--- a/src/libs/client/DeprecatedLoader.cpp
+++ b/src/libs/client/DeprecatedLoader.cpp
@@ -269,7 +269,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename,
list<ControlModel>::const_iterator i = pm->controls().begin();
for ( ; i != pm->controls().end(); ++i) {
const float value = i->value();
- _engine->set_port_value(i->port_path(), "ingen:control", sizeof(float), &value);
+ _engine->set_port_value(i->port_path(), "ingen:Float", sizeof(float), &value);
}
} else {
cerr << "WARNING: Unknown preset: \"" << pm->name() << endl;
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index 8cad1754..3f5447d0 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -35,7 +35,7 @@ OSCClientReceiver::OSCClientReceiver(int listen_port)
, _listen_port(listen_port)
, _st(NULL)
{
- start(true); // true = dump, false = shutup
+ start(false); // true = dump, false = shutup
}
diff --git a/src/libs/client/OSCEngineSender.cpp b/src/libs/client/OSCEngineSender.cpp
index 20070ff9..48fee877 100644
--- a/src/libs/client/OSCEngineSender.cpp
+++ b/src/libs/client/OSCEngineSender.cpp
@@ -124,6 +124,28 @@ OSCEngineSender::unregister_client(const string& uri)
}
+// Bundles
+
+void
+OSCEngineSender::bundle_begin()
+{
+ //cerr << "BUNDLE {" << endl;
+ /*assert(!_bundle);
+ _bundle = lo_bundle_new(LO_TT_IMMEDIATE);*/
+}
+
+
+void
+OSCEngineSender::bundle_end()
+{
+ //cerr << "} BUNDLE" << endl;
+ /*assert(_bundle);
+ lo_send_bundle(_address, _bundle);
+ lo_bundle_free(_bundle);
+ _bundle = NULL;*/
+}
+
+
// Engine commands
void
@@ -358,19 +380,23 @@ OSCEngineSender::set_port_value(const string& port_path,
const void* data)
{
assert(_engine_addr);
- if (type_uri == "ingen:control") {
+ if (type_uri == "ingen:Float") {
assert(data_size == 4);
lo_send(_engine_addr, "/ingen/set_port_value", "isf",
next_id(),
port_path.c_str(),
*(float*)data);
- } else {
+ } else if (type_uri == "lv2_midi:MidiEvent") {
lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value", "isb",
+ lo_send(_engine_addr, "/ingen/set_port_value", "issb",
next_id(),
port_path.c_str(),
+ type_uri.c_str(),
b);
lo_blob_free(b);
+ // FIXME: support atomic bundles of events here
+ } else {
+ cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
}
}
@@ -383,19 +409,22 @@ OSCEngineSender::set_port_value(const string& port_path,
const void* data)
{
assert(_engine_addr);
- if (type_uri == "ingen:control") {
+ if (type_uri == "ingen:Float") {
assert(data_size == 4);
lo_send(_engine_addr, "/ingen/set_port_value", "isf",
next_id(),
port_path.c_str(),
*(float*)data);
- } else {
+ } else if (type_uri == "lv2_midi:MidiEvent") {
lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value", "isb",
+ lo_send(_engine_addr, "/ingen/set_port_value", "issb",
next_id(),
port_path.c_str(),
+ type_uri.c_str(),
b);
lo_blob_free(b);
+ } else {
+ cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
}
}
@@ -408,19 +437,22 @@ OSCEngineSender::set_port_value_immediate(const string& port_path,
{
assert(_engine_addr);
- if (type_uri == "ingen:control") {
+ if (type_uri == "ingen:Float") {
assert(data_size == 4);
lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isf",
next_id(),
port_path.c_str(),
*(float*)data);
- } else {
+ } else if (type_uri == "lv2_midi:MidiEvent") {
lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isb",
+ lo_send(_engine_addr, "/ingen/set_port_value_immediate", "issb",
next_id(),
port_path.c_str(),
+ type_uri.c_str(),
b);
lo_blob_free(b);
+ } else {
+ cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
}
}
@@ -434,21 +466,24 @@ OSCEngineSender::set_port_value_immediate(const string& port_path,
{
assert(_engine_addr);
- if (type_uri == "ingen:control") {
+ if (type_uri == "ingen:Float") {
assert(data_size == 4);
lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isif",
next_id(),
port_path.c_str(),
voice,
*(float*)data);
- } else {
+ } else if (type_uri == "lv2_midi:MidiEvent") {
lo_blob b = lo_blob_new(data_size, (void*)data);
- lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isib",
+ lo_send(_engine_addr, "/ingen/set_port_value_immediate", "isisb",
next_id(),
port_path.c_str(),
voice,
+ type_uri.c_str(),
b);
lo_blob_free(b);
+ } else {
+ cerr << "ERROR: Unknown value type '" << type_uri << "', ignoring" << endl;
}
}
diff --git a/src/libs/client/OSCEngineSender.hpp b/src/libs/client/OSCEngineSender.hpp
index 6bd088ec..dfbdff62 100644
--- a/src/libs/client/OSCEngineSender.hpp
+++ b/src/libs/client/OSCEngineSender.hpp
@@ -61,14 +61,16 @@ public:
void register_client(ClientInterface* client);
void unregister_client(const string& uri);
-
// Engine commands
void load_plugins();
void activate();
void deactivate();
void quit();
-
+ // Bundles
+ void bundle_begin();
+ void bundle_end();
+
// Object commands
void create_patch(const string& path,
@@ -165,6 +167,7 @@ public:
void request_all_objects();
protected:
+ lo_bundle _bundle;
string _engine_url;
lo_address _engine_addr;
int _client_port;
diff --git a/src/libs/client/PluginModel.cpp b/src/libs/client/PluginModel.cpp
index 9e4df473..fa39c0e3 100644
--- a/src/libs/client/PluginModel.cpp
+++ b/src/libs/client/PluginModel.cpp
@@ -57,44 +57,6 @@ PluginModel::default_node_name(SharedPtr<PatchModel> parent)
}
-#if 0
-struct NodeController {
- EngineInterface* engine;
- NodeModel* node;
-};
-
-
-void
-lv2_ui_write(LV2UI_Controller controller,
- uint32_t port_index,
- uint32_t buffer_size,
- const void* buffer)
-{
- /*cerr << "********* LV2 UI WRITE:" << endl;
- lv2_osc_message_print((const LV2Message*)buffer);
-
- fprintf(stderr, "RAW:\n");
- for (uint32_t i=0; i < buffer_size; ++i) {
- unsigned char byte = ((unsigned char*)buffer)[i];
- if (byte >= 32 && byte <= 126)
- fprintf(stderr, "%c ", ((unsigned char*)buffer)[i]);
- else
- fprintf(stderr, "%2X ", ((unsigned char*)buffer)[i]);
- }
-
- fprintf(stderr, "\n");
- */
-
- NodeController* nc = (NodeController*)controller;
-
- SharedPtr<PortModel> port = nc->node->ports()[port_index];
-
- nc->engine->set_port_value_immediate(port->path(),
- port->type().uri(), buffer_size, buffer);
-}
-#endif
-
-
#ifdef HAVE_SLV2
SharedPtr<PluginUI>
PluginModel::ui(Ingen::Shared::World* world, SharedPtr<NodeModel> node) const
diff --git a/src/libs/client/PluginUI.cpp b/src/libs/client/PluginUI.cpp
index c7c3ffc5..b341bb0f 100644
--- a/src/libs/client/PluginUI.cpp
+++ b/src/libs/client/PluginUI.cpp
@@ -25,6 +25,7 @@
using namespace std;
using Ingen::Shared::EngineInterface;
using Ingen::Shared::LV2URIMap;
+using Ingen::Shared::LV2Features;
namespace Ingen {
namespace Client {
@@ -53,7 +54,8 @@ lv2_ui_write(LV2UI_Controller controller,
SharedPtr<PortModel> port = ui->node()->ports()[port_index];
- LV2URIMap* map = (LV2URIMap*)ui->world()->lv2_features->feature(LV2_URI_MAP_URI);
+ const LV2Features::Feature* f = ui->world()->lv2_features->feature(LV2_URI_MAP_URI);
+ LV2URIMap* map = (LV2URIMap*)f->controller;
assert(map);
// float (special case, always 0)
@@ -66,25 +68,31 @@ lv2_ui_write(LV2UI_Controller controller,
port->type().uri(),
buffer_size, buffer);
- // FIXME: assumes event
- } else {
+ // FIXME: slow, need to cache ID
+ } else if (format == map->uri_to_id(NULL, "http://lv2plug.in/ns/extensions/ui#Events")) {
+ uint32_t midi_event_type = map->uri_to_id(NULL, "http://lv2plug.in/ns/ext/midi#MidiEvent");
LV2_Event_Buffer* buf = (LV2_Event_Buffer*)buffer;
LV2_Event_Iterator iter;
uint8_t* data;
lv2_event_begin(&iter, buf);
while (lv2_event_is_valid(&iter)) {
LV2_Event* const ev = lv2_event_get(&iter, &data);
-
- // FIXME: bundle multiple events
- ui->world()->engine->set_port_value_immediate(port->path(),
- port->type().uri(),
- ev->size, data);
+ if (ev->type == midi_event_type) {
+ // FIXME: bundle multiple events by writing an entire buffer here
+ ui->world()->engine->set_port_value_immediate(port->path(),
+ "lv2_midi:MidiEvent", ev->size, data);
+ } else {
+ cerr << "WARNING: Unable to send event type " << ev->type <<
+ " over OSC, ignoring event" << endl;
+ }
lv2_event_increment(&iter);
}
+ } else {
+ cerr << "WARNING: Unknown value format " << format
+ << ", either plugin " << ui->node()->plugin()->uri() << " is broken"
+ << " or this is an Ingen bug" << endl;
}
-
-
}