summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2006-10-15 20:46:26 +0000
committerDavid Robillard <d@drobilla.net>2006-10-15 20:46:26 +0000
commit4174fb8f94139e0a38da150ffb0874b636497dfe (patch)
tree7170dd4b13ee0fe42c67aeabeef3f95437f146b2 /src/libs
parent14542a4634cb211be5bdf590574ae3b8e1715486 (diff)
downloadingen-4174fb8f94139e0a38da150ffb0874b636497dfe.tar.gz
ingen-4174fb8f94139e0a38da150ffb0874b636497dfe.tar.bz2
ingen-4174fb8f94139e0a38da150ffb0874b636497dfe.zip
Fixed feedback problems (CPU chewing) with port controls.
git-svn-id: http://svn.drobilla.net/lad/ingen@176 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/OSCClientReceiver.cpp2
-rw-r--r--src/libs/client/OSCClientReceiver.h4
-rw-r--r--src/libs/client/SigClientInterface.h4
-rw-r--r--src/libs/client/ThreadedSigClientInterface.cpp3
-rw-r--r--src/libs/client/ThreadedSigClientInterface.h7
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp2
-rw-r--r--src/libs/engine/OSCClientSender.cpp54
-rw-r--r--src/libs/engine/OSCClientSender.h8
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp15
-rw-r--r--src/libs/engine/OSCResponder.cpp8
-rw-r--r--src/libs/engine/Responder.h7
-rw-r--r--src/libs/engine/events/SetPortValueEvent.cpp7
12 files changed, 105 insertions, 16 deletions
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index eb320df0..14bff1f1 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -67,7 +67,7 @@ OSCClientReceiver::start()
}
// Print all incoming messages
- //lo_server_thread_add_method(_st, NULL, NULL, generic_cb, NULL);
+ lo_server_thread_add_method(_st, NULL, NULL, generic_cb, NULL);
//lo_server_thread_add_method(_st, "/om/response/ok", "i", om_response_ok_cb, this);
//lo_server_thread_add_method(_st, "/om/response/error", "is", om_responseerror_cb, this);
diff --git a/src/libs/client/OSCClientReceiver.h b/src/libs/client/OSCClientReceiver.h
index 287f5e45..57faec77 100644
--- a/src/libs/client/OSCClientReceiver.h
+++ b/src/libs/client/OSCClientReceiver.h
@@ -60,6 +60,10 @@ public:
OSCClientReceiver(int listen_port);
~OSCClientReceiver();
+ // Engine side only
+ //void enable() {}
+ //void disable() {}
+
void start();
void stop();
diff --git a/src/libs/client/SigClientInterface.h b/src/libs/client/SigClientInterface.h
index 4639bdc7..9f8a4537 100644
--- a/src/libs/client/SigClientInterface.h
+++ b/src/libs/client/SigClientInterface.h
@@ -67,6 +67,10 @@ protected:
// ClientInterface hooks that fire the above signals
+ // FIXME: implement for this (is implemented for ThreadedSigClientInterface)
+ void enable() { }
+ void disable() { }
+
void bundle_begin() {}
void bundle_end() {}
diff --git a/src/libs/client/ThreadedSigClientInterface.cpp b/src/libs/client/ThreadedSigClientInterface.cpp
index 28719598..bbe336a6 100644
--- a/src/libs/client/ThreadedSigClientInterface.cpp
+++ b/src/libs/client/ThreadedSigClientInterface.cpp
@@ -27,6 +27,9 @@ namespace Client {
void
ThreadedSigClientInterface::push_sig(Closure ev)
{
+ if (!_enabled)
+ return;
+
bool success = false;
bool first = true;
diff --git a/src/libs/client/ThreadedSigClientInterface.h b/src/libs/client/ThreadedSigClientInterface.h
index 056540fb..57afd0fa 100644
--- a/src/libs/client/ThreadedSigClientInterface.h
+++ b/src/libs/client/ThreadedSigClientInterface.h
@@ -44,7 +44,8 @@ class ThreadedSigClientInterface : public SigClientInterface
{
public:
ThreadedSigClientInterface(uint32_t queue_size)
- : _sigs(queue_size)
+ : _enabled(true)
+ , _sigs(queue_size)
, response_slot(response_sig.make_slot())
, error_slot(error_sig.make_slot())
, new_plugin_slot(new_plugin_sig.make_slot())
@@ -64,6 +65,8 @@ public:
, program_remove_slot(program_remove_sig.make_slot())
{}
+ void enable() { _enabled = true; }
+ void disable() { _enabled = false ; }
// FIXME: make this insert bundle-boundary-events, where the GTK thread
// process all events between start and finish in one cycle, guaranteed
@@ -133,6 +136,8 @@ public:
private:
void push_sig(Closure ev);
+ bool _enabled;
+
Queue<Closure> _sigs;
uint32_t _num_plugins;
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 6e722024..872cbb14 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -110,7 +110,7 @@ ClientBroadcaster::client(const ClientKey& key)
if ((*i).first == key)
return (*i).second;
- cerr << "[ClientBroadcaster] Failed to find client." << endl;
+ cerr << "[ClientBroadcaster] Failed to find client " << key.uri() << endl;
return SharedPtr<ClientInterface>();
}
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index 24dc1cb0..2032e47b 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -100,6 +100,9 @@ OSCClientSender::transfer_end()
void
OSCClientSender::response(int32_t id, bool success, string msg)
{
+ if (!_enabled)
+ return;
+
if (lo_send(_address, "/om/response", "iis", id, success ? 1 : 0, msg.c_str()) < 0) {
cerr << "Unable to send response " << id << "! ("
<< lo_address_errstr(_address) << ")" << endl;
@@ -122,6 +125,9 @@ OSCClientSender::response(int32_t id, bool success, string msg)
void
OSCClientSender::error(string msg)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/error", "s", msg.c_str());
}
@@ -143,6 +149,9 @@ OSCClientSender::error(string msg)
void
OSCClientSender::num_plugins(uint32_t num)
{
+ if (!_enabled)
+ return;
+
lo_message m = lo_message_new();
lo_message_add_int32(m, num);
lo_send_message(_address, "/om/num_plugins", m);
@@ -222,6 +231,9 @@ void OSCClientSender::new_node(string plugin_uri,
bool is_polyphonic,
uint32_t num_ports)
{
+ if (!_enabled)
+ return;
+
//cerr << "Sending node " << node_path << endl;
lo_send(_address, "/om/new_node", "ssii", plugin_uri.c_str(),
@@ -334,6 +346,9 @@ OSCClientSender::new_port(string path,
string data_type,
bool is_output)
{
+ if (!_enabled)
+ return;
+
//PortInfo* info = port->port_info();
lo_send(_address, "/om/new_port", "ssi", path.c_str(), data_type.c_str(), is_output);
@@ -352,6 +367,9 @@ OSCClientSender::new_port(string path,
void
OSCClientSender::object_destroyed(string path)
{
+ if (!_enabled)
+ return;
+
assert(path != "/");
lo_send(_address, "/om/destroyed", "s", path.c_str());
@@ -365,6 +383,9 @@ OSCClientSender::object_destroyed(string path)
void
OSCClientSender::patch_cleared(string patch_path)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/patch_cleared", "s", patch_path.c_str());
}
@@ -376,6 +397,9 @@ OSCClientSender::patch_cleared(string patch_path)
void
OSCClientSender::patch_enabled(string patch_path)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/patch_enabled", "s", patch_path.c_str());
}
@@ -387,6 +411,9 @@ OSCClientSender::patch_enabled(string patch_path)
void
OSCClientSender::patch_disabled(string patch_path)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/patch_disabled", "s", patch_path.c_str());
}
@@ -399,6 +426,9 @@ OSCClientSender::patch_disabled(string patch_path)
void
OSCClientSender::connection(string src_port_path, string dst_port_path)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/new_connection", "ss", src_port_path.c_str(), dst_port_path.c_str());
}
@@ -411,6 +441,9 @@ OSCClientSender::connection(string src_port_path, string dst_port_path)
void
OSCClientSender::disconnection(string src_port_path, string dst_port_path)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/disconnection", "ss", src_port_path.c_str(), dst_port_path.c_str());
}
@@ -424,6 +457,9 @@ OSCClientSender::disconnection(string src_port_path, string dst_port_path)
void
OSCClientSender::metadata_update(string path, string key, Atom value)
{
+ if (!_enabled)
+ return;
+
lo_message m = lo_message_new();
lo_message_add_string(m, path.c_str());
lo_message_add_string(m, key.c_str());
@@ -443,6 +479,9 @@ OSCClientSender::metadata_update(string path, string key, Atom value)
void
OSCClientSender::control_change(string port_path, float value)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/control_change", "sf", port_path.c_str(), value);
}
@@ -456,6 +495,9 @@ OSCClientSender::control_change(string port_path, float value)
void
OSCClientSender::new_plugin(string uri, string name)
{
+ if (!_enabled)
+ return;
+
lo_message m = lo_message_new();
lo_message_add_string(m, uri.c_str());
lo_message_add_string(m, name.c_str());
@@ -475,6 +517,9 @@ OSCClientSender::new_plugin(string uri, string name)
void
OSCClientSender::new_patch(string path, uint32_t poly)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/new_patch", "si", path.c_str(), poly);
/*
@@ -498,6 +543,9 @@ OSCClientSender::new_patch(string path, uint32_t poly)
void
OSCClientSender::object_renamed(string old_path, string new_path)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/object_renamed", "ss", old_path.c_str(), new_path.c_str());
}
@@ -507,6 +555,9 @@ OSCClientSender::object_renamed(string old_path, string new_path)
void
OSCClientSender::program_add(string node_path, uint32_t bank, uint32_t program, string name)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/program_add", "siis",
node_path.c_str(), bank, program, name.c_str());
}
@@ -515,6 +566,9 @@ OSCClientSender::program_add(string node_path, uint32_t bank, uint32_t program,
void
OSCClientSender::program_remove(string node_path, uint32_t bank, uint32_t program)
{
+ if (!_enabled)
+ return;
+
lo_send(_address, "/om/program_remove", "sii",
node_path.c_str(), bank, program);
}
diff --git a/src/libs/engine/OSCClientSender.h b/src/libs/engine/OSCClientSender.h
index a2ee9e26..8b465288 100644
--- a/src/libs/engine/OSCClientSender.h
+++ b/src/libs/engine/OSCClientSender.h
@@ -42,7 +42,8 @@ public:
OSCClientSender(const string& url)
: _url(url),
_address(lo_address_new_from_url(url.c_str())),
- _transfer(NULL)
+ _transfer(NULL),
+ _enabled(true)
{}
virtual ~OSCClientSender()
@@ -60,6 +61,9 @@ public:
//void client_registration(string url, int client_id);
+ void enable() { _enabled = true; }
+ void disable() { _enabled = false; }
+
void bundle_begin();
void bundle_end();
@@ -128,6 +132,8 @@ private:
lo_address _address;
lo_bundle _transfer;
+
+ bool _enabled;
};
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 3354e648..b7e8f3a1 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -214,11 +214,11 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types,
const int id = argv[0]->i;
+ const lo_address addr = lo_message_get_source(msg);
+ char* const url = lo_address_get_url(addr);
+
// Need to respond
if (id != -1) {
- const lo_address addr = lo_message_get_source(msg);
- char* const url = lo_address_get_url(addr);
-
//cerr << "** need to respond\n";
// Currently have an OSC responder, check if it's still okay
@@ -246,12 +246,19 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types,
me->set_responder(me->_osc_responder);
//cerr << "** Setting response address to " << url << "(2)" << endl;
}
-
+
me->set_next_response_id(id);
// Don't respond
} else {
me->disable_responses();
+ SharedPtr<ClientInterface> client = me->_engine->broadcaster()->client(
+ ClientKey(ClientKey::OSC_URL, (const char*)url));
+ if (client)
+ client->disable();
+ else
+ cerr << "UNKNOWN CLIENT!\n";
+
//cerr << "** Not responding." << endl;
}
diff --git a/src/libs/engine/OSCResponder.cpp b/src/libs/engine/OSCResponder.cpp
index acc7e7ac..7a63c180 100644
--- a/src/libs/engine/OSCResponder.cpp
+++ b/src/libs/engine/OSCResponder.cpp
@@ -54,6 +54,10 @@ OSCResponder::~OSCResponder()
void
OSCResponder::respond_ok()
{
+ SharedPtr<ClientInterface> client = this->client();
+ if (client)
+ client->enable();
+
_addr = lo_address_new_from_url(_url);
//cerr << "OK " << _id << endl;
@@ -67,6 +71,10 @@ OSCResponder::respond_ok()
void
OSCResponder::respond_error(const string& msg)
{
+ SharedPtr<ClientInterface> client = this->client();
+ if (client)
+ client->enable();
+
_addr = lo_address_new_from_url(_url);
//cerr << "ERR " << _id << endl;
diff --git a/src/libs/engine/Responder.h b/src/libs/engine/Responder.h
index acfa6beb..fad5c1a3 100644
--- a/src/libs/engine/Responder.h
+++ b/src/libs/engine/Responder.h
@@ -44,6 +44,11 @@ using Shared::ClientInterface;
* ClientInterface and Responder are seperate because responding might not
* actually get exposed to the client interface (eg in simulated blocking
* interfaces that wait for responses before returning).
+ *
+ * Note for messages that have a "response" and some broadcasted effect
+ * (eg setting a port value) the "response" MUST be sent first since Responder
+ * is responsible for controlling whether the client wishes to receive the
+ * notification.
*/
class Responder
{
@@ -51,7 +56,7 @@ public:
Responder() {}
virtual ~Responder() {}
- virtual ClientKey client_key() { return ClientKey(); }
+ virtual ClientKey client_key() { return ClientKey(); }
virtual SharedPtr<ClientInterface> client() { return SharedPtr<ClientInterface>(); }
virtual void set_id(int32_t id) {}
diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp
index 417cab32..bba5bc3c 100644
--- a/src/libs/engine/events/SetPortValueEvent.cpp
+++ b/src/libs/engine/events/SetPortValueEvent.cpp
@@ -81,13 +81,6 @@ SetPortValueEvent::post_process()
_responder->respond_ok();
_engine.broadcaster()->send_control_change(m_port_path, m_val);
- // Send patch port control change, if this is a bridge port
- /*Port* parent_port = m_port->parent_node()->as_port();
- if (parent_port != NULL) {
- assert(parent_port->type() == DataType::FLOAT);
- _engine.broadcaster()->send_control_change(parent_port->path(), m_val);
- }*/
-
} else if (m_error == PORT_NOT_FOUND) {
string msg = "Unable to find port ";
msg.append(m_port_path).append(" for set_port_value");