summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/client/OSCClientReceiver.cpp37
-rw-r--r--src/client/OSCClientReceiver.hpp8
-rw-r--r--src/client/OSCEngineSender.cpp30
-rw-r--r--src/server/OSCClientSender.cpp27
-rw-r--r--src/server/OSCEngineReceiver.cpp37
-rw-r--r--src/server/OSCEngineReceiver.hpp8
6 files changed, 144 insertions, 3 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
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);