From 46459ab2f46fdb826102562c266b0bc2921a3737 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 28 Sep 2008 04:55:46 +0000 Subject: Remove header namespace pollution (particularly from libs/gui/App.hpp). Fix more LV2 plugin RDF race/lock issues with -eg. Show human readable names on new ports when human readable is set (fix ticket #202). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1523 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/ClientStore.hpp | 6 ++-- src/libs/engine/InternalPlugin.cpp | 23 ++++--------- src/libs/engine/InternalPlugin.hpp | 5 +-- src/libs/engine/LADSPAPlugin.cpp | 8 +++-- src/libs/engine/LADSPAPlugin.hpp | 3 +- src/libs/engine/LV2Node.cpp | 3 +- src/libs/engine/LV2Plugin.cpp | 11 +++++-- src/libs/engine/LV2Plugin.hpp | 3 +- src/libs/engine/PatchPlugin.hpp | 3 +- src/libs/engine/PluginImpl.hpp | 4 +-- src/libs/engine/events/CreateNodeEvent.cpp | 3 +- src/libs/gui/App.hpp | 53 ++++++++++++++---------------- src/libs/gui/Configuration.hpp | 7 ++++ src/libs/gui/ConnectWindow.cpp | 1 + src/libs/gui/ControlPanel.cpp | 2 ++ src/libs/gui/LoadPatchWindow.cpp | 1 + src/libs/gui/LoadPluginWindow.hpp | 2 +- src/libs/gui/LoadRemotePatchWindow.cpp | 1 + src/libs/gui/LoadSubpatchWindow.cpp | 1 + src/libs/gui/NodeModule.cpp | 9 ++++- src/libs/gui/PatchCanvas.cpp | 1 + src/libs/gui/PatchPortModule.cpp | 2 +- src/libs/gui/PatchTreeWindow.cpp | 2 ++ src/libs/gui/PatchTreeWindow.hpp | 10 +++--- src/libs/gui/Port.cpp | 10 ++++-- src/libs/gui/Port.hpp | 6 +++- src/libs/gui/PortPropertiesWindow.cpp | 2 +- src/libs/gui/RenameWindow.cpp | 1 - 28 files changed, 100 insertions(+), 83 deletions(-) diff --git a/src/libs/client/ClientStore.hpp b/src/libs/client/ClientStore.hpp index 954dcc04..f08fcd9b 100644 --- a/src/libs/client/ClientStore.hpp +++ b/src/libs/client/ClientStore.hpp @@ -15,8 +15,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef STORE_H -#define STORE_H +#ifndef CLIENT_STORE_HPP +#define CLIENT_STORE_HPP #include #include @@ -148,4 +148,4 @@ private: } // namespace Client } // namespace Ingen -#endif // STORE_H +#endif // CLIENT_STORE_HPP diff --git a/src/libs/engine/InternalPlugin.cpp b/src/libs/engine/InternalPlugin.cpp index 9141b545..1c6a92a5 100644 --- a/src/libs/engine/InternalPlugin.cpp +++ b/src/libs/engine/InternalPlugin.cpp @@ -21,33 +21,22 @@ #include "MidiTriggerNode.hpp" #include "MidiControlNode.hpp" #include "TransportNode.hpp" +#include "Engine.hpp" +#include "AudioDriver.hpp" namespace Ingen { -#if 0 -InternalPlugin::InternalPlugin(const InternalPlugin* const copy) -{ - _type = copy->_type; - _uri = copy->_uri; - _lib_path = copy->_lib_path; - _lib_name = copy->_lib_name; - _plug_label = copy->_plug_label; - _name = copy->_name; - _id = _id; - _module = copy->_module; -} -#endif - - NodeImpl* InternalPlugin::instantiate(const string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size) + Engine& engine) { assert(_type == Internal); + + SampleCount srate = engine.audio_driver()->sample_rate(); + SampleCount buffer_size = engine.audio_driver()->buffer_size(); if (_uri == NS_INGEN "note_node") { return new MidiNoteNode(name, polyphonic, parent, srate, buffer_size); diff --git a/src/libs/engine/InternalPlugin.hpp b/src/libs/engine/InternalPlugin.hpp index 02ca3e59..c04c9015 100644 --- a/src/libs/engine/InternalPlugin.hpp +++ b/src/libs/engine/InternalPlugin.hpp @@ -54,13 +54,10 @@ public: , _name(name) {} - //InternalPlugin(const InternalPlugin* const copy); - NodeImpl* instantiate(const std::string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size); + Engine& engine); const string symbol() const { return _symbol; } const string name() const { return _name; } diff --git a/src/libs/engine/LADSPAPlugin.cpp b/src/libs/engine/LADSPAPlugin.cpp index a43baa9a..4a0b5c14 100644 --- a/src/libs/engine/LADSPAPlugin.cpp +++ b/src/libs/engine/LADSPAPlugin.cpp @@ -21,6 +21,8 @@ #include "LADSPAPlugin.hpp" #include "LADSPANode.hpp" #include "NodeImpl.hpp" +#include "Engine.hpp" +#include "AudioDriver.hpp" using namespace std; @@ -31,11 +33,13 @@ NodeImpl* LADSPAPlugin::instantiate(const string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size) + Engine& engine) { assert(_id != 0); + SampleCount srate = engine.audio_driver()->sample_rate(); + SampleCount buffer_size = engine.audio_driver()->buffer_size(); + LADSPA_Descriptor_Function df = NULL; LADSPANode* n = NULL; diff --git a/src/libs/engine/LADSPAPlugin.hpp b/src/libs/engine/LADSPAPlugin.hpp index 59a6972b..2414be7c 100644 --- a/src/libs/engine/LADSPAPlugin.hpp +++ b/src/libs/engine/LADSPAPlugin.hpp @@ -54,8 +54,7 @@ public: NodeImpl* instantiate(const std::string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size); + Engine& engine); const std::string& label() const { return _label; } unsigned long id() const { return _id; } diff --git a/src/libs/engine/LV2Node.cpp b/src/libs/engine/LV2Node.cpp index 974c5858..cfc9be78 100644 --- a/src/libs/engine/LV2Node.cpp +++ b/src/libs/engine/LV2Node.cpp @@ -129,8 +129,7 @@ LV2Node::instantiate() uint32_t num_ports = slv2_plugin_get_num_ports(plug); assert(num_ports > 0); - _ports = new Raul::Array(num_ports, NULL); - + _ports = new Raul::Array(num_ports, NULL); _instances = new Raul::Array(_polyphony, NULL); uint32_t port_buffer_size = 0; diff --git a/src/libs/engine/LV2Plugin.cpp b/src/libs/engine/LV2Plugin.cpp index 09d48a10..90a3a6b8 100644 --- a/src/libs/engine/LV2Plugin.cpp +++ b/src/libs/engine/LV2Plugin.cpp @@ -16,9 +16,13 @@ */ #include +#include +#include #include "LV2Plugin.hpp" #include "LV2Node.hpp" #include "NodeImpl.hpp" +#include "Engine.hpp" +#include "AudioDriver.hpp" namespace Ingen { @@ -58,11 +62,14 @@ NodeImpl* LV2Plugin::instantiate(const string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size) + Engine& engine) { + SampleCount srate = engine.audio_driver()->sample_rate(); + SampleCount buffer_size = engine.audio_driver()->buffer_size(); + load(); // FIXME: unload at some point + Glib::Mutex::Lock lock(engine.world()->rdf_world->mutex()); LV2Node* n = new LV2Node(this, name, polyphonic, parent, srate, buffer_size); if ( ! n->instantiate() ) { diff --git a/src/libs/engine/LV2Plugin.hpp b/src/libs/engine/LV2Plugin.hpp index 827e7e89..c1f8671d 100644 --- a/src/libs/engine/LV2Plugin.hpp +++ b/src/libs/engine/LV2Plugin.hpp @@ -61,8 +61,7 @@ public: NodeImpl* instantiate(const string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size); + Engine& engine); const string symbol() const; const string name() const; diff --git a/src/libs/engine/PatchPlugin.hpp b/src/libs/engine/PatchPlugin.hpp index 24a2679a..a7334392 100644 --- a/src/libs/engine/PatchPlugin.hpp +++ b/src/libs/engine/PatchPlugin.hpp @@ -44,8 +44,7 @@ public: NodeImpl* instantiate(const std::string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size) + Engine& engine) { return NULL; } diff --git a/src/libs/engine/PluginImpl.hpp b/src/libs/engine/PluginImpl.hpp index 9ad16ee3..0301d942 100644 --- a/src/libs/engine/PluginImpl.hpp +++ b/src/libs/engine/PluginImpl.hpp @@ -36,6 +36,7 @@ namespace Ingen { class PatchImpl; class NodeImpl; +class Engine; /** Implementation of a plugin (internal code, or a loaded shared library). @@ -55,8 +56,7 @@ public: virtual NodeImpl* instantiate(const std::string& name, bool polyphonic, Ingen::PatchImpl* parent, - SampleRate srate, - size_t buffer_size) = 0; + Engine& engine) = 0; virtual const string symbol() const = 0; virtual const string name() const = 0; diff --git a/src/libs/engine/events/CreateNodeEvent.cpp b/src/libs/engine/events/CreateNodeEvent.cpp index a3681597..b58bc2c3 100644 --- a/src/libs/engine/events/CreateNodeEvent.cpp +++ b/src/libs/engine/events/CreateNodeEvent.cpp @@ -87,8 +87,7 @@ CreateNodeEvent::pre_process() if (_patch && plugin) { - _node = plugin->instantiate(_path.name(), _polyphonic, _patch, - _engine.audio_driver()->sample_rate(), _engine.audio_driver()->buffer_size()); + _node = plugin->instantiate(_path.name(), _polyphonic, _patch, _engine); if (_node != NULL) { _node->activate(); diff --git a/src/libs/gui/App.hpp b/src/libs/gui/App.hpp index 08ceb271..4a4b6580 100644 --- a/src/libs/gui/App.hpp +++ b/src/libs/gui/App.hpp @@ -15,23 +15,20 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef APP_H -#define APP_H +#ifndef INGEN_APP_HPP +#define INGEN_APP_HPP #include #include #include -#include +#include #include #include #include #include #include -#include +#include #include -#include - -using namespace std; namespace Ingen { class Engine; @@ -51,10 +48,6 @@ namespace Ingen { } } -using namespace Ingen::Shared; -using namespace Ingen::Serialisation; -using namespace Ingen::Client; - /** \defgroup GUI GTK GUI */ @@ -84,10 +77,10 @@ class App public: ~App(); - void error_message(const string& msg); + void error_message(const std::string& msg); - void attach(SharedPtr client, - SharedPtr handle=SharedPtr()); + void attach(SharedPtr client, + SharedPtr handle=SharedPtr()); void detach(); @@ -110,14 +103,14 @@ public: Configuration* configuration() const { return _configuration; } WindowFactory* window_factory() const { return _window_factory; } - Glib::RefPtr icon_from_path(const string& path, int size); + Glib::RefPtr icon_from_path(const std::string& path, int size); - const SharedPtr& engine() const { return _world->engine; } - const SharedPtr& client() const { return _client; } - const SharedPtr& store() const { return _store; } - const SharedPtr& loader() const { return _loader; } + const SharedPtr& engine() const { return _world->engine; } + const SharedPtr& client() const { return _client; } + const SharedPtr& store() const { return _store; } + const SharedPtr& loader() const { return _loader; } - const SharedPtr& serialiser(); + const SharedPtr& serialiser(); static inline App& instance() { assert(_instance); return *_instance; } @@ -130,29 +123,31 @@ protected: /** This is needed for the icon map. */ template struct LexicalCompare { - bool operator()(const pair& p1, const pair& p2) { + bool operator()(const std::pair& p1, const std::pair& p2) { return (p1.first < p2.first) || ((p1.first == p2.first) && (p1.second < p2.second)); } }; - typedef map, Gdk::Pixbuf*, LexicalCompare > Icons; + typedef std::map< std::pair, + Gdk::Pixbuf*, + LexicalCompare > Icons; Icons _icons; App(Ingen::Shared::World* world); bool animate(); - void error_response(int32_t id, const string& str); + void error_response(int32_t id, const std::string& str); static void* icon_destroyed(void* data); static App* _instance; - SharedPtr _client; - SharedPtr _handle; - SharedPtr _store; - SharedPtr _serialiser; - SharedPtr _loader; + SharedPtr _client; + SharedPtr _handle; + SharedPtr _store; + SharedPtr _serialiser; + SharedPtr _loader; Configuration* _configuration; @@ -174,5 +169,5 @@ protected: } // namespace GUI } // namespace Ingen -#endif // APP_H +#endif // INGEN_APP_HPP diff --git a/src/libs/gui/Configuration.hpp b/src/libs/gui/Configuration.hpp index 5baa7a09..124b41c8 100644 --- a/src/libs/gui/Configuration.hpp +++ b/src/libs/gui/Configuration.hpp @@ -52,11 +52,18 @@ public: void set_patch_folder(const string& f) { _patch_folder = f; } uint32_t get_port_color(const PortModel* pi); + + enum NameStyle { PATH, HUMAN }; + + NameStyle name_style() const { return _name_style; } + void set_name_style(NameStyle s) { _name_style = s; } private: /** Most recent patch folder shown in open dialog */ string _patch_folder; + NameStyle _name_style; + uint32_t _audio_port_color; uint32_t _control_port_color; uint32_t _event_port_color; diff --git a/src/libs/gui/ConnectWindow.cpp b/src/libs/gui/ConnectWindow.cpp index 3037ee88..5600a0b2 100644 --- a/src/libs/gui/ConnectWindow.cpp +++ b/src/libs/gui/ConnectWindow.cpp @@ -40,6 +40,7 @@ #include "ConnectWindow.hpp" using Ingen::QueuedEngineInterface; using Ingen::Client::ThreadedSigClientInterface; +using namespace std; namespace Ingen { namespace GUI { diff --git a/src/libs/gui/ControlPanel.cpp b/src/libs/gui/ControlPanel.cpp index 032f5758..0e637721 100644 --- a/src/libs/gui/ControlPanel.cpp +++ b/src/libs/gui/ControlPanel.cpp @@ -25,6 +25,8 @@ #include "Controls.hpp" #include "GladeFactory.hpp" +using namespace std; + namespace Ingen { namespace GUI { diff --git a/src/libs/gui/LoadPatchWindow.cpp b/src/libs/gui/LoadPatchWindow.cpp index 2f3b6af7..c33ad495 100644 --- a/src/libs/gui/LoadPatchWindow.cpp +++ b/src/libs/gui/LoadPatchWindow.cpp @@ -27,6 +27,7 @@ using namespace Ingen::Serialisation; using boost::optional; +using namespace std; namespace Ingen { namespace GUI { diff --git a/src/libs/gui/LoadPluginWindow.hpp b/src/libs/gui/LoadPluginWindow.hpp index a5246c39..98644dde 100644 --- a/src/libs/gui/LoadPluginWindow.hpp +++ b/src/libs/gui/LoadPluginWindow.hpp @@ -94,7 +94,7 @@ public: LoadPluginWindow(BaseObjectType* cobject, const Glib::RefPtr& xml); void set_patch(SharedPtr patch); - void set_plugins(SharedPtr plugins); + void set_plugins(SharedPtr plugins); void add_plugin(SharedPtr plugin); diff --git a/src/libs/gui/LoadRemotePatchWindow.cpp b/src/libs/gui/LoadRemotePatchWindow.cpp index 5d4bcb5c..5567d67b 100644 --- a/src/libs/gui/LoadRemotePatchWindow.cpp +++ b/src/libs/gui/LoadRemotePatchWindow.cpp @@ -30,6 +30,7 @@ using boost::optional; using namespace Raul; +using namespace std; namespace Ingen { namespace GUI { diff --git a/src/libs/gui/LoadSubpatchWindow.cpp b/src/libs/gui/LoadSubpatchWindow.cpp index df954e48..52a989af 100644 --- a/src/libs/gui/LoadSubpatchWindow.cpp +++ b/src/libs/gui/LoadSubpatchWindow.cpp @@ -28,6 +28,7 @@ #include "Configuration.hpp" #include "ThreadedLoader.hpp" using boost::optional; +using namespace std; namespace Ingen { namespace GUI { diff --git a/src/libs/gui/NodeModule.cpp b/src/libs/gui/NodeModule.cpp index 09df174e..f8308264 100644 --- a/src/libs/gui/NodeModule.cpp +++ b/src/libs/gui/NodeModule.cpp @@ -31,6 +31,9 @@ #include "RenameWindow.hpp" #include "SubpatchModule.hpp" #include "WindowFactory.hpp" +#include "Configuration.hpp" + +using namespace std; namespace Ingen { namespace GUI { @@ -227,8 +230,12 @@ NodeModule::add_port(SharedPtr port, bool resize_to_fit) { uint32_t index = _ports.size(); // FIXME: kludge, engine needs to tell us this + string name = (App::instance().configuration()->name_style() == Configuration::PATH) + ? port->path().name() + : ((PluginModel*)node()->plugin())->port_human_name(index); + Module::add_port(boost::shared_ptr( - new Port(PtrCast(shared_from_this()), port))); + new Port(PtrCast(shared_from_this()), port, name))); port->signal_value_changed.connect(sigc::bind<0>( sigc::mem_fun(this, &NodeModule::value_changed), index)); diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index ddbbdc2b..f96a9f57 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -47,6 +47,7 @@ using Ingen::Client::ClientStore; using Ingen::Serialisation::Serialiser; using Ingen::Client::PluginModel; +using namespace std; namespace Ingen { namespace GUI { diff --git a/src/libs/gui/PatchPortModule.cpp b/src/libs/gui/PatchPortModule.cpp index 76bc8812..d8aaa91d 100644 --- a/src/libs/gui/PatchPortModule.cpp +++ b/src/libs/gui/PatchPortModule.cpp @@ -70,7 +70,7 @@ PatchPortModule::create(boost::shared_ptr canvas, SharedPtr_patch_port = boost::shared_ptr(new Port(ret, port, true)); + ret->_patch_port = boost::shared_ptr(new Port(ret, port, port->symbol(), true)); ret->add_port(ret->_patch_port); diff --git a/src/libs/gui/PatchTreeWindow.cpp b/src/libs/gui/PatchTreeWindow.cpp index 87393cec..4730da2b 100644 --- a/src/libs/gui/PatchTreeWindow.cpp +++ b/src/libs/gui/PatchTreeWindow.cpp @@ -25,6 +25,8 @@ #include "SubpatchModule.hpp" #include "WindowFactory.hpp" +using namespace std; + namespace Ingen { namespace GUI { diff --git a/src/libs/gui/PatchTreeWindow.hpp b/src/libs/gui/PatchTreeWindow.hpp index 5cd078a5..f549a322 100644 --- a/src/libs/gui/PatchTreeWindow.hpp +++ b/src/libs/gui/PatchTreeWindow.hpp @@ -45,12 +45,12 @@ public: void init(ClientStore& store); - void new_object(SharedPtr object); + void new_object(SharedPtr object); void patch_property_changed(const string& key, const Raul::Atom& value, const Path& path); void patch_renamed(const Path& old_path, const Path& new_path); - void add_patch(SharedPtr pm); + void add_patch(SharedPtr pm); void remove_patch(const Path& path); void show_patch_menu(GdkEventButton* ev); @@ -68,9 +68,9 @@ protected: PatchTreeModelColumns() { add(name_col); add(enabled_col); add(patch_model_col); } - Gtk::TreeModelColumn name_col; - Gtk::TreeModelColumn enabled_col; - Gtk::TreeModelColumn > patch_model_col; + Gtk::TreeModelColumn name_col; + Gtk::TreeModelColumn enabled_col; + Gtk::TreeModelColumn > patch_model_col; }; bool _enable_signal; diff --git a/src/libs/gui/Port.cpp b/src/libs/gui/Port.cpp index 0452edc6..ab574f88 100644 --- a/src/libs/gui/Port.cpp +++ b/src/libs/gui/Port.cpp @@ -28,6 +28,7 @@ #include "GladeFactory.hpp" using namespace Ingen::Client; +using namespace std; namespace Ingen { namespace GUI { @@ -35,9 +36,12 @@ namespace GUI { /** @param flip Make an input port appear as an output port, and vice versa. */ -Port::Port(boost::shared_ptr module, SharedPtr pm, bool flip) - : FlowCanvas::Port(module, - pm->path().name(), +Port::Port( + boost::shared_ptr module, + SharedPtr pm, + const string& name, + bool flip) + : FlowCanvas::Port(module, name, flip ? (!pm->is_input()) : pm->is_input(), App::instance().configuration()->get_port_color(pm.get())) , _port_model(pm) diff --git a/src/libs/gui/Port.hpp b/src/libs/gui/Port.hpp index 4851a63f..7b347194 100644 --- a/src/libs/gui/Port.hpp +++ b/src/libs/gui/Port.hpp @@ -38,7 +38,11 @@ namespace GUI { class Port : public FlowCanvas::Port { public: - Port(boost::shared_ptr module, SharedPtr pm, bool flip=false); + Port(boost::shared_ptr module, + SharedPtr pm, + const std::string& name, + bool flip=false); + ~Port(); SharedPtr model() const { return _port_model; } diff --git a/src/libs/gui/PortPropertiesWindow.cpp b/src/libs/gui/PortPropertiesWindow.cpp index 0129993b..ddab5715 100644 --- a/src/libs/gui/PortPropertiesWindow.cpp +++ b/src/libs/gui/PortPropertiesWindow.cpp @@ -24,7 +24,7 @@ #include "Controls.hpp" #include "PortPropertiesWindow.hpp" -using std::string; +using namespace std; namespace Ingen { namespace GUI { diff --git a/src/libs/gui/RenameWindow.cpp b/src/libs/gui/RenameWindow.cpp index 465b6b1b..b9c252d0 100644 --- a/src/libs/gui/RenameWindow.cpp +++ b/src/libs/gui/RenameWindow.cpp @@ -91,7 +91,6 @@ RenameWindow::name_changed() void RenameWindow::cancel_clicked() { - cout << "cancel\n"; _name_entry->set_text(""); hide(); } -- cgit v1.2.1