From 36b22fe2bea643d7d4ff69764016ae5be9c6de69 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 19 Sep 2007 05:30:41 +0000 Subject: 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 --- src/libs/engine/ClientBroadcaster.cpp | 8 ++++++++ src/libs/engine/ClientBroadcaster.hpp | 1 + src/libs/engine/LV2Node.cpp | 2 +- src/libs/engine/OSCClientSender.cpp | 15 +++++++++++++++ src/libs/engine/OSCClientSender.hpp | 3 +++ src/libs/engine/OSCEngineReceiver.cpp | 4 ++-- src/libs/engine/Port.cpp | 2 +- src/libs/engine/events/SetPolyphonyEvent.cpp | 6 ++++-- 8 files changed, 35 insertions(+), 6 deletions(-) (limited to 'src/libs/engine') 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(_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 @@ -435,6 +435,21 @@ OSCClientSender::patch_disabled(const std::string& patch_path) } +/** \page client_osc_namespace + *

\b /ingen/patch_polyphony - Notification a patch's DSP processing has been polyphony. + * \arg \b path (const std::string&) - Path of polyphony patch

\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 *

\b /ingen/new_connection - Notification a new connection has been made. * \arg \b src-path (const std::string&) - Path of the source port 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(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"); + } } -- cgit v1.2.1