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/client | |
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/client')
-rw-r--r-- | src/libs/client/Makefile.am | 2 | ||||
-rw-r--r-- | src/libs/client/ModelClientInterface.cpp | 22 | ||||
-rw-r--r-- | src/libs/client/ModelClientInterface.h | 28 | ||||
-rw-r--r-- | src/libs/client/NodeModel.cpp | 27 | ||||
-rw-r--r-- | src/libs/client/NodeModel.h | 4 | ||||
-rw-r--r-- | src/libs/client/OSCClientReceiver.cpp | 2 | ||||
-rw-r--r-- | src/libs/client/OSCEngineSender.h | 2 | ||||
-rw-r--r-- | src/libs/client/PatchLibrarian.h | 7 | ||||
-rw-r--r-- | src/libs/client/PatchModel.cpp | 2 | ||||
-rw-r--r-- | src/libs/client/PortModel.h | 36 | ||||
-rw-r--r-- | src/libs/client/SigClientInterface.h | 40 | ||||
-rw-r--r-- | src/libs/client/Store.cpp | 18 | ||||
-rw-r--r-- | src/libs/client/ThreadedSigClientInterface.cpp | 5 | ||||
-rw-r--r-- | src/libs/client/ThreadedSigClientInterface.h | 43 |
14 files changed, 142 insertions, 96 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. */ |