diff options
Diffstat (limited to 'src/libs')
64 files changed, 486 insertions, 343 deletions
diff --git a/src/libs/client/Makefile.am b/src/libs/client/Makefile.am index effa2759..f29529e5 100644 --- a/src/libs/client/Makefile.am +++ b/src/libs/client/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS = -I$(top_srcdir)/src/common -fno-exceptions -fno-rtti +AM_CXXFLAGS = -I$(top_srcdir)/src/common -fno-exceptions if BUILD_CLIENT_LIB noinst_LTLIBRARIES = libomclient.la diff --git a/src/libs/client/ModelClientInterface.cpp b/src/libs/client/ModelClientInterface.cpp index f2fcd10e..440f2a73 100644 --- a/src/libs/client/ModelClientInterface.cpp +++ b/src/libs/client/ModelClientInterface.cpp @@ -63,9 +63,9 @@ ModelClientInterface::connection_model(ConnectionModel* cm) void -ModelClientInterface::new_plugin(const string& type, - const string& uri, - const string& name) +ModelClientInterface::new_plugin(string type, + string uri, + string name) { PluginModel* plugin = new PluginModel(type, uri); plugin->name(name); @@ -75,7 +75,7 @@ ModelClientInterface::new_plugin(const string& type, void -ModelClientInterface::new_patch(const string& path, uint32_t poly) +ModelClientInterface::new_patch(string path, uint32_t poly) { PatchModel* pm = new PatchModel(path, poly); //PluginModel* pi = new PluginModel(PluginModel::Patch); @@ -86,9 +86,9 @@ ModelClientInterface::new_patch(const string& path, uint32_t poly) void -ModelClientInterface::new_node(const string& plugin_type, - const string& plugin_uri, - const string& node_path, +ModelClientInterface::new_node(string plugin_type, + string plugin_uri, + string node_path, bool is_polyphonic, uint32_t num_ports) { @@ -104,8 +104,8 @@ ModelClientInterface::new_node(const string& plugin_type, void -ModelClientInterface::new_port(const string& path, - const string& type, +ModelClientInterface::new_port(string path, + string type, bool is_output) { PortModel::Type ptype = PortModel::CONTROL; @@ -123,8 +123,8 @@ ModelClientInterface::new_port(const string& path, void -ModelClientInterface::connection(const string& src_port_path, - const string& dst_port_path) +ModelClientInterface::connection(string src_port_path, + string dst_port_path) { connection_model(new ConnectionModel(src_port_path, dst_port_path)); } diff --git a/src/libs/client/ModelClientInterface.h b/src/libs/client/ModelClientInterface.h index d4362a38..84472137 100644 --- a/src/libs/client/ModelClientInterface.h +++ b/src/libs/client/ModelClientInterface.h @@ -59,24 +59,24 @@ public: // ClientInterface functions to drive the above: - 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 connection(const string& src_port_path, - const string& dst_port_path); + virtual void connection(string src_port_path, + string dst_port_path); protected: ModelClientInterface() {} diff --git a/src/libs/client/NodeModel.cpp b/src/libs/client/NodeModel.cpp index 496e02db..f544e812 100644 --- a/src/libs/client/NodeModel.cpp +++ b/src/libs/client/NodeModel.cpp @@ -119,6 +119,8 @@ NodeModel::add_program(int bank, int program, const string& name) { m_banks[bank][program] = name; } + + void NodeModel::remove_program(int bank, int program) { @@ -127,5 +129,30 @@ NodeModel::remove_program(int bank, int program) m_banks.erase(bank); } + +void +NodeModel::x(float a) +{ + if (m_x != a) { + m_x = a; + char temp_buf[16]; + snprintf(temp_buf, 16, "%f", a); + set_metadata("module-x", temp_buf); + } +} + + +void +NodeModel::y(float a) +{ + if (m_y != a) { + m_y = a; + char temp_buf[16]; + snprintf(temp_buf, 16, "%f", a); + set_metadata("module-y", temp_buf); + } +} + + } // namespace Client } // namespace Ingen diff --git a/src/libs/client/NodeModel.h b/src/libs/client/NodeModel.h index 6ab6b873..2a8b6973 100644 --- a/src/libs/client/NodeModel.h +++ b/src/libs/client/NodeModel.h @@ -67,9 +67,9 @@ public: virtual bool polyphonic() const { return m_polyphonic; } void polyphonic(bool b) { m_polyphonic = b; } float x() const { return m_x; } - void x(float a) { m_x = a; } float y() const { return m_y; } - void y(float a) { m_y = a; } + void x(float a); + void y(float a); // Signals sigc::signal<void, CountedPtr<PortModel> > new_port_sig; diff --git a/src/libs/client/OSCClientReceiver.cpp b/src/libs/client/OSCClientReceiver.cpp index 1d52caa3..ae607af1 100644 --- a/src/libs/client/OSCClientReceiver.cpp +++ b/src/libs/client/OSCClientReceiver.cpp @@ -70,7 +70,7 @@ OSCClientReceiver::start() cout << "[OSCClientReceiver] Started OSC listener on port " << lo_server_thread_get_port(_st) << endl; } - // FIXME + // Print all incoming messages 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); diff --git a/src/libs/client/OSCEngineSender.h b/src/libs/client/OSCEngineSender.h index 3335a91f..2603667a 100644 --- a/src/libs/client/OSCEngineSender.h +++ b/src/libs/client/OSCEngineSender.h @@ -49,7 +49,7 @@ public: inline size_t next_id() { int32_t ret = (_id == -1) ? -1 : _id++; return ret; } - void enable_responses() { _id = 0; } + void set_next_response_id(int32_t id) { _id = id; } void disable_responses() { _id = -1; } void attach(int32_t ping_id, bool block); diff --git a/src/libs/client/PatchLibrarian.h b/src/libs/client/PatchLibrarian.h index a41d47e3..cd4b4b7a 100644 --- a/src/libs/client/PatchLibrarian.h +++ b/src/libs/client/PatchLibrarian.h @@ -22,6 +22,7 @@ #include <string> #include <libxml/tree.h> #include <cassert> +#include "util/CountedPtr.h" //#include "DummyModelClientInterface.h" using std::string; @@ -46,7 +47,7 @@ class PatchLibrarian public: // FIXME: return booleans and set an errstr that can be checked or something? - PatchLibrarian(ModelEngineInterface* _engine) + PatchLibrarian(CountedPtr<ModelEngineInterface> _engine) : _patch_search_path("."), _engine(_engine) { assert(_engine); @@ -63,8 +64,8 @@ public: private: string translate_load_path(const string& path); - string _patch_search_path; - ModelEngineInterface* const _engine; + string _patch_search_path; + CountedPtr<ModelEngineInterface> _engine; /// Translations of paths from the loading file to actual paths (for deprecated patches) std::map<string, string> _load_path_translations; diff --git a/src/libs/client/PatchModel.cpp b/src/libs/client/PatchModel.cpp index 5afec7ab..5b1348b2 100644 --- a/src/libs/client/PatchModel.cpp +++ b/src/libs/client/PatchModel.cpp @@ -168,7 +168,7 @@ PatchModel::add_connection(CountedPtr<ConnectionModel> cm) //assert(cm->dst_port_path().parent().parent() == m_path); assert(cm->patch_path() == path()); - cerr << "PatchModel::add_connection: " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl; + //cerr << "PatchModel::add_connection: " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl; CountedPtr<ConnectionModel> existing = get_connection(cm->src_port_path(), cm->dst_port_path()); diff --git a/src/libs/client/PortModel.h b/src/libs/client/PortModel.h index 37e312f3..3aedc639 100644 --- a/src/libs/client/PortModel.h +++ b/src/libs/client/PortModel.h @@ -47,11 +47,11 @@ public: m_hint(hint), m_default_val(default_val), m_min_val(min), - m_user_min(min), + //m_user_min(min), m_max_val(max), - m_user_max(max), + //m_user_max(max), m_current_val(default_val), - m_connected(false) + m_connections(0) { } @@ -62,26 +62,25 @@ public: m_hint(NONE), m_default_val(0.0f), m_min_val(0.0f), - m_user_min(0.0f), + //m_user_min(0.0f), m_max_val(0.0f), - m_user_max(0.0f), + //m_user_max(0.0f), m_current_val(0.0f), - m_connected(false) + m_connections(0) { } inline float min_val() const { return m_min_val; } - inline float user_min() const { return m_user_min; } - inline void user_min(float f) { m_user_min = f; } + inline float user_min() const { return atof(get_metadata("min").c_str()); } // FIXME: haaack + //inline void user_min(float f) { m_user_min = f; } inline float default_val() const { return m_default_val; } inline void default_val(float f) { m_default_val = f; } inline float max_val() const { return m_max_val; } - inline float user_max() const { return m_user_max; } - inline void user_max(float f) { m_user_max = f; } + inline float user_max() const { return atof(get_metadata("max").c_str()); } + //inline void user_max(float f) { m_user_max = f; } inline float value() const { return m_current_val; } inline void value(float f) { m_current_val = f; control_change_sig.emit(f); } - inline bool connected() { return m_connected; } - inline void connected(bool b) { m_connected = b; } + inline bool connected() { return (m_connections > 0); } inline Type type() { return m_type; } inline bool is_input() const { return (m_direction == INPUT); } @@ -96,8 +95,13 @@ public: inline bool operator==(const PortModel& pm) { return (m_path == pm.m_path); } + void connected_to(CountedPtr<PortModel> p) { ++m_connections; connection_sig.emit(p); } + void disconnected_from(CountedPtr<PortModel> p) { --m_connections; disconnection_sig.emit(p); } + // Signals - sigc::signal<void, float> control_change_sig; ///< "Control" ports only + sigc::signal<void, float> control_change_sig; ///< "Control" ports only + sigc::signal<void, CountedPtr<PortModel> > connection_sig; + sigc::signal<void, CountedPtr<PortModel> > disconnection_sig; private: // Prevent copies (undefined) @@ -109,11 +113,11 @@ private: Hint m_hint; float m_default_val; float m_min_val; - float m_user_min; + //float m_user_min; float m_max_val; - float m_user_max; + //float m_user_max; float m_current_val; - bool m_connected; + size_t m_connections; }; typedef list<CountedPtr<PortModel> > PortModelList; diff --git a/src/libs/client/SigClientInterface.h b/src/libs/client/SigClientInterface.h index de76f9c1..cef7d27d 100644 --- a/src/libs/client/SigClientInterface.h +++ b/src/libs/client/SigClientInterface.h @@ -39,26 +39,26 @@ public: // See the corresponding emitting functions below for parameter meanings - sigc::signal<void, int32_t,bool,const string&> response_sig; - sigc::signal<void> bundle_begin_sig; - sigc::signal<void> bundle_end_sig; - sigc::signal<void, const string&> error_sig; - sigc::signal<void, uint32_t> num_plugins_sig; - sigc::signal<void, const string&, const string&, const string&> new_plugin_sig; - sigc::signal<void, const string&, uint32_t> new_patch_sig; - sigc::signal<void, const string&, const string&, const string&, bool, uint32_t> new_node_sig; - sigc::signal<void, const string&, const string&, bool> new_port_sig; - sigc::signal<void, const string&> patch_enabled_sig; - sigc::signal<void, const string&> patch_disabled_sig; - sigc::signal<void, const string&> patch_cleared_sig; - sigc::signal<void, const string&, const string&> object_renamed_sig; - sigc::signal<void, const string&> object_destroyed_sig; - sigc::signal<void, const string&, const string&> connection_sig; - sigc::signal<void, const string&, const string&> disconnection_sig; - sigc::signal<void, const string&, const string&, const string&> metadata_update_sig; - sigc::signal<void, const string&, float> control_change_sig; - sigc::signal<void, const string&, uint32_t, uint32_t, const string&> program_add_sig; - sigc::signal<void, const string&, uint32_t, uint32_t> program_remove_sig; + sigc::signal<void, int32_t, bool, string> response_sig; + sigc::signal<void> bundle_begin_sig; + sigc::signal<void> bundle_end_sig; + sigc::signal<void, string> error_sig; + sigc::signal<void, uint32_t> num_plugins_sig; + sigc::signal<void, string, string, string> new_plugin_sig; + sigc::signal<void, string, uint32_t> new_patch_sig; + sigc::signal<void, string, string, string, bool, uint32_t> new_node_sig; + 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> patch_cleared_sig; + sigc::signal<void, string, string> object_renamed_sig; + sigc::signal<void, string> object_destroyed_sig; + sigc::signal<void, string, string> connection_sig; + sigc::signal<void, string, string> disconnection_sig; + sigc::signal<void, string, string, string> metadata_update_sig; + sigc::signal<void, string, float> control_change_sig; + sigc::signal<void, string, uint32_t, uint32_t, string> program_add_sig; + sigc::signal<void, string, uint32_t, uint32_t> program_remove_sig; protected: SigClientInterface() {} diff --git a/src/libs/client/Store.cpp b/src/libs/client/Store.cpp index 7fd011b7..71dc06a2 100644 --- a/src/libs/client/Store.cpp +++ b/src/libs/client/Store.cpp @@ -62,7 +62,7 @@ Store::add_object(CountedPtr<ObjectModel> object) m_objects[object->path()] = object; - cout << "[Store] Added " << object->path() << endl; + //cout << "[Store] Added " << object->path() << endl; } @@ -75,7 +75,7 @@ Store::remove_object(const string& path) assert((*i).second->path() == path); CountedPtr<ObjectModel> result = (*i).second; m_objects.erase(i); - cout << "[Store] Removed " << path << endl; + //cout << "[Store] Removed " << path << endl; return result; } else { cerr << "[Store] Unable to find object " << path << " to remove." << endl; @@ -163,11 +163,11 @@ Store::port(const string& path) void Store::add_plugin(CountedPtr<PluginModel> pm) { - if (m_plugins.find(pm->uri()) != m_plugins.end()) { - cerr << "DUPE PLUGIN: " << pm->uri() << endl; - } else { + //if (m_plugins.find(pm->uri()) != m_plugins.end()) { + // cerr << "DUPE PLUGIN: " << pm->uri() << endl; + //} else { m_plugins[pm->uri()] = pm; - } + //} } @@ -363,6 +363,9 @@ Store::connection_event(const Path& src_port_path, const Path& dst_port_path) assert(src_port); assert(dst_port); + src_port->connected_to(dst_port); + dst_port->connected_to(src_port); + CountedPtr<ConnectionModel> cm = new ConnectionModel(src_port, dst_port); CountedPtr<PatchModel> patch = this->object(cm->patch_path()); @@ -385,6 +388,9 @@ Store::disconnection_event(const Path& src_port_path, const Path& dst_port_path) assert(src_port); assert(dst_port); + + src_port->disconnected_from(dst_port); + dst_port->disconnected_from(src_port); CountedPtr<ConnectionModel> cm = new ConnectionModel(src_port, dst_port); diff --git a/src/libs/client/ThreadedSigClientInterface.cpp b/src/libs/client/ThreadedSigClientInterface.cpp index dd4503e7..28719598 100644 --- a/src/libs/client/ThreadedSigClientInterface.cpp +++ b/src/libs/client/ThreadedSigClientInterface.cpp @@ -33,6 +33,7 @@ ThreadedSigClientInterface::push_sig(Closure ev) // (Very) slow busy-wait if the queue is full // FIXME: Make this wait on a signal from process_sigs iff this happens while (!success) { + //printf("push %zu\n", _sigs.fill()); success = _sigs.push(ev); if (!success) { if (first) { @@ -55,8 +56,10 @@ ThreadedSigClientInterface::emit_signals() { // Process a maximum of queue-size events, to prevent locking the GTK // thread indefinitely while processing continually arriving events + const size_t limit = _sigs.capacity(); size_t num_processed = 0; - while (!_sigs.is_empty() && num_processed++ < _sigs.capacity()/2) { + while (!_sigs.is_empty() && num_processed++ < limit) { + //printf("emit %zu\n", _sigs.fill()); Closure& ev = _sigs.pop(); ev(); ev.disconnect(); diff --git a/src/libs/client/ThreadedSigClientInterface.h b/src/libs/client/ThreadedSigClientInterface.h index afc756c4..5a677034 100644 --- a/src/libs/client/ThreadedSigClientInterface.h +++ b/src/libs/client/ThreadedSigClientInterface.h @@ -39,7 +39,7 @@ namespace Client { * function, which fires all enqueued signals up until the present. You can * use this in a GTK idle callback for receiving thread safe engine signals. */ -class ThreadedSigClientInterface : virtual public SigClientInterface +class ThreadedSigClientInterface : public SigClientInterface { public: ThreadedSigClientInterface(uint32_t queue_size) @@ -64,61 +64,66 @@ public: {} - // FIXME + // FIXME: make this insert bundle-boundary-events, where the GTK thread + // process all events between start and finish in one cycle, guaranteed + // (no more node jumping) void bundle_begin() {} void bundle_end() {} + + void transfer_begin() {} + void transfer_end() {} void num_plugins(uint32_t num) { _num_plugins = num; } - void response(int32_t id, bool success, const string& msg) + void response(int32_t id, bool success, string msg) { push_sig(sigc::bind(response_slot, id, success, msg)); } - void error(const string& msg) + void error(string msg) { push_sig(sigc::bind(error_slot, msg)); } - void new_plugin(const string& type, const string& uri, const string& name) + void new_plugin(string type, string uri, string name) { push_sig(sigc::bind(new_plugin_slot, type, uri, name)); } - void new_patch(const string& path, uint32_t poly) + void new_patch(string path, uint32_t poly) { push_sig(sigc::bind(new_patch_slot, path, poly)); } - void new_node(const string& plugin_type, const string& plugin_uri, const string& node_path, bool is_polyphonic, uint32_t num_ports) + void new_node(string plugin_type, string plugin_uri, string node_path, bool is_polyphonic, uint32_t num_ports) { push_sig(sigc::bind(new_node_slot, plugin_type, plugin_uri, node_path, is_polyphonic, num_ports)); } - void new_port(const string& path, const string& data_type, bool is_output) + void new_port(string path, string data_type, bool is_output) { push_sig(sigc::bind(new_port_slot, path, data_type, is_output)); } - void connection(const string& src_port_path, const string& dst_port_path) + void connection(string src_port_path, string dst_port_path) { push_sig(sigc::bind(connection_slot, src_port_path, dst_port_path)); } - void object_destroyed(const string& path) + void object_destroyed(string path) { push_sig(sigc::bind(object_destroyed_slot, path)); } - void patch_enabled(const string& path) + void patch_enabled(string path) { push_sig(sigc::bind(patch_enabled_slot, path)); } - void patch_disabled(const string& path) + void patch_disabled(string path) { push_sig(sigc::bind(patch_disabled_slot, path)); } - void patch_cleared(const string& path) + void patch_cleared(string path) { push_sig(sigc::bind(patch_cleared_slot, path)); } - void object_renamed(const string& old_path, const string& new_path) + void object_renamed(string old_path, string new_path) { push_sig(sigc::bind(object_renamed_slot, old_path, new_path)); } - void disconnection(const string& src_port_path, const string& dst_port_path) + void disconnection(string src_port_path, string dst_port_path) { push_sig(sigc::bind(disconnection_slot, src_port_path, dst_port_path)); } - void metadata_update(const string& path, const string& key, const string& value) + void metadata_update(string path, string key, string value) { push_sig(sigc::bind(metadata_update_slot, path, key, value)); } - void control_change(const string& port_path, float value) + void control_change(string port_path, float value) { push_sig(sigc::bind(control_change_slot, port_path, value)); } - void program_add(const string& path, uint32_t bank, uint32_t program, const string& name) + void program_add(string path, uint32_t bank, uint32_t program, string name) { push_sig(sigc::bind(program_add_slot, path, bank, program, name)); } - void program_remove(const string& path, uint32_t bank, uint32_t program) + void program_remove(string path, uint32_t bank, uint32_t program) { push_sig(sigc::bind(program_remove_slot, path, bank, program)); } /** Process all queued events - Called from GTK thread to emit signals. */ 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"); |