summaryrefslogtreecommitdiffstats
path: root/src/client
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-05-19 20:44:19 +0000
committerDavid Robillard <d@drobilla.net>2011-05-19 20:44:19 +0000
commit8f01b24d7a258d0e717eedcbb3618258bfe9883e (patch)
treee76f0306c67c67e616d86eed348d04615e702cd5 /src/client
parent4d365e0c45e69d2a0ace0faec50547d37588bf0c (diff)
downloadingen-8f01b24d7a258d0e717eedcbb3618258bfe9883e.tar.gz
ingen-8f01b24d7a258d0e717eedcbb3618258bfe9883e.tar.bz2
ingen-8f01b24d7a258d0e717eedcbb3618258bfe9883e.zip
Fix delta via OSC (OSC bindings should be fully functional again).
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3285 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client')
-rw-r--r--src/client/OSCClientReceiver.cpp37
-rw-r--r--src/client/OSCClientReceiver.hpp8
-rw-r--r--src/client/OSCEngineSender.cpp30
3 files changed, 73 insertions, 2 deletions
diff --git a/src/client/OSCClientReceiver.cpp b/src/client/OSCClientReceiver.cpp
index 2e28019b..402a6974 100644
--- a/src/client/OSCClientReceiver.cpp
+++ b/src/client/OSCClientReceiver.cpp
@@ -141,6 +141,10 @@ OSCClientReceiver::setup_callbacks()
lo_server_thread_add_method(_st, "/error", "is", response_error_cb, this);
lo_server_thread_add_method(_st, "/plugin", "sss", plugin_cb, this);
lo_server_thread_add_method(_st, "/put", NULL, put_cb, this);
+ lo_server_thread_add_method(_st, "/delta_begin", NULL, delta_begin_cb, this);
+ lo_server_thread_add_method(_st, "/delta_remove", NULL, delta_remove_cb, this);
+ lo_server_thread_add_method(_st, "/delta_add", NULL, delta_add_cb, this);
+ lo_server_thread_add_method(_st, "/delta_end", NULL, delta_end_cb, this);
lo_server_thread_add_method(_st, "/move", "ss", move_cb, this);
lo_server_thread_add_method(_st, "/delete", "s", del_cb, this);
lo_server_thread_add_method(_st, "/connect", "ss", connection_cb, this);
@@ -177,6 +181,39 @@ OSCClientReceiver::_put_cb(const char* path, const char* types, lo_arg** argv, i
}
int
+OSCClientReceiver::_delta_begin_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ const char* obj_path = &argv[1]->s;
+ assert(_delta_remove.empty());
+ assert(_delta_add.empty());
+ _delta_uri = obj_path;
+ return 0;
+}
+
+int
+OSCClientReceiver::_delta_remove_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ _delta_remove.insert(make_pair(&argv[1]->s,
+ AtomLiblo::lo_arg_to_atom(types[2], argv[2])));
+ return 0;
+}
+
+int
+OSCClientReceiver::_delta_add_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ _delta_add.insert(make_pair(&argv[1]->s,
+ AtomLiblo::lo_arg_to_atom(types[2], argv[2])));
+ return 0;
+}
+
+int
+OSCClientReceiver::_delta_end_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ _target->delta(_delta_uri, _delta_remove, _delta_add);
+ return 0;
+}
+
+int
OSCClientReceiver::_move_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* old_path = &argv[1]->s;
diff --git a/src/client/OSCClientReceiver.hpp b/src/client/OSCClientReceiver.hpp
index 9f256c15..e3fda0fa 100644
--- a/src/client/OSCClientReceiver.hpp
+++ b/src/client/OSCClientReceiver.hpp
@@ -78,6 +78,10 @@ private:
int _listen_port;
lo_server_thread _st;
+ Raul::URI _delta_uri;
+ Resource::Properties _delta_remove;
+ Resource::Properties _delta_add;
+
LO_HANDLER(error);
LO_HANDLER(response_ok);
LO_HANDLER(response_error);
@@ -89,6 +93,10 @@ private:
LO_HANDLER(connection);
LO_HANDLER(disconnection);
LO_HANDLER(put);
+ LO_HANDLER(delta_begin);
+ LO_HANDLER(delta_remove);
+ LO_HANDLER(delta_add);
+ LO_HANDLER(delta_end);
LO_HANDLER(set_property);
LO_HANDLER(activity);
};
diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp
index 9c3b836c..49b20df1 100644
--- a/src/client/OSCEngineSender.cpp
+++ b/src/client/OSCEngineSender.cpp
@@ -117,11 +117,37 @@ OSCEngineSender::put(const Raul::URI& path,
}
void
-OSCEngineSender::delta(const Raul::URI& path,
+OSCEngineSender::delta(const Raul::URI& path,
const Resource::Properties& remove,
const Resource::Properties& add)
{
- warn << "FIXME: OSC DELTA" << endl;
+ typedef Resource::Properties::const_iterator iterator;
+
+ const bool bundle = !_bundle;
+ if (bundle)
+ bundle_begin();
+
+ const int32_t id = next_id();
+ send("/delta_begin", "is", id, path.c_str(), LO_ARGS_END);
+
+ for (iterator i = remove.begin(); i != remove.end(); ++i) {
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, i->first.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, i->second);
+ send_message("/delta_remove", m);
+ }
+
+ for (iterator i = add.begin(); i != add.end(); ++i) {
+ lo_message m = lo_message_new();
+ lo_message_add_string(m, i->first.c_str());
+ Raul::AtomLiblo::lo_message_add_atom(m, i->second);
+ send_message("/delta_add", m);
+ }
+
+ send("/delta_end", "i", id, LO_ARGS_END);
+
+ if (bundle)
+ bundle_end();
}
void