diff options
Diffstat (limited to 'src/progs')
-rw-r--r-- | src/progs/demolition/Makefile.am | 4 | ||||
-rw-r--r-- | src/progs/demolition/demolition.cpp | 8 | ||||
-rw-r--r-- | src/progs/ingenuity/Loader.cpp | 42 | ||||
-rw-r--r-- | src/progs/ingenuity/Loader.h | 16 | ||||
-rw-r--r-- | src/progs/ingenuity/Makefile.am | 11 | ||||
-rw-r--r-- | src/progs/ingenuity/NodeModule.cpp | 12 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchCanvas.cpp | 8 | ||||
-rw-r--r-- | src/progs/ingenuity/PatchPortModule.cpp | 16 | ||||
-rw-r--r-- | src/progs/patch_loader/Makefile.am | 10 | ||||
-rw-r--r-- | src/progs/patch_loader/patch_loader.cpp | 6 |
10 files changed, 72 insertions, 61 deletions
diff --git a/src/progs/demolition/Makefile.am b/src/progs/demolition/Makefile.am index b01b062b..fe2b20b6 100644 --- a/src/progs/demolition/Makefile.am +++ b/src/progs/demolition/Makefile.am @@ -1,11 +1,11 @@ EXTRA_DIST = README om_demolition_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS) $(LSIGCPP_CFLAGS) -om_demolition_LDADD = ../../libs/client/libomclient.la $(LOSC_LIBS) $(LXML2_LIBS) $(LSIGCPP_LIBS) +om_demolition_LDADD = ../../libs/client/libingenclient.la $(LOSC_LIBS) $(LXML2_LIBS) $(LSIGCPP_LIBS) bin_PROGRAMS = om_demolition -om_demolition_DEPENDENCIES = ../../libs/client/libomclient.la +om_demolition_DEPENDENCIES = ../../libs/client/libingenclient.la om_demolition_SOURCES = \ demolition.cpp \ diff --git a/src/progs/demolition/demolition.cpp b/src/progs/demolition/demolition.cpp index 3015200e..3693b5f3 100644 --- a/src/progs/demolition/demolition.cpp +++ b/src/progs/demolition/demolition.cpp @@ -229,8 +229,8 @@ create_patch() engine->create_patch(path, (rand()%8)+1); // Spread them out a bit for easier monitoring with ingenuity - engine->set_metadata(path, "module-x", 1600 + rand()%800 - 400); - engine->set_metadata(path, "module-y", 1200 + rand()%700 - 350); + engine->set_metadata(path, "ingenuity:module-x", 1600 + rand()%800 - 400); + engine->set_metadata(path, "ingenuity:module-y", 1200 + rand()%700 - 350); } @@ -255,8 +255,8 @@ add_node() engine->create_node(path, random_plugin(), rand()%2); // Spread them out a bit for easier monitoring with ingenuity - engine->set_metadata(path, "module-x", 1600 + rand()%800 - 400); - engine->set_metadata(path, "module-y", 1200 + rand()%700 - 350); + engine->set_metadata(path, "ingenuity:module-x", 1600 + rand()%800 - 400); + engine->set_metadata(path, "ingenuity:module-y", 1200 + rand()%700 - 350); } diff --git a/src/progs/ingenuity/Loader.cpp b/src/progs/ingenuity/Loader.cpp index 59d718c7..485e450d 100644 --- a/src/progs/ingenuity/Loader.cpp +++ b/src/progs/ingenuity/Loader.cpp @@ -18,7 +18,7 @@ #include <fstream> #include <cassert> #include <string> -#include "PatchLibrarian.h" +#include "Serializer.h" #include "PatchModel.h" using std::cout; using std::endl; @@ -26,9 +26,9 @@ namespace Ingenuity { Loader::Loader(CountedPtr<ModelEngineInterface> engine) -: _patch_librarian(new PatchLibrarian(engine)) +: _serializer(new Serializer(engine)) { - assert(_patch_librarian != NULL); + assert(_serializer != NULL); // FIXME: rework this so the thread is only present when it's doing something (save mem) start(); @@ -37,7 +37,7 @@ Loader::Loader(CountedPtr<ModelEngineInterface> engine) Loader::~Loader() { - delete _patch_librarian; + delete _serializer; } @@ -45,12 +45,12 @@ void Loader::_whipped() { _mutex.lock(); + + while ( ! _events.empty() ) { + _events.front()(); + _events.pop_front(); + } - Closure& ev = _event; - ev(); - ev.disconnect(); - - _cond.signal(); _mutex.unlock(); } @@ -65,23 +65,29 @@ Loader::load_patch(const string& filename, { _mutex.lock(); - _event = sigc::hide_return(sigc::bind( - sigc::mem_fun(_patch_librarian, &PatchLibrarian::load_patch), - filename, parent_path, name, poly, initial_data, existing)); + _events.push_back(sigc::hide_return(sigc::bind( + sigc::mem_fun(_serializer, &Serializer::load_patch), + filename, parent_path, name, poly, initial_data, existing))); - whip(); - - _cond.wait(_mutex); _mutex.unlock(); + + whip(); } void Loader::save_patch(CountedPtr<PatchModel> model, const string& filename, bool recursive) { - cerr << "FIXME: (loader) save patch\n"; - //cout << "[Loader] Saving patch " << filename << endl; - //set_event(new SavePatchEvent(m_patch_librarian, model, filename, recursive)); + _mutex.lock(); + + _events.push_back(sigc::hide_return(sigc::bind( + sigc::mem_fun(_serializer, &Serializer::save_patch), + model, filename, recursive))); + + _mutex.unlock(); + + whip(); } + } // namespace Ingenuity diff --git a/src/progs/ingenuity/Loader.h b/src/progs/ingenuity/Loader.h index a33945a1..7459378e 100644 --- a/src/progs/ingenuity/Loader.h +++ b/src/progs/ingenuity/Loader.h @@ -18,6 +18,7 @@ #define LOADERTHREAD_H #include <string> +#include <list> #include <cassert> #include "util/Thread.h" #include "util/Slave.h" @@ -26,9 +27,10 @@ #include "ModelEngineInterface.h" #include "ObjectModel.h" using std::string; +using std::list; namespace Ingen { namespace Client { - class PatchLibrarian; + class Serializer; class PatchModel; } } using namespace Ingen::Client; @@ -42,6 +44,9 @@ namespace Ingenuity { * blocking everything else, so the app can respond to the incoming events * caused as a result of the patch loading, while the patch loads. * + * Implemented as a slave with a list of closures (events) which processes + * all events in the (mutex protected) list each time it's whipped. + * * \ingroup Ingenuity */ class Loader : public Slave @@ -50,7 +55,7 @@ public: Loader(CountedPtr<ModelEngineInterface> engine); ~Loader(); - PatchLibrarian& librarian() { return *_patch_librarian; } + Serializer& serializer() const { return *_serializer; } void load_patch(const string& filename, const string& parent_path, @@ -69,10 +74,9 @@ private: void _whipped(); - PatchLibrarian* const _patch_librarian; - Mutex _mutex; - Condition _cond; - Closure _event; + Serializer* const _serializer; + Mutex _mutex; + list<Closure> _events; }; diff --git a/src/progs/ingenuity/Makefile.am b/src/progs/ingenuity/Makefile.am index 48b53f33..3044a2fc 100644 --- a/src/progs/ingenuity/Makefile.am +++ b/src/progs/ingenuity/Makefile.am @@ -6,14 +6,15 @@ MAINTAINERCLEANFILES = Makefile.in sharefilesdir = $(pkgdatadir) dist_sharefiles_DATA = ingenuity.glade om-icon.png -AM_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ -ingenuity_LDADD = @GTKMM_LIBS@ @LIBGLADEMM_LIBS@ @GNOMECANVASMM_LIBS@ @LOSC_LIBS@ @LASH_LIBS@ @FLOWCANVAS_LIBS@ ../../libs/client/libomclient.la -ingenuity_DEPENDENCIES = ../../libs/client/libomclient.la +ingenuity_CXXFLAGS = -DGTK_DISABLE_DEPRECATED -DGDK_DISABLE_DEPRECATED -I$(top_srcdir)/src/common -I$(top_srcdir)/src/libs/client -DPKGDATADIR=\"$(pkgdatadir)\" @GTKMM_CFLAGS@ @LIBGLADEMM_CFLAGS@ @GNOMECANVASMM_CFLAGS@ @LOSC_CFLAGS@ @LASH_CFLAGS@ @FLOWCANVAS_CFLAGS@ +ingenuity_LDADD = @GTKMM_LIBS@ @LIBGLADEMM_LIBS@ @GNOMECANVASMM_LIBS@ @LOSC_LIBS@ @LASH_LIBS@ @FLOWCANVAS_LIBS@ ../../libs/client/libingenclient.la +ingenuity_DEPENDENCIES = ../../libs/client/libingenclient.la # FIXME: make engine have a separate include dir if MONOLITHIC_INGENUITY -AM_CXXFLAGS += -I$(top_srcdir)/src/libs -ingenuity_LDADD += @JACK_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt ../../libs/engine/libingen.la +ingenuity_CXXFLAGS += -I$(top_srcdir)/src/libs +#ingenuity_LDADD += @JACK_LIBS@ @ALSA_LIBS@ @LASH_LIBS@ @SLV2_LIBS@ -lrt ../../libs/engine/libingen.la +ingenuity_LDADD += ../../libs/engine/libingen.la ingenuity_DEPENDENCIES += ../../libs/engine/libingen.la endif diff --git a/src/progs/ingenuity/NodeModule.cpp b/src/progs/ingenuity/NodeModule.cpp index 8545e493..29af857e 100644 --- a/src/progs/ingenuity/NodeModule.cpp +++ b/src/progs/ingenuity/NodeModule.cpp @@ -104,13 +104,13 @@ NodeModule::store_location() const float x = static_cast<float>(property_x()); const float y = static_cast<float>(property_y()); - const Atom& existing_x = m_node->get_metadata("module-x"); - const Atom& existing_y = m_node->get_metadata("module-y"); + const Atom& existing_x = m_node->get_metadata("ingenuity:canvas-x"); + const Atom& existing_y = m_node->get_metadata("ingenuity:canvas-y"); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_metadata(m_node->path(), "module-x", Atom(x)); - App::instance().engine()->set_metadata(m_node->path(), "module-y", Atom(y)); + App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_metadata(m_node->path(), "ingenuity:canvas-y", Atom(y)); } } @@ -126,9 +126,9 @@ NodeModule::on_right_click(GdkEventButton* event) void NodeModule::metadata_update(const string& key, const Atom& value) { - if (key == "module-x" && value.type() == Atom::FLOAT) + if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) move_to(value.get_float(), property_y()); - else if (key == "module-y" && value.type() == Atom::FLOAT) + else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) move_to(property_x(), value.get_float()); } diff --git a/src/progs/ingenuity/PatchCanvas.cpp b/src/progs/ingenuity/PatchCanvas.cpp index 9419b252..707b8856 100644 --- a/src/progs/ingenuity/PatchCanvas.cpp +++ b/src/progs/ingenuity/PatchCanvas.cpp @@ -217,9 +217,9 @@ PatchCanvas::connect(const LibFlowCanvas::Port* src_port, const LibFlowCanvas::P CountedPtr<PluginModel> pm(new PluginModel(PluginModel::Internal, "", "midi_control_in", "")); CountedPtr<NodeModel> nm(new NodeModel(pm, m_patch->path().base() + src->name() + "-" + dst->name(), false)); - nm->set_metadata("module-x", Atom((float) + nm->set_metadata("canvas-x", Atom((float) (dst->module()->property_x() - dst->module()->width() - 20))); - nm->set_metadata("module-y", Atom((float) + nm->set_metadata("canvas-y", Atom((float) (dst->module()->property_y()))); App::instance().engine()->create_node_from_model(nm.get()); App::instance().engine()->connect(src->model()->path(), nm->path() + "/MIDI_In"); @@ -332,8 +332,8 @@ PatchCanvas::get_initial_data() { MetadataMap result; - result["module-x"] = Atom((float)m_last_click_x); - result["module-y"] = Atom((float)m_last_click_y); + result["ingenuity:canvas-x"] = Atom((float)m_last_click_x); + result["ingenuity:canvas-y"] = Atom((float)m_last_click_y); return result; } diff --git a/src/progs/ingenuity/PatchPortModule.cpp b/src/progs/ingenuity/PatchPortModule.cpp index 369a04b1..8843882b 100644 --- a/src/progs/ingenuity/PatchPortModule.cpp +++ b/src/progs/ingenuity/PatchPortModule.cpp @@ -51,8 +51,8 @@ PatchPortModule::PatchPortModule(PatchCanvas* canvas, CountedPtr<PortModel> port resize(); - const Atom& x_atom = port->get_metadata("module-x"); - const Atom& y_atom = port->get_metadata("module-y"); + const Atom& x_atom = port->get_metadata("ingenuity:canvas-x"); + const Atom& y_atom = port->get_metadata("ingenuity:canvas-y"); if (x_atom && y_atom && x_atom.type() == Atom::FLOAT && y_atom.type() == Atom::FLOAT) { move_to(x_atom.get_float(), y_atom.get_float()); @@ -73,13 +73,13 @@ PatchPortModule::store_location() const float x = static_cast<float>(property_x()); const float y = static_cast<float>(property_y()); - const Atom& existing_x = m_port->get_metadata("module-x"); - const Atom& existing_y = m_port->get_metadata("module-y"); + const Atom& existing_x = m_port->get_metadata("ingenuity:canvas-x"); + const Atom& existing_y = m_port->get_metadata("ingenuity:canvas-y"); if (existing_x.type() != Atom::FLOAT || existing_y.type() != Atom::FLOAT || existing_x.get_float() != x || existing_y.get_float() != y) { - App::instance().engine()->set_metadata(m_port->path(), "module-x", Atom(x)); - App::instance().engine()->set_metadata(m_port->path(), "module-y", Atom(y)); + App::instance().engine()->set_metadata(m_port->path(), "ingenuity:canvas-x", Atom(x)); + App::instance().engine()->set_metadata(m_port->path(), "ingenuity:canvas-y", Atom(y)); } } @@ -87,9 +87,9 @@ PatchPortModule::store_location() void PatchPortModule::metadata_update(const string& key, const Atom& value) { - if (key == "module-x" && value.type() == Atom::FLOAT) + if (key == "ingenuity:canvas-x" && value.type() == Atom::FLOAT) move_to(value.get_float(), property_y()); - else if (key == "module-y" && value.type() == Atom::FLOAT) + else if (key == "ingenuity:canvas-y" && value.type() == Atom::FLOAT) move_to(property_x(), value.get_float()); } diff --git a/src/progs/patch_loader/Makefile.am b/src/progs/patch_loader/Makefile.am index c14814ff..33947a36 100644 --- a/src/progs/patch_loader/Makefile.am +++ b/src/progs/patch_loader/Makefile.am @@ -1,13 +1,13 @@ EXTRA_DIST = README -om_patch_loader_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common -DPKGDATADIR=\"$(pkgdatadir)\" $(LXML2_CFLAGS) $(LOSC_CFLAGS) $(LSIGCPP_CFLAGS) -om_patch_loader_LDADD = ../../libs/client/libomclient.la $(LOSC_LIBS) $(LXML2_LIBS) $(LSIGCPP_LIBS) +ingen_load_CXXFLAGS = -I$(top_srcdir)/src/libs/client -I$(top_srcdir)/src/common @LSIGCPP_CFLAGS@ +ingen_load_LDADD = ../../libs/client/libingenclient.la -bin_PROGRAMS = om_patch_loader +bin_PROGRAMS = ingen_load -om_patch_loader_DEPENDENCIES = ../../libs/client/libomclient.la +ingen_load_DEPENDENCIES = ../../libs/client/libingenclient.la -om_patch_loader_SOURCES = \ +ingen_load_SOURCES = \ patch_loader.cpp \ cmdline.h \ cmdline.c diff --git a/src/progs/patch_loader/patch_loader.cpp b/src/progs/patch_loader/patch_loader.cpp index 69a06407..b0d8bc94 100644 --- a/src/progs/patch_loader/patch_loader.cpp +++ b/src/progs/patch_loader/patch_loader.cpp @@ -16,7 +16,7 @@ #include "OSCModelEngineInterface.h" -#include "PatchLibrarian.h" +#include "Serializer.h" #include "PatchModel.h" #include "util/Path.h" #include <iostream> @@ -53,7 +53,7 @@ int main(int argc, char** argv) CountedPtr<OSCModelEngineInterface> engine(new OSCModelEngineInterface(engine_url)); - PatchLibrarian librarian(engine); + Serializer serializer(engine); /* Connect to engine */ engine->attach(-1, client_port); @@ -74,7 +74,7 @@ int main(int argc, char** argv) cerr << "FIXME: load patch" << endl; //CountedPtr<PatchModel> pm(new PatchModel("", 0)); //pm->filename(args_info.inputs[i]); - //librarian.load_patch(pm, true); + //serializer.load_patch(pm, true); } return 0; |