From 75911e8ae28f011727ce303961a1adb56643689d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 25 Jul 2007 06:07:42 +0000 Subject: Fix running with ingen -eg. Start basic framework of an Ingen "Core" system/library (in module library for now). git-svn-id: http://svn.drobilla.net/lad/ingen@624 a436a847-0d15-0410-975c-d299462d15a1 --- src/libs/client/PluginModel.hpp | 1 - src/libs/client/SigClientInterface.hpp | 2 +- src/libs/engine/Engine.cpp | 7 ++-- src/libs/engine/Engine.hpp | 11 +++++- src/libs/engine/NodeFactory.cpp | 29 ++++++---------- src/libs/engine/NodeFactory.hpp | 6 ++-- src/libs/engine/QueuedEngineInterface.cpp | 1 + src/libs/engine/engine.cpp | 6 ++-- src/libs/engine/engine.hpp | 10 ++---- src/libs/gui/App.cpp | 28 +++++++++------ src/libs/gui/App.hpp | 17 ++++----- src/libs/gui/ConnectWindow.cpp | 5 +-- src/libs/gui/ConnectWindow.hpp | 8 ++++- src/libs/gui/LoadRemotePatchWindow.cpp | 7 ++-- src/libs/gui/PatchCanvas.cpp | 3 +- src/libs/gui/ThreadedLoader.cpp | 6 ++-- src/libs/gui/UploadPatchWindow.cpp | 3 +- src/libs/gui/gui.cpp | 20 ++--------- src/libs/gui/gui.hpp | 3 ++ src/libs/module/Makefile.am | 2 ++ src/libs/module/World.hpp | 58 +++++++++++++++++++++++++++++++ src/libs/module/module.cpp | 50 ++++++++++++++++++++++++++ src/libs/module/module.h | 39 +++++++++++++++++++++ src/progs/ingen/Makefile.am | 4 +-- src/progs/ingen/main.cpp | 36 +++++++------------ 25 files changed, 252 insertions(+), 110 deletions(-) create mode 100644 src/libs/module/World.hpp create mode 100644 src/libs/module/module.cpp create mode 100644 src/libs/module/module.h (limited to 'src') diff --git a/src/libs/client/PluginModel.hpp b/src/libs/client/PluginModel.hpp index f02528d1..63603687 100644 --- a/src/libs/client/PluginModel.hpp +++ b/src/libs/client/PluginModel.hpp @@ -103,7 +103,6 @@ public: static void set_slv2_world(SLV2World world) { _slv2_world = world; - slv2_world_load_all(_slv2_world); _slv2_plugins = slv2_world_get_all_plugins(_slv2_world); } diff --git a/src/libs/client/SigClientInterface.hpp b/src/libs/client/SigClientInterface.hpp index f19f4a5e..58a3297a 100644 --- a/src/libs/client/SigClientInterface.hpp +++ b/src/libs/client/SigClientInterface.hpp @@ -41,7 +41,7 @@ class SigClientInterface : virtual public Ingen::Shared::ClientInterface, public { public: - // Signal parameters math up directly with ClientInterface calls + // Signal parameters match up directly with ClientInterface calls sigc::signal response_sig; sigc::signal bundle_begin_sig; diff --git a/src/libs/engine/Engine.cpp b/src/libs/engine/Engine.cpp index 69f7ebe0..7b4c4f48 100644 --- a/src/libs/engine/Engine.cpp +++ b/src/libs/engine/Engine.cpp @@ -48,14 +48,15 @@ using namespace std; namespace Ingen { -Engine::Engine() -: _midi_driver(NULL), +Engine::Engine(Ingen::Shared::World* world) +: _world(world), + _midi_driver(NULL), _osc_driver(NULL), _maid(new Raul::Maid(maid_queue_size)), _post_processor(new PostProcessor(*_maid, post_processor_queue_size)), _broadcaster(new ClientBroadcaster()), _object_store(new ObjectStore()), - _node_factory(new NodeFactory()), + _node_factory(new NodeFactory(world)), /*#ifdef HAVE_LASH _lash_driver(new LashDriver()), #else */ diff --git a/src/libs/engine/Engine.hpp b/src/libs/engine/Engine.hpp index b9780501..fc64e024 100644 --- a/src/libs/engine/Engine.hpp +++ b/src/libs/engine/Engine.hpp @@ -18,6 +18,9 @@ #ifndef ENGINE_H #define ENGINE_H +#include "../../../config/config.h" +#include "module/module.h" + #include #include #include @@ -55,7 +58,8 @@ class Driver; class Engine : boost::noncopyable { public: - Engine(); + Engine(Ingen::Shared::World* world); + virtual ~Engine(); virtual int main(); @@ -90,8 +94,13 @@ public: /** Return the active driver for the given type */ Driver* driver(DataType type); + + Ingen::Shared::World* world() { return _world; } private: + + Ingen::Shared::World* _world; + SharedPtr _event_source; SharedPtr _audio_driver; MidiDriver* _midi_driver; diff --git a/src/libs/engine/NodeFactory.cpp b/src/libs/engine/NodeFactory.cpp index 24221dd7..30e13ac2 100644 --- a/src/libs/engine/NodeFactory.cpp +++ b/src/libs/engine/NodeFactory.cpp @@ -32,7 +32,6 @@ #ifdef HAVE_SLV2 #include "LV2Node.hpp" #include -#include // old slv2 compat #endif #ifdef HAVE_LADSPA #include "LADSPANode.hpp" @@ -41,9 +40,7 @@ #include "DSSINode.hpp" #endif -using std::string; -using std::cerr; using std::cout; using std::endl; - +using namespace std; namespace Ingen { @@ -54,14 +51,10 @@ namespace Ingen { -NodeFactory::NodeFactory() -: _has_loaded(false) +NodeFactory::NodeFactory(Ingen::Shared::World* world) + : _world(world) + , _has_loaded(false) { -#ifdef HAVE_SLV2 - _world = slv2_world_new(); - slv2_world_load_all(_world); -#endif - // Add builtin plugin types to _internal_plugins list // FIXME: ewwww, definitely a better way to do this! @@ -95,11 +88,6 @@ NodeFactory::~NodeFactory() for (list::iterator i = _libraries.begin(); i != _libraries.end(); ++i) delete (*i); _libraries.clear(); - -#ifdef HAVE_SLV2 - slv2_world_free(_world); -#endif - } @@ -270,7 +258,7 @@ NodeFactory::load_internal_plugin(const string& uri, void NodeFactory::load_lv2_plugins() { - SLV2Plugins plugins = slv2_world_get_all_plugins(_world); + SLV2Plugins plugins = slv2_world_get_all_plugins(_world->slv2_world); //cerr << "[NodeFactory] Found " << slv2_plugins_size(plugins) << " LV2 plugins:" << endl; @@ -300,7 +288,10 @@ NodeFactory::load_lv2_plugins() plug->module(NULL); // FIXME? plug->lib_path(slv2_uri_to_path(slv2_plugin_get_library_uri(lv2_plug))); char* name = slv2_plugin_get_name(lv2_plug); - assert(name); + if (!name) { + cerr << "ERROR: LV2 Plugin " << uri << " has no name. Ignoring." << endl; + continue; + } plug->name(name); free(name); @@ -308,7 +299,7 @@ NodeFactory::load_lv2_plugins() _plugins.push_back(plug); } - slv2_plugins_free(_world, plugins); + slv2_plugins_free(_world->slv2_world, plugins); } diff --git a/src/libs/engine/NodeFactory.hpp b/src/libs/engine/NodeFactory.hpp index 3b8eb711..184af94c 100644 --- a/src/libs/engine/NodeFactory.hpp +++ b/src/libs/engine/NodeFactory.hpp @@ -19,6 +19,7 @@ #define NODEFACTORY_H #include "../../../../config/config.h" +#include "module/module.h" #include #include @@ -52,7 +53,7 @@ class Plugin; class NodeFactory { public: - NodeFactory(); + NodeFactory(Ingen::Shared::World* world); ~NodeFactory(); void load_plugins(); @@ -72,8 +73,6 @@ private: #ifdef HAVE_SLV2 void load_lv2_plugins(); Node* load_lv2_plugin(const string& plugin_uri, const string& name, size_t poly, Patch* parent, SampleRate srate, size_t buffer_size); - - SLV2World _world; #endif #ifdef HAVE_DSSI @@ -87,6 +86,7 @@ private: list _internal_plugins; list _plugins; // FIXME: make a map + Ingen::Shared::World* _world; bool _has_loaded; }; diff --git a/src/libs/engine/QueuedEngineInterface.cpp b/src/libs/engine/QueuedEngineInterface.cpp index a8906c97..68115d79 100644 --- a/src/libs/engine/QueuedEngineInterface.cpp +++ b/src/libs/engine/QueuedEngineInterface.cpp @@ -99,6 +99,7 @@ QueuedEngineInterface::load_plugins() void QueuedEngineInterface::activate() { + QueuedEventSource::activate(); push_queued(new PingQueuedEvent(_engine, _responder, now())); } diff --git a/src/libs/engine/engine.cpp b/src/libs/engine/engine.cpp index bc272663..53db86f8 100644 --- a/src/libs/engine/engine.cpp +++ b/src/libs/engine/engine.cpp @@ -15,6 +15,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "../../../../config/config.h" + #include #include "engine.hpp" #include "Engine.hpp" @@ -25,10 +27,10 @@ namespace Ingen { Engine* -new_engine() +new_engine(Ingen::Shared::World* world) { set_denormal_flags(); - return new Engine(); + return new Engine(world); } diff --git a/src/libs/engine/engine.hpp b/src/libs/engine/engine.hpp index 940db440..93b426ac 100644 --- a/src/libs/engine/engine.hpp +++ b/src/libs/engine/engine.hpp @@ -18,20 +18,16 @@ #ifndef INGEN_ENGINE_H #define INGEN_ENGINE_H -#include - namespace Ingen { -class Engine; -namespace Shared { class EngineInterface; } +namespace Shared { class World; } +class Engine; extern "C" { - //void run(int argc, char** argv); - /** Create a new engine in this process */ - Engine* new_engine(); + Engine* new_engine(Ingen::Shared::World* world); /** Launch an OSC engine as a completely separate process * \return true if successful diff --git a/src/libs/gui/App.cpp b/src/libs/gui/App.cpp index acebf04e..7b1204d2 100644 --- a/src/libs/gui/App.cpp +++ b/src/libs/gui/App.cpp @@ -16,6 +16,7 @@ */ #include "../../../config/config.h" +#include "module/module.h" #include "App.hpp" #include #include @@ -44,6 +45,9 @@ /*#ifdef HAVE_LASH #include "LashController.hpp" #endif*/ +#ifdef HAVE_SLV2 +#include +#endif using std::cerr; using std::cout; using std::endl; using std::string; namespace Ingen { namespace Client { class PluginModel; } } @@ -59,10 +63,11 @@ class Port; App* App::_instance = 0; -App::App() +App::App(Ingen::Shared::World* world) : _configuration(new Configuration()), _about_dialog(NULL), _window_factory(new WindowFactory()), + _world(world), _enable_signal(true) { Glib::RefPtr glade_xml = GladeFactory::new_glade_reference(); @@ -73,18 +78,19 @@ App::App() glade_xml->get_widget_derived("config_win", _config_window); glade_xml->get_widget("about_win", _about_dialog); - _rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#"); - _rdf_world.add_prefix("ingen", "http://drobilla.net/ns/ingen#"); - _rdf_world.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#"); - _rdf_world.add_prefix("lv2", "http://lv2plug.in/ns/lv2core#"); - _rdf_world.add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); - _rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#"); + Raul::RDF::World& rdf_world = world->rdf_world; + + rdf_world.add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#"); + rdf_world.add_prefix("ingen", "http://drobilla.net/ns/ingen#"); + rdf_world.add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#"); + rdf_world.add_prefix("lv2", "http://lv2plug.in/ns/lv2core#"); + rdf_world.add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#"); + rdf_world.add_prefix("doap", "http://usefulinc.com/ns/doap#"); _config_window->configuration(_configuration); #ifdef HAVE_SLV2 - SLV2World slv2_world = slv2_world_new_using_rdf_world(_rdf_world.world()); - PluginModel::set_slv2_world(slv2_world); + PluginModel::set_slv2_world(world->slv2_world); #endif } @@ -93,9 +99,9 @@ App::~App() { } - void App::run(int argc, char** argv, + Ingen::Shared::World* world, SharedPtr engine, SharedPtr interface) { @@ -103,7 +109,7 @@ App::run(int argc, char** argv, Gtk::Main main(argc, argv); if (!_instance) - _instance = new App(); + _instance = new App(world); /* Load settings */ _instance->configuration()->load_settings(); diff --git a/src/libs/gui/App.hpp b/src/libs/gui/App.hpp index 97bbb661..4ef36718 100644 --- a/src/libs/gui/App.hpp +++ b/src/libs/gui/App.hpp @@ -28,13 +28,14 @@ #include #include #include -using std::string; using std::map; using std::list; -using std::cerr; using std::endl; + +using namespace std; namespace Ingen { class Engine; namespace Shared { class EngineInterface; + class World; } namespace Client { class PatchModel; @@ -92,8 +93,6 @@ public: Configuration* configuration() const { return _configuration; } WindowFactory* window_factory() const { return _window_factory; } - Raul::RDF::World* rdf_world() { return &_rdf_world; } - const SharedPtr& engine() const { return _engine; } const SharedPtr& client() const { return _client; } const SharedPtr& store() const { return _store; } @@ -102,15 +101,17 @@ public: static inline App& instance() { assert(_instance); return *_instance; } static void run(int argc, char** argv, + Ingen::Shared::World* world, SharedPtr engine, SharedPtr interface); + Ingen::Shared::World* world() { return _world; } + protected: - App(); + App(Ingen::Shared::World* world); + static App* _instance; - static void instantiate(int argc, char** argv); - SharedPtr _engine; SharedPtr _client; SharedPtr _store; @@ -125,7 +126,7 @@ protected: Gtk::Dialog* _about_dialog; WindowFactory* _window_factory; - Raul::RDF::World _rdf_world; + Ingen::Shared::World* _world; /** Used to avoid feedback loops with (eg) process checkbutton * FIXME: Maybe this should be globally implemented at the Controller level, diff --git a/src/libs/gui/ConnectWindow.cpp b/src/libs/gui/ConnectWindow.cpp index 86660d40..ca9dbbbc 100644 --- a/src/libs/gui/ConnectWindow.cpp +++ b/src/libs/gui/ConnectWindow.cpp @@ -229,7 +229,7 @@ ConnectWindow::connect() } else if (_mode == INTERNAL) { assert(_new_engine); - SharedPtr engine(_new_engine()); + SharedPtr engine(_new_engine(App::instance().world())); engine->start_jack_driver(); @@ -371,7 +371,8 @@ ConnectWindow::gtk_callback() //App::instance().engine()->register_client(App::instance().engine()->client_hooks()); // FIXME //auto_ptr client(new ThreadedSigClientInterface(); - App::instance().engine()->register_client("FIXME_CLIENT_URI", App::instance().client()); + // FIXME: client URI + App::instance().engine()->register_client("", App::instance().client()); App::instance().engine()->load_plugins(); ++_connect_stage; } else if (_connect_stage == 3) { diff --git a/src/libs/gui/ConnectWindow.hpp b/src/libs/gui/ConnectWindow.hpp index 5a0e67ad..fe26d549 100644 --- a/src/libs/gui/ConnectWindow.hpp +++ b/src/libs/gui/ConnectWindow.hpp @@ -18,6 +18,12 @@ #ifndef CONNECT_WINDOW_H #define CONNECT_WINDOW_H +#include "../../../config/config.h" + +#ifdef HAVE_SLV2 +#include +#endif + #include #include #include @@ -70,7 +76,7 @@ private: int _connect_stage; SharedPtr _engine_module; - Ingen::Engine* (*_new_engine)(); + Ingen::Engine* (*_new_engine)(Ingen::Shared::World* world); Gtk::Image* _icon; Gtk::ProgressBar* _progress_bar; diff --git a/src/libs/gui/LoadRemotePatchWindow.cpp b/src/libs/gui/LoadRemotePatchWindow.cpp index 096f6d61..77a03386 100644 --- a/src/libs/gui/LoadRemotePatchWindow.cpp +++ b/src/libs/gui/LoadRemotePatchWindow.cpp @@ -15,6 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "module/module.h" #include "LoadRemotePatchWindow.hpp" #include #include @@ -65,17 +66,17 @@ LoadRemotePatchWindow::present(SharedPtr patch, MetadataMap data) set_patch(patch); _initial_data = data; - RDF::Model model(*App::instance().rdf_world(), + RDF::Model model(App::instance().world()->rdf_world, "http://rdf.drobilla.net/ingen_patches/index.ttl", "http://rdf.drobilla.net/ingen_patches/"); - RDF::Query query(*App::instance().rdf_world(), Glib::ustring( + RDF::Query query(App::instance().world()->rdf_world, Glib::ustring( "SELECT DISTINCT ?name ?uri WHERE {" " ?uri a ingen:Patch ;" " doap:name ?name ." "}")); - RDF::Query::Results results = query.run(*App::instance().rdf_world(), model); + RDF::Query::Results results = query.run(App::instance().world()->rdf_world, model); for (RDF::Query::Results::iterator i = results.begin(); i != results.end(); ++i) { Gtk::TreeModel::iterator iter = _liststore->append(); diff --git a/src/libs/gui/PatchCanvas.cpp b/src/libs/gui/PatchCanvas.cpp index ba7a58ce..8f6b53e9 100644 --- a/src/libs/gui/PatchCanvas.cpp +++ b/src/libs/gui/PatchCanvas.cpp @@ -16,6 +16,7 @@ */ #include "../../../../config/config.h" +#include "module/module.h" #include #include @@ -425,7 +426,7 @@ PatchCanvas::destroy_selection() void PatchCanvas::copy_selection() { - Serializer serializer(*App::instance().rdf_world()); + Serializer serializer(App::instance().world()->rdf_world); serializer.start_to_string(); for (list >::iterator m = _selected_items.begin(); m != _selected_items.end(); ++m) { diff --git a/src/libs/gui/ThreadedLoader.cpp b/src/libs/gui/ThreadedLoader.cpp index 653f18b0..63c5bf3c 100644 --- a/src/libs/gui/ThreadedLoader.cpp +++ b/src/libs/gui/ThreadedLoader.cpp @@ -19,7 +19,7 @@ #include #include #include "client/PatchModel.hpp" -#include "module/Module.hpp" +#include "module/module.h" #include "App.hpp" #include "ThreadedLoader.hpp" using std::cout; using std::endl; @@ -32,7 +32,7 @@ ThreadedLoader::ThreadedLoader(SharedPtr engine) : _serialisation_module(Ingen::Shared::load_module("ingen_serialisation")) , _engine(engine) , _deprecated_loader(engine) - , _serializer(*App::instance().rdf_world()) + , _serializer(App::instance().world()->rdf_world) { set_name("Loader"); @@ -97,7 +97,7 @@ ThreadedLoader::load_patch(bool merge, _events.push_back(sigc::hide_return(sigc::bind( sigc::mem_fun(_loader.get(), &Ingen::Serialisation::Loader::load), App::instance().engine(), - App::instance().rdf_world(), + &App::instance().world()->rdf_world, data_base_uri, engine_parent, (engine_name) ? engine_name.get() : "", diff --git a/src/libs/gui/UploadPatchWindow.cpp b/src/libs/gui/UploadPatchWindow.cpp index 46be0987..aec4d8e6 100644 --- a/src/libs/gui/UploadPatchWindow.cpp +++ b/src/libs/gui/UploadPatchWindow.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "module/module.h" #include "interface/EngineInterface.hpp" #include "client/Serializer.hpp" #include "client/PatchModel.hpp" @@ -247,7 +248,7 @@ UploadPatchWindow::upload_clicked() _upload_progress->set_fraction(0.0); _upload_progress->set_text(""); - Serializer s(*App::instance().rdf_world()); + Serializer s(App::instance().world()->rdf_world); s.start_to_string(); s.serialize(_patch); const string str = s.finish(); diff --git a/src/libs/gui/gui.cpp b/src/libs/gui/gui.cpp index 689adf62..ca160e00 100644 --- a/src/libs/gui/gui.cpp +++ b/src/libs/gui/gui.cpp @@ -25,27 +25,11 @@ namespace GUI { void run(int argc, char** argv, + Ingen::Shared::World* world, SharedPtr engine, SharedPtr interface) { - App::run(argc, argv, engine, interface); -#if 0 - Gnome::Canvas::init(); - Gtk::Main gtk_main(argc, argv); - Gtk::Window::set_default_icon_from_file(PKGDATADIR "/ingen.svg"); - - /* Instantiate singleton (bad, FIXME) */ - App::instantiate(argc, argv); - - /* Load settings */ - App::instance().configuration()->load_settings(); - App::instance().configuration()->apply_settings(); - - App::instance().connect_window()->start(); - gtk_main.run(); - - return 0; -#endif + App::run(argc, argv, world, engine, interface); } diff --git a/src/libs/gui/gui.hpp b/src/libs/gui/gui.hpp index 992aa9d4..d99e4091 100644 --- a/src/libs/gui/gui.hpp +++ b/src/libs/gui/gui.hpp @@ -18,6 +18,8 @@ #ifndef INGEN_GUI_H #define INGEN_GUI_H +#include "../../../config/config.h" +#include "module/module.h" #include namespace Ingen { @@ -32,6 +34,7 @@ namespace GUI { extern "C" { void run(int argc, char** argv, + Ingen::Shared::World* world, SharedPtr engine, SharedPtr interface); diff --git a/src/libs/module/Makefile.am b/src/libs/module/Makefile.am index bcd2ea4f..7f5865db 100644 --- a/src/libs/module/Makefile.am +++ b/src/libs/module/Makefile.am @@ -5,5 +5,7 @@ libingen_module_la_CXXFLAGS = -I$(top_srcdir)/raul -DINGEN_MODULE_DIR=\"$(libdir libingen_module_la_LIBADD = @RAUL_LIBS@ @GLIBMM_LIBS@ libingen_module_la_SOURCES = \ + module.h \ + module.cpp \ Module.hpp \ Module.cpp diff --git a/src/libs/module/World.hpp b/src/libs/module/World.hpp new file mode 100644 index 00000000..c809080b --- /dev/null +++ b/src/libs/module/World.hpp @@ -0,0 +1,58 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_WORLD_HPP +#define INGEN_WORLD_HPP + +#include +#include +#include +#include + +#include "../../../../config/config.h" + +#ifdef HAVE_SLV2 +#include +#endif + +namespace Ingen { +namespace Shared { + + +/** The "world" all Ingen modules may share. + * + * This is required for shared access to things like Redland, so locking can + * take place centrally and the engine/gui using the same library won't + * explode horribly. + * + * Hopefully at some point in the future it can allow some fun things like + * scripting bindings that play with all loaded components of + * The Ingen System(TM) and whatnot. + */ +struct World { +#ifdef HAVE_SLV2 + SLV2World slv2_world; +#endif + Raul::RDF::World rdf_world; +}; + + +} // namespace Shared +} // namespace Ingen + +#endif // INGEN_WORLD_HPP + diff --git a/src/libs/module/module.cpp b/src/libs/module/module.cpp new file mode 100644 index 00000000..25c68c67 --- /dev/null +++ b/src/libs/module/module.cpp @@ -0,0 +1,50 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "module.h" +#include "World.hpp" + +namespace Ingen { +namespace Shared { + +World* world; + +World* +get_world() +{ + if (!world) { + world = new World(); +#ifdef HAVE_SLV2 + world->slv2_world = slv2_world_new_using_rdf_world(world->rdf_world.world()); + slv2_world_load_all(world->slv2_world); +#endif + } + + return world; +} + +void +destroy_world() +{ + slv2_world_free(world->slv2_world); + delete world; +} + + +} // namesace Shared +} // namespace Ingen + diff --git a/src/libs/module/module.h b/src/libs/module/module.h new file mode 100644 index 00000000..6c809f7e --- /dev/null +++ b/src/libs/module/module.h @@ -0,0 +1,39 @@ +/* This file is part of Ingen. + * Copyright (C) 2007 Dave Robillard + * + * Ingen is free software; you can redistribute it and/or modify it under the + * terms of the GNU General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) any later + * version. + * + * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef INGEN_MODULE_H +#define INGEN_MODULE_H + +#include "World.hpp" +#include "Module.hpp" + +namespace Ingen { +namespace Shared { + +extern "C" { + + World* get_world(); + void destroy_world(); + +} + + +} // namesace Shared +} // namespace Ingen + +#endif // INGEN_MODULE_H + diff --git a/src/progs/ingen/Makefile.am b/src/progs/ingen/Makefile.am index 7f84191e..9226d6aa 100644 --- a/src/progs/ingen/Makefile.am +++ b/src/progs/ingen/Makefile.am @@ -1,4 +1,4 @@ -AM_CXXFLAGS = -I$(top_srcdir)/raul -I$(top_srcdir)/ingen/src/common -I$(top_srcdir)/ingen/src/libs -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" @GTHREAD_CFLAGS@ @GLIBMM_CFLAGS@ +AM_CXXFLAGS = -I$(top_srcdir)/slv2 -I$(top_srcdir)/raul -I$(top_srcdir)/ingen/src/common -I$(top_srcdir)/ingen/src/libs -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" @GTHREAD_CFLAGS@ @GLIBMM_CFLAGS@ MAINTAINERCLEANFILES = Makefile.in @@ -6,7 +6,7 @@ desktopfilesdir = $(datadir)/applications dist_desktopfiles_DATA = ingen.desktop bin_PROGRAMS = ingen -ingen_LDADD = @RAUL_LIBS@ @GTHREAD_LIBS@ @GLIBMM_LIBS@ ../../libs/module/libingen_module.la +ingen_LDADD = @SLV2_LIBS@ @RAUL_LIBS@ @GTHREAD_LIBS@ @GLIBMM_LIBS@ ../../libs/module/libingen_module.la ingen_DEPENDENCIES = ../../libs/module/libingen_module.la ingen_SOURCES = \ diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp index 68c0abdc..5f4070b9 100644 --- a/src/progs/ingen/main.cpp +++ b/src/progs/ingen/main.cpp @@ -27,7 +27,7 @@ #include #include #include -#include "module/Module.hpp" +#include "module/module.h" #include "engine/Engine.hpp" #include "engine/QueuedEngineInterface.hpp" #include "serialisation/Loader.hpp" @@ -75,32 +75,20 @@ main(int argc, char** argv) Glib::thread_init(); + Ingen::Shared::World* world = Ingen::Shared::get_world(); + /* Run engine */ if (args.engine_flag) { engine_module = Ingen::Shared::load_module("ingen_engine"); if (engine_module) { - /*if (args.engine_port_given) { - bool (*launch_engine)(int) = NULL; - if ( ! module->get_symbol("launch_osc_engine", (void*&)launch_engine)) - module.reset(); - else - launch_engine(args.engine_port_arg); - - } else if (args.gui_given || args.load_given) {*/ - Engine* (*new_engine)() = NULL; - if (engine_module->get_symbol("new_engine", (void*&)new_engine)) { - engine = SharedPtr(new_engine()); - //engine->start_jack_driver(); - //engine->start_osc_driver(args.engine_port_arg); - } else { - engine_module.reset(); - } - - /*} else { - cerr << "Nonsense command line parameters, engine not loaded." << endl; - }*/ + Engine* (*new_engine)(Ingen::Shared::World* world) = NULL; + if (engine_module->get_symbol("new_engine", (void*&)new_engine)) { + engine = SharedPtr(new_engine(world)); + } else { + engine_module.reset(); + } } else { cerr << "Unable to load engine module, engine not loaded." << endl; cerr << "Try using src/set_dev_environment.sh, or setting INGEN_MODULE_PATH." << endl; @@ -194,12 +182,12 @@ main(int argc, char** argv) bool ran_gui = false; if (args.gui_given) { gui_module = Ingen::Shared::load_module("ingen_gui"); - void (*run)(int, char**, SharedPtr, SharedPtr) = NULL; + void (*run)(int, char**, Ingen::Shared::World*, SharedPtr, SharedPtr) = NULL; bool found = gui_module->get_symbol("run", (void*&)run); if (found) { ran_gui = true; - run(argc, argv, engine, engine_interface); + run(argc, argv, world, engine, engine_interface); } else { cerr << "Unable to find GUI module, GUI not loaded." << endl; cerr << "Try using src/set_dev_environment.sh, or setting INGEN_MODULE_PATH." << endl; @@ -224,6 +212,8 @@ main(int argc, char** argv) engine.reset(); } + Ingen::Shared::destroy_world(); + return 0; } -- cgit v1.2.1