From 7e5bf17f9e14b4a24346c402bf5fcf88772c50f3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 9 Feb 2012 23:23:54 +0000 Subject: Portability fixes (plugins work on OSX). --- plugins/eg-amp.lv2/amp.ttl | 2 +- plugins/eg-amp.lv2/manifest.ttl | 91 ---------------------------------- plugins/eg-amp.lv2/manifest.ttl.in | 91 ++++++++++++++++++++++++++++++++++ plugins/eg-amp.lv2/wscript | 18 +++++-- plugins/eg-sampler.lv2/manifest.ttl | 7 --- plugins/eg-sampler.lv2/manifest.ttl.in | 13 +++++ plugins/eg-sampler.lv2/sampler.c | 18 +++---- plugins/eg-sampler.lv2/sampler.ttl | 5 +- plugins/eg-sampler.lv2/wscript | 17 +++++-- 9 files changed, 140 insertions(+), 122 deletions(-) delete mode 100644 plugins/eg-amp.lv2/manifest.ttl create mode 100644 plugins/eg-amp.lv2/manifest.ttl.in delete mode 100644 plugins/eg-sampler.lv2/manifest.ttl create mode 100644 plugins/eg-sampler.lv2/manifest.ttl.in diff --git a/plugins/eg-amp.lv2/amp.ttl b/plugins/eg-amp.lv2/amp.ttl index 7d3d9e6..1fe7dc7 100644 --- a/plugins/eg-amp.lv2/amp.ttl +++ b/plugins/eg-amp.lv2/amp.ttl @@ -1,6 +1,6 @@ # LV2 Amp Example Plugin +# Copyright 2006-2012 David Robillard # Copyright 2006-2011 Steve Harris -# Copyright 2006-2011 David Robillard # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above diff --git a/plugins/eg-amp.lv2/manifest.ttl b/plugins/eg-amp.lv2/manifest.ttl deleted file mode 100644 index 821c977..0000000 --- a/plugins/eg-amp.lv2/manifest.ttl +++ /dev/null @@ -1,91 +0,0 @@ -# LV2 Bundle Manifest -# -# All LV2 plugins are installed as "bundles", a directory with a particular -# format. Inside the bundle, the entry point is a file called "manifest.ttl". -# This file lists what plugins are in this bundle, and which files are (.so, -# .ttl, etc.) are associated with those plugins. -# -# Hosts read bundles' manifest.ttl to discover what plugins (and other -# resources) are available. Manifest files should be as small as possible for -# performance reasons. -# -# The syntax of this file (and most other LV2 data files) is a language called -# Turtle ("Turse RDF Triple Language").[1] RDF[3] is a data model that -# expresses the relationship between things as (subject, predicate, object) -# triples. Turtle is a simple, terse, abbreviated syntax for RDF. - -# Namespace Prefixes - -@prefix lv2: . -@prefix rdfs: . - -# Data (list of resources in this bundle, hence "manifest") - - - a lv2:Plugin ; - lv2:binary ; - rdfs:seeAlso . - -# Explanation -# -# In short, this declares that the resource with URI -# "http://lv2plug.in/plugins/eg-amp") is an LV2 plugin, with executable code in -# the file "amp.so" and a full description in "amp.ttl". These paths are -# relative to the bundle directory. -# -# There are 3 statements in this description: -# -# # | Subject | Predicate | Object -# ------------------------------------------------------------------- -# 1 | | a | lv2:Plugin -# 2 | | lv2:binary | -# 3 | | rdfs:seeAlso | -# -# The semicolon is used to continue the previous subject, an equivalent -# but more verbose syntax for the same data is: -# -# a lv2:Plugin . -# lv2:binary ; -# rdfs:seeAlso . -# -# Note that the documentation for a URI can often be found by visiting that URI -# in a web browser, e.g. the documentation for lv2:binary can be found at -# . If you encounter a predicate in some -# data which you do not understand, try this first. -# -# Note the URI of a plugin does NOT need to be an actual web address, it's just -# a global identifier. It is, however, a good idea to use an actual web -# address if possible, since it can be used to easily access documentation, -# downloads, etc. Note there are compatibility rules for when the URI of a -# plugin must be changed, see the LV2 specification[4] for details. -# -# A detailed explanation of each statement follows. -# -# 1: a lv2:Plugin -# -# The "a" is a Turtle shortcut for rdf:type and more or less means "is a". -# lv2:Plugin expands to (using the -# "lv2:" prefix above) and is the established URI for the type "LV2 Plugin". -# This statement literally means "this resource is an LV2 plugin". -# -# 2: lv2:binary -# -# This says "this plugin has executable code ("binary") in the file -# named "amp.so", which is located in this bundle. The LV2 specification -# defines that all relative URIs in manifest files are relative to the bundle -# directory, so this refers to the file amp.so in the same directory as this -# manifest.ttl file. -# -# 3: rdfs:seeAlso -# -# This says "there is more information about this plugin located in the file -# "amp.ttl". The host will look at all such files when it needs to actually -# use or investigate the plugin. - -# Footnotes -# -# [1] http://www.w3.org/TeamSubmission/turtle/ -# [2] http://www.w3.org/RDF/ -# http://www.w3.org/TR/2004/REC-rdf-primer-20040210/ -# [3] http://tools.ietf.org/html/rfc3986 -# [4] http://lv2plug.in/ns/lv2core \ No newline at end of file diff --git a/plugins/eg-amp.lv2/manifest.ttl.in b/plugins/eg-amp.lv2/manifest.ttl.in new file mode 100644 index 0000000..c642766 --- /dev/null +++ b/plugins/eg-amp.lv2/manifest.ttl.in @@ -0,0 +1,91 @@ +# LV2 Bundle Manifest +# +# All LV2 plugins are installed as "bundles", a directory with a particular +# format. Inside the bundle, the entry point is a file called "manifest.ttl". +# This file lists what plugins are in this bundle, and which files are (.so, +# .ttl, etc.) are associated with those plugins. +# +# Hosts read bundles' manifest.ttl to discover what plugins (and other +# resources) are available. Manifest files should be as small as possible for +# performance reasons. +# +# The syntax of this file (and most other LV2 data files) is a language called +# Turtle ("Turse RDF Triple Language").[1] RDF[3] is a data model that +# expresses the relationship between things as (subject, predicate, object) +# triples. Turtle is a simple, terse, abbreviated syntax for RDF. + +# Namespace Prefixes + +@prefix lv2: . +@prefix rdfs: . + +# Data (list of resources in this bundle, hence "manifest") + + + a lv2:Plugin ; + lv2:binary ; + rdfs:seeAlso . + +# Explanation +# +# In short, this declares that the resource with URI +# "http://lv2plug.in/plugins/eg-amp") is an LV2 plugin, with executable code in +# the file "amp.so" and a full description in "amp.ttl". These paths are +# relative to the bundle directory. +# +# There are 3 statements in this description: +# +# # | Subject | Predicate | Object +# ------------------------------------------------------------------- +# 1 | | a | lv2:Plugin +# 2 | | lv2:binary | +# 3 | | rdfs:seeAlso | +# +# The semicolon is used to continue the previous subject, an equivalent +# but more verbose syntax for the same data is: +# +# a lv2:Plugin . +# lv2:binary ; +# rdfs:seeAlso . +# +# Note that the documentation for a URI can often be found by visiting that URI +# in a web browser, e.g. the documentation for lv2:binary can be found at +# . If you encounter a predicate in some +# data which you do not understand, try this first. +# +# Note the URI of a plugin does NOT need to be an actual web address, it's just +# a global identifier. It is, however, a good idea to use an actual web +# address if possible, since it can be used to easily access documentation, +# downloads, etc. Note there are compatibility rules for when the URI of a +# plugin must be changed, see the LV2 specification[4] for details. +# +# A detailed explanation of each statement follows. +# +# 1: a lv2:Plugin +# +# The "a" is a Turtle shortcut for rdf:type and more or less means "is a". +# lv2:Plugin expands to (using the +# "lv2:" prefix above) and is the established URI for the type "LV2 Plugin". +# This statement literally means "this resource is an LV2 plugin". +# +# 2: lv2:binary +# +# This says "this plugin has executable code ("binary") in the file +# named "amp.so", which is located in this bundle. The LV2 specification +# defines that all relative URIs in manifest files are relative to the bundle +# directory, so this refers to the file amp.so in the same directory as this +# manifest.ttl file. +# +# 3: rdfs:seeAlso +# +# This says "there is more information about this plugin located in the file +# "amp.ttl". The host will look at all such files when it needs to actually +# use or investigate the plugin. + +# Footnotes +# +# [1] http://www.w3.org/TeamSubmission/turtle/ +# [2] http://www.w3.org/RDF/ +# http://www.w3.org/TR/2004/REC-rdf-primer-20040210/ +# [3] http://tools.ietf.org/html/rfc3986 +# [4] http://lv2plug.in/ns/lv2core \ No newline at end of file diff --git a/plugins/eg-amp.lv2/wscript b/plugins/eg-amp.lv2/wscript index 3eda122..37ab9b7 100644 --- a/plugins/eg-amp.lv2/wscript +++ b/plugins/eg-amp.lv2/wscript @@ -40,12 +40,20 @@ def configure(conf): def build(bld): bundle = 'eg-amp.lv2' - # Copy data files to build bundle (build/eg-amp.lv2) - for i in [ 'amp.ttl', 'manifest.ttl' ]: - bld(rule = 'cp ${SRC} ${TGT}', + # Build manifest.ttl by substitution (for portable lib extension) + bld(features = 'subst', + source = 'manifest.ttl.in', + target = '%s/%s' % (bundle, 'manifest.ttl'), + install_path = '${LV2DIR}/%s' % bundle, + LIB_EXT = bld.env['pluginlib_EXT']) + + # Copy other data files to build bundle (build/eg-amp.lv2) + for i in [ 'amp.ttl' ]: + bld(features = 'subst', source = i, - target = bld.path.get_bld().make_node('%s/%s' % (bundle, i)), - install_path = '${LV2DIR}/%s' % bundle) + target = '%s/%s' % (bundle, i), + install_path = '${LV2DIR}/%s' % bundle, + LIB_EXT = bld.env['pluginlib_EXT']) # Create a build environment that builds module-style library names # e.g. eg-amp.so instead of libeg-amp.so diff --git a/plugins/eg-sampler.lv2/manifest.ttl b/plugins/eg-sampler.lv2/manifest.ttl deleted file mode 100644 index f6ab02d..0000000 --- a/plugins/eg-sampler.lv2/manifest.ttl +++ /dev/null @@ -1,7 +0,0 @@ -@prefix lv2: . -@prefix rdfs: . - - - a lv2:Plugin ; - lv2:binary ; - rdfs:seeAlso . diff --git a/plugins/eg-sampler.lv2/manifest.ttl.in b/plugins/eg-sampler.lv2/manifest.ttl.in new file mode 100644 index 0000000..b4fa23e --- /dev/null +++ b/plugins/eg-sampler.lv2/manifest.ttl.in @@ -0,0 +1,13 @@ +@prefix lv2: . +@prefix rdfs: . +@prefix ui: . + + + a lv2:Plugin ; + lv2:binary ; + rdfs:seeAlso . + + + a ui:GtkUI ; + ui:binary ; + rdfs:seeAlso . diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index 5292aee..8ee2c05 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -41,14 +41,14 @@ #include -#include - #include "lv2/lv2plug.in/ns/ext/atom/atom-helpers.h" #include "lv2/lv2plug.in/ns/ext/message/message.h" #include "lv2/lv2plug.in/ns/ext/state/state.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "lv2/lv2plug.in/ns/lv2core/lv2.h" +#include "zix/sem.h" + #include "./uris.h" #define STRING_BUF 8192 @@ -73,7 +73,7 @@ typedef struct { /* Sample */ SampleFile* samp; SampleFile* pending_samp; - sem_t signal; + ZixSem signal; int pending_sample_ready; /* Ports */ @@ -142,12 +142,10 @@ worker_thread_main(void* arg) { Sampler* plugin = (Sampler*)arg; + /* TODO: This thread never exits cleanly */ while (true) { /* Wait for run() to signal that we need to load a sample */ - if (sem_wait(&plugin->signal)) { - fprintf(stderr, "Odd, sem_wait failed...\n"); - continue; - } + zix_sem_wait(&plugin->signal); /* Then load it */ handle_load_sample(plugin); @@ -162,7 +160,7 @@ cleanup(LV2_Handle instance) Sampler* plugin = (Sampler*)instance; pthread_cancel(plugin->worker_thread); pthread_join(plugin->worker_thread, 0); - sem_destroy(&plugin->signal); + zix_sem_destroy(&plugin->signal); free(plugin->samp->data); free(plugin->pending_samp->data); @@ -212,7 +210,7 @@ instantiate(const LV2_Descriptor* descriptor, memset(&plugin->uris, 0, sizeof(plugin->uris)); /* Create signal for waking up worker thread */ - if (sem_init(&plugin->signal, 0, 0)) { + if (zix_sem_init(&plugin->signal, 0)) { fprintf(stderr, "Could not initialize semaphore.\n"); goto fail; } @@ -309,7 +307,7 @@ run(LV2_Handle instance, char* str = (char*)LV2_ATOM_BODY(filename); fprintf(stderr, "Request to load %s\n", str); memcpy(plugin->pending_samp->filepath, str, filename->size); - sem_post(&plugin->signal); + zix_sem_post(&plugin->signal); } else { fprintf(stderr, "Unknown message type %d\n", obj->id); } diff --git a/plugins/eg-sampler.lv2/sampler.ttl b/plugins/eg-sampler.lv2/sampler.ttl index 7548396..7f317aa 100644 --- a/plugins/eg-sampler.lv2/sampler.ttl +++ b/plugins/eg-sampler.lv2/sampler.ttl @@ -1,7 +1,7 @@ # LV2 Sampler Example Plugin +# Copyright 2011-2012 David Robillard # Copyright 2011 Gabriel M. Beddingfield # Copyright 2011 James Morris -# Copyright 2011 David Robillard # # Permission to use, copy, modify, and/or distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -47,5 +47,4 @@ a ui:GtkUI ; - lv2:requiredFeature ; - ui:binary . + lv2:requiredFeature . diff --git a/plugins/eg-sampler.lv2/wscript b/plugins/eg-sampler.lv2/wscript index e5988ed..cbff316 100644 --- a/plugins/eg-sampler.lv2/wscript +++ b/plugins/eg-sampler.lv2/wscript @@ -54,11 +54,18 @@ def configure(conf): def build(bld): bundle = 'eg-sampler.lv2' - # Copy data files to build bundle (build/eg-sampler.lv2) - for i in [ 'sampler.ttl', 'manifest.ttl', 'monosample.wav' ]: + # Build manifest.ttl by substitution (for portable lib extension) + bld(features = 'subst', + source = 'manifest.ttl.in', + target = '%s/%s' % (bundle, 'manifest.ttl'), + install_path = '${LV2DIR}/%s' % bundle, + LIB_EXT = bld.env['pluginlib_EXT']) + + # Copy other data files to build bundle (build/eg-sampler.lv2) + for i in [ 'sampler.ttl', 'monosample.wav' ]: bld(rule = 'cp ${SRC} ${TGT}', source = i, - target = bld.path.get_bld().make_node('%s/%s' % (bundle, i)), + target = '%s/%s' % (bundle, i), install_path = '${LV2DIR}/%s' % bundle) # Create a build environment that builds module-style library names @@ -67,9 +74,9 @@ def build(bld): penv = bld.env.derive() penv['cshlib_PATTERN'] = bld.env['pluginlib_PATTERN'] - includes = None + includes = ['.'] if autowaf.is_child: - includes = '../..' + includes += ['../..'] # Build plugin library obj = bld(features = 'c cshlib', -- cgit v1.2.1