summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-03-12 07:37:52 +0000
committerDavid Robillard <d@drobilla.net>2012-03-12 07:37:52 +0000
commit8a69f9bdbf45a049d9dbb93a198dd92bda733927 (patch)
tree869e9b25cd1eb3f473b8674644c3a60f326d6696 /src
parentd2904911d85a2acf58543d831be27fc40b2e6841 (diff)
downloadingen-8a69f9bdbf45a049d9dbb93a198dd92bda733927.tar.gz
ingen-8a69f9bdbf45a049d9dbb93a198dd92bda733927.tar.bz2
ingen-8a69f9bdbf45a049d9dbb93a198dd92bda733927.zip
Move bundle patch finding stuff to ingen_lv2.cpp and simplify it to not require
the World. Remove all the heavyweight initialisation stuff from plugin library instantiation, just parse the manifest with Sord directly and don't initialise the World until the plugin is actually loaded. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4056 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/serialisation/Parser.cpp31
-rw-r--r--src/server/ingen_lv2.cpp101
2 files changed, 52 insertions, 80 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 1477e167..b84bedae 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -538,37 +538,6 @@ Parser::Parser(Ingen::Shared::World& world)
{
}
-Parser::PatchRecords
-Parser::find_patches(Ingen::Shared::World* world,
- SerdEnv* env,
- const Glib::ustring& manifest_uri)
-{
- const Sord::URI ingen_Patch (*world->rdf_world(), NS_INGEN "Patch");
- const Sord::URI rdf_type (*world->rdf_world(), NS_RDF "type");
- const Sord::URI rdfs_seeAlso(*world->rdf_world(), NS_RDFS "seeAlso");
-
- Sord::Model model(*world->rdf_world(), manifest_uri);
- model.load_file(env, SERD_TURTLE, manifest_uri);
-
- std::list<PatchRecord> records;
- for (Sord::Iter i = model.find(nil, rdf_type, ingen_Patch); !i.end(); ++i) {
- const Sord::Node patch = i.get_subject();
- Sord::Iter f = model.find(patch, rdfs_seeAlso, nil);
- std::string patch_uri_str = patch.to_c_string();
- if (patch_uri_str[0] == '/') {
- // FIXME: Kludge path to be a proper URI (not sure why this is happening)
- patch_uri_str = string("file://") + patch_uri_str;
- }
- if (!f.end()) {
- records.push_back(PatchRecord(patch_uri_str,
- f.get_object().to_c_string()));
- } else {
- LOG(error) << "Patch has no rdfs:seeAlso" << endl;
- }
- }
- return records;
-}
-
/** Parse a patch from RDF into a CommonInterface (engine or client).
* @return whether or not load was successful.
*/
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index a568531c..db8a642e 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -51,6 +51,8 @@
#include "ThreadManager.hpp"
#define NS_INGEN "http://drobilla.net/ns/ingen#"
+#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
/** Record of a patch in this Ingen LV2 bundle */
struct LV2Patch {
@@ -68,10 +70,7 @@ public:
typedef std::vector< SharedPtr<const LV2Patch> > Patches;
- Patches patches;
- Ingen::Shared::Configuration* conf;
- int argc;
- char** argv;
+ Patches patches;
};
/** Library state (constructed/destructed on library load/unload) */
@@ -249,9 +248,13 @@ private:
};
struct IngenPlugin {
- Ingen::Shared::World* world;
- MainThread* main;
- LV2_URID_Map* map;
+ Raul::Forge forge;
+ Ingen::Shared::Configuration* conf;
+ Ingen::Shared::World* world;
+ MainThread* main;
+ LV2_URID_Map* map;
+ int argc;
+ char** argv;
};
static LV2_Handle
@@ -276,13 +279,17 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
}
IngenPlugin* plugin = (IngenPlugin*)malloc(sizeof(IngenPlugin));
- plugin->world = new Ingen::Shared::World(lib.conf, lib.argc, lib.argv);
+ plugin->conf = new Ingen::Shared::Configuration(&plugin->forge);
+ plugin->world = new Ingen::Shared::World(plugin->conf,
+ plugin->argc,
+ plugin->argv);
if (!plugin->world->load_module("serialisation")) {
delete plugin->world;
return NULL;
}
- plugin->map = NULL;
+ plugin->main = NULL;
+ plugin->map = NULL;
for (int i = 0; features[i]; ++i) {
if (!strcmp(features[i]->URI, LV2_URID_URI "#map")) {
plugin->map = (LV2_URID_Map*)features[i]->data;
@@ -503,52 +510,48 @@ LV2Patch::LV2Patch(const std::string& u, const std::string& f)
descriptor.extension_data = ingen_extension_data;
}
-/** Library constructor (called on shared library load) */
-Lib::Lib()
- : argc(0)
- , argv(NULL)
+static Lib::Patches
+find_patches(const Glib::ustring& manifest_uri)
{
- if (!Glib::thread_supported())
- Glib::thread_init();
-
- using namespace Ingen;
-
- // FIXME
- Raul::Forge forge;
- conf = new Ingen::Shared::Configuration(&forge);
- Ingen::Shared::set_bundle_path_from_code((void*)&lv2_descriptor);
-
- Ingen::Shared::World* world = new Ingen::Shared::World(conf, argc, argv);
- if (!world->load_module("serialisation")) {
- delete world;
- return;
+ Sord::World world;
+ const Sord::URI base(world, manifest_uri);
+ const Sord::Node nil;
+ const Sord::URI ingen_Patch (world, NS_INGEN "Patch");
+ const Sord::URI rdf_type (world, NS_RDF "type");
+ const Sord::URI rdfs_seeAlso(world, NS_RDFS "seeAlso");
+
+ SerdEnv* env = serd_env_new(sord_node_to_serd_node(base.c_obj()));
+ Sord::Model model(world, manifest_uri);
+ model.load_file(env, SERD_TURTLE, manifest_uri);
+
+ Lib::Patches patches;
+ for (Sord::Iter i = model.find(nil, rdf_type, ingen_Patch); !i.end(); ++i) {
+ const Sord::Node patch = i.get_subject();
+ Sord::Iter f = model.find(patch, rdfs_seeAlso, nil);
+ const std::string patch_uri = patch.to_c_string();
+ if (!f.end()) {
+ const uint8_t* file_uri = f.get_object().to_u_string();
+ uint8_t* file_path = serd_file_uri_parse(file_uri, NULL);
+ patches.push_back(boost::shared_ptr<const LV2Patch>(
+ new LV2Patch(patch_uri, (const char*)file_path)));
+ free(file_path);
+ } else {
+ Raul::error << "[Ingen] Patch has no rdfs:seeAlso" << endl;
+ }
}
- assert(world->parser());
-
- typedef Serialisation::Parser::PatchRecords Records;
-
- const std::string manifest_path = Shared::bundle_file_path("manifest.ttl");
- const std::string manifest_uri = Glib::filename_to_uri(manifest_path);
- const SerdNode base_node = serd_node_from_string(
- SERD_URI, (const uint8_t*)manifest_uri.c_str());
-
- SerdEnv* env = serd_env_new(&base_node);
- Records records(
- world->parser()->find_patches(world, env, manifest_uri));
serd_env_free(env);
+ return patches;
+}
- for (Records::iterator i = records.begin(); i != records.end(); ++i) {
- uint8_t* path = serd_file_uri_parse((const uint8_t*)i->file_uri.c_str(), NULL);
- if (path) {
- patches.push_back(
- SharedPtr<const LV2Patch>(
- new LV2Patch(i->patch_uri.str(), (const char*)path)));
- }
- free(path);
- }
- delete world;
+/** Library constructor (called on shared library load) */
+Lib::Lib()
+{
+ Ingen::Shared::set_bundle_path_from_code((void*)&lv2_descriptor);
+
+ patches = find_patches(Glib::filename_to_uri(
+ Shared::bundle_file_path("manifest.ttl")));
}
/** Library destructor (called on shared library unload) */