summaryrefslogtreecommitdiffstats
path: root/src/libs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-09-19 05:30:41 +0000
committerDavid Robillard <d@drobilla.net>2007-09-19 05:30:41 +0000
commit36b22fe2bea643d7d4ff69764016ae5be9c6de69 (patch)
tree19e99c3bfa011f8ef86ce1438b676d6826cad31a /src/libs
parent80d9c348e1e571837ae37cd28d342c81c14a52be (diff)
downloadingen-36b22fe2bea643d7d4ff69764016ae5be9c6de69.tar.gz
ingen-36b22fe2bea643d7d4ff69764016ae5be9c6de69.tar.bz2
ingen-36b22fe2bea643d7d4ff69764016ae5be9c6de69.zip
Broadcast polyphony changes to clients.
Fix some (not all) crashes on polyphony change. git-svn-id: http://svn.drobilla.net/lad/ingen@725 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs')
-rw-r--r--src/libs/client/OSCClientReceiver.cpp2
-rw-r--r--src/libs/client/SigClientInterface.hpp4
-rw-r--r--src/libs/client/ThreadedSigClientInterface.hpp5
-rw-r--r--src/libs/engine/ClientBroadcaster.cpp8
-rw-r--r--src/libs/engine/ClientBroadcaster.hpp1
-rw-r--r--src/libs/engine/LV2Node.cpp2
-rw-r--r--src/libs/engine/OSCClientSender.cpp15
-rw-r--r--src/libs/engine/OSCClientSender.hpp3
-rw-r--r--src/libs/engine/OSCEngineReceiver.cpp4
-rw-r--r--src/libs/engine/Port.cpp2
-rw-r--r--src/libs/engine/events/SetPolyphonyEvent.cpp6
11 files changed, 45 insertions, 7 deletions
diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp
index de51ad22..058bf006 100644
--- a/src/libs/client/OSCClientReceiver.cpp
+++ b/src/libs/client/OSCClientReceiver.cpp
@@ -39,7 +39,7 @@ OSCClientReceiver::OSCClientReceiver(int listen_port)
// _receiving_node_num_ports(0),
// _num_received_ports(0)
{
- start(false);
+ start(true);
}
diff --git a/src/libs/client/SigClientInterface.hpp b/src/libs/client/SigClientInterface.hpp
index bdb1ff23..29c13741 100644
--- a/src/libs/client/SigClientInterface.hpp
+++ b/src/libs/client/SigClientInterface.hpp
@@ -55,6 +55,7 @@ public:
sigc::signal<void, string, string, bool> new_port_sig;
sigc::signal<void, string> patch_enabled_sig;
sigc::signal<void, string> patch_disabled_sig;
+ sigc::signal<void, string, uint32_t> patch_polyphony_sig;
sigc::signal<void, string> patch_cleared_sig;
sigc::signal<void, string, string> object_renamed_sig;
sigc::signal<void, string> object_destroyed_sig;
@@ -113,6 +114,9 @@ protected:
void patch_disabled(const string& path)
{ patch_disabled_sig.emit(path); }
+
+ void patch_polyphony(const string& path, uint32_t poly)
+ { patch_polyphony_sig.emit(path, poly); }
void patch_cleared(const string& path)
{ patch_cleared_sig.emit(path); }
diff --git a/src/libs/client/ThreadedSigClientInterface.hpp b/src/libs/client/ThreadedSigClientInterface.hpp
index ed9f0ed4..71ee96d2 100644
--- a/src/libs/client/ThreadedSigClientInterface.hpp
+++ b/src/libs/client/ThreadedSigClientInterface.hpp
@@ -57,6 +57,7 @@ public:
, connection_slot(connection_sig.make_slot())
, patch_enabled_slot(patch_enabled_sig.make_slot())
, patch_disabled_slot(patch_disabled_sig.make_slot())
+ , patch_polyphony_slot(patch_polyphony_sig.make_slot())
, patch_cleared_slot(patch_cleared_sig.make_slot())
, object_destroyed_slot(object_destroyed_sig.make_slot())
, object_renamed_slot(object_renamed_sig.make_slot())
@@ -115,6 +116,9 @@ public:
void patch_disabled(const string& path)
{ push_sig(sigc::bind(patch_disabled_slot, path)); }
+
+ void patch_polyphony(const string& path, uint32_t poly)
+ { push_sig(sigc::bind(patch_polyphony_slot, path, poly)); }
void patch_cleared(const string& path)
{ push_sig(sigc::bind(patch_cleared_slot, path)); }
@@ -161,6 +165,7 @@ private:
sigc::slot<void, string, string> connection_slot;
sigc::slot<void, string> patch_enabled_slot;
sigc::slot<void, string> patch_disabled_slot;
+ sigc::slot<void, string, uint32_t> patch_polyphony_slot;
sigc::slot<void, string> patch_cleared_slot;
sigc::slot<void, string> object_destroyed_slot;
sigc::slot<void, string, string> object_renamed_slot;
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp
index 5023b2e0..0a98c05c 100644
--- a/src/libs/engine/ClientBroadcaster.cpp
+++ b/src/libs/engine/ClientBroadcaster.cpp
@@ -229,6 +229,14 @@ ClientBroadcaster::send_patch_disable(const string& patch_path)
}
+void
+ClientBroadcaster::send_patch_polyphony(const string& patch_path, uint32_t poly)
+{
+ for (Clients::const_iterator i = _clients.begin(); i != _clients.end(); ++i)
+ (*i).second->patch_polyphony(patch_path, poly);
+}
+
+
/** Send notification of a metadata update.
*
* Like control changes, does not send update to client that set the metadata, if applicable.
diff --git a/src/libs/engine/ClientBroadcaster.hpp b/src/libs/engine/ClientBroadcaster.hpp
index 40fef365..1c1217bc 100644
--- a/src/libs/engine/ClientBroadcaster.hpp
+++ b/src/libs/engine/ClientBroadcaster.hpp
@@ -81,6 +81,7 @@ public:
void send_all_objects();
void send_patch_enable(const string& patch_path);
void send_patch_disable(const string& patch_path);
+ void send_patch_polyphony(const string& patch_path, uint32_t poly);
void send_metadata_update(const string& node_path, const string& key, const Raul::Atom& value);
void send_control_change(const string& port_path, float value);
void send_program_add(const string& node_path, int bank, int program, const string& name);
diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp
index 8e2e9b81..8ecd00b7 100644
--- a/src/libs/engine/LV2Node.cpp
+++ b/src/libs/engine/LV2Node.cpp
@@ -63,7 +63,7 @@ LV2Node::prepare_poly(uint32_t poly)
_prepared_instances = new Raul::Array<SLV2Instance>(_prepared_poly, *_instances);
for (uint32_t i=_poly; i < _prepared_poly; ++i) {
_prepared_instances->at(i) = slv2_plugin_instantiate(_lv2_plugin, _srate, NULL);
- if ((*_instances)[i] == NULL) {
+ if ((*_prepared_instances)[i] == NULL) {
cerr << "Failed to instantiate plugin!" << endl;
return false;
}
diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp
index 66b1ed02..2bcd8282 100644
--- a/src/libs/engine/OSCClientSender.cpp
+++ b/src/libs/engine/OSCClientSender.cpp
@@ -436,6 +436,21 @@ OSCClientSender::patch_disabled(const std::string& patch_path)
/** \page client_osc_namespace
+ * <p> \b /ingen/patch_polyphony - Notification a patch's DSP processing has been polyphony.
+ * \arg \b path (const std::string&) - Path of polyphony patch</p> \n \n
+ */
+void
+OSCClientSender::patch_polyphony(const std::string& patch_path, uint32_t poly)
+{
+ if (!_enabled)
+ return;
+
+ lo_send(_address, "/ingen/patch_polyphony", "si", patch_path.c_str(), poly);
+}
+
+
+
+/** \page client_osc_namespace
* <p> \b /ingen/new_connection - Notification a new connection has been made.
* \arg \b src-path (const std::string&) - Path of the source port
* \arg \b dst-path (const std::string&) - Path of the destination port</p> \n \n
diff --git a/src/libs/engine/OSCClientSender.hpp b/src/libs/engine/OSCClientSender.hpp
index 1930e708..ac45bef4 100644
--- a/src/libs/engine/OSCClientSender.hpp
+++ b/src/libs/engine/OSCClientSender.hpp
@@ -94,6 +94,9 @@ public:
virtual void patch_disabled(const std::string& path);
+ virtual void patch_polyphony(const std::string& path,
+ uint32_t poly);
+
virtual void patch_cleared(const std::string& path);
virtual void object_destroyed(const std::string& path);
diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp
index 4d31d836..d922d3c9 100644
--- a/src/libs/engine/OSCEngineReceiver.cpp
+++ b/src/libs/engine/OSCEngineReceiver.cpp
@@ -83,7 +83,7 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t
lo_server_add_method(_server, "/ingen/enable_patch", "is", enable_patch_cb, this);
lo_server_add_method(_server, "/ingen/disable_patch", "is", disable_patch_cb, this);
lo_server_add_method(_server, "/ingen/clear_patch", "is", clear_patch_cb, this);
- lo_server_add_method(_server, "/ingen/set_polyphony", "ii", set_polyphony_cb, this);
+ lo_server_add_method(_server, "/ingen/set_polyphony", "isi", set_polyphony_cb, this);
lo_server_add_method(_server, "/ingen/create_port", "issi", create_port_cb, this);
lo_server_add_method(_server, "/ingen/create_node", "issssi", create_node_cb, this);
lo_server_add_method(_server, "/ingen/create_node", "issi", create_node_by_uri_cb, this);
@@ -448,7 +448,7 @@ int
OSCEngineReceiver::_set_polyphony_cb(const char* path, const char* types, lo_arg** argv, int argc, lo_message msg)
{
const char* patch_path = &argv[1]->s;
- const uint32_t poly = argv[1]->i;
+ const uint32_t poly = argv[2]->i;
set_polyphony(patch_path, poly);
return 0;
diff --git a/src/libs/engine/Port.cpp b/src/libs/engine/Port.cpp
index fe9e2c09..0a4c9f06 100644
--- a/src/libs/engine/Port.cpp
+++ b/src/libs/engine/Port.cpp
@@ -64,7 +64,7 @@ Port::prepare_poly(uint32_t poly)
_prepared_buffers = new Raul::Array<Buffer*>(poly, *_buffers);
_prepared_poly = poly;
for (uint32_t i = _poly; i < _prepared_poly; ++i)
- _buffers->at(i) = BufferFactory::create(_type, _buffer_size);
+ _prepared_buffers->at(i) = BufferFactory::create(_type, _buffer_size);
}
return true;
diff --git a/src/libs/engine/events/SetPolyphonyEvent.cpp b/src/libs/engine/events/SetPolyphonyEvent.cpp
index 8dfed9c8..bdf4e1a1 100644
--- a/src/libs/engine/events/SetPolyphonyEvent.cpp
+++ b/src/libs/engine/events/SetPolyphonyEvent.cpp
@@ -66,10 +66,12 @@ SetPolyphonyEvent::execute(SampleCount nframes, FrameTime start, FrameTime end)
void
SetPolyphonyEvent::post_process()
{
- if (_patch)
+ if (_patch) {
_responder->respond_ok();
- else
+ _engine.broadcaster()->send_patch_polyphony(_patch_path, _poly);
+ } else {
_responder->respond_error("Unable to find patch");
+ }
}