diff options
author | David Robillard <d@drobilla.net> | 2006-09-09 14:24:56 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2006-09-09 14:24:56 +0000 |
commit | fca95e5d454d37bd74b98f5bce35cfcbaee86c3f (patch) | |
tree | 97fcf6e8afaf4356d46a24236e9aa2451ab55698 /src/libs/engine | |
parent | b853b3dde1f7028dd275f78433a6ad9b5b9f61c7 (diff) | |
download | ingen-fca95e5d454d37bd74b98f5bce35cfcbaee86c3f.tar.gz ingen-fca95e5d454d37bd74b98f5bce35cfcbaee86c3f.tar.bz2 ingen-fca95e5d454d37bd74b98f5bce35cfcbaee86c3f.zip |
Drove 'er home! Working monolothic Ingenuity (ie. in-process engine).
Countless bugfixes.
git-svn-id: http://svn.drobilla.net/lad/ingen@123 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/libs/engine')
50 files changed, 344 insertions, 247 deletions
diff --git a/src/libs/engine/ClientBroadcaster.cpp b/src/libs/engine/ClientBroadcaster.cpp index 355d4232..181e5a2c 100644 --- a/src/libs/engine/ClientBroadcaster.cpp +++ b/src/libs/engine/ClientBroadcaster.cpp @@ -42,9 +42,6 @@ namespace Ingen { void ClientBroadcaster::register_client(const ClientKey key, CountedPtr<ClientInterface> client) { - assert(key.type() == ClientKey::OSC_URL); - assert(key.uri() != ""); - bool found = false; for (ClientList::iterator i = _clients.begin(); i != _clients.end(); ++i) if ((*i).first == key) @@ -126,12 +123,10 @@ ClientBroadcaster::send_error(const string& msg) (*i).second->error(msg); } - -/* FIXME: Make a copy method for list and just make a copy and pass it here - * instead of this global+locking mess */ void -ClientBroadcaster::send_plugins_to(ClientInterface* client, const list<Plugin*>& plugin_list) +ClientBroadcaster::send_plugins_to(CountedPtr<ClientInterface> client, const list<Plugin*>& plugin_list) { +#if 0 // FIXME: This probably isn't actually thread safe const list<Plugin*> plugs = plugin_list; // make a copy @@ -175,6 +170,23 @@ ClientBroadcaster::send_plugins_to(ClientInterface* client, const list<Plugin*>& } for (list<lo_bundle>::const_iterator i = msgs.begin(); i != msgs.end(); ++i) lo_message_free(*i); +#endif + client->transfer_begin(); + + for (list<Plugin*>::const_iterator i = plugin_list.begin(); i != plugin_list.end(); ++i) { + const Plugin* const plugin = *i; + client->new_plugin(plugin->type_string(), plugin->uri(), plugin->name()); + } + + client->transfer_end(); +} + + +void +ClientBroadcaster::send_plugins(const list<Plugin*>& plugin_list) +{ + for (ClientList::const_iterator c = _clients.begin(); c != _clients.end(); ++c) + send_plugins_to((*c).second, plugin_list); } diff --git a/src/libs/engine/ClientBroadcaster.h b/src/libs/engine/ClientBroadcaster.h index adc0e7e9..ed4bec4e 100644 --- a/src/libs/engine/ClientBroadcaster.h +++ b/src/libs/engine/ClientBroadcaster.h @@ -66,10 +66,11 @@ public: // Error that isn't the direct result of a request void send_error(const string& msg); - void send_plugins_to(ClientInterface* client, const list<Plugin*>& plugin_list); + //void send_node_creation_messages(const Node* const node); + void send_plugins(const list<Plugin*>& plugin_list); void send_patch(const Patch* const p); void send_node(const Node* const node); void send_port(const Port* port); @@ -85,6 +86,8 @@ public: 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); void send_program_remove(const string& node_path, int bank, int program); + + void send_plugins_to(CountedPtr<ClientInterface>, const list<Plugin*>& plugin_list); private: typedef list<pair<ClientKey, CountedPtr<ClientInterface> > > ClientList; diff --git a/src/libs/engine/DSSINode.cpp b/src/libs/engine/DSSINode.cpp index 11fda753..df94c775 100644 --- a/src/libs/engine/DSSINode.cpp +++ b/src/libs/engine/DSSINode.cpp @@ -276,7 +276,7 @@ DSSINode::update_programs(bool send_events) iter->second.find(descriptor->Program)->second != descriptor->Name) { _banks[descriptor->Bank][descriptor->Program] = descriptor->Name; if (send_events) { - _engine.client_broadcaster()->send_program_add(path(), descriptor->Bank, + _engine.broadcaster()->send_program_add(path(), descriptor->Bank, descriptor->Program, descriptor->Name); } @@ -291,7 +291,7 @@ DSSINode::update_programs(bool send_events) set_iter != to_be_deleted.end(); ++set_iter) { _banks[set_iter->first].erase(set_iter->second); if (send_events) - _engine.client_broadcaster()->send_program_remove(path(), set_iter->first, set_iter->second); + _engine.broadcaster()->send_program_remove(path(), set_iter->first, set_iter->second); if (_banks[set_iter->first].size() == 0) _banks.erase(set_iter->first); } diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index ebe8e4f7..94f964dc 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -60,7 +60,7 @@ Engine::Engine(AudioDriver* audio_driver) #endif m_maid(new Maid(maid_queue_size)), m_post_processor(new PostProcessor(*m_maid, post_processor_queue_size)), - m_client_broadcaster(new ClientBroadcaster()), + m_broadcaster(new ClientBroadcaster()), m_object_store(new ObjectStore()), m_node_factory(new NodeFactory()), #ifdef HAVE_LASH @@ -85,7 +85,7 @@ Engine::~Engine() } delete m_object_store; - delete m_client_broadcaster; + delete m_broadcaster; delete m_node_factory; delete m_midi_driver; delete m_audio_driver; @@ -114,13 +114,7 @@ Engine::main() // Loop until quit flag is set (by OSCReceiver) while ( ! m_quit_flag) { nanosleep(&main_rate, NULL); -#ifdef HAVE_LASH - // Process any pending LASH events - if (lash_driver->enabled()) - lash_driver->process_events(); -#endif - // Run the maid (garbage collector) - m_maid->cleanup(); + main_iteration(); } cout << "[Main] Done main loop." << endl; @@ -134,6 +128,25 @@ Engine::main() } +/** Run one iteration of the main loop. + * + * NOT realtime safe (this is where deletion actually occurs) + */ +bool +Engine::main_iteration() +{ +#ifdef HAVE_LASH + // Process any pending LASH events + if (lash_driver->enabled()) + lash_driver->process_events(); +#endif + // Run the maid (garbage collector) + m_maid->cleanup(); + + return !m_quit_flag; +} + + void Engine::activate() { diff --git a/src/libs/engine/Engine.h b/src/libs/engine/Engine.h index 35192bb5..1f84d867 100644 --- a/src/libs/engine/Engine.h +++ b/src/libs/engine/Engine.h @@ -53,7 +53,8 @@ public: Engine(AudioDriver* audio_driver = 0); ~Engine(); - int main(); + int main(); + bool main_iteration(); /** Set the quit flag that should kill all threads and exit cleanly. * Note that it will take some time. */ @@ -62,6 +63,8 @@ public: void activate(); void deactivate(); + bool activated() { return m_activated; } + void set_event_source(EventSource* es) { m_event_source = es; } EventSource* event_source() const { return m_event_source; } @@ -69,7 +72,7 @@ public: MidiDriver* midi_driver() const { return m_midi_driver; } Maid* maid() const { return m_maid; } PostProcessor* post_processor() const { return m_post_processor; } - ClientBroadcaster* client_broadcaster() const { return m_client_broadcaster; } + ClientBroadcaster* broadcaster() const { return m_broadcaster; } ObjectStore* object_store() const { return m_object_store; } NodeFactory* node_factory() const { return m_node_factory; } LashDriver* lash_driver() const { return m_lash_driver; } @@ -87,7 +90,7 @@ private: MidiDriver* m_midi_driver; Maid* m_maid; PostProcessor* m_post_processor; - ClientBroadcaster* m_client_broadcaster; + ClientBroadcaster* m_broadcaster; ObjectStore* m_object_store; NodeFactory* m_node_factory; LashDriver* m_lash_driver; diff --git a/src/libs/engine/LADSPANode.cpp b/src/libs/engine/LADSPANode.cpp index b01f8900..76550d0b 100644 --- a/src/libs/engine/LADSPANode.cpp +++ b/src/libs/engine/LADSPANode.cpp @@ -110,8 +110,11 @@ LADSPANode::instantiate() _ports->at(j) = port; } - assert(_ports->at(j) != NULL); - Sample default_val = default_port_value(j); + assert(port); + assert(_ports->at(j) == port); + + Sample default_val, min, max; + get_port_limits(j, default_val, min, max); // Set default value if (port->buffer_size() == 1) { @@ -119,6 +122,12 @@ LADSPANode::instantiate() } else { ((TypedPort<Sample>*)port)->set_value(0.0f, 0); } + + char tmp_buf[16]; + snprintf(tmp_buf, 16, "%f", min); + port->set_metadata("min", tmp_buf); + snprintf(tmp_buf, 16, "%f", max); + port->set_metadata("max", tmp_buf); } return true; @@ -262,12 +271,9 @@ LADSPANode::get_port_vals(ulong port_index, PortInfo* info) #endif -Sample -LADSPANode::default_port_value(ulong port_index) +void +LADSPANode::get_port_limits(unsigned long port_index, Sample& normal, Sample& lower, Sample& upper) { - LADSPA_Data normal = 0.0f; - LADSPA_Data upper = 0.0f; - LADSPA_Data lower = 0.0f; LADSPA_PortRangeHintDescriptor hint_descriptor = _descriptor->PortRangeHints[port_index].HintDescriptor; /* set upper and lower, possibly adjusted to the sample rate */ @@ -328,10 +334,6 @@ LADSPANode::default_port_value(ulong port_index) normal = upper; } } - - cerr << path() << " Port " << port_index << " LADSPA Default value: " << normal << endl; - // FIXME: set min/max as metadata - return normal; } diff --git a/src/libs/engine/LADSPANode.h b/src/libs/engine/LADSPANode.h index 7fc78fb6..6c5d6a5d 100644 --- a/src/libs/engine/LADSPANode.h +++ b/src/libs/engine/LADSPANode.h @@ -54,7 +54,7 @@ protected: LADSPANode& operator=(const LADSPANode&); //void get_port_vals(ulong port_index, PortInfo* info); - Sample default_port_value(ulong port_index); + void get_port_limits(unsigned long port_index, Sample& default_value, Sample& lower_bound, Sample& upper_bound); const LADSPA_Descriptor* _descriptor; LADSPA_Handle* _instances; diff --git a/src/libs/engine/Makefile.am b/src/libs/engine/Makefile.am index 1f3b4d45..daf6db6c 100644 --- a/src/libs/engine/Makefile.am +++ b/src/libs/engine/Makefile.am @@ -26,6 +26,7 @@ libingen_la_SOURCES = \ OSCEngineReceiver.h \ OSCEngineReceiver.cpp \ Responder.h \ + DirectResponder.h \ OSCResponder.h \ OSCResponder.cpp \ ClientKey.h \ diff --git a/src/libs/engine/NodeBase.cpp b/src/libs/engine/NodeBase.cpp index 2532064e..abba3c33 100644 --- a/src/libs/engine/NodeBase.cpp +++ b/src/libs/engine/NodeBase.cpp @@ -84,7 +84,7 @@ void NodeBase::send_creation_messages(ClientInterface* client) const { cerr << "FIXME: send_creation\n"; - //_engine.client_broadcaster()->send_node_to(client, this); + //_engine.broadcaster()->send_node_to(client, this); } */ diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp index 7bac3bd8..9ab03a73 100644 --- a/src/libs/engine/NodeFactory.cpp +++ b/src/libs/engine/NodeFactory.cpp @@ -145,9 +145,9 @@ NodeFactory::load_plugin(const Plugin* a_plugin, // DEPRECATED: Search by lib name / plug label if (a_plugin->uri().length() == 0) { assert(a_plugin->lib_name().length() > 0 && a_plugin->plug_label().length() > 0); - cerr << "Searching for: " << a_plugin->lib_name() << " : " << a_plugin->plug_label() << endl; + //cerr << "Searching for: " << a_plugin->lib_name() << " : " << a_plugin->plug_label() << endl; for (list<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { - cerr << (*i)->lib_name() << " : " << (*i)->plug_label() << endl; + //cerr << (*i)->lib_name() << " : " << (*i)->plug_label() << endl; if (a_plugin->lib_name() == (*i)->lib_name() && a_plugin->plug_label() == (*i)->plug_label()) { plugin = *i; break; @@ -155,7 +155,6 @@ NodeFactory::load_plugin(const Plugin* a_plugin, } } else { // Search by URI - cerr << "Searching for " << name << " by URI" << endl; for (list<Plugin*>::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { if (a_plugin->uri() == (*i)->uri()) { plugin = *i; diff --git a/src/libs/engine/OSCClientSender.cpp b/src/libs/engine/OSCClientSender.cpp index 65fb89fe..068c461a 100644 --- a/src/libs/engine/OSCClientSender.cpp +++ b/src/libs/engine/OSCClientSender.cpp @@ -34,9 +34,41 @@ using std::cout; using std::cerr; using std::endl; namespace Ingen { - +void +OSCClientSender::bundle_begin() +{ + // FIXME +} + +void +OSCClientSender::bundle_end() +{ + // FIXME +} + + +void +OSCClientSender::transfer_begin() +{ + //_transfer = lo_bundle_new(LO_TT_IMMEDIATE); +} + + +void +OSCClientSender::transfer_end() +{ + /*assert(_transfer); + lo_send_bundle(_address, _transfer); + lo_bundle_free(_transfer); + _transfer = NULL;*/ +} + + /*! \page client_osc_namespace Client OSC Namespace Documentation * + * <p>NOTE: this comment doesn't really apply any longer.. sort of. + * but maybe it still should.. maybe. so it remains...</p> + * * <p>These are all the messages sent from the engine to the client. * Communication takes place over two distinct bands: control band and * notification band.</p> @@ -57,29 +89,16 @@ namespace Ingen { */ -/* Documentation for namespace portion implemented in Responder.cpp */ - -/** \page client_osc_namespace - * \n - * <h3>Notification Band</h3> - */ /** \page client_osc_namespace - * <p> \b /om/response/ok - Respond successfully to a user command - * \arg \b responder-id (int) - Responder ID this is a response to - * </p> \n \n - */ - -/** \page client_osc_namespace - * <p> \b /om/response/error - Respond negatively to a user command - * \arg \b responder-id (int) - Request ID this is a response to + * <p> \b /om/response - Respond to a user command + * \arg \b response-id (int) - Request ID this is a response to + * \arg \b success (boolean int) - Whether response is affirmative or an error * \arg \b message (string) - Error message (natural language text) * </p> \n \n */ - - void -OSCClientSender::response(int32_t id, bool success, const string& msg) +OSCClientSender::response(int32_t id, bool success, string msg) { if (lo_send(_address, "/om/response", "iis", id, success ? 1 : 0, msg.c_str()) < 0) { cerr << "Unable to send response " << id << "! (" @@ -101,7 +120,7 @@ OSCClientSender::response(int32_t id, bool success, const string& msg) * user command, ie "unexpected" errors.</p> \n \n */ void -OSCClientSender::error(const string& msg) +OSCClientSender::error(string msg) { lo_send(_address, "/om/error", "s", msg.c_str()); } @@ -198,9 +217,9 @@ OSCClientSender::plugins() * this one (/om/new_node), followed by a series of /om/new_port commands, * followed by /om/new_node_end. </p> \n \n */ -void OSCClientSender::new_node(const string& plugin_type, - const string& plugin_uri, - const string& node_path, +void OSCClientSender::new_node(string plugin_type, + string plugin_uri, + string node_path, bool is_polyphonic, uint32_t num_ports) { @@ -310,8 +329,8 @@ void OSCClientSender::new_node(const string& plugin_type, * as metadata.</p> \n \n */ void -OSCClientSender::new_port(const string& path, - const string& data_type, +OSCClientSender::new_port(string path, + string data_type, bool is_output) { //PortInfo* info = port->port_info(); @@ -330,7 +349,7 @@ OSCClientSender::new_port(const string& path, * \arg \b path (string) - Path of object (which no longer exists) </p> \n \n */ void -OSCClientSender::object_destroyed(const string& path) +OSCClientSender::object_destroyed(string path) { assert(path != "/"); @@ -343,7 +362,7 @@ OSCClientSender::object_destroyed(const string& path) * \arg \b path (string) - Path of patch (which is now empty)</p> \n \n */ void -OSCClientSender::patch_cleared(const string& patch_path) +OSCClientSender::patch_cleared(string patch_path) { lo_send(_address, "/om/patch_cleared", "s", patch_path.c_str()); } @@ -354,7 +373,7 @@ OSCClientSender::patch_cleared(const string& patch_path) * \arg \b path (string) - Path of enabled patch</p> \n \n */ void -OSCClientSender::patch_enabled(const string& patch_path) +OSCClientSender::patch_enabled(string patch_path) { lo_send(_address, "/om/patch_enabled", "s", patch_path.c_str()); } @@ -365,7 +384,7 @@ OSCClientSender::patch_enabled(const string& patch_path) * \arg \b path (string) - Path of disabled patch</p> \n \n */ void -OSCClientSender::patch_disabled(const string& patch_path) +OSCClientSender::patch_disabled(string patch_path) { lo_send(_address, "/om/patch_disabled", "s", patch_path.c_str()); } @@ -377,7 +396,7 @@ OSCClientSender::patch_disabled(const string& patch_path) * \arg \b dst-path (string) - Path of the destination port</p> \n \n */ void -OSCClientSender::connection(const string& src_port_path, const string& dst_port_path) +OSCClientSender::connection(string src_port_path, string dst_port_path) { lo_send(_address, "/om/new_connection", "ss", src_port_path.c_str(), dst_port_path.c_str()); } @@ -389,7 +408,7 @@ OSCClientSender::connection(const string& src_port_path, const string& dst_port_ * \arg \b dst-path (string) - Path of the destination port</p> \n \n */ void -OSCClientSender::disconnection(const string& src_port_path, const string& dst_port_path) +OSCClientSender::disconnection(string src_port_path, string dst_port_path) { lo_send(_address, "/om/disconnection", "ss", src_port_path.c_str(), dst_port_path.c_str()); } @@ -402,7 +421,7 @@ OSCClientSender::disconnection(const string& src_port_path, const string& dst_po * \arg \b value (string)</p> \n \n */ void -OSCClientSender::metadata_update(const string& path, const string& key, const string& value) +OSCClientSender::metadata_update(string path, string key, string value) { lo_send(_address, "/om/metadata/update", "sss", path.c_str(), key.c_str(), value.c_str()); } @@ -417,7 +436,7 @@ OSCClientSender::metadata_update(const string& path, const string& key, const st * changing because of connections to other ports!</p> \n \n */ void -OSCClientSender::control_change(const string& port_path, float value) +OSCClientSender::control_change(string port_path, float value) { lo_send(_address, "/om/control_change", "sf", port_path.c_str(), value); } @@ -430,13 +449,17 @@ OSCClientSender::control_change(const string& port_path, float value) * \arg \b name (string) - Descriptive human-readable name of plugin (ie "ADSR Envelope") */ void -OSCClientSender::new_plugin(const string& type, const string& uri, const string& name) +OSCClientSender::new_plugin(string type, string uri, string name) { lo_message m = lo_message_new(); lo_message_add_string(m, type.c_str()); lo_message_add_string(m, uri.c_str()); lo_message_add_string(m, name.c_str()); - lo_send_message(_address, "/om/plugin", m); + + //if (_transfer) + // lo_bundle_add_message(_transfer, "/om/plugin", m); + //else + lo_send_message(_address, "/om/plugin", m); } @@ -446,7 +469,7 @@ OSCClientSender::new_plugin(const string& type, const string& uri, const string& * \arg \b poly (int) - Polyphony of new patch (\em not a boolean like new_node) </p> \n \n */ void -OSCClientSender::new_patch(const string& path, uint32_t poly) +OSCClientSender::new_patch(string path, uint32_t poly) { lo_send(_address, "/om/new_patch", "si", path.c_str(), poly); @@ -469,7 +492,7 @@ OSCClientSender::new_patch(const string& path, uint32_t poly) * \arg \b new-path (string) - New path of object </p> \n \n */ void -OSCClientSender::object_renamed(const string& old_path, const string& new_path) +OSCClientSender::object_renamed(string old_path, string new_path) { lo_send(_address, "/om/object_renamed", "ss", old_path.c_str(), new_path.c_str()); } @@ -478,7 +501,7 @@ OSCClientSender::object_renamed(const string& old_path, const string& new_path) /** Sends information about a program associated with a DSSI plugin node. */ void -OSCClientSender::program_add(const string& node_path, uint32_t bank, uint32_t program, const string& name) +OSCClientSender::program_add(string node_path, uint32_t bank, uint32_t program, string name) { lo_send(_address, "/om/program_add", "siis", node_path.c_str(), bank, program, name.c_str()); @@ -486,7 +509,7 @@ OSCClientSender::program_add(const string& node_path, uint32_t bank, uint32_t pr void -OSCClientSender::program_remove(const string& node_path, uint32_t bank, uint32_t program) +OSCClientSender::program_remove(string node_path, uint32_t bank, uint32_t program) { 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 8427c51a..e2404c1a 100644 --- a/src/libs/engine/OSCClientSender.h +++ b/src/libs/engine/OSCClientSender.h @@ -17,6 +17,7 @@ #ifndef OSCCLIENTSENDER_H #define OSCCLIENTSENDER_H +#include <cassert> #include <string> #include <iostream> #include <list> @@ -40,7 +41,8 @@ class OSCClientSender : public Shared::ClientInterface public: OSCClientSender(const string& url) : _url(url), - _address(lo_address_new_from_url(url.c_str())) + _address(lo_address_new_from_url(url.c_str())), + _transfer(NULL) {} virtual ~OSCClientSender() @@ -56,66 +58,68 @@ public: /* *** ClientInterface Implementation Below *** */ - //void client_registration(const string& url, int client_id); + //void client_registration(string url, int client_id); - // need a liblo feature to make this possible :/ - void bundle_begin() {} - void bundle_end() {} + void bundle_begin(); + void bundle_end(); + + void transfer_begin(); + void transfer_end(); - void response(int32_t id, bool success, const string& msg); + void response(int32_t id, bool success, string msg); void num_plugins(uint32_t num); - void error(const string& msg); + void error(string msg); - virtual void new_plugin(const string& type, - const string& uri, - const string& name); + virtual void new_plugin(string type, + string uri, + string name); - virtual void new_patch(const string& path, uint32_t poly); + virtual void new_patch(string path, uint32_t poly); - virtual void new_node(const string& plugin_type, - const string& plugin_uri, - const string& node_path, - bool is_polyphonic, - uint32_t num_ports); + virtual void new_node(string plugin_type, + string plugin_uri, + string node_path, + bool is_polyphonic, + uint32_t num_ports); - virtual void new_port(const string& path, - const string& data_type, - bool is_output); + virtual void new_port(string path, + string data_type, + bool is_output); - virtual void patch_enabled(const string& path); + virtual void patch_enabled(string path); - virtual void patch_disabled(const string& path); + virtual void patch_disabled(string path); - virtual void patch_cleared(const string& path); + virtual void patch_cleared(string path); - virtual void object_destroyed(const string& path); + virtual void object_destroyed(string path); - virtual void object_renamed(const string& old_path, - const string& new_path); + virtual void object_renamed(string old_path, + string new_path); - virtual void connection(const string& src_port_path, - const string& dst_port_path); + virtual void connection(string src_port_path, + string dst_port_path); - virtual void disconnection(const string& src_port_path, - const string& dst_port_path); + virtual void disconnection(string src_port_path, + string dst_port_path); - virtual void metadata_update(const string& subject_path, - const string& predicate, - const string& value); + virtual void metadata_update(string subject_path, + string predicate, + string value); - virtual void control_change(const string& port_path, - float value); + virtual void control_change(string port_path, + float value); - virtual void program_add(const string& node_path, - uint32_t bank, - uint32_t program, - const string& program_name); + virtual void program_add(string node_path, + uint32_t bank, + uint32_t program, + string program_name); - virtual void program_remove(const string& node_path, - uint32_t bank, - uint32_t program); + virtual void program_remove(string node_path, + uint32_t bank, + uint32_t program); private: // Prevent copies (undefined) @@ -124,6 +128,8 @@ private: string _url; lo_address _address; + + lo_bundle _transfer; }; diff --git a/src/libs/engine/OSCEngineReceiver.cpp b/src/libs/engine/OSCEngineReceiver.cpp index 4b1ae496..84c9f0fe 100644 --- a/src/libs/engine/OSCEngineReceiver.cpp +++ b/src/libs/engine/OSCEngineReceiver.cpp @@ -47,8 +47,9 @@ using Shared::ClientKey; */ -OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, const char* const port) -: QueuedEngineInterface(engine, queue_size, queue_size), // FIXME +OSCEngineReceiver::OSCEngineReceiver(CountedPtr<Engine> engine, size_t queue_size, const char* const port) +: EngineInterface(), + QueuedEngineInterface(engine, queue_size, queue_size), // FIXME _port(port), _server(NULL), _osc_responder(NULL) @@ -65,7 +66,7 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, const ch } // For debugging, print all incoming OSC messages - lo_server_add_method(_server, NULL, NULL, generic_cb, NULL); + //lo_server_add_method(_server, NULL, NULL, generic_cb, NULL); // Set response address for this message. // It's important this is first and returns nonzero. @@ -119,6 +120,8 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, const ch #endif lo_server_add_method(_server, NULL, NULL, unknown_cb, NULL); + + Thread::set_name("OSC Receiver"); } @@ -224,7 +227,9 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, } else { // Shitty deal, make a new one //cerr << "** Setting response address to " << url << "(2)" << endl; - me->_osc_responder = CountedPtr<OSCResponder>(new OSCResponder(id, url)); + me->_osc_responder = CountedPtr<OSCResponder>( + new OSCResponder(me->_engine->broadcaster(), id, url)); + me->set_responder(me->_osc_responder); // (responder takes ownership of url, no leak) } @@ -232,7 +237,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, // Otherwise we have a NULL responder, definitely need to set a new one } else { //cerr << "** null responder\n"; - me->_osc_responder = CountedPtr<OSCResponder>(new OSCResponder(id, url)); + me->_osc_responder = CountedPtr<OSCResponder>(new OSCResponder(me->_engine->broadcaster(), id, url)); me->set_responder(me->_osc_responder); //cerr << "** Setting response address to " << url << "(2)" << endl; } @@ -900,7 +905,7 @@ OSCEngineReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv string error_msg = "Unknown command: "; error_msg.append(path).append(" ").append(types); - OSCResponder(0, url).respond_error(error_msg); + OSCResponder(NULL, 0, url).respond_error(error_msg); return 0; } diff --git a/src/libs/engine/OSCEngineReceiver.h b/src/libs/engine/OSCEngineReceiver.h index cc2d7350..793286d4 100644 --- a/src/libs/engine/OSCEngineReceiver.h +++ b/src/libs/engine/OSCEngineReceiver.h @@ -20,6 +20,7 @@ #include "config.h" #include <string> #include <lo/lo.h> +#include "util/CountedPtr.h" #include "QueuedEngineInterface.h" #include "OSCResponder.h" using std::string; @@ -59,7 +60,7 @@ inline static int name##_cb(LO_HANDLER_ARGS, void* myself)\ class OSCEngineReceiver : public QueuedEngineInterface { public: - OSCEngineReceiver(Engine& engine, size_t queue_size, const char* const port); + OSCEngineReceiver(CountedPtr<Engine> engine, size_t queue_size, const char* const port); ~OSCEngineReceiver(); void activate(); diff --git a/src/libs/engine/OSCResponder.cpp b/src/libs/engine/OSCResponder.cpp index 50619089..a6d68721 100644 --- a/src/libs/engine/OSCResponder.cpp +++ b/src/libs/engine/OSCResponder.cpp @@ -30,8 +30,9 @@ namespace Ingen { /** Construct an OSCResponder from \a addr. * Takes ownership of @a url. */ -OSCResponder::OSCResponder(int32_t id, char* url) +OSCResponder::OSCResponder(ClientBroadcaster* broadcaster, int32_t id, char* url) : Responder() +, _broadcaster(broadcaster) , _id(id) , _url(url) , _addr(NULL) @@ -75,5 +76,15 @@ OSCResponder::respond_error(const string& msg) } } + +CountedPtr<ClientInterface> +OSCResponder::client() +{ + if (_broadcaster) + return _broadcaster->client(client_key()); + else + return NULL; +} + } // namespace OM diff --git a/src/libs/engine/OSCResponder.h b/src/libs/engine/OSCResponder.h index 78b40894..767375dc 100644 --- a/src/libs/engine/OSCResponder.h +++ b/src/libs/engine/OSCResponder.h @@ -24,6 +24,8 @@ namespace Ingen { +class ClientBroadcaster; + /** Responder for (liblo) OSC clients. * @@ -38,20 +40,26 @@ namespace Ingen { class OSCResponder : public Responder { public: - OSCResponder(int32_t id, char* url); + OSCResponder(ClientBroadcaster* broadcaster, int32_t id, char* url); ~OSCResponder(); + void set_id(int32_t id) { _id = id; } + void respond_ok(); void respond_error(const string& msg); const char* url() const { return _url; } ClientKey client_key() { return ClientKey(ClientKey::OSC_URL, _url); } + + CountedPtr<ClientInterface> client(); + private: - int32_t _id; - char* const _url; - lo_address _addr; + ClientBroadcaster* _broadcaster; + int32_t _id; + char* const _url; + lo_address _addr; }; diff --git a/src/libs/engine/Patch.cpp b/src/libs/engine/Patch.cpp index 257deb59..bcbe4e68 100644 --- a/src/libs/engine/Patch.cpp +++ b/src/libs/engine/Patch.cpp @@ -294,7 +294,7 @@ Patch::remove_port(const Port* port) Array<Node*>* Patch::build_process_order() const { - cerr << "*********** BUILDING PROCESS ORDER FOR " << path() << endl; + //cerr << "*********** BUILDING PROCESS ORDER FOR " << path() << endl; Array<Node*>* const process_order = new Array<Node*>(_nodes.size(), NULL); @@ -334,12 +334,14 @@ Patch::build_process_order() const } }*/ + /* cerr << "----------------------------------------\n"; for (size_t i=0; i < process_order->size(); ++i) { assert(process_order->at(i)); cerr << process_order->at(i)->path() << endl; } cerr << "----------------------------------------\n"; + */ assert(process_order->size() == _nodes.size()); diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index 4d38f91c..919d3054 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -23,7 +23,7 @@ namespace Ingen { -QueuedEngineInterface::QueuedEngineInterface(Engine& engine, size_t queued_size, size_t stamped_size) +QueuedEngineInterface::QueuedEngineInterface(CountedPtr<Engine> engine, size_t queued_size, size_t stamped_size) : QueuedEventSource(queued_size, stamped_size) , _responder(CountedPtr<Responder>(new Responder())) // NULL responder , _engine(engine) @@ -34,7 +34,7 @@ QueuedEngineInterface::QueuedEngineInterface(Engine& engine, size_t queued_size, SampleCount QueuedEngineInterface::now() const { - return _engine.audio_driver()->frame_time(); + return _engine->audio_driver()->frame_time(); } /** Set the Responder to send responses to commands with, once the commands @@ -50,6 +50,14 @@ QueuedEngineInterface::set_responder(CountedPtr<Responder> responder) void +QueuedEngineInterface::set_next_response_id(int32_t id) +{ + if (_responder) + _responder->set_id(id); +} + + +void QueuedEngineInterface::disable_responses() { static CountedPtr<Responder> null_responder(new Responder()); @@ -64,14 +72,14 @@ QueuedEngineInterface::disable_responses() void QueuedEngineInterface::register_client(ClientKey key, CountedPtr<ClientInterface> client) { - push_queued(new RegisterClientEvent(_engine, _responder, now(), key, client)); + push_queued(new RegisterClientEvent(*_engine.get(), _responder, now(), key, client)); } void QueuedEngineInterface::unregister_client(ClientKey key) { - push_queued(new UnregisterClientEvent(_engine, _responder, now(), key)); + push_queued(new UnregisterClientEvent(*_engine.get(), _responder, now(), key)); } @@ -80,7 +88,7 @@ QueuedEngineInterface::unregister_client(ClientKey key) void QueuedEngineInterface::load_plugins() { - push_queued(new LoadPluginsEvent(_engine, _responder, now())); + push_queued(new LoadPluginsEvent(*_engine.get(), _responder, now())); } @@ -88,14 +96,14 @@ QueuedEngineInterface::load_plugins() void QueuedEngineInterface::activate() { - push_queued(new ActivateEvent(_engine, _responder, now())); + push_queued(new ActivateEvent(*_engine.get(), _responder, now())); } void QueuedEngineInterface::deactivate() { - push_queued(new DeactivateEvent(_engine, _responder, now())); + push_queued(new DeactivateEvent(*_engine.get(), _responder, now())); } @@ -103,7 +111,7 @@ void QueuedEngineInterface::quit() { _responder->respond_ok(); - _engine.quit(); + _engine->quit(); } @@ -114,7 +122,7 @@ void QueuedEngineInterface::create_patch(const string& path, uint32_t poly) { - push_queued(new CreatePatchEvent(_engine, _responder, now(), path, poly)); + push_queued(new CreatePatchEvent(*_engine.get(), _responder, now(), path, poly)); } @@ -123,7 +131,7 @@ void QueuedEngineInterface::create_port(const string& path, const string& data_type, bool direction) { - push_queued(new AddPortEvent(_engine, _responder, now(), path, data_type, direction)); + push_queued(new AddPortEvent(*_engine.get(), _responder, now(), path, data_type, direction)); } @@ -139,7 +147,7 @@ QueuedEngineInterface::create_node(const string& path, plugin->set_type(plugin_type); plugin->uri(plugin_uri); - push_queued(new AddNodeEvent(_engine, _responder, now(), path, plugin, polyphonic)); + push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), path, plugin, polyphonic)); } @@ -157,42 +165,42 @@ QueuedEngineInterface::create_node(const string& path, plugin->lib_name(plugin_lib); plugin->plug_label(plugin_label); - push_queued(new AddNodeEvent(_engine, _responder, now(), path, plugin, polyphonic)); + push_queued(new AddNodeEvent(*_engine.get(), _responder, now(), path, plugin, polyphonic)); } void QueuedEngineInterface::rename(const string& old_path, const string& new_name) { - push_queued(new RenameEvent(_engine, _responder, now(), old_path, new_name)); + push_queued(new RenameEvent(*_engine.get(), _responder, now(), old_path, new_name)); } void QueuedEngineInterface::destroy(const string& path) { - push_queued(new DestroyEvent(_engine, _responder, now(), this, path)); + push_queued(new DestroyEvent(*_engine.get(), _responder, now(), this, path)); } void QueuedEngineInterface::clear_patch(const string& patch_path) { - push_queued(new ClearPatchEvent(_engine, _responder, now(), patch_path)); + push_queued(new ClearPatchEvent(*_engine.get(), _responder, now(), patch_path)); } void QueuedEngineInterface::enable_patch(const string& patch_path) { - push_queued(new EnablePatchEvent(_engine, _responder, now(), patch_path)); + push_queued(new EnablePatchEvent(*_engine.get(), _responder, now(), patch_path)); } void QueuedEngineInterface::disable_patch(const string& patch_path) { - push_queued(new DisablePatchEvent(_engine, _responder, now(), patch_path)); + push_queued(new DisablePatchEvent(*_engine.get(), _responder, now(), patch_path)); } @@ -200,7 +208,7 @@ void QueuedEngineInterface::connect(const string& src_port_path, const string& dst_port_path) { - push_queued(new ConnectionEvent(_engine, _responder, now(), src_port_path, dst_port_path)); + push_queued(new ConnectionEvent(*_engine.get(), _responder, now(), src_port_path, dst_port_path)); } @@ -209,14 +217,14 @@ void QueuedEngineInterface::disconnect(const string& src_port_path, const string& dst_port_path) { - push_queued(new DisconnectionEvent(_engine, _responder, now(), src_port_path, dst_port_path)); + push_queued(new DisconnectionEvent(*_engine.get(), _responder, now(), src_port_path, dst_port_path)); } void QueuedEngineInterface::disconnect_all(const string& node_path) { - push_queued(new DisconnectNodeEvent(_engine, _responder, now(), node_path)); + push_queued(new DisconnectNodeEvent(*_engine.get(), _responder, now(), node_path)); } @@ -224,7 +232,7 @@ void QueuedEngineInterface::set_port_value(const string& port_path, float value) { - push_stamped(new SetPortValueEvent(_engine, _responder, now(), port_path, value)); + push_stamped(new SetPortValueEvent(*_engine.get(), _responder, now(), port_path, value)); } @@ -233,7 +241,7 @@ QueuedEngineInterface::set_port_value(const string& port_path, uint32_t voice, float value) { - push_stamped(new SetPortValueEvent(_engine, _responder, now(), voice, port_path, value)); + push_stamped(new SetPortValueEvent(*_engine.get(), _responder, now(), voice, port_path, value)); } @@ -241,7 +249,7 @@ void QueuedEngineInterface::set_port_value_queued(const string& port_path, float value) { - push_queued(new SetPortValueQueuedEvent(_engine, _responder, now(), port_path, value)); + push_queued(new SetPortValueQueuedEvent(*_engine.get(), _responder, now(), port_path, value)); } @@ -250,14 +258,14 @@ QueuedEngineInterface::set_program(const string& node_path, uint32_t bank, uint32_t program) { - push_queued(new DSSIProgramEvent(_engine, _responder, now(), node_path, bank, program)); + push_queued(new DSSIProgramEvent(*_engine.get(), _responder, now(), node_path, bank, program)); } void QueuedEngineInterface::midi_learn(const string& node_path) { - push_queued(new MidiLearnEvent(_engine, _responder, now(), node_path)); + push_queued(new MidiLearnEvent(*_engine.get(), _responder, now(), node_path)); } @@ -266,7 +274,7 @@ QueuedEngineInterface::set_metadata(const string& path, const string& predicate, const string& value) { - push_queued(new SetMetadataEvent(_engine, _responder, now(), path, predicate, value)); + push_queued(new SetMetadataEvent(*_engine.get(), _responder, now(), path, predicate, value)); } @@ -275,28 +283,32 @@ QueuedEngineInterface::set_metadata(const string& path, void QueuedEngineInterface::ping() { - push_queued(new PingQueuedEvent(_engine, _responder, now())); + if (_engine->activated()) { + push_queued(new PingQueuedEvent(*_engine.get(), _responder, now())); + } else if (_responder) { + _responder->respond_ok(); + } } void QueuedEngineInterface::request_port_value(const string& port_path) { - push_queued(new RequestPortValueEvent(_engine, _responder, now(), port_path)); + push_queued(new RequestPortValueEvent(*_engine.get(), _responder, now(), port_path)); } void QueuedEngineInterface::request_plugins() { - push_queued(new RequestPluginsEvent(_engine, _responder, now())); + push_queued(new RequestPluginsEvent(*_engine.get(), _responder, now())); } void QueuedEngineInterface::request_all_objects() { - push_queued(new RequestAllObjectsEvent(_engine, _responder, now())); + push_queued(new RequestAllObjectsEvent(*_engine.get(), _responder, now())); } diff --git a/src/libs/engine/QueuedEngineInterface.h b/src/libs/engine/QueuedEngineInterface.h index c5904a2e..1e35738f 100644 --- a/src/libs/engine/QueuedEngineInterface.h +++ b/src/libs/engine/QueuedEngineInterface.h @@ -25,6 +25,7 @@ #include "interface/ClientInterface.h" #include "interface/ClientKey.h" #include "QueuedEventSource.h" +#include "Engine.h" #include "Responder.h" using std::string; @@ -56,12 +57,14 @@ class Engine; * events and get pushed directly into the realtime event queue. Should that * be separated into a different interface/client? */ -class QueuedEngineInterface : public QueuedEventSource, public EngineInterface +class QueuedEngineInterface : public QueuedEventSource, public virtual EngineInterface { public: - QueuedEngineInterface(Engine& engine, size_t queued_size, size_t stamped_size); + QueuedEngineInterface(CountedPtr<Engine> engine, size_t queued_size, size_t stamped_size); virtual ~QueuedEngineInterface() {} + void set_next_response_id(int32_t id); + virtual void set_responder(CountedPtr<Responder> responder); virtual void disable_responses(); @@ -151,10 +154,10 @@ protected: /** Where responses to current messages will go. */ CountedPtr<Responder> _responder; + CountedPtr<Engine> _engine; + private: SampleCount now() const; - - Engine& _engine; }; diff --git a/src/libs/engine/QueuedEventSource.cpp b/src/libs/engine/QueuedEventSource.cpp index 915b7811..08e1c63e 100644 --- a/src/libs/engine/QueuedEventSource.cpp +++ b/src/libs/engine/QueuedEventSource.cpp @@ -36,6 +36,8 @@ QueuedEventSource::QueuedEventSource(size_t queued_size, size_t stamped_size) _events = (QueuedEvent**)calloc(_size, sizeof(QueuedEvent*)); mlock(_events, _size * sizeof(QueuedEvent*)); + + Thread::set_name("PreProcessor"); } @@ -151,15 +153,10 @@ QueuedEventSource::_whipped() QueuedEvent* const ev = _events[_prepared_back]; assert(ev); - if (ev == NULL) { - cerr << "[QueuedEventSource] ERROR: Signalled, but event is NULL." << endl; - return; - } - - assert(ev); + assert(!ev->is_prepared()); - ev->pre_process(); + assert(ev->is_prepared()); _prepared_back = (_prepared_back+1) % _size; diff --git a/src/libs/engine/Responder.h b/src/libs/engine/Responder.h index 162af23f..3976883d 100644 --- a/src/libs/engine/Responder.h +++ b/src/libs/engine/Responder.h @@ -21,11 +21,13 @@ #include <string> #include "util/CountedPtr.h" #include "interface/ClientKey.h" +#include "interface/ClientInterface.h" using std::string; namespace Ingen { using Shared::ClientKey; +using Shared::ClientInterface; /** Class to handle responding to clients. @@ -49,7 +51,10 @@ public: Responder() {} virtual ~Responder() {} - virtual ClientKey client_key() { return ClientKey(); } + virtual ClientKey client_key() { return ClientKey(); } + virtual CountedPtr<ClientInterface> client() { return NULL; } + + virtual void set_id(int32_t id) {} virtual void respond_ok() {} virtual void respond_error(const string& msg) {} diff --git a/src/libs/engine/TypedPort.cpp b/src/libs/engine/TypedPort.cpp index 484dcaf7..4cc184e6 100644 --- a/src/libs/engine/TypedPort.cpp +++ b/src/libs/engine/TypedPort.cpp @@ -65,8 +65,6 @@ TypedPort<Sample>::set_value(Sample val, size_t offset) offset = 0; assert(offset < _buffer_size); - cerr << path() << " setting value " << val << endl; - for (size_t v=0; v < _poly; ++v) m_buffers.at(v)->set(val, offset); } diff --git a/src/libs/engine/events/ActivateEvent.cpp b/src/libs/engine/events/ActivateEvent.cpp index 9d8162ec..c63c86e1 100644 --- a/src/libs/engine/events/ActivateEvent.cpp +++ b/src/libs/engine/events/ActivateEvent.cpp @@ -24,18 +24,9 @@ namespace Ingen { ActivateEvent::ActivateEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp) : QueuedEvent(engine, responder, timestamp) { -} - - -void -ActivateEvent::pre_process() -{ - QueuedEvent::pre_process(); - _engine.activate(); } - void ActivateEvent::post_process() { diff --git a/src/libs/engine/events/ActivateEvent.h b/src/libs/engine/events/ActivateEvent.h index 26ee5b84..696fc0de 100644 --- a/src/libs/engine/events/ActivateEvent.h +++ b/src/libs/engine/events/ActivateEvent.h @@ -31,7 +31,6 @@ class ActivateEvent : public QueuedEvent public: ActivateEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp); - void pre_process(); void post_process(); }; diff --git a/src/libs/engine/events/AddNodeEvent.cpp b/src/libs/engine/events/AddNodeEvent.cpp index 5287c7cd..19ff6bf5 100644 --- a/src/libs/engine/events/AddNodeEvent.cpp +++ b/src/libs/engine/events/AddNodeEvent.cpp @@ -117,8 +117,8 @@ AddNodeEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - //_engine.client_broadcaster()->send_node_creation_messages(m_node); - _engine.client_broadcaster()->send_node(m_node); + //_engine.broadcaster()->send_node_creation_messages(m_node); + _engine.broadcaster()->send_node(m_node); } } diff --git a/src/libs/engine/events/AddPortEvent.cpp b/src/libs/engine/events/AddPortEvent.cpp index 7b034f43..06ddae94 100644 --- a/src/libs/engine/events/AddPortEvent.cpp +++ b/src/libs/engine/events/AddPortEvent.cpp @@ -126,7 +126,7 @@ AddPortEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - _engine.client_broadcaster()->send_port(_patch_port); + _engine.broadcaster()->send_port(_patch_port); } } diff --git a/src/libs/engine/events/ClearPatchEvent.cpp b/src/libs/engine/events/ClearPatchEvent.cpp index e73fd376..3518dc03 100644 --- a/src/libs/engine/events/ClearPatchEvent.cpp +++ b/src/libs/engine/events/ClearPatchEvent.cpp @@ -103,7 +103,7 @@ ClearPatchEvent::post_process() // Reply _responder->respond_ok(); - _engine.client_broadcaster()->send_patch_cleared(m_patch_path); + _engine.broadcaster()->send_patch_cleared(m_patch_path); } else { _responder->respond_error(string("Patch ") + m_patch_path + " not found"); } diff --git a/src/libs/engine/events/ConnectionEvent.cpp b/src/libs/engine/events/ConnectionEvent.cpp index b873bccb..7c97de03 100644 --- a/src/libs/engine/events/ConnectionEvent.cpp +++ b/src/libs/engine/events/ConnectionEvent.cpp @@ -250,7 +250,7 @@ TypedConnectionEvent<T>::post_process() _responder->respond_ok(); - _engine.client_broadcaster()->send_connection(m_connection); + _engine.broadcaster()->send_connection(m_connection); } else { _responder->respond_error("Unable to make connection."); } diff --git a/src/libs/engine/events/CreatePatchEvent.cpp b/src/libs/engine/events/CreatePatchEvent.cpp index d66a3ff9..7532291b 100644 --- a/src/libs/engine/events/CreatePatchEvent.cpp +++ b/src/libs/engine/events/CreatePatchEvent.cpp @@ -121,10 +121,10 @@ CreatePatchEvent::post_process() _responder->respond_ok(); // Don't want to send nodes that have been added since prepare() - //_engine.client_broadcaster()->send_node_creation_messages(m_patch); + //_engine.broadcaster()->send_node_creation_messages(m_patch); // Patches are always empty on creation, so this is fine - _engine.client_broadcaster()->send_patch(m_patch); + _engine.broadcaster()->send_patch(m_patch); } else if (m_error == OBJECT_EXISTS) { string msg = "Unable to create patch: "; diff --git a/src/libs/engine/events/DSSIConfigureEvent.cpp b/src/libs/engine/events/DSSIConfigureEvent.cpp index de79a083..fb006444 100644 --- a/src/libs/engine/events/DSSIConfigureEvent.cpp +++ b/src/libs/engine/events/DSSIConfigureEvent.cpp @@ -63,7 +63,7 @@ DSSIConfigureEvent::post_process() } else { string key = "dssi-configure--"; key += m_key; - _engine.client_broadcaster()->send_metadata_update(m_node_path, key, m_val); + _engine.broadcaster()->send_metadata_update(m_node_path, key, m_val); } } diff --git a/src/libs/engine/events/DSSIProgramEvent.cpp b/src/libs/engine/events/DSSIProgramEvent.cpp index 4545268a..d602b57c 100644 --- a/src/libs/engine/events/DSSIProgramEvent.cpp +++ b/src/libs/engine/events/DSSIProgramEvent.cpp @@ -67,7 +67,7 @@ DSSIProgramEvent::post_process() // sends program as metadata in the form bank/program char* temp_buf = new char[16]; snprintf(temp_buf, 16, "%d/%d", m_bank, m_program); - _engine.client_broadcaster()->send_metadata_update(m_node_path, "dssi-program", temp_buf); + _engine.broadcaster()->send_metadata_update(m_node_path, "dssi-program", temp_buf); } } diff --git a/src/libs/engine/events/DestroyEvent.cpp b/src/libs/engine/events/DestroyEvent.cpp index dd172e7f..ced323a1 100644 --- a/src/libs/engine/events/DestroyEvent.cpp +++ b/src/libs/engine/events/DestroyEvent.cpp @@ -34,16 +34,16 @@ namespace Ingen { -DestroyEvent::DestroyEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, QueuedEventSource* source, const string& path, bool lock_mutex) -: QueuedEvent(engine, responder, true, source), +DestroyEvent::DestroyEvent(Engine& engine, CountedPtr<Responder> responder, FrameTime time, QueuedEventSource* source, const string& path, bool lock_mutex) +: QueuedEvent(engine, responder, time, true, source), m_path(path), m_node(NULL), m_patch_listnode(NULL), m_store_treenode(NULL), m_process_order(NULL), - m_disconnect_event(NULL), - m_parent_disconnect_event(NULL) + m_disconnect_event(NULL) { + assert(_source); } @@ -54,8 +54,7 @@ DestroyEvent::DestroyEvent(Engine& engine, CountedPtr<Responder> responder, Samp m_patch_listnode(NULL), m_store_treenode(NULL), m_process_order(NULL), - m_disconnect_event(NULL), - m_parent_disconnect_event(NULL) + m_disconnect_event(NULL) { } @@ -63,7 +62,6 @@ DestroyEvent::DestroyEvent(Engine& engine, CountedPtr<Responder> responder, Samp DestroyEvent::~DestroyEvent() { delete m_disconnect_event; - delete m_parent_disconnect_event; } @@ -86,14 +84,6 @@ DestroyEvent::pre_process() m_disconnect_event->pre_process(); } - // Create a recursive disconnect event for the parent port, if a bridge node - cerr << "FIXME: Destroy bridge\n"; - /*Port* parent_port = m_patch_listnode->elem()->as_port(); - if (parent_port != NULL) { // Bridge node - m_parent_disconnect_event = new DisconnectPortEvent(Engine& engine, parent_port); - m_parent_disconnect_event->pre_process(); - }*/ - if (m_node->parent_patch()->enabled()) { m_process_order = m_node->parent_patch()->build_process_order(); // Remove node to be removed from the process order so it isn't executed by @@ -125,8 +115,6 @@ DestroyEvent::execute(SampleCount nframes, FrameTime start, FrameTime end) if (m_disconnect_event != NULL) m_disconnect_event->execute(nframes, start, end); - if (m_parent_disconnect_event != NULL) - m_parent_disconnect_event->execute(nframes, start, end); if (m_node->parent_patch()->process_order() != NULL) _engine.maid()->push(m_node->parent_patch()->process_order()); @@ -151,9 +139,7 @@ DestroyEvent::post_process() _responder->respond_ok(); if (m_disconnect_event != NULL) m_disconnect_event->post_process(); - if (m_parent_disconnect_event != NULL) - m_parent_disconnect_event->post_process(); - _engine.client_broadcaster()->send_destroyed(m_path); + _engine.broadcaster()->send_destroyed(m_path); _engine.maid()->push(m_patch_listnode); _engine.maid()->push(m_node); } else { diff --git a/src/libs/engine/events/DestroyEvent.h b/src/libs/engine/events/DestroyEvent.h index 6eda8006..92b1c194 100644 --- a/src/libs/engine/events/DestroyEvent.h +++ b/src/libs/engine/events/DestroyEvent.h @@ -44,8 +44,8 @@ class DisconnectPortEvent; class DestroyEvent : public QueuedEvent { public: - DestroyEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, QueuedEventSource* source, const string& path, bool lock_mutex = true); - DestroyEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp, Node* node, bool lock_mutex = true); + DestroyEvent(Engine& engine, CountedPtr<Responder> responder, FrameTime timestamp, QueuedEventSource* source, const string& path, bool lock_mutex = true); + DestroyEvent(Engine& engine, CountedPtr<Responder> responder, FrameTime timestamp, Node* node, bool lock_mutex = true); ~DestroyEvent(); void pre_process(); @@ -53,13 +53,12 @@ public: void post_process(); private: - Path m_path; - Node* m_node; - ListNode<Node*>* m_patch_listnode; + Path m_path; + Node* m_node; + ListNode<Node*>* m_patch_listnode; TreeNode<GraphObject*>* m_store_treenode; - Array<Node*>* m_process_order; // Patch's new process order - DisconnectNodeEvent* m_disconnect_event; - DisconnectPortEvent* m_parent_disconnect_event; // used for input/output nodes + Array<Node*>* m_process_order; // Patch's new process order + DisconnectNodeEvent* m_disconnect_event; }; diff --git a/src/libs/engine/events/DisablePatchEvent.cpp b/src/libs/engine/events/DisablePatchEvent.cpp index 299e4fdc..064dd9fd 100644 --- a/src/libs/engine/events/DisablePatchEvent.cpp +++ b/src/libs/engine/events/DisablePatchEvent.cpp @@ -58,7 +58,7 @@ DisablePatchEvent::post_process() { if (m_patch != NULL) { _responder->respond_ok(); - _engine.client_broadcaster()->send_patch_disable(m_patch_path); + _engine.broadcaster()->send_patch_disable(m_patch_path); } else { _responder->respond_error(string("Patch ") + m_patch_path + " not found"); } diff --git a/src/libs/engine/events/DisconnectNodeEvent.cpp b/src/libs/engine/events/DisconnectNodeEvent.cpp index c1a965ad..df85e1db 100644 --- a/src/libs/engine/events/DisconnectNodeEvent.cpp +++ b/src/libs/engine/events/DisconnectNodeEvent.cpp @@ -53,7 +53,7 @@ DisconnectNodeEvent::DisconnectNodeEvent(Engine& engine, CountedPtr<Responder> r */ DisconnectNodeEvent::DisconnectNodeEvent(Engine& engine, Node* node) : QueuedEvent(engine), - m_node_path(""), + m_node_path(node->path()), m_patch(node->parent_patch()), m_node(node), m_succeeded(true), diff --git a/src/libs/engine/events/DisconnectionEvent.cpp b/src/libs/engine/events/DisconnectionEvent.cpp index c246e9dc..7e050369 100644 --- a/src/libs/engine/events/DisconnectionEvent.cpp +++ b/src/libs/engine/events/DisconnectionEvent.cpp @@ -271,7 +271,7 @@ TypedDisconnectionEvent<T>::post_process() _responder->respond_ok(); - _engine.client_broadcaster()->send_disconnection(m_src_port->path(), m_dst_port->path()); + _engine.broadcaster()->send_disconnection(m_src_port->path(), m_dst_port->path()); } else { _responder->respond_error("Unable to disconnect ports."); } diff --git a/src/libs/engine/events/EnablePatchEvent.cpp b/src/libs/engine/events/EnablePatchEvent.cpp index 132aefcc..01144013 100644 --- a/src/libs/engine/events/EnablePatchEvent.cpp +++ b/src/libs/engine/events/EnablePatchEvent.cpp @@ -70,7 +70,7 @@ EnablePatchEvent::post_process() { if (m_patch != NULL) { _responder->respond_ok(); - _engine.client_broadcaster()->send_patch_enable(m_patch_path); + _engine.broadcaster()->send_patch_enable(m_patch_path); } else { _responder->respond_error(string("Patch ") + m_patch_path + " not found"); } diff --git a/src/libs/engine/events/LoadPluginsEvent.cpp b/src/libs/engine/events/LoadPluginsEvent.cpp index 6962387b..daf61378 100644 --- a/src/libs/engine/events/LoadPluginsEvent.cpp +++ b/src/libs/engine/events/LoadPluginsEvent.cpp @@ -18,6 +18,7 @@ #include "Responder.h" #include "Engine.h" #include "NodeFactory.h" +#include "ClientBroadcaster.h" #include <iostream> using std::cerr; @@ -28,10 +29,22 @@ namespace Ingen { LoadPluginsEvent::LoadPluginsEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp) : QueuedEvent(engine, responder, timestamp) { - cerr << "LOADING PLUGINS\n"; - _engine.node_factory()->load_plugins(); } +void +LoadPluginsEvent::pre_process() +{ + _engine.node_factory()->load_plugins(); + + // FIXME: send the changes (added and removed plugins) instead of the entire list each time + + // Take a copy to send in the post processing thread (to avoid problems + // because std::list isn't thread safe) + _plugins = _engine.node_factory()->plugins(); + cerr << "loaded " << _plugins.size() << "plugins.\n"; + + QueuedEvent::pre_process(); +} void LoadPluginsEvent::post_process() diff --git a/src/libs/engine/events/LoadPluginsEvent.h b/src/libs/engine/events/LoadPluginsEvent.h index ae784e3a..a143d812 100644 --- a/src/libs/engine/events/LoadPluginsEvent.h +++ b/src/libs/engine/events/LoadPluginsEvent.h @@ -17,10 +17,13 @@ #ifndef LOADPLUGINSEVENT_H #define LOADPLUGINSEVENT_H +#include <list> #include "QueuedEvent.h" namespace Ingen { +class Plugin; + /** Loads all plugins into the internal plugin database (in NodeFactory). * @@ -31,7 +34,11 @@ class LoadPluginsEvent : public QueuedEvent public: LoadPluginsEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp); + void pre_process(); void post_process(); + +private: + std::list<Plugin*> _plugins; }; diff --git a/src/libs/engine/events/MidiLearnEvent.cpp b/src/libs/engine/events/MidiLearnEvent.cpp index 822573e0..c56db8d8 100644 --- a/src/libs/engine/events/MidiLearnEvent.cpp +++ b/src/libs/engine/events/MidiLearnEvent.cpp @@ -30,7 +30,7 @@ namespace Ingen { void MidiLearnResponseEvent::post_process() { - _engine.client_broadcaster()->send_control_change(m_port_path, m_value); + _engine.broadcaster()->send_control_change(m_port_path, m_value); } diff --git a/src/libs/engine/events/RegisterClientEvent.cpp b/src/libs/engine/events/RegisterClientEvent.cpp index e35b7fdb..81cb3b81 100644 --- a/src/libs/engine/events/RegisterClientEvent.cpp +++ b/src/libs/engine/events/RegisterClientEvent.cpp @@ -36,7 +36,7 @@ RegisterClientEvent::RegisterClientEvent(Engine& engine, CountedPtr<Responder> void RegisterClientEvent::pre_process() { - _engine.client_broadcaster()->register_client(_key, _client); + _engine.broadcaster()->register_client(_key, _client); QueuedEvent::pre_process(); } diff --git a/src/libs/engine/events/RenameEvent.cpp b/src/libs/engine/events/RenameEvent.cpp index 465f4946..82fe3737 100644 --- a/src/libs/engine/events/RenameEvent.cpp +++ b/src/libs/engine/events/RenameEvent.cpp @@ -103,7 +103,7 @@ RenameEvent::post_process() if (m_error == NO_ERROR) { _responder->respond_ok(); - _engine.client_broadcaster()->send_rename(m_old_path, m_new_path); + _engine.broadcaster()->send_rename(m_old_path, m_new_path); } else { if (m_error == OBJECT_EXISTS) msg.append("Object already exists at ").append(m_new_path); diff --git a/src/libs/engine/events/RequestAllObjectsEvent.cpp b/src/libs/engine/events/RequestAllObjectsEvent.cpp index 5eb780b3..f51a514e 100644 --- a/src/libs/engine/events/RequestAllObjectsEvent.cpp +++ b/src/libs/engine/events/RequestAllObjectsEvent.cpp @@ -25,8 +25,7 @@ namespace Ingen { RequestAllObjectsEvent::RequestAllObjectsEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp) -: QueuedEvent(engine, responder, timestamp), - m_client(CountedPtr<ClientInterface>(NULL)) +: QueuedEvent(engine, responder, timestamp) { } @@ -34,7 +33,7 @@ RequestAllObjectsEvent::RequestAllObjectsEvent(Engine& engine, CountedPtr<Respon void RequestAllObjectsEvent::pre_process() { - m_client = _engine.client_broadcaster()->client(_responder->client_key()); + m_client = _engine.broadcaster()->client(_responder->client_key()); QueuedEvent::pre_process(); } diff --git a/src/libs/engine/events/RequestMetadataEvent.cpp b/src/libs/engine/events/RequestMetadataEvent.cpp index 03d84d7f..e2169f54 100644 --- a/src/libs/engine/events/RequestMetadataEvent.cpp +++ b/src/libs/engine/events/RequestMetadataEvent.cpp @@ -41,7 +41,7 @@ RequestMetadataEvent::RequestMetadataEvent(Engine& engine, CountedPtr<Responder> void RequestMetadataEvent::pre_process() { - m_client = _engine.client_broadcaster()->client(_responder->client_key()); + m_client = _engine.broadcaster()->client(_responder->client_key()); if (m_client) { m_object = _engine.object_store()->find(m_path); diff --git a/src/libs/engine/events/RequestPluginsEvent.cpp b/src/libs/engine/events/RequestPluginsEvent.cpp index 9efb2388..789be0ea 100644 --- a/src/libs/engine/events/RequestPluginsEvent.cpp +++ b/src/libs/engine/events/RequestPluginsEvent.cpp @@ -24,8 +24,7 @@ namespace Ingen { RequestPluginsEvent::RequestPluginsEvent(Engine& engine, CountedPtr<Responder> responder, SampleCount timestamp) -: QueuedEvent(engine, responder, timestamp), - m_client(CountedPtr<ClientInterface>(NULL)) +: QueuedEvent(engine, responder, timestamp) { } @@ -33,7 +32,7 @@ RequestPluginsEvent::RequestPluginsEvent(Engine& engine, CountedPtr<Responder> r void RequestPluginsEvent::pre_process() { - m_client = _engine.client_broadcaster()->client(_responder->client_key()); + m_client = _engine.broadcaster()->client(_responder->client_key()); // Take a copy to send in the post processing thread (to avoid problems // because std::list isn't thread safe) @@ -47,7 +46,7 @@ void RequestPluginsEvent::post_process() { if (m_client) { - _engine.client_broadcaster()->send_plugins_to(m_client.get(), m_plugins); + _engine.broadcaster()->send_plugins_to(m_client, m_plugins); _responder->respond_ok(); } else { _responder->respond_error("Unable to find client to send plugins"); diff --git a/src/libs/engine/events/RequestPortValueEvent.cpp b/src/libs/engine/events/RequestPortValueEvent.cpp index 830ef852..12dea975 100644 --- a/src/libs/engine/events/RequestPortValueEvent.cpp +++ b/src/libs/engine/events/RequestPortValueEvent.cpp @@ -41,7 +41,7 @@ RequestPortValueEvent::RequestPortValueEvent(Engine& engine, CountedPtr<Responde void RequestPortValueEvent::pre_process() { - m_client = _engine.client_broadcaster()->client(_responder->client_key()); + m_client = _engine.broadcaster()->client(_responder->client_key()); m_port = _engine.object_store()->find_port(m_port_path); QueuedEvent::pre_process(); diff --git a/src/libs/engine/events/SetMetadataEvent.cpp b/src/libs/engine/events/SetMetadataEvent.cpp index 1ce5d6f4..428437e3 100644 --- a/src/libs/engine/events/SetMetadataEvent.cpp +++ b/src/libs/engine/events/SetMetadataEvent.cpp @@ -70,7 +70,7 @@ SetMetadataEvent::post_process() _responder->respond_error(msg); } else { _responder->respond_ok(); - _engine.client_broadcaster()->send_metadata_update(m_path, m_key, m_value); + _engine.broadcaster()->send_metadata_update(m_path, m_key, m_value); } } diff --git a/src/libs/engine/events/SetPortValueEvent.cpp b/src/libs/engine/events/SetPortValueEvent.cpp index 4018139a..efe53b37 100644 --- a/src/libs/engine/events/SetPortValueEvent.cpp +++ b/src/libs/engine/events/SetPortValueEvent.cpp @@ -78,13 +78,13 @@ SetPortValueEvent::post_process() assert(m_port != NULL); _responder->respond_ok(); - _engine.client_broadcaster()->send_control_change(m_port_path, m_val); + _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.client_broadcaster()->send_control_change(parent_port->path(), m_val); + _engine.broadcaster()->send_control_change(parent_port->path(), m_val); }*/ } else if (m_error == PORT_NOT_FOUND) { diff --git a/src/libs/engine/events/SetPortValueQueuedEvent.cpp b/src/libs/engine/events/SetPortValueQueuedEvent.cpp index caee68a6..dcbec0be 100644 --- a/src/libs/engine/events/SetPortValueQueuedEvent.cpp +++ b/src/libs/engine/events/SetPortValueQueuedEvent.cpp @@ -69,9 +69,9 @@ SetPortValueQueuedEvent::pre_process() void SetPortValueQueuedEvent::execute(SampleCount nframes, FrameTime start, FrameTime end) { - assert(_time >= start && _time <= end); - QueuedEvent::execute(nframes, start, end); + + assert(_time >= start && _time <= end); if (m_error == NO_ERROR) { assert(m_port != NULL); @@ -90,13 +90,13 @@ SetPortValueQueuedEvent::post_process() assert(m_port != NULL); _responder->respond_ok(); - _engine.client_broadcaster()->send_control_change(m_port_path, m_val); + _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.client_broadcaster()->send_control_change(parent_port->path(), m_val); + _engine.broadcaster()->send_control_change(parent_port->path(), m_val); }*/ } else if (m_error == PORT_NOT_FOUND) { diff --git a/src/libs/engine/events/UnregisterClientEvent.cpp b/src/libs/engine/events/UnregisterClientEvent.cpp index 13709959..310df7c5 100644 --- a/src/libs/engine/events/UnregisterClientEvent.cpp +++ b/src/libs/engine/events/UnregisterClientEvent.cpp @@ -33,7 +33,7 @@ UnregisterClientEvent::UnregisterClientEvent(Engine& engine, CountedPtr<Responde void UnregisterClientEvent::post_process() { - if (_engine.client_broadcaster()->unregister_client(_key)) + if (_engine.broadcaster()->unregister_client(_key)) _responder->respond_ok(); else _responder->respond_error("Unable to unregister client"); |