summaryrefslogtreecommitdiffstats
path: root/src/server
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/server
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/server')
-rw-r--r--src/server/OSCClientSender.cpp27
-rw-r--r--src/server/OSCEngineReceiver.cpp37
-rw-r--r--src/server/OSCEngineReceiver.hpp8
3 files changed, 71 insertions, 1 deletions
diff --git a/src/server/OSCClientSender.cpp b/src/server/OSCClientSender.cpp
index df2a8f3a..5095eeef 100644
--- a/src/server/OSCClientSender.cpp
+++ b/src/server/OSCClientSender.cpp
@@ -130,7 +130,32 @@ OSCClientSender::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();
+
+ send("/delta_begin", "s", 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", "", LO_ARGS_END);
+
+ if (bundle)
+ bundle_end();
}
/** @page client_osc_namespace
diff --git a/src/server/OSCEngineReceiver.cpp b/src/server/OSCEngineReceiver.cpp
index 338fb985..ad59c490 100644
--- a/src/server/OSCEngineReceiver.cpp
+++ b/src/server/OSCEngineReceiver.cpp
@@ -98,6 +98,10 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, uint16_t port)
lo_server_add_method(_server, "/register_client", "i", register_client_cb, this);
lo_server_add_method(_server, "/unregister_client", "i", unregister_client_cb, this);
lo_server_add_method(_server, "/put", NULL, put_cb, this);
+ lo_server_add_method(_server, "/delta_begin", NULL, delta_begin_cb, this);
+ lo_server_add_method(_server, "/delta_remove", NULL, delta_remove_cb, this);
+ lo_server_add_method(_server, "/delta_add", NULL, delta_add_cb, this);
+ lo_server_add_method(_server, "/delta_end", NULL, delta_end_cb, this);
lo_server_add_method(_server, "/move", "iss", move_cb, this);
lo_server_add_method(_server, "/delete", "is", del_cb, this);
lo_server_add_method(_server, "/connect", "iss", connect_cb, this);
@@ -346,6 +350,39 @@ OSCEngineReceiver::_put_cb(const char* path, const char* types, lo_arg** argv, i
return 0;
}
+int
+OSCEngineReceiver::_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
+OSCEngineReceiver::_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
+OSCEngineReceiver::_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
+OSCEngineReceiver::_delta_end_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
+{
+ delta(_delta_uri, _delta_remove, _delta_add);
+ return 0;
+}
+
/** @page engine_osc_namespace
* <h2>/move</h2>
* @arg @p response-id :: Integer
diff --git a/src/server/OSCEngineReceiver.hpp b/src/server/OSCEngineReceiver.hpp
index c9585f44..3c84e1d5 100644
--- a/src/server/OSCEngineReceiver.hpp
+++ b/src/server/OSCEngineReceiver.hpp
@@ -72,6 +72,10 @@ private:
ReceiveThread* _receive_thread;
+ Raul::URI _delta_uri;
+ Resource::Properties _delta_remove;
+ Resource::Properties _delta_add;
+
#ifdef LIBLO_BUNDLES
static int bundle_start_cb(lo_timetag time, void* myself) {
return ((OSCEngineReceiver*)myself)->_bundle_start_cb(time);
@@ -96,6 +100,10 @@ private:
LO_HANDLER(unregister_client);
LO_HANDLER(get);
LO_HANDLER(put);
+ LO_HANDLER(delta_begin);
+ LO_HANDLER(delta_remove);
+ LO_HANDLER(delta_add);
+ LO_HANDLER(delta_end);
LO_HANDLER(move);
LO_HANDLER(del);
LO_HANDLER(connect);