aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-16 03:15:41 +0000
committerDavid Robillard <d@drobilla.net>2012-03-16 03:15:41 +0000
commit119468f621a59d86da10bedf75c4427b70f9d370 (patch)
treef15ea3f345d43b37d492096876c483543fcc1426
parent0b93e39af34d3af361f35d510224fda4fda56071 (diff)
downloadingen-119468f621a59d86da10bedf75c4427b70f9d370.tar.gz
ingen-119468f621a59d86da10bedf75c4427b70f9d370.tar.bz2
ingen-119468f621a59d86da10bedf75c4427b70f9d370.zip
Remove activity from interface and use set_property() instead.
Move client registration stuff to Engine and remove corresponding events. Simply response ID interface. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4066 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ingen/ClientInterface.hpp3
-rw-r--r--ingen/EngineBase.hpp16
-rw-r--r--ingen/ServerInterface.hpp11
-rw-r--r--ingen/client/ClientStore.hpp2
-rw-r--r--ingen/client/SigClientInterface.hpp4
-rw-r--r--ingen/client/ThreadedSigClientInterface.hpp37
-rw-r--r--ingen/shared/URIs.hpp1
-rw-r--r--src/bindings/Client.hpp3
-rw-r--r--src/client/ClientStore.cpp10
-rw-r--r--src/client/PortModel.cpp2
-rw-r--r--src/gui/App.cpp4
-rw-r--r--src/gui/ConnectWindow.cpp5
-rw-r--r--src/http/HTTPClientSender.cpp19
-rw-r--r--src/http/HTTPClientSender.hpp3
-rw-r--r--src/http/HTTPEngineSender.hpp3
-rw-r--r--src/osc/OSCClientReceiver.cpp14
-rw-r--r--src/osc/OSCClientReceiver.hpp1
-rw-r--r--src/osc/OSCClientSender.cpp19
-rw-r--r--src/osc/OSCClientSender.hpp3
-rw-r--r--src/osc/OSCEngineReceiver.cpp2
-rw-r--r--src/osc/OSCEngineSender.hpp3
-rw-r--r--src/server/ClientBroadcaster.cpp18
-rw-r--r--src/server/ClientBroadcaster.hpp7
-rw-r--r--src/server/Engine.cpp12
-rw-r--r--src/server/Engine.hpp4
-rw-r--r--src/server/ServerInterfaceImpl.cpp34
-rw-r--r--src/server/ServerInterfaceImpl.hpp7
-rw-r--r--src/server/events.hpp2
-rw-r--r--src/server/events/Get.cpp10
-rw-r--r--src/server/events/RegisterClient.cpp70
-rw-r--r--src/server/events/RegisterClient.hpp53
-rw-r--r--src/server/events/UnregisterClient.cpp52
-rw-r--r--src/server/events/UnregisterClient.hpp51
-rw-r--r--src/server/wscript2
-rw-r--r--src/shared/URIs.cpp1
35 files changed, 104 insertions, 384 deletions
diff --git a/ingen/ClientInterface.hpp b/ingen/ClientInterface.hpp
index 0bed231c..d59e25b5 100644
--- a/ingen/ClientInterface.hpp
+++ b/ingen/ClientInterface.hpp
@@ -44,9 +44,6 @@ public:
virtual void response(int32_t id, Status status) = 0;
virtual void error(const std::string& msg) = 0;
-
- virtual void activity(const Raul::Path& path,
- const Raul::Atom& value) = 0;
};
} // namespace Ingen
diff --git a/ingen/EngineBase.hpp b/ingen/EngineBase.hpp
index 80d1c789..a0fba00f 100644
--- a/ingen/EngineBase.hpp
+++ b/ingen/EngineBase.hpp
@@ -18,8 +18,12 @@
#ifndef INGEN_ENGINE_BASE_HPP
#define INGEN_ENGINE_BASE_HPP
+#include "raul/URI.hpp"
+
namespace Ingen {
+class ClientInterface;
+
/**
The engine which executes the process graph.
@@ -60,6 +64,18 @@ public:
caller should cease calling main_iteration() and stop the engine.
*/
virtual bool main_iteration() = 0;
+
+ /**
+ Register a client to receive updates about engine changes.
+ */
+ virtual void register_client(const Raul::URI& uri,
+ ClientInterface* client) = 0;
+
+ /**
+ Unregister a client.
+ */
+ virtual bool unregister_client(const Raul::URI& uri) = 0;
+
};
} // namespace Ingen
diff --git a/ingen/ServerInterface.hpp b/ingen/ServerInterface.hpp
index 25016416..dade9658 100644
--- a/ingen/ServerInterface.hpp
+++ b/ingen/ServerInterface.hpp
@@ -36,13 +36,10 @@ class ServerInterface : public CommonInterface
public:
virtual ~ServerInterface() {}
- // Responses
- virtual void respond_to(ClientInterface* client, int32_t id) = 0;
- virtual void disable_responses() = 0;
-
- // Client registration
- virtual void register_client(ClientInterface* client) = 0;
- virtual void unregister_client(const Raul::URI& uri) = 0;
+ /** Set the ID to use to respond to the next message.
+ * Setting the ID to -1 will disable responses.
+ */
+ virtual void set_response_id(int32_t id) = 0;
// Requests
virtual void ping() = 0;
diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp
index b6042086..e29723ae 100644
--- a/ingen/client/ClientStore.hpp
+++ b/ingen/client/ClientStore.hpp
@@ -125,8 +125,6 @@ private:
void bundle_end() {}
// Slots for SigClientInterface signals
- void activity(const Raul::Path& path, const Raul::Atom& value);
-
bool attempt_connection(const Raul::Path& src_port_path,
const Raul::Path& dst_port_path);
diff --git a/ingen/client/SigClientInterface.hpp b/ingen/client/SigClientInterface.hpp
index 559d1b15..db59be9d 100644
--- a/ingen/client/SigClientInterface.hpp
+++ b/ingen/client/SigClientInterface.hpp
@@ -60,7 +60,6 @@ public:
INGEN_SIGNAL(variable_change, void, Raul::URI, Raul::URI, Raul::Atom)
INGEN_SIGNAL(property_change, void, Raul::URI, Raul::URI, Raul::Atom)
INGEN_SIGNAL(port_value, void, Raul::Path, Raul::Atom)
- INGEN_SIGNAL(activity, void, Raul::Path, Raul::Atom)
/** Fire pending signals. Only does anything on derived classes (that may queue) */
virtual bool emit_signals() { return false; }
@@ -110,9 +109,6 @@ protected:
void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value)
{ EMIT(property_change, subject, key, value); }
-
- void activity(const Raul::Path& port_path, const Raul::Atom& value)
- { EMIT(activity, port_path, value); }
};
} // namespace Client
diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp
index 6ded560e..2a33eae8 100644
--- a/ingen/client/ThreadedSigClientInterface.hpp
+++ b/ingen/client/ThreadedSigClientInterface.hpp
@@ -65,7 +65,6 @@ public:
, variable_change_slot(_signal_variable_change.make_slot())
, property_change_slot(_signal_property_change.make_slot())
, port_value_slot(_signal_port_value.make_slot())
- , activity_slot(_signal_activity.make_slot())
{}
virtual Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; }
@@ -110,9 +109,6 @@ public:
void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value)
{ push_sig(sigc::bind(property_change_slot, subject, key, value)); }
- void activity(const Raul::Path& port_path, const Raul::Atom& value)
- { push_sig(sigc::bind(activity_slot, port_path, value)); }
-
/** Process all queued events - Called from GTK thread to emit signals. */
bool emit_signals();
@@ -124,25 +120,24 @@ private:
Raul::SRSWQueue<Closure> _sigs;
- sigc::slot<void> bundle_begin_slot;
- sigc::slot<void> bundle_end_slot;
- sigc::slot<void, int32_t, Status> response_slot;
- sigc::slot<void, std::string> error_slot;
- sigc::slot<void, Raul::URI, Raul::URI, Raul::Symbol> new_plugin_slot;
- sigc::slot<void, Raul::Path, Raul::URI, uint32_t, bool> new_port_slot;
+ sigc::slot<void> bundle_begin_slot;
+ sigc::slot<void> bundle_end_slot;
+ sigc::slot<void, int32_t, Status> response_slot;
+ sigc::slot<void, std::string> error_slot;
+ sigc::slot<void, Raul::URI, Raul::URI, Raul::Symbol> new_plugin_slot;
+ sigc::slot<void, Raul::Path, Raul::URI, uint32_t, bool> new_port_slot;
sigc::slot<void, Raul::URI, Resource::Properties,
- Resource::Graph> put_slot;
+ Resource::Graph> put_slot;
sigc::slot<void, Raul::URI, Resource::Properties,
- Resource::Properties> delta_slot;
- sigc::slot<void, Raul::Path, Raul::Path> connection_slot;
- sigc::slot<void, Raul::URI> object_deleted_slot;
- sigc::slot<void, Raul::Path, Raul::Path> object_moved_slot;
- sigc::slot<void, Raul::URI, Raul::URI> disconnection_slot;
- sigc::slot<void, Raul::Path, Raul::Path> disconnect_all_slot;
- sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> variable_change_slot;
- sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> property_change_slot;
- sigc::slot<void, Raul::Path, Raul::Atom> port_value_slot;
- sigc::slot<void, Raul::Path, Raul::Atom> activity_slot;
+ Resource::Properties> delta_slot;
+ sigc::slot<void, Raul::Path, Raul::Path> connection_slot;
+ sigc::slot<void, Raul::URI> object_deleted_slot;
+ sigc::slot<void, Raul::Path, Raul::Path> object_moved_slot;
+ sigc::slot<void, Raul::URI, Raul::URI> disconnection_slot;
+ sigc::slot<void, Raul::Path, Raul::Path> disconnect_all_slot;
+ sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> variable_change_slot;
+ sigc::slot<void, Raul::URI, Raul::URI, Raul::Atom> property_change_slot;
+ sigc::slot<void, Raul::Path, Raul::Atom> port_value_slot;
};
} // namespace Client
diff --git a/ingen/shared/URIs.hpp b/ingen/shared/URIs.hpp
index b3d8d301..a99e45d0 100644
--- a/ingen/shared/URIs.hpp
+++ b/ingen/shared/URIs.hpp
@@ -60,6 +60,7 @@ public:
const Quark ingen_Node;
const Quark ingen_Patch;
const Quark ingen_Port;
+ const Quark ingen_activity;
const Quark ingen_broadcast;
const Quark ingen_controlBinding;
const Quark ingen_document;
diff --git a/src/bindings/Client.hpp b/src/bindings/Client.hpp
index 8a5b99aa..8adb1239 100644
--- a/src/bindings/Client.hpp
+++ b/src/bindings/Client.hpp
@@ -7,7 +7,7 @@ class Client : public Ingen::ClientInterface
{
public:
/** Wrapper for engine->register_client to appease SWIG */
- virtual void subscribe(Ingen::yServerInterface* engine) {
+ virtual void subscribe(Ingen::ServerInterface* engine) {
engine->register_client(this);
}
@@ -21,5 +21,4 @@ public:
void move(const Raul::Path& old_path, const Raul::Path& new_path) {}
void disconnect(const Raul::Path& src_port_path, const Raul::Path& dst_port_path) {}
void set_property(const Raul::URI& subject, const Raul::URI& key, const Raul::Atom& value) {}
- void activity(const Raul::Path& port_path) {}
};
diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp
index 7dbc5b0e..c7d5b9a2 100644
--- a/src/client/ClientStore.cpp
+++ b/src/client/ClientStore.cpp
@@ -65,7 +65,6 @@ ClientStore::ClientStore(SharedPtr<Shared::URIs> uris,
CONNECT(disconnection, disconnect);
CONNECT(disconnect_all, disconnect_all);
CONNECT(property_change, set_property);
- CONNECT(activity, activity);
}
void
@@ -413,15 +412,6 @@ ClientStore::set_property(const URI& subject_uri, const URI& predicate, const At
}
}
-void
-ClientStore::activity(const Path& path, const Atom& value)
-{
- SharedPtr<PortModel> port = PtrCast<PortModel>(_object(path));
- if (port) {
- port->signal_activity().emit(value);
- }
-}
-
SharedPtr<PatchModel>
ClientStore::connection_patch(const Path& src_port_path, const Path& dst_port_path)
{
diff --git a/src/client/PortModel.cpp b/src/client/PortModel.cpp
index 2fc649a7..afd28816 100644
--- a/src/client/PortModel.cpp
+++ b/src/client/PortModel.cpp
@@ -27,6 +27,8 @@ PortModel::on_property(const Raul::URI& uri, const Raul::Atom& value)
{
if (uri == _uris.ingen_value) {
this->value(value);
+ } else if (uri == _uris.ingen_activity) {
+ signal_activity().emit(value);
}
}
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index e23ef5a6..5ef4575d 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -159,7 +159,9 @@ App::attach(SharedPtr<SigClientInterface> client)
assert(!_store);
assert(!_loader);
- _world->engine()->register_client(client.get());
+ if (_world->local_engine()) {
+ _world->local_engine()->register_client(client->uri(), client.get());
+ }
_client = client;
_store = SharedPtr<ClientStore>(new ClientStore(_world->uris(), _world->engine(), client));
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index b14e388e..2d1516cd 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -380,7 +380,7 @@ ConnectWindow::gtk_callback()
sigc::mem_fun(this, &ConnectWindow::ingen_response));
_ping_id = abs(rand()) / 2 * 2; // avoid -1
- _app->engine()->respond_to(_app->client().get(), _ping_id);
+ _app->engine()->set_response_id(_ping_id);
_app->engine()->ping();
if (_widgets_loaded) {
@@ -397,12 +397,13 @@ ConnectWindow::gtk_callback()
const float ms_since_last = (now.tv_sec - last.tv_sec) * 1000.0f +
(now.tv_usec - last.tv_usec) * 0.001f;
if (ms_since_last > 1000) {
- _app->engine()->respond_to(_app->client().get(), _ping_id);
+ _app->engine()->set_response_id(_ping_id);
_app->engine()->ping();
last = now;
}
}
} else if (_connect_stage == 2) {
+ _app->engine()->get("ingen:engine");
_app->engine()->get(Path("/"));
if (_widgets_loaded)
_progress_label->set_text(string("Requesting root patch..."));
diff --git a/src/http/HTTPClientSender.cpp b/src/http/HTTPClientSender.cpp
index 1dfc1da7..afaca6d5 100644
--- a/src/http/HTTPClientSender.cpp
+++ b/src/http/HTTPClientSender.cpp
@@ -126,25 +126,6 @@ HTTPClientSender::set_property(const URI& subject, const URI& key, const Atom& v
}
void
-HTTPClientSender::activity(const Path& path, const Raul::Atom& value)
-{
- if (value.type() == Atom::BOOL) {
- const string msg = string(
- "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n\n<").append(
- path.str()).append("> ingen:activity true .\n");
- send_chunk(msg);
- } else if (value.type() == Atom::FLOAT) {
- const string msg = string(
- "@prefix ingen: <http://drobilla.net/ns/ingen#> .\n\n<").append(
- path.str()).append("> ingen:activity ").append(
- value.get_bool() ? "true" : "false").append(" .\n");
- send_chunk(msg);
- } else {
- warn << "Unknown activity type at " << path << endl;
- }
-}
-
-void
HTTPClientSender::move(const Path& old_path, const Path& new_path)
{
string msg = string(
diff --git a/src/http/HTTPClientSender.hpp b/src/http/HTTPClientSender.hpp
index c0af96df..b7eb777f 100644
--- a/src/http/HTTPClientSender.hpp
+++ b/src/http/HTTPClientSender.hpp
@@ -93,9 +93,6 @@ public:
const Raul::URI& predicate,
const Raul::Atom& value);
- virtual void activity(const Raul::Path& path,
- const Raul::Atom& value);
-
private:
Engine& _engine;
std::string _url;
diff --git a/src/http/HTTPEngineSender.hpp b/src/http/HTTPEngineSender.hpp
index c7296bcc..d9ac4481 100644
--- a/src/http/HTTPEngineSender.hpp
+++ b/src/http/HTTPEngineSender.hpp
@@ -59,8 +59,7 @@ public:
inline int32_t next_id()
{ int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
- void respond_to(ClientInterface* client, int32_t id) { _id = id; }
- void disable_responses() { _id = -1; }
+ void set_response_id(int32_t id) { _id = id; }
void attach(int32_t ping_id, bool block);
diff --git a/src/osc/OSCClientReceiver.cpp b/src/osc/OSCClientReceiver.cpp
index a0cd58b7..a7965296 100644
--- a/src/osc/OSCClientReceiver.cpp
+++ b/src/osc/OSCClientReceiver.cpp
@@ -149,8 +149,6 @@ OSCClientReceiver::setup_callbacks()
lo_server_thread_add_method(_st, "/connect", "ss", connection_cb, this);
lo_server_thread_add_method(_st, "/disconnect", "ss", disconnection_cb, this);
lo_server_thread_add_method(_st, "/set_property", NULL, set_property_cb, this);
- lo_server_thread_add_method(_st, "/activity", "sT", activity_cb, this);
- lo_server_thread_add_method(_st, "/activity", "sf", activity_cb, this);
}
/** Catches errors that aren't a direct result of a client request.
@@ -269,18 +267,6 @@ OSCClientReceiver::_set_property_cb(const char* path, const char* types, lo_arg*
}
int
-OSCClientReceiver::_activity_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
-{
- const char* const port_path = &argv[0]->s;
-
- Atom value = AtomLiblo::lo_arg_to_atom(types[1], argv[1]);
-
- _target->activity(port_path, value);
-
- return 0;
-}
-
-int
OSCClientReceiver::_response_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
assert(!strcmp(types, "ii"));
diff --git a/src/osc/OSCClientReceiver.hpp b/src/osc/OSCClientReceiver.hpp
index a04ed5f5..c3effb10 100644
--- a/src/osc/OSCClientReceiver.hpp
+++ b/src/osc/OSCClientReceiver.hpp
@@ -80,7 +80,6 @@ private:
LO_HANDLER(OSCClientReceiver, delta_add);
LO_HANDLER(OSCClientReceiver, delta_end);
LO_HANDLER(OSCClientReceiver, set_property);
- LO_HANDLER(OSCClientReceiver, activity);
};
} // namespace Client
diff --git a/src/osc/OSCClientSender.cpp b/src/osc/OSCClientSender.cpp
index 1a6289f4..5a50ddf3 100644
--- a/src/osc/OSCClientSender.cpp
+++ b/src/osc/OSCClientSender.cpp
@@ -225,24 +225,5 @@ OSCClientSender::set_property(const URI& path,
send_message("/set_property", m);
}
-/** @page client_osc_namespace
- * <h2>/activity</h2>
- * @arg @p path :: String
- *
- * @par
- * Notification of "activity" (e.g. port message blinkenlights).
- */
-void
-OSCClientSender::activity(const Path& path, const Raul::Atom& value)
-{
- if (!_enabled)
- return;
-
- lo_message m = lo_message_new();
- lo_message_add_string(m, path.c_str());
- AtomLiblo::lo_message_add_atom(m, value);
- send_message("/activity", m);
-}
-
} // namespace Server
} // namespace Ingen
diff --git a/src/osc/OSCClientSender.hpp b/src/osc/OSCClientSender.hpp
index 67e76fee..ffb7323b 100644
--- a/src/osc/OSCClientSender.hpp
+++ b/src/osc/OSCClientSender.hpp
@@ -96,9 +96,6 @@ public:
const Raul::URI& predicate,
const Raul::Atom& value);
- virtual void activity(const Raul::Path& path,
- const Raul::Atom& value);
-
private:
Raul::URI _url;
};
diff --git a/src/osc/OSCEngineReceiver.cpp b/src/osc/OSCEngineReceiver.cpp
index ad505b76..b75d76a4 100644
--- a/src/osc/OSCEngineReceiver.cpp
+++ b/src/osc/OSCEngineReceiver.cpp
@@ -180,7 +180,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types,
if (id != -1) {
// TODO: Cache client
ClientInterface* client = me->_engine.broadcaster()->client(url);
- me->_interface->respond_to(client, id);
+ me->_interface->set_response_id(id);
} else {
me->_interface->disable_responses();
}
diff --git a/src/osc/OSCEngineSender.hpp b/src/osc/OSCEngineSender.hpp
index 5aeeed7b..ff74fb4a 100644
--- a/src/osc/OSCEngineSender.hpp
+++ b/src/osc/OSCEngineSender.hpp
@@ -54,8 +54,7 @@ public:
inline int32_t next_id()
{ int32_t ret = (_id == -1) ? -1 : _id++; return ret; }
- void respond_to(ClientInterface* client, int32_t id) { _id = id; }
- void disable_responses() { _id = -1; }
+ void set_response_id(int32_t id) { _id = id; }
void attach(int32_t ping_id, bool block);
diff --git a/src/server/ClientBroadcaster.cpp b/src/server/ClientBroadcaster.cpp
index 2931497a..1a55d355 100644
--- a/src/server/ClientBroadcaster.cpp
+++ b/src/server/ClientBroadcaster.cpp
@@ -39,6 +39,7 @@ namespace Server {
void
ClientBroadcaster::register_client(const URI& uri, ClientInterface* client)
{
+ Glib::Mutex::Lock lock(_clients_mutex);
Clients::iterator i = _clients.find(uri);
if (i == _clients.end()) {
@@ -56,12 +57,14 @@ ClientBroadcaster::register_client(const URI& uri, ClientInterface* client)
bool
ClientBroadcaster::unregister_client(const URI& uri)
{
- size_t erased = _clients.erase(uri);
+ Glib::Mutex::Lock lock(_clients_mutex);
+ const size_t erased = _clients.erase(uri);
- if (erased > 0)
+ if (erased > 0) {
LOG(info) << "Unregistered client: " << uri << endl;
- else
+ } else {
LOG(warn) << "Failed to find client to unregister: " << uri << endl;
+ }
return (erased > 0);
}
@@ -72,6 +75,7 @@ ClientBroadcaster::unregister_client(const URI& uri)
ClientInterface*
ClientBroadcaster::client(const URI& uri)
{
+ Glib::Mutex::Lock lock(_clients_mutex);
Clients::iterator i = _clients.find(uri);
if (i != _clients.end()) {
return (*i).second;
@@ -83,8 +87,10 @@ ClientBroadcaster::client(const URI& uri)
void
ClientBroadcaster::send_plugins(const NodeFactory::Plugins& plugins)
{
- for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c)
+ Glib::Mutex::Lock lock(_clients_mutex);
+ for (Clients::const_iterator c = _clients.begin(); c != _clients.end(); ++c) {
send_plugins_to((*c).second, plugins);
+ }
}
void
@@ -108,8 +114,10 @@ ClientBroadcaster::send_plugins_to(ClientInterface* client, const NodeFactory::P
void
ClientBroadcaster::send_object(const GraphObjectImpl* o, bool recursive)
{
- for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
+ Glib::Mutex::Lock lock(_clients_mutex);
+ for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) {
ObjectSender::send_object((*i).second, o, recursive);
+ }
}
} // namespace Server
diff --git a/src/server/ClientBroadcaster.hpp b/src/server/ClientBroadcaster.hpp
index c9c56d56..b004433b 100644
--- a/src/server/ClientBroadcaster.hpp
+++ b/src/server/ClientBroadcaster.hpp
@@ -22,6 +22,8 @@
#include <map>
#include <string>
+#include <glibmm/thread.h>
+
#include "raul/SharedPtr.hpp"
#include "ingen/ClientInterface.hpp"
@@ -61,6 +63,7 @@ public:
void send_object(const GraphObjectImpl* p, bool recursive);
#define BROADCAST(msg, ...) \
+ Glib::Mutex::Lock lock(_clients_mutex); \
for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i) \
(*i).second->msg(__VA_ARGS__)
@@ -121,7 +124,9 @@ public:
private:
typedef std::map<Raul::URI, ClientInterface*> Clients;
- Clients _clients;
+
+ Glib::Mutex _clients_mutex;
+ Clients _clients;
};
} // namespace Server
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index d9878bee..89062d4a 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -240,5 +240,17 @@ Engine::process_events(ProcessContext& context)
(*i)->process(*_post_processor, context);
}
+void
+Engine::register_client(const Raul::URI& uri, ClientInterface* client)
+{
+ _broadcaster->register_client(uri, client);
+}
+
+bool
+Engine::unregister_client(const Raul::URI& uri)
+{
+ return _broadcaster->unregister_client(uri);
+}
+
} // namespace Server
} // namespace Ingen
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index d4f39bd8..64f874c2 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -76,6 +76,10 @@ public:
virtual void process_events(ProcessContext& context);
+ virtual void register_client(const Raul::URI& uri, ClientInterface* client);
+
+ virtual bool unregister_client(const Raul::URI& uri);
+
Ingen::Shared::World* world() const { return _world; }
ClientBroadcaster* broadcaster() const { return _broadcaster; }
diff --git a/src/server/ServerInterfaceImpl.cpp b/src/server/ServerInterfaceImpl.cpp
index eb615e9a..1bd388ec 100644
--- a/src/server/ServerInterfaceImpl.cpp
+++ b/src/server/ServerInterfaceImpl.cpp
@@ -21,6 +21,7 @@
#include "ingen/shared/URIs.hpp"
+#include "ClientBroadcaster.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
#include "EventSource.hpp"
@@ -63,37 +64,18 @@ ServerInterfaceImpl::now() const
}
void
-ServerInterfaceImpl::respond_to(ClientInterface* client, int32_t id)
+ServerInterfaceImpl::set_response_id(int32_t id)
{
- _request_client = client;
- _request_id = id;
-}
-
-void
-ServerInterfaceImpl::disable_responses()
-{
- _request_client = NULL;
- _request_id = -1;
+ if (!_request_client) { // Kludge
+ _request_client = _engine.broadcaster()->client(
+ "http://drobilla.net/ns/ingen#internal");
+ std::cerr << "SET REQUEST CLIENT " << (void*)_request_client << std::endl;
+ }
+ _request_id = id;
}
/* *** ServerInterface implementation below here *** */
-void
-ServerInterfaceImpl::register_client(ClientInterface* client)
-{
- push_queued(new Events::RegisterClient(_engine, client, _request_id, now(), client->uri()));
- _request_client = client;
- _request_id = 1;
-}
-
-void
-ServerInterfaceImpl::unregister_client(const URI& uri)
-{
- push_queued(new Events::UnregisterClient(_engine, _request_client, _request_id, now(), uri));
- _request_client = NULL;
- _request_id = -1;
-}
-
// Bundle commands
void
diff --git a/src/server/ServerInterfaceImpl.hpp b/src/server/ServerInterfaceImpl.hpp
index b43549ef..e3dcabad 100644
--- a/src/server/ServerInterfaceImpl.hpp
+++ b/src/server/ServerInterfaceImpl.hpp
@@ -52,12 +52,7 @@ public:
Raul::URI uri() const { return "http://drobilla.net/ns/ingen#internal"; }
- virtual void respond_to(ClientInterface* client, int32_t id);
- virtual void disable_responses();
-
- // Client registration
- virtual void register_client(ClientInterface* client);
- virtual void unregister_client(const Raul::URI& uri);
+ virtual void set_response_id(int32_t id);
// Bundles
virtual void bundle_begin();
diff --git a/src/server/events.hpp b/src/server/events.hpp
index 776b6c52..40e4f3d2 100644
--- a/src/server/events.hpp
+++ b/src/server/events.hpp
@@ -29,10 +29,8 @@
#include "events/Get.hpp"
#include "events/Move.hpp"
#include "events/Ping.hpp"
-#include "events/RegisterClient.hpp"
#include "events/SetMetadata.hpp"
#include "events/SetPortValue.hpp"
-#include "events/UnregisterClient.hpp"
#endif // INGEN_ENGINE_EVENTS_HPP
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 08ac3e10..605e392a 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -18,6 +18,7 @@
#include "ingen/ClientInterface.hpp"
#include "ClientBroadcaster.hpp"
+#include "Driver.hpp"
#include "Engine.hpp"
#include "EngineStore.hpp"
#include "Get.hpp"
@@ -67,6 +68,15 @@ Get::post_process()
if (_request_client) {
_engine.broadcaster()->send_plugins_to(_request_client, _plugins);
}
+ } else if (_uri == "ingen:engine") {
+ // TODO: Keep a proper RDF model of the engine
+ if (_request_client) {
+ Shared::URIs& uris = *_engine.world()->uris().get();
+ _request_client->set_property(
+ uris.ingen_engine,
+ uris.ingen_sampleRate,
+ uris.forge.make(int32_t(_engine.driver()->sample_rate())));
+ }
} else if (!_object && !_plugin) {
respond(NOT_FOUND);
} else if (_request_client) {
diff --git a/src/server/events/RegisterClient.cpp b/src/server/events/RegisterClient.cpp
deleted file mode 100644
index 088cf296..00000000
--- a/src/server/events/RegisterClient.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/* This file is part of Ingen.
- * Copyright 2007-2011 David Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ingen/shared/LV2URIMap.hpp"
-#include "ingen/shared/URIs.hpp"
-
-#include "ClientBroadcaster.hpp"
-#include "Driver.hpp"
-#include "Engine.hpp"
-#include "events/RegisterClient.hpp"
-
-using namespace Raul;
-
-namespace Ingen {
-namespace Server {
-namespace Events {
-
-RegisterClient::RegisterClient(Engine& engine,
- ClientInterface* client,
- int32_t id,
- SampleCount timestamp,
- const URI& uri)
- : Event(engine, client, id, timestamp)
- , _uri(uri)
-{
-}
-
-void
-RegisterClient::pre_process()
-{
- _engine.broadcaster()->register_client(_uri, _request_client);
-
- Event::pre_process();
-}
-
-void
-RegisterClient::post_process()
-{
- respond(SUCCESS);
-
- /* Tell the client the engine's sample rate (which it needs to know to
- interpret control bounds for lv2:sampleRate ports). This is a bit of a
- kludge. TODO: keep a proper RDF model to describe the engine and send
- that to clients.
- */
- const Ingen::Shared::URIs& uris = *_engine.world()->uris().get();
- _request_client->set_property(
- uris.ingen_engine,
- uris.ingen_sampleRate,
- _engine.world()->forge().make(int32_t(_engine.driver()->sample_rate())));
-}
-
-} // namespace Server
-} // namespace Ingen
-} // namespace Events
-
diff --git a/src/server/events/RegisterClient.hpp b/src/server/events/RegisterClient.hpp
deleted file mode 100644
index 0f82a33d..00000000
--- a/src/server/events/RegisterClient.hpp
+++ /dev/null
@@ -1,53 +0,0 @@
-/* This file is part of Ingen.
- * Copyright 2007-2011 David Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INGEN_EVENTS_REGISTERCLIENT_HPP
-#define INGEN_EVENTS_REGISTERCLIENT_HPP
-
-#include "raul/URI.hpp"
-#include "ingen/ClientInterface.hpp"
-#include "Event.hpp"
-
-namespace Ingen {
-namespace Server {
-namespace Events {
-
-/** Registers a new client with the OSC system, so it can receive updates.
- *
- * \ingroup engine
- */
-class RegisterClient : public Event
-{
-public:
- RegisterClient(Engine& engine,
- ClientInterface* client,
- int32_t id,
- SampleCount timestamp,
- const Raul::URI& uri);
-
- void pre_process();
- void post_process();
-
-private:
- Raul::URI _uri;
-};
-
-} // namespace Server
-} // namespace Ingen
-} // namespace Events
-
-#endif // INGEN_EVENTS_REGISTERCLIENT_HPP
diff --git a/src/server/events/UnregisterClient.cpp b/src/server/events/UnregisterClient.cpp
deleted file mode 100644
index a673c25a..00000000
--- a/src/server/events/UnregisterClient.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-/* This file is part of Ingen.
- * Copyright 2007-2011 David Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "ingen/ClientInterface.hpp"
-#include "UnregisterClient.hpp"
-#include "Engine.hpp"
-#include "ClientBroadcaster.hpp"
-
-using namespace Raul;
-
-namespace Ingen {
-namespace Server {
-namespace Events {
-
-UnregisterClient::UnregisterClient(Engine& engine,
- ClientInterface* client,
- int32_t id,
- SampleCount timestamp,
- const URI& uri)
- : Event(engine, client, id, timestamp)
- , _uri(uri)
-{
-}
-
-void
-UnregisterClient::post_process()
-{
- if (_engine.broadcaster()->unregister_client(_uri)) {
- respond(SUCCESS);
- } else {
- respond(FAILURE);
- }
-}
-
-} // namespace Server
-} // namespace Ingen
-} // namespace Events
-
diff --git a/src/server/events/UnregisterClient.hpp b/src/server/events/UnregisterClient.hpp
deleted file mode 100644
index 089b8d8e..00000000
--- a/src/server/events/UnregisterClient.hpp
+++ /dev/null
@@ -1,51 +0,0 @@
-/* This file is part of Ingen.
- * Copyright 2007-2011 David Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef INGEN_EVENTS_UNREGISTERCLIENT_HPP
-#define INGEN_EVENTS_UNREGISTERCLIENT_HPP
-
-#include "Event.hpp"
-#include "raul/URI.hpp"
-
-namespace Ingen {
-namespace Server {
-namespace Events {
-
-/** Unregisters an OSC client so it no longer receives notifications.
- *
- * \ingroup engine
- */
-class UnregisterClient : public Event
-{
-public:
- UnregisterClient(Engine& engine,
- ClientInterface* client,
- int32_t id,
- SampleCount timestamp,
- const Raul::URI& uri);
-
- void post_process();
-
-private:
- Raul::URI _uri;
-};
-
-} // namespace Server
-} // namespace Ingen
-} // namespace Events
-
-#endif // INGEN_EVENTS_UNREGISTERCLIENT_HPP
diff --git a/src/server/wscript b/src/server/wscript
index 593664be..33ffc58a 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -43,10 +43,8 @@ def build(bld):
events/DisconnectAll.cpp
events/Get.cpp
events/Move.cpp
- events/RegisterClient.cpp
events/SetMetadata.cpp
events/SetPortValue.cpp
- events/UnregisterClient.cpp
ingen_engine.cpp
internals/Controller.cpp
internals/Delay.cpp
diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp
index 3e9c0637..1cefbca3 100644
--- a/src/shared/URIs.cpp
+++ b/src/shared/URIs.cpp
@@ -68,6 +68,7 @@ URIs::URIs(Raul::Forge& f, LV2URIMap* map)
, ingen_Node (map, NS_INGEN "Node")
, ingen_Patch (map, NS_INGEN "Patch")
, ingen_Port (map, NS_INGEN "Port")
+ , ingen_activity (map, NS_INGEN "activity")
, ingen_broadcast (map, NS_INGEN "broadcast")
, ingen_controlBinding (map, NS_INGEN "controlBinding")
, ingen_document (map, NS_INGEN "document")