From 0caf3e7f786e3fd232d926c2794293fa0dc975c5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 7 Nov 2011 18:30:40 +0000 Subject: Use standard style LV2 extension include paths. This has a few benefits: * As system installed extensions become more ubiquitous, we can optionally build against those rather than including them in the source tree, without any source changes * No need to hack extension headers to change the include paths to match our specific scheme (i.e. headers are precisely those from the extension, even if they include other extension headers) * Consistency, lack of ambiguity, easy code sharing, blah blah, etc. git-svn-id: svn://localhost/ardour2/branches/3.0@10476 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/lv2_event_buffer.h | 4 +- libs/ardour/ardour/lv2_state.h | 2 +- libs/ardour/ardour/uri_map.h | 4 +- .../lv2/lv2plug.in/ns/ext/event/event-helpers.h | 243 +++++++++++++++++++ libs/ardour/lv2/lv2plug.in/ns/ext/event/event.h | 260 +++++++++++++++++++++ libs/ardour/lv2/lv2plug.in/ns/ext/files/files.h | 140 +++++++++++ .../ardour/lv2/lv2plug.in/ns/ext/persist/persist.h | 228 ++++++++++++++++++ .../ardour/lv2/lv2plug.in/ns/ext/uri-map/uri-map.h | 88 +++++++ .../lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h | 81 +++++++ libs/ardour/lv2_event_buffer.cc | 4 +- libs/ardour/lv2_plugin_lilv.cc | 4 +- libs/ardour/lv2ext/lv2_event.h | 260 --------------------- libs/ardour/lv2ext/lv2_event_helpers.h | 243 ------------------- libs/ardour/lv2ext/lv2_files.h | 140 ----------- libs/ardour/lv2ext/lv2_persist.h | 228 ------------------ libs/ardour/lv2ext/lv2_uri_map.h | 88 ------- libs/ardour/lv2ext/lv2_uri_unmap.h | 81 ------- 17 files changed, 1049 insertions(+), 1049 deletions(-) create mode 100644 libs/ardour/lv2/lv2plug.in/ns/ext/event/event-helpers.h create mode 100644 libs/ardour/lv2/lv2plug.in/ns/ext/event/event.h create mode 100644 libs/ardour/lv2/lv2plug.in/ns/ext/files/files.h create mode 100644 libs/ardour/lv2/lv2plug.in/ns/ext/persist/persist.h create mode 100644 libs/ardour/lv2/lv2plug.in/ns/ext/uri-map/uri-map.h create mode 100644 libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h delete mode 100644 libs/ardour/lv2ext/lv2_event.h delete mode 100644 libs/ardour/lv2ext/lv2_event_helpers.h delete mode 100644 libs/ardour/lv2ext/lv2_files.h delete mode 100644 libs/ardour/lv2ext/lv2_persist.h delete mode 100644 libs/ardour/lv2ext/lv2_uri_map.h delete mode 100644 libs/ardour/lv2ext/lv2_uri_unmap.h (limited to 'libs') diff --git a/libs/ardour/ardour/lv2_event_buffer.h b/libs/ardour/ardour/lv2_event_buffer.h index 6bdd02eee5..089681a730 100644 --- a/libs/ardour/ardour/lv2_event_buffer.h +++ b/libs/ardour/ardour/lv2_event_buffer.h @@ -20,8 +20,8 @@ #ifndef __ardour_lv2_event_buffer_h__ #define __ardour_lv2_event_buffer_h__ -#include "lv2ext/lv2_event.h" -#include "lv2ext/lv2_event_helpers.h" +#include "lv2/lv2plug.in/ns/ext/event/event.h" +#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h" namespace ARDOUR { diff --git a/libs/ardour/ardour/lv2_state.h b/libs/ardour/ardour/lv2_state.h index c8e2d01f02..5311efd049 100644 --- a/libs/ardour/ardour/lv2_state.h +++ b/libs/ardour/ardour/lv2_state.h @@ -29,7 +29,7 @@ #include "pbd/error.h" #include "ardour/uri_map.h" -#include "lv2ext/lv2_persist.h" +#include "lv2/lv2plug.in/ns/ext/persist/persist.h" #include "rdff.h" namespace ARDOUR { diff --git a/libs/ardour/ardour/uri_map.h b/libs/ardour/ardour/uri_map.h index d75836e619..f24d03f18c 100644 --- a/libs/ardour/ardour/uri_map.h +++ b/libs/ardour/ardour/uri_map.h @@ -27,8 +27,8 @@ #include #include "lv2.h" -#include "lv2ext/lv2_uri_map.h" -#include "lv2ext/lv2_uri_unmap.h" +#include "lv2/lv2plug.in/ns/ext/uri-map/uri-map.h" +#include "lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h" namespace ARDOUR { diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/event/event-helpers.h b/libs/ardour/lv2/lv2plug.in/ns/ext/event/event-helpers.h new file mode 100644 index 0000000000..79f8a35fe8 --- /dev/null +++ b/libs/ardour/lv2/lv2plug.in/ns/ext/event/event-helpers.h @@ -0,0 +1,243 @@ +/* lv2_event_helpers.h - Helper functions for the LV2 events extension. + * + * Copyright (C) 2008 David Robillard + * + * This header is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This header 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this header; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA + */ + +#ifndef LV2_EVENT_HELPERS_H +#define LV2_EVENT_HELPERS_H + +#include +#include +#include +#include +#include +#include "lv2/lv2plug.in/ns/ext/event/event.h" + +/** @file + * This header defines some helper functions for the the LV2 events extension + * with URI ('lv2ev'). + * + * These functions are provided for convenience only, use of them is not + * required for supporting lv2ev (i.e. the events extension is defined by the + * raw buffer format described in lv2_event.h and NOT by this API). + * + * Note that these functions are all static inline which basically means: + * do not take the address of these functions. */ + + +/** Pad a size to 64 bits (for event sizes) */ +static inline uint16_t +lv2_event_pad_size(uint16_t size) +{ + return (size + 7) & (~7); +} + + +/** Initialize (empty, reset..) an existing event buffer. + * The contents of buf are ignored entirely and overwritten, except capacity + * which is unmodified. */ +static inline void +lv2_event_buffer_reset(LV2_Event_Buffer* buf, uint16_t stamp_type, uint8_t *data) +{ + buf->data = data; + buf->header_size = sizeof(LV2_Event_Buffer); + buf->stamp_type = stamp_type; + buf->event_count = 0; + buf->size = 0; +} + + +/** Allocate a new, empty event buffer. */ +static inline LV2_Event_Buffer* +lv2_event_buffer_new(uint32_t capacity, uint16_t stamp_type) +{ + LV2_Event_Buffer* buf = (LV2_Event_Buffer*)malloc(sizeof(LV2_Event_Buffer) + capacity); + if (buf != NULL) { + buf->capacity = capacity; + lv2_event_buffer_reset(buf, stamp_type, (uint8_t *)(buf + 1)); + return buf; + } else { + return NULL; + } +} + + +/** An iterator over an LV2_Event_Buffer. + * + * Multiple simultaneous read iterators over a single buffer is fine, + * but changing the buffer invalidates all iterators (e.g. RW Lock). */ +typedef struct { + LV2_Event_Buffer* buf; + uint32_t offset; +} LV2_Event_Iterator; + + +/** Reset an iterator to point to the start of @a buf. + * @return True if @a iter is valid, otherwise false (buffer is empty) */ +static inline bool +lv2_event_begin(LV2_Event_Iterator* iter, + LV2_Event_Buffer* buf) +{ + iter->buf = buf; + iter->offset = 0; + return (buf->size > 0); +} + + +/** Check if @a iter is valid.. + * @return True if @a iter is valid, otherwise false (past end of buffer) */ +static inline bool +lv2_event_is_valid(LV2_Event_Iterator* iter) +{ + return (iter->offset < iter->buf->size); +} + + +/** Advance @a iter forward one event. + * @a iter must be valid. + * @return True if @a iter is valid, otherwise false (reached end of buffer) */ +static inline bool +lv2_event_increment(LV2_Event_Iterator* iter) +{ + assert(lv2_event_is_valid(iter)); + + LV2_Event* const ev = (LV2_Event*)( + (uint8_t*)iter->buf->data + iter->offset); + + iter->offset += lv2_event_pad_size(sizeof(LV2_Event) + ev->size); + + return true; +} + + +/** Dereference an event iterator (get the event currently pointed at). + * @a iter must be valid. + * @a data if non-NULL, will be set to point to the contents of the event + * returned. + * @return A Pointer to the event @a iter is currently pointing at, or NULL + * if the end of the buffer is reached (in which case @a data is + * also set to NULL). */ +static inline LV2_Event* +lv2_event_get(LV2_Event_Iterator* iter, + uint8_t** data) +{ + assert(lv2_event_is_valid(iter)); + + LV2_Event* const ev = (LV2_Event*)( + (uint8_t*)iter->buf->data + iter->offset); + + if (data) + *data = (uint8_t*)ev + sizeof(LV2_Event); + + return ev; +} + + +/** Write an event at @a iter. + * The event (if any) pointed to by @iter will be overwritten, and @a iter + * incremented to point to the following event (i.e. several calls to this + * function can be done in sequence without twiddling iter in-between). + * @return True if event was written, otherwise false (buffer is full). */ +static inline bool +lv2_event_write(LV2_Event_Iterator* iter, + uint32_t frames, + uint32_t subframes, + uint16_t type, + uint16_t size, + const uint8_t* data) +{ + if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) + return false; + + LV2_Event* const ev = (LV2_Event*)( + (uint8_t*)iter->buf->data + iter->offset); + + ev->frames = frames; + ev->subframes = subframes; + ev->type = type; + ev->size = size; + memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size); + ++iter->buf->event_count; + + size = lv2_event_pad_size(sizeof(LV2_Event) + size); + iter->buf->size += size; + iter->offset += size; + + return true; +} + + +/** Reserve space for an event in the buffer and return a pointer to + the memory where the caller can write the event data, or NULL if there + is not enough room in the buffer. */ +static inline uint8_t* +lv2_event_reserve(LV2_Event_Iterator* iter, + uint32_t frames, + uint32_t subframes, + uint16_t type, + uint16_t size) +{ + size = lv2_event_pad_size(size); + if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) + return NULL; + + LV2_Event* const ev = (LV2_Event*)((uint8_t*)iter->buf->data + + iter->offset); + + ev->frames = frames; + ev->subframes = subframes; + ev->type = type; + ev->size = size; + ++iter->buf->event_count; + + size = lv2_event_pad_size(sizeof(LV2_Event) + size); + iter->buf->size += size; + iter->offset += size; + + return (uint8_t*)ev + sizeof(LV2_Event); +} + + +/** Write an event at @a iter. + * The event (if any) pointed to by @iter will be overwritten, and @a iter + * incremented to point to the following event (i.e. several calls to this + * function can be done in sequence without twiddling iter in-between). + * @return True if event was written, otherwise false (buffer is full). */ +static inline bool +lv2_event_write_event(LV2_Event_Iterator* iter, + const LV2_Event* ev, + const uint8_t* data) +{ + if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + ev->size) + return false; + + LV2_Event* const write_ev = (LV2_Event*)( + (uint8_t*)iter->buf->data + iter->offset); + + *write_ev = *ev; + memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size); + ++iter->buf->event_count; + + const uint16_t size = lv2_event_pad_size(sizeof(LV2_Event) + ev->size); + iter->buf->size += size; + iter->offset += size; + + return true; +} + +#endif // LV2_EVENT_HELPERS_H + diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/event/event.h b/libs/ardour/lv2/lv2plug.in/ns/ext/event/event.h new file mode 100644 index 0000000000..701fecb534 --- /dev/null +++ b/libs/ardour/lv2/lv2plug.in/ns/ext/event/event.h @@ -0,0 +1,260 @@ +/* lv2_event.h - C header file for the LV2 events extension. + * + * Copyright (C) 2006-2007 Lars Luthman + * Copyright (C) 2008 David Robillard + * + * This header is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This header 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this header; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA + */ + +#ifndef LV2_EVENT_H +#define LV2_EVENT_H + +#define LV2_EVENT_URI "http://lv2plug.in/ns/ext/event" +#define LV2_EVENT_AUDIO_STAMP 0 + +#include + +/** @file + * This header defines the code portion of the LV2 events extension with URI + * ('lv2ev'). + * + * This extension is a generic transport mechanism for time stamped events + * of any type (e.g. MIDI, OSC, ramps, etc). Each port can transport mixed + * events of any type; the type of events and timestamps are defined by a URI + * which is mapped to an integer by the host for performance reasons. + * + * This extension requires the host to support the LV2 URI Map extension. + * Any host which supports this extension MUST guarantee that any call to + * the LV2 URI Map uri_to_id function with the URI of this extension as the + * 'map' argument returns a value within the range of uint16_t. + */ + + +/** The best Pulses Per Quarter Note for tempo-based uint32_t timestmaps. + * Equal to 2^12 * 5 * 7 * 9 * 11 * 13 * 17, which is evenly divisble + * by all integers from 1 through 18 inclusive, and powers of 2 up to 2^12. + */ +static const uint32_t LV2_EVENT_PPQN = 3136573440U; + + +/** An LV2 event (header only). + * + * LV2 events are generic time-stamped containers for any type of event. + * The type field defines the format of a given event's contents. + * + * This struct defines the header of an LV2 event. An LV2 event is a single + * chunk of POD (plain old data), usually contained in a flat buffer + * (see LV2_EventBuffer below). Unless a required feature says otherwise, + * hosts may assume a deep copy of an LV2 event can be created safely + * using a simple: + * + * memcpy(ev_copy, ev, sizeof(LV2_Event) + ev->size); (or equivalent) + */ +typedef struct { + + /** The frames portion of timestamp. The units used here can optionally be + * set for a port (with the lv2ev:timeUnits property), otherwise this + * is audio frames, corresponding to the sample_count parameter of the + * LV2 run method (e.g. frame 0 is the first frame for that call to run). + */ + uint32_t frames; + + /** The sub-frames portion of timestamp. The units used here can + * optionally be set for a port (with the lv2ev:timeUnits property), + * otherwise this is 1/(2^32) of an audio frame. + */ + uint32_t subframes; + + /** The type of this event, as a number which represents some URI + * defining an event type. This value MUST be some value previously + * returned from a call to the uri_to_id function defined in the LV2 + * URI map extension (see lv2_uri_map.h). + * There are special rules which must be followed depending on the type + * of an event. If the plugin recognizes an event type, the definition + * of that event type will describe how to interpret the event, and + * any required behaviour. Otherwise, if the type is 0, this event is a + * non-POD event and lv2_event_unref MUST be called if the event is + * 'dropped' (see above). Even if the plugin does not understand an event, + * it may pass the event through to an output by simply copying (and NOT + * calling lv2_event_unref). These rules are designed to allow for generic + * event handling plugins and large non-POD events, but with minimal hassle + * on simple plugins that "don't care" about these more advanced features. + */ + uint16_t type; + + /** The size of the data portion of this event in bytes, which immediately + * follows. The header size (12 bytes) is not included in this value. + */ + uint16_t size; + + /* size bytes of data follow here */ + +} LV2_Event; + + + +/** A buffer of LV2 events (header only). + * + * Like events (which this contains) an event buffer is a single chunk of POD: + * the entire buffer (including contents) can be copied with a single memcpy. + * The first contained event begins sizeof(LV2_EventBuffer) bytes after + * the start of this struct. + * + * After this header, the buffer contains an event header (defined by struct + * LV2_Event), followed by that event's contents (padded to 64 bits), followed by + * another header, etc: + * + * | | | | | | | + * | | | | | | | | | | | | | | | | | | | | | | | | | + * |FRAMES |SUBFRMS|TYP|LEN|DATA..DATA..PAD|FRAMES | ... + */ +typedef struct { + + /** The contents of the event buffer. This may or may not reside in the + * same block of memory as this header, plugins must not assume either. + * The host guarantees this points to at least capacity bytes of allocated + * memory (though only size bytes of that are valid events). + */ + uint8_t* data; + + /** The size of this event header in bytes (including everything). + * + * This is to allow for extending this header in the future without + * breaking binary compatibility. Whenever this header is copied, + * it MUST be done using this field (and NOT the sizeof this struct). + */ + uint16_t header_size; + + /** The type of the time stamps for events in this buffer. + * As a special exception, '0' always means audio frames and subframes + * (1/UINT32_MAX'th of a frame) in the sample rate passed to instantiate. + * INPUTS: The host must set this field to the numeric ID of some URI + * defining the meaning of the frames/subframes fields of contained + * events (obtained by the LV2 URI Map uri_to_id function with the URI + * of this extension as the 'map' argument, see lv2_uri_map.h). + * The host must never pass a plugin a buffer which uses a stamp type + * the plugin does not 'understand'. The value of this field must + * never change, except when connect_port is called on the input + * port, at which time the host MUST have set the stamp_type field to + * the value that will be used for all subsequent run calls. + * OUTPUTS: The plugin may set this to any value that has been returned + * from uri_to_id with the URI of this extension for a 'map' argument. + * When connected to a buffer with connect_port, output ports MUST set + * this field to the type of time stamp they will be writing. On any + * call to connect_port on an event input port, the plugin may change + * this field on any output port, it is the responsibility of the host + * to check if any of these values have changed and act accordingly. + */ + uint16_t stamp_type; + + /** The number of events in this buffer. + * INPUTS: The host must set this field to the number of events + * contained in the data buffer before calling run(). + * The plugin must not change this field. + * OUTPUTS: The plugin must set this field to the number of events it + * has written to the buffer before returning from run(). + * Any initial value should be ignored by the plugin. + */ + uint32_t event_count; + + /** The size of the data buffer in bytes. + * This is set by the host and must not be changed by the plugin. + * The host is allowed to change this between run() calls. + */ + uint32_t capacity; + + /** The size of the initial portion of the data buffer containing data. + * INPUTS: The host must set this field to the number of bytes used + * by all events it has written to the buffer (including headers) + * before calling the plugin's run(). + * The plugin must not change this field. + * OUTPUTS: The plugin must set this field to the number of bytes + * used by all events it has written to the buffer (including headers) + * before returning from run(). + * Any initial value should be ignored by the plugin. + */ + uint32_t size; + +} LV2_Event_Buffer; + + +/** Opaque pointer to host data. */ +typedef void* LV2_Event_Callback_Data; + + +/** The data field of the LV2_Feature for this extension. + * + * To support this feature the host must pass an LV2_Feature struct to the + * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/event" + * and data pointed to an instance of this struct. + */ +typedef struct { + + /** Opaque pointer to host data. + * + * The plugin MUST pass this to any call to functions in this struct. + * Otherwise, it must not be interpreted in any way. + */ + LV2_Event_Callback_Data callback_data; + + /** Take a reference to a non-POD event. + * + * If a plugin receives an event with type 0, it means the event is a + * pointer to some object in memory and not a flat sequence of bytes + * in the buffer. When receiving a non-POD event, the plugin already + * has an implicit reference to the event. If the event is stored AND + * passed to an output, lv2_event_ref MUST be called on that event. + * If the event is only stored OR passed through, this is not necessary + * (as the plugin already has 1 implicit reference). + * + * @param event An event received at an input that will not be copied to + * an output or stored in any way. + * @param context The calling context. (Like event types) this is a mapped + * URI, see lv2_context.h. Simple plugin with just a run() + * method should pass 0 here (the ID of the 'standard' LV2 + * run context). The host guarantees that this function is + * realtime safe iff @a context is realtime safe. + * + * PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS. + */ + uint32_t (*lv2_event_ref)(LV2_Event_Callback_Data callback_data, + LV2_Event* event); + + /** Drop a reference to a non-POD event. + * + * If a plugin receives an event with type 0, it means the event is a + * pointer to some object in memory and not a flat sequence of bytes + * in the buffer. If the plugin does not pass the event through to + * an output or store it internally somehow, it MUST call this function + * on the event (more information on using non-POD events below). + * + * @param event An event received at an input that will not be copied to + * an output or stored in any way. + * @param context The calling context. (Like event types) this is a mapped + * URI, see lv2_context.h. Simple plugin with just a run() + * method should pass 0 here (the ID of the 'standard' LV2 + * run context). The host guarantees that this function is + * realtime safe iff @a context is realtime safe. + * + * PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS. + */ + uint32_t (*lv2_event_unref)(LV2_Event_Callback_Data callback_data, + LV2_Event* event); + +} LV2_Event_Feature; + + +#endif // LV2_EVENT_H + diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/files/files.h b/libs/ardour/lv2/lv2plug.in/ns/ext/files/files.h new file mode 100644 index 0000000000..f996e2ed16 --- /dev/null +++ b/libs/ardour/lv2/lv2plug.in/ns/ext/files/files.h @@ -0,0 +1,140 @@ +/* + Copyright 2010-2011 David Robillard + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + OTHER DEALINGS IN THE SOFTWARE. +*/ + +/** + @file files.h + C API for the LV2 Files extension . +*/ + +#ifndef LV2_FILES_H +#define LV2_FILES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LV2_FILES_URI "http://lv2plug.in/ns/ext/files" +#define LV2_FILES_PATH_SUPPORT_URI LV2_FILES_URI "#pathSupport" +#define LV2_FILES_NEW_FILE_SUPPORT_URI LV2_FILES_URI "#newFileSupport" + +typedef void* LV2_Files_Host_Data; + +/** + files:pathSupport feature struct. + + To support this feature, the host MUST pass an LV2_Feature struct with @a + URI @ref LV2_FILES_PATH_SUPPORT_URI and @a data pointed to an instance of + this struct. +*/ +typedef struct { + + /** + Opaque host data. + */ + LV2_Files_Host_Data host_data; + + /** + Map an absolute path to an abstract path for use in plugin state. + @param host_data MUST be the @a host_data member of this struct. + @param absolute_path The absolute path of a file. + @return An abstract path suitable for use in plugin state. + + The plugin MUST use this function to map any paths that will be stored + in plugin state. The returned value is an abstract path which MAY not + be an actual file system path; @ref absolute_path MUST be used to map it + to an actual path in order to use the file. + + Hosts MAY map paths in any way (e.g. by creating symbolic links within + the plugin's state directory or storing a list of referenced files for + later export). Plugins MUST NOT make any assumptions about abstract + paths except that they can be mapped to an absolute path using @ref + absolute_path. Particularly when restoring from state, this absolute + path MAY not be the same as the original absolute path, but the host + MUST guarantee it refers to a file with contents equivalent to the + original. + + This function may only be called within the context of + LV2_Persist.save() or LV2_Persist.restore(). The caller is responsible + for freeing the returned value. + */ + char* (*abstract_path)(LV2_Files_Host_Data host_data, + const char* absolute_path); + + /** + Map an abstract path from plugin state to an absolute path. + @param host_data MUST be the @a host_data member of this struct. + @param abstract_path An abstract path (e.g. a path from plugin state). + @return An absolute file system path. + + Since abstract paths are not necessarily actual file paths (or at least + not necessarily absolute paths), this function MUST be used in order to + actually open or otherwise use the file referred to by an abstract path. + + This function may only be called within the context of + LV2_Persist.save() or LV2_Persist.restore(). The caller is responsible + for freeing the returned value. + */ + char* (*absolute_path)(LV2_Files_Host_Data host_data, + const char* abstract_path); + +} LV2_Files_Path_Support; + +/** + files:newFileSupport feature struct. + + To support this feature, the host MUST pass an LV2_Feature struct with @a + URI @ref LV2_FILES_NEW_FILE_SUPPORT_URI and @a data pointed to an instance + of this struct. +*/ +typedef struct { + + /** + Opaque host data. + */ + LV2_Files_Host_Data host_data; + + /** + Return an absolute path the plugin may use to create a new file. + @param host_data MUST be the @a host_data member of this struct. + @param relative_path The relative path of the file. + @return The absolute path to use for the new file. + + The plugin can assume @a relative_path is relative to a namespace + dedicated to that plugin instance; hosts MUST ensure this, e.g. by + giving each plugin instance its own state directory. The returned path + is absolute and thus suitable for creating and using a file, but NOT + suitable for storing in plugin state (it MUST be mapped to an abstract + path using @ref LV2_Files_Path_Support::abstract_path to do so). + + This function may be called from any non-realtime context. The caller + is responsible for freeing the returned value. + */ + char* (*new_file_path)(LV2_Files_Host_Data host_data, + const char* relative_path); + +} LV2_Files_New_File_Support; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* LV2_FILES_H */ diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/persist/persist.h b/libs/ardour/lv2/lv2plug.in/ns/ext/persist/persist.h new file mode 100644 index 0000000000..6879a865ba --- /dev/null +++ b/libs/ardour/lv2/lv2plug.in/ns/ext/persist/persist.h @@ -0,0 +1,228 @@ +/* + Copyright 2010-2011 David Robillard + Copyright 2010 Leonard Ritter + + This header is free software; you can redistribute it and/or modify it + under the terms of the GNU Lesser General Public License as published + by the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This header 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 Lesser General Public + License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with this header; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA +*/ + +/** + @file + C API for the LV2 Persist extension . +*/ + +#ifndef LV2_PERSIST_H +#define LV2_PERSIST_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define LV2_PERSIST_URI "http://lv2plug.in/ns/ext/persist" + +/** + Flags describing value characteristics. + + These flags are used along with the value's type URI to determine how to + (de-)serialise the value data, or whether it is even possible to do so. +*/ +typedef enum { + + /** + Plain Old Data. + + Values with this flag contain no references to non-persistent or + non-global resources (e.g. pointers, handles, local paths, etc.). It is + safe to copy POD values with a simple memcpy and store them for use at + any time in the future on a machine with a compatible architecture + (e.g. the same endianness and alignment). + + Implementations MUST NOT attempt to copy or serialise a non-POD value if + they do not understand its type (and thus know how to correctly do so). + */ + LV2_PERSIST_IS_POD = 1, + + /** + Portable (architecture independent) data. + + Values with this flag are in a format that is usable on any + architecture, i.e. if the value is saved on one machine it can safely be + restored on another machine regardless of endianness, alignment, etc. + */ + LV2_PERSIST_IS_PORTABLE = 1 << 1 + +} LV2_Persist_Flags; + +/** + A host-provided function to store a plugin instance property. + @param callback_data Must be the callback_data passed to LV2_Persist.save(). + @param key The key (predicate) to store @a value under (URI mapped integer). + @param value Pointer to the value (object) to be stored. + @param size The size of the data at @a value in bytes. + @param type The type of @a value (URI). + @param flags LV2_Persist_Flags for @a value. + @return 0 on success, otherwise a non-zero error code. + + The host passes a callback of this type to LV2_Persist.save(). This callback + is called repeatedly by the plugin within LV2_Persist.save() to store all + the statements that describe its current state. + + The host MAY fail to store a property if the type is not understood and is + not LV2_PERSIST_IS_POD and/or LV2_PERSIST_IS_PORTABLE. Implementations are + encouraged to use POD and portable values (e.g. string literals) wherever + possible, and use common types (e.g. types from + http://lv2plug.in/ns/ext/atom) regardless, since hosts are likely to already + contain the necessary implementation. + + Note that @a size MUST be > 0, and @a value MUST point to a valid region of + memory @a size bytes long (this is required to make restore unambiguous). + + The plugin MUST NOT attempt to use this function outside of the + LV2_Persist.restore() context. +*/ +typedef int (*LV2_Persist_Store_Function)( + void* callback_data, + uint32_t key, + const void* value, + size_t size, + uint32_t type, + uint32_t flags); + +/** + A host-provided function to retrieve a property. + @param callback_data Must be the callback_data passed to LV2_Persist.restore(). + @param key The key (predicate) of the property to retrieve (URI). + @param size (Output) If non-NULL, set to the size of the restored value. + @param type (Output) If non-NULL, set to the type of the restored value. + @param flags (Output) If non-NULL, set to the LV2_Persist_Flags for + the returned value. + @return A pointer to the restored value (object), or NULL if no value + has been stored under @a key. + + A callback of this type is passed by the host to LV2_Persist.restore(). This + callback is called repeatedly by the plugin within LV2_Persist.restore() to + retrieve any properties it requires to restore its state. + + The returned value MUST remain valid until LV2_Persist.restore() returns. + + The plugin MUST NOT attempt to use this function, or any value returned from + it, outside of the LV2_Persist.restore() context. Returned values MAY be + copied for later use if necessary, assuming the plugin knows how to do so + correctly (e.g. the value is POD, or the plugin understands the type). +*/ +typedef const void* (*LV2_Persist_Retrieve_Function)( + void* callback_data, + uint32_t key, + size_t* size, + uint32_t* type, + uint32_t* flags); + +/** + Persist Extension Data. + + When the plugin's extension_data is called with argument LV2_PERSIST_URI, + the plugin MUST return an LV2_Persist structure, which remains valid for the + lifetime of the plugin. + + The host can use the contained function pointers to save and restore the + state of a plugin instance at any time (provided the threading restrictions + for the given function are met). + + The typical use case is to save the plugin's state when a project is saved, + and to restore the state when a project has been loaded. Other uses are + possible (e.g. cloning plugin instances or taking a snapshot of plugin + state). + + Stored data is only guaranteed to be compatible between instances of plugins + with the same URI (i.e. if a change to a plugin would cause a fatal error + when restoring state saved by a previous version of that plugin, the plugin + URI MUST change just as it must when ports change incompatibly). Plugin + authors should consider this possibility, and always store sensible data + with meaningful types to avoid such compatibility issues in the future. +*/ +typedef struct _LV2_Persist { + + /** + Save plugin state using a host-provided @a store callback. + + @param instance The instance handle of the plugin. + @param store The host-provided store callback. + @param callback_data An opaque pointer to host data, e.g. the map or + file where the values are to be stored. If @a store is called, + this MUST be passed as its callback_data parameter. + + The plugin is expected to store everything necessary to completely + restore its state later (possibly much later, in a different process, on + a completely different machine, etc.) + + The @a callback_data pointer and @a store function MUST NOT be used + beyond the scope of save(). + + This function has its own special threading class: it may not be called + concurrently with any "Instantiation" function, but it may be called + concurrently with functions in any other class, unless the definition of + that class prohibits it (e.g. it may not be called concurrently with a + "Discovery" function, but it may be called concurrently with an "Audio" + function. The plugin is responsible for any locking or lock-free + techniques necessary to make this possible. + + Note that in the simple case where state is only modified by restore(), + there are no synchronization issues since save() is never called + concurrently with restore() (though run() may read it during a save). + + Plugins that dynamically modify state while running, however, must take + care to do so in such a way that a concurrent call to save() will save a + consistent representation of plugin state for a single instant in time. + */ + void (*save)(LV2_Handle instance, + LV2_Persist_Store_Function store, + void* callback_data); + + /** + Restore plugin state using a host-provided @a retrieve callback. + + @param instance The instance handle of the plugin. + @param retrieve The host-provided retrieve callback. + @param callback_data An opaque pointer to host data, e.g. the map or + file from which the values are to be restored. If @a retrieve is + called, this MUST be passed as its callback_data parameter. + + The plugin MAY assume a restored value was set by a previous call to + LV2_Persist.save() by a plugin with the same URI. + + The plugin MUST gracefully fall back to a default value when a value can + not be retrieved. This allows the host to reset the plugin state with an + empty map. + + The @a callback_data pointer and @a store function MUST NOT be used + beyond the scope of restore(). + + This function is in the "Instantiation" threading class as defined by + LV2. This means it MUST NOT be called concurrently with any other + function on the same plugin instance. + */ + void (*restore)(LV2_Handle instance, + LV2_Persist_Retrieve_Function retrieve, + void* callback_data); + +} LV2_Persist; + +#ifdef __cplusplus +} /* extern "C" */ +#endif + +#endif /* LV2_PERSIST_H */ diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/uri-map/uri-map.h b/libs/ardour/lv2/lv2plug.in/ns/ext/uri-map/uri-map.h new file mode 100644 index 0000000000..4066a2f468 --- /dev/null +++ b/libs/ardour/lv2/lv2plug.in/ns/ext/uri-map/uri-map.h @@ -0,0 +1,88 @@ +/* lv2_uri_map.h - C header file for the LV2 URI Map extension. + * + * Copyright (C) 2008 David Robillard + * + * This header is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This header 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this header; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA + */ + +#ifndef LV2_URI_MAP_H +#define LV2_URI_MAP_H + +#define LV2_URI_MAP_URI "http://lv2plug.in/ns/ext/uri-map" + +#include + +/** @file + * This header defines the LV2 URI Map extension with the URI + * (preferred prefix 'lv2urimap'). + * + * This extension defines a simple mechanism for plugins to map URIs to + * integers, usually for performance reasons (e.g. processing events + * typed by URIs in real time). The expected use case is for plugins to + * map URIs to integers for things they 'understand' at instantiation time, + * and store those values for use in the audio thread without doing any string + * comparison. This allows the extensibility of RDF with the performance of + * integers (or centrally defined enumerations). + */ + + +/** Opaque pointer to host data. */ +typedef void* LV2_URI_Map_Callback_Data; + + +/** The data field of the LV2_Feature for this extension. + * + * To support this feature the host must pass an LV2_Feature struct to the + * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-map" + * and data pointed to an instance of this struct. + */ +typedef struct { + + /** Opaque pointer to host data. + * + * The plugin MUST pass this to any call to functions in this struct. + * Otherwise, it must not be interpreted in any way. + */ + LV2_URI_Map_Callback_Data callback_data; + + /** Get the numeric ID of a URI from the host. + * + * @param callback_data Must be the callback_data member of this struct. + * @param map The 'context' of this URI. Certain extensions may define a + * URI that must be passed here with certain restrictions on the + * return value (e.g. limited range). This value may be NULL if + * the plugin needs an ID for a URI in general. + * @param uri The URI to be mapped to an integer ID. + * + * This function is referentially transparent - any number of calls with + * the same arguments is guaranteed to return the same value over the life + * of a plugin instance (though the same URI may return different values + * with a different map parameter). However, this function is not + * necessarily very fast: plugins should cache any IDs they might need in + * performance critical situations. + * The return value 0 is reserved and means an ID for that URI could not + * be created for whatever reason. Extensions may define more precisely + * what this means, but in general plugins should gracefully handle 0 + * and consider whatever they wanted the URI for "unsupported". + */ + uint32_t (*uri_to_id)(LV2_URI_Map_Callback_Data callback_data, + const char* map, + const char* uri); + +} LV2_URI_Map_Feature; + + +#endif // LV2_URI_MAP_H + diff --git a/libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h b/libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h new file mode 100644 index 0000000000..d6cb90039a --- /dev/null +++ b/libs/ardour/lv2/lv2plug.in/ns/ext/uri-unmap/uri-unmap.h @@ -0,0 +1,81 @@ +/* lv2_uri_unmap.h - C header file for the LV2 URI Unmap extension. + * + * Copyright (C) 2010 David Robillard + * + * This header is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This header 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 Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this header; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA + */ + +/** @file + * C header for the LV2 URI Map extension . + */ + +#ifndef LV2_URI_UNMAP_H +#define LV2_URI_UNMAP_H + +#define LV2_URI_UNMAP_URI "http://lv2plug.in/ns/ext/uri-unmap" + +#include + + +/** Opaque pointer to host data. */ +typedef void* LV2_URI_Unmap_Callback_Data; + + +/** The data field of the LV2_Feature for the URI Unmap extension. + * + * To support this extension the host must pass an LV2_Feature struct to the + * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-unmap" + * and data pointed to an instance of this struct. + */ +typedef struct { + + /** Opaque pointer to host data. + * + * The plugin MUST pass this to any call to functions in this struct. + * Otherwise, it must not be interpreted in any way. + */ + LV2_URI_Unmap_Callback_Data callback_data; + + /** Get the numeric ID of a URI from the host. + * + * @param callback_data Must be the callback_data member of this struct. + * @param map The 'context' used to map this URI. + * @param id The URI ID to unmap. + * @return The string form of @a id, or NULL on error. + * + * The @a id MUST be a value previously returned from + * LV2_Uri_Map_Feature.uri_to_id. + * + * The returned string is owned by the host and MUST NOT be freed by + * the plugin or stored for a long period of time (e.g. across run + * invocations) without copying. + * + * This function is referentially transparent - any number of calls with + * the same arguments is guaranteed to return the same value over the life + * of a plugin instance (though the same ID may return different values + * with a different map parameter). + * + * This function may be called from any non-realtime thread, possibly + * concurrently (hosts may simply use a mutex to meet these requirements). + */ + const char* (*id_to_uri)(LV2_URI_Unmap_Callback_Data callback_data, + const char* map, + uint32_t id); + +} LV2_URI_Unmap_Feature; + + +#endif /* LV2_URI_UNMAP_H */ + diff --git a/libs/ardour/lv2_event_buffer.cc b/libs/ardour/lv2_event_buffer.cc index dd666203fd..f1e5e4d0d1 100644 --- a/libs/ardour/lv2_event_buffer.cc +++ b/libs/ardour/lv2_event_buffer.cc @@ -19,8 +19,8 @@ #include #include -#include "lv2ext/lv2_event.h" -#include "lv2ext/lv2_event_helpers.h" +#include "lv2/lv2plug.in/ns/ext/event/event.h" +#include "lv2/lv2plug.in/ns/ext/event/event-helpers.h" #include "ardour/lv2_event_buffer.h" using namespace std; diff --git a/libs/ardour/lv2_plugin_lilv.cc b/libs/ardour/lv2_plugin_lilv.cc index 25020e541a..e4c14383f6 100644 --- a/libs/ardour/lv2_plugin_lilv.cc +++ b/libs/ardour/lv2_plugin_lilv.cc @@ -51,8 +51,8 @@ #include -#include "lv2ext/lv2_files.h" -#include "lv2ext/lv2_persist.h" +#include "lv2/lv2plug.in/ns/ext/files/files.h" +#include "lv2/lv2plug.in/ns/ext/persist/persist.h" #include "rdff.h" #ifdef HAVE_SUIL #include diff --git a/libs/ardour/lv2ext/lv2_event.h b/libs/ardour/lv2ext/lv2_event.h deleted file mode 100644 index 701fecb534..0000000000 --- a/libs/ardour/lv2ext/lv2_event.h +++ /dev/null @@ -1,260 +0,0 @@ -/* lv2_event.h - C header file for the LV2 events extension. - * - * Copyright (C) 2006-2007 Lars Luthman - * Copyright (C) 2008 David Robillard - * - * This header is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This header 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this header; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA - */ - -#ifndef LV2_EVENT_H -#define LV2_EVENT_H - -#define LV2_EVENT_URI "http://lv2plug.in/ns/ext/event" -#define LV2_EVENT_AUDIO_STAMP 0 - -#include - -/** @file - * This header defines the code portion of the LV2 events extension with URI - * ('lv2ev'). - * - * This extension is a generic transport mechanism for time stamped events - * of any type (e.g. MIDI, OSC, ramps, etc). Each port can transport mixed - * events of any type; the type of events and timestamps are defined by a URI - * which is mapped to an integer by the host for performance reasons. - * - * This extension requires the host to support the LV2 URI Map extension. - * Any host which supports this extension MUST guarantee that any call to - * the LV2 URI Map uri_to_id function with the URI of this extension as the - * 'map' argument returns a value within the range of uint16_t. - */ - - -/** The best Pulses Per Quarter Note for tempo-based uint32_t timestmaps. - * Equal to 2^12 * 5 * 7 * 9 * 11 * 13 * 17, which is evenly divisble - * by all integers from 1 through 18 inclusive, and powers of 2 up to 2^12. - */ -static const uint32_t LV2_EVENT_PPQN = 3136573440U; - - -/** An LV2 event (header only). - * - * LV2 events are generic time-stamped containers for any type of event. - * The type field defines the format of a given event's contents. - * - * This struct defines the header of an LV2 event. An LV2 event is a single - * chunk of POD (plain old data), usually contained in a flat buffer - * (see LV2_EventBuffer below). Unless a required feature says otherwise, - * hosts may assume a deep copy of an LV2 event can be created safely - * using a simple: - * - * memcpy(ev_copy, ev, sizeof(LV2_Event) + ev->size); (or equivalent) - */ -typedef struct { - - /** The frames portion of timestamp. The units used here can optionally be - * set for a port (with the lv2ev:timeUnits property), otherwise this - * is audio frames, corresponding to the sample_count parameter of the - * LV2 run method (e.g. frame 0 is the first frame for that call to run). - */ - uint32_t frames; - - /** The sub-frames portion of timestamp. The units used here can - * optionally be set for a port (with the lv2ev:timeUnits property), - * otherwise this is 1/(2^32) of an audio frame. - */ - uint32_t subframes; - - /** The type of this event, as a number which represents some URI - * defining an event type. This value MUST be some value previously - * returned from a call to the uri_to_id function defined in the LV2 - * URI map extension (see lv2_uri_map.h). - * There are special rules which must be followed depending on the type - * of an event. If the plugin recognizes an event type, the definition - * of that event type will describe how to interpret the event, and - * any required behaviour. Otherwise, if the type is 0, this event is a - * non-POD event and lv2_event_unref MUST be called if the event is - * 'dropped' (see above). Even if the plugin does not understand an event, - * it may pass the event through to an output by simply copying (and NOT - * calling lv2_event_unref). These rules are designed to allow for generic - * event handling plugins and large non-POD events, but with minimal hassle - * on simple plugins that "don't care" about these more advanced features. - */ - uint16_t type; - - /** The size of the data portion of this event in bytes, which immediately - * follows. The header size (12 bytes) is not included in this value. - */ - uint16_t size; - - /* size bytes of data follow here */ - -} LV2_Event; - - - -/** A buffer of LV2 events (header only). - * - * Like events (which this contains) an event buffer is a single chunk of POD: - * the entire buffer (including contents) can be copied with a single memcpy. - * The first contained event begins sizeof(LV2_EventBuffer) bytes after - * the start of this struct. - * - * After this header, the buffer contains an event header (defined by struct - * LV2_Event), followed by that event's contents (padded to 64 bits), followed by - * another header, etc: - * - * | | | | | | | - * | | | | | | | | | | | | | | | | | | | | | | | | | - * |FRAMES |SUBFRMS|TYP|LEN|DATA..DATA..PAD|FRAMES | ... - */ -typedef struct { - - /** The contents of the event buffer. This may or may not reside in the - * same block of memory as this header, plugins must not assume either. - * The host guarantees this points to at least capacity bytes of allocated - * memory (though only size bytes of that are valid events). - */ - uint8_t* data; - - /** The size of this event header in bytes (including everything). - * - * This is to allow for extending this header in the future without - * breaking binary compatibility. Whenever this header is copied, - * it MUST be done using this field (and NOT the sizeof this struct). - */ - uint16_t header_size; - - /** The type of the time stamps for events in this buffer. - * As a special exception, '0' always means audio frames and subframes - * (1/UINT32_MAX'th of a frame) in the sample rate passed to instantiate. - * INPUTS: The host must set this field to the numeric ID of some URI - * defining the meaning of the frames/subframes fields of contained - * events (obtained by the LV2 URI Map uri_to_id function with the URI - * of this extension as the 'map' argument, see lv2_uri_map.h). - * The host must never pass a plugin a buffer which uses a stamp type - * the plugin does not 'understand'. The value of this field must - * never change, except when connect_port is called on the input - * port, at which time the host MUST have set the stamp_type field to - * the value that will be used for all subsequent run calls. - * OUTPUTS: The plugin may set this to any value that has been returned - * from uri_to_id with the URI of this extension for a 'map' argument. - * When connected to a buffer with connect_port, output ports MUST set - * this field to the type of time stamp they will be writing. On any - * call to connect_port on an event input port, the plugin may change - * this field on any output port, it is the responsibility of the host - * to check if any of these values have changed and act accordingly. - */ - uint16_t stamp_type; - - /** The number of events in this buffer. - * INPUTS: The host must set this field to the number of events - * contained in the data buffer before calling run(). - * The plugin must not change this field. - * OUTPUTS: The plugin must set this field to the number of events it - * has written to the buffer before returning from run(). - * Any initial value should be ignored by the plugin. - */ - uint32_t event_count; - - /** The size of the data buffer in bytes. - * This is set by the host and must not be changed by the plugin. - * The host is allowed to change this between run() calls. - */ - uint32_t capacity; - - /** The size of the initial portion of the data buffer containing data. - * INPUTS: The host must set this field to the number of bytes used - * by all events it has written to the buffer (including headers) - * before calling the plugin's run(). - * The plugin must not change this field. - * OUTPUTS: The plugin must set this field to the number of bytes - * used by all events it has written to the buffer (including headers) - * before returning from run(). - * Any initial value should be ignored by the plugin. - */ - uint32_t size; - -} LV2_Event_Buffer; - - -/** Opaque pointer to host data. */ -typedef void* LV2_Event_Callback_Data; - - -/** The data field of the LV2_Feature for this extension. - * - * To support this feature the host must pass an LV2_Feature struct to the - * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/event" - * and data pointed to an instance of this struct. - */ -typedef struct { - - /** Opaque pointer to host data. - * - * The plugin MUST pass this to any call to functions in this struct. - * Otherwise, it must not be interpreted in any way. - */ - LV2_Event_Callback_Data callback_data; - - /** Take a reference to a non-POD event. - * - * If a plugin receives an event with type 0, it means the event is a - * pointer to some object in memory and not a flat sequence of bytes - * in the buffer. When receiving a non-POD event, the plugin already - * has an implicit reference to the event. If the event is stored AND - * passed to an output, lv2_event_ref MUST be called on that event. - * If the event is only stored OR passed through, this is not necessary - * (as the plugin already has 1 implicit reference). - * - * @param event An event received at an input that will not be copied to - * an output or stored in any way. - * @param context The calling context. (Like event types) this is a mapped - * URI, see lv2_context.h. Simple plugin with just a run() - * method should pass 0 here (the ID of the 'standard' LV2 - * run context). The host guarantees that this function is - * realtime safe iff @a context is realtime safe. - * - * PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS. - */ - uint32_t (*lv2_event_ref)(LV2_Event_Callback_Data callback_data, - LV2_Event* event); - - /** Drop a reference to a non-POD event. - * - * If a plugin receives an event with type 0, it means the event is a - * pointer to some object in memory and not a flat sequence of bytes - * in the buffer. If the plugin does not pass the event through to - * an output or store it internally somehow, it MUST call this function - * on the event (more information on using non-POD events below). - * - * @param event An event received at an input that will not be copied to - * an output or stored in any way. - * @param context The calling context. (Like event types) this is a mapped - * URI, see lv2_context.h. Simple plugin with just a run() - * method should pass 0 here (the ID of the 'standard' LV2 - * run context). The host guarantees that this function is - * realtime safe iff @a context is realtime safe. - * - * PLUGINS THAT VIOLATE THESE RULES MAY CAUSE CRASHES AND MEMORY LEAKS. - */ - uint32_t (*lv2_event_unref)(LV2_Event_Callback_Data callback_data, - LV2_Event* event); - -} LV2_Event_Feature; - - -#endif // LV2_EVENT_H - diff --git a/libs/ardour/lv2ext/lv2_event_helpers.h b/libs/ardour/lv2ext/lv2_event_helpers.h deleted file mode 100644 index de7d07e0f8..0000000000 --- a/libs/ardour/lv2ext/lv2_event_helpers.h +++ /dev/null @@ -1,243 +0,0 @@ -/* lv2_event_helpers.h - Helper functions for the LV2 events extension. - * - * Copyright (C) 2008 David Robillard - * - * This header is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This header 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this header; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA - */ - -#ifndef LV2_EVENT_HELPERS_H -#define LV2_EVENT_HELPERS_H - -#include -#include -#include -#include -#include -#include "lv2_event.h" - -/** @file - * This header defines some helper functions for the the LV2 events extension - * with URI ('lv2ev'). - * - * These functions are provided for convenience only, use of them is not - * required for supporting lv2ev (i.e. the events extension is defined by the - * raw buffer format described in lv2_event.h and NOT by this API). - * - * Note that these functions are all static inline which basically means: - * do not take the address of these functions. */ - - -/** Pad a size to 64 bits (for event sizes) */ -static inline uint16_t -lv2_event_pad_size(uint16_t size) -{ - return (size + 7) & (~7); -} - - -/** Initialize (empty, reset..) an existing event buffer. - * The contents of buf are ignored entirely and overwritten, except capacity - * which is unmodified. */ -static inline void -lv2_event_buffer_reset(LV2_Event_Buffer* buf, uint16_t stamp_type, uint8_t *data) -{ - buf->data = data; - buf->header_size = sizeof(LV2_Event_Buffer); - buf->stamp_type = stamp_type; - buf->event_count = 0; - buf->size = 0; -} - - -/** Allocate a new, empty event buffer. */ -static inline LV2_Event_Buffer* -lv2_event_buffer_new(uint32_t capacity, uint16_t stamp_type) -{ - LV2_Event_Buffer* buf = (LV2_Event_Buffer*)malloc(sizeof(LV2_Event_Buffer) + capacity); - if (buf != NULL) { - buf->capacity = capacity; - lv2_event_buffer_reset(buf, stamp_type, (uint8_t *)(buf + 1)); - return buf; - } else { - return NULL; - } -} - - -/** An iterator over an LV2_Event_Buffer. - * - * Multiple simultaneous read iterators over a single buffer is fine, - * but changing the buffer invalidates all iterators (e.g. RW Lock). */ -typedef struct { - LV2_Event_Buffer* buf; - uint32_t offset; -} LV2_Event_Iterator; - - -/** Reset an iterator to point to the start of @a buf. - * @return True if @a iter is valid, otherwise false (buffer is empty) */ -static inline bool -lv2_event_begin(LV2_Event_Iterator* iter, - LV2_Event_Buffer* buf) -{ - iter->buf = buf; - iter->offset = 0; - return (buf->size > 0); -} - - -/** Check if @a iter is valid.. - * @return True if @a iter is valid, otherwise false (past end of buffer) */ -static inline bool -lv2_event_is_valid(LV2_Event_Iterator* iter) -{ - return (iter->offset < iter->buf->size); -} - - -/** Advance @a iter forward one event. - * @a iter must be valid. - * @return True if @a iter is valid, otherwise false (reached end of buffer) */ -static inline bool -lv2_event_increment(LV2_Event_Iterator* iter) -{ - assert(lv2_event_is_valid(iter)); - - LV2_Event* const ev = (LV2_Event*)( - (uint8_t*)iter->buf->data + iter->offset); - - iter->offset += lv2_event_pad_size(sizeof(LV2_Event) + ev->size); - - return true; -} - - -/** Dereference an event iterator (get the event currently pointed at). - * @a iter must be valid. - * @a data if non-NULL, will be set to point to the contents of the event - * returned. - * @return A Pointer to the event @a iter is currently pointing at, or NULL - * if the end of the buffer is reached (in which case @a data is - * also set to NULL). */ -static inline LV2_Event* -lv2_event_get(LV2_Event_Iterator* iter, - uint8_t** data) -{ - assert(lv2_event_is_valid(iter)); - - LV2_Event* const ev = (LV2_Event*)( - (uint8_t*)iter->buf->data + iter->offset); - - if (data) - *data = (uint8_t*)ev + sizeof(LV2_Event); - - return ev; -} - - -/** Write an event at @a iter. - * The event (if any) pointed to by @iter will be overwritten, and @a iter - * incremented to point to the following event (i.e. several calls to this - * function can be done in sequence without twiddling iter in-between). - * @return True if event was written, otherwise false (buffer is full). */ -static inline bool -lv2_event_write(LV2_Event_Iterator* iter, - uint32_t frames, - uint32_t subframes, - uint16_t type, - uint16_t size, - const uint8_t* data) -{ - if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) - return false; - - LV2_Event* const ev = (LV2_Event*)( - (uint8_t*)iter->buf->data + iter->offset); - - ev->frames = frames; - ev->subframes = subframes; - ev->type = type; - ev->size = size; - memcpy((uint8_t*)ev + sizeof(LV2_Event), data, size); - ++iter->buf->event_count; - - size = lv2_event_pad_size(sizeof(LV2_Event) + size); - iter->buf->size += size; - iter->offset += size; - - return true; -} - - -/** Reserve space for an event in the buffer and return a pointer to - the memory where the caller can write the event data, or NULL if there - is not enough room in the buffer. */ -static inline uint8_t* -lv2_event_reserve(LV2_Event_Iterator* iter, - uint32_t frames, - uint32_t subframes, - uint16_t type, - uint16_t size) -{ - size = lv2_event_pad_size(size); - if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + size) - return NULL; - - LV2_Event* const ev = (LV2_Event*)((uint8_t*)iter->buf->data + - iter->offset); - - ev->frames = frames; - ev->subframes = subframes; - ev->type = type; - ev->size = size; - ++iter->buf->event_count; - - size = lv2_event_pad_size(sizeof(LV2_Event) + size); - iter->buf->size += size; - iter->offset += size; - - return (uint8_t*)ev + sizeof(LV2_Event); -} - - -/** Write an event at @a iter. - * The event (if any) pointed to by @iter will be overwritten, and @a iter - * incremented to point to the following event (i.e. several calls to this - * function can be done in sequence without twiddling iter in-between). - * @return True if event was written, otherwise false (buffer is full). */ -static inline bool -lv2_event_write_event(LV2_Event_Iterator* iter, - const LV2_Event* ev, - const uint8_t* data) -{ - if (iter->buf->capacity - iter->buf->size < sizeof(LV2_Event) + ev->size) - return false; - - LV2_Event* const write_ev = (LV2_Event*)( - (uint8_t*)iter->buf->data + iter->offset); - - *write_ev = *ev; - memcpy((uint8_t*)write_ev + sizeof(LV2_Event), data, ev->size); - ++iter->buf->event_count; - - const uint16_t size = lv2_event_pad_size(sizeof(LV2_Event) + ev->size); - iter->buf->size += size; - iter->offset += size; - - return true; -} - -#endif // LV2_EVENT_HELPERS_H - diff --git a/libs/ardour/lv2ext/lv2_files.h b/libs/ardour/lv2ext/lv2_files.h deleted file mode 100644 index f996e2ed16..0000000000 --- a/libs/ardour/lv2ext/lv2_files.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright 2010-2011 David Robillard - - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR - OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR - OTHER DEALINGS IN THE SOFTWARE. -*/ - -/** - @file files.h - C API for the LV2 Files extension . -*/ - -#ifndef LV2_FILES_H -#define LV2_FILES_H - -#ifdef __cplusplus -extern "C" { -#endif - -#define LV2_FILES_URI "http://lv2plug.in/ns/ext/files" -#define LV2_FILES_PATH_SUPPORT_URI LV2_FILES_URI "#pathSupport" -#define LV2_FILES_NEW_FILE_SUPPORT_URI LV2_FILES_URI "#newFileSupport" - -typedef void* LV2_Files_Host_Data; - -/** - files:pathSupport feature struct. - - To support this feature, the host MUST pass an LV2_Feature struct with @a - URI @ref LV2_FILES_PATH_SUPPORT_URI and @a data pointed to an instance of - this struct. -*/ -typedef struct { - - /** - Opaque host data. - */ - LV2_Files_Host_Data host_data; - - /** - Map an absolute path to an abstract path for use in plugin state. - @param host_data MUST be the @a host_data member of this struct. - @param absolute_path The absolute path of a file. - @return An abstract path suitable for use in plugin state. - - The plugin MUST use this function to map any paths that will be stored - in plugin state. The returned value is an abstract path which MAY not - be an actual file system path; @ref absolute_path MUST be used to map it - to an actual path in order to use the file. - - Hosts MAY map paths in any way (e.g. by creating symbolic links within - the plugin's state directory or storing a list of referenced files for - later export). Plugins MUST NOT make any assumptions about abstract - paths except that they can be mapped to an absolute path using @ref - absolute_path. Particularly when restoring from state, this absolute - path MAY not be the same as the original absolute path, but the host - MUST guarantee it refers to a file with contents equivalent to the - original. - - This function may only be called within the context of - LV2_Persist.save() or LV2_Persist.restore(). The caller is responsible - for freeing the returned value. - */ - char* (*abstract_path)(LV2_Files_Host_Data host_data, - const char* absolute_path); - - /** - Map an abstract path from plugin state to an absolute path. - @param host_data MUST be the @a host_data member of this struct. - @param abstract_path An abstract path (e.g. a path from plugin state). - @return An absolute file system path. - - Since abstract paths are not necessarily actual file paths (or at least - not necessarily absolute paths), this function MUST be used in order to - actually open or otherwise use the file referred to by an abstract path. - - This function may only be called within the context of - LV2_Persist.save() or LV2_Persist.restore(). The caller is responsible - for freeing the returned value. - */ - char* (*absolute_path)(LV2_Files_Host_Data host_data, - const char* abstract_path); - -} LV2_Files_Path_Support; - -/** - files:newFileSupport feature struct. - - To support this feature, the host MUST pass an LV2_Feature struct with @a - URI @ref LV2_FILES_NEW_FILE_SUPPORT_URI and @a data pointed to an instance - of this struct. -*/ -typedef struct { - - /** - Opaque host data. - */ - LV2_Files_Host_Data host_data; - - /** - Return an absolute path the plugin may use to create a new file. - @param host_data MUST be the @a host_data member of this struct. - @param relative_path The relative path of the file. - @return The absolute path to use for the new file. - - The plugin can assume @a relative_path is relative to a namespace - dedicated to that plugin instance; hosts MUST ensure this, e.g. by - giving each plugin instance its own state directory. The returned path - is absolute and thus suitable for creating and using a file, but NOT - suitable for storing in plugin state (it MUST be mapped to an abstract - path using @ref LV2_Files_Path_Support::abstract_path to do so). - - This function may be called from any non-realtime context. The caller - is responsible for freeing the returned value. - */ - char* (*new_file_path)(LV2_Files_Host_Data host_data, - const char* relative_path); - -} LV2_Files_New_File_Support; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* LV2_FILES_H */ diff --git a/libs/ardour/lv2ext/lv2_persist.h b/libs/ardour/lv2ext/lv2_persist.h deleted file mode 100644 index 6879a865ba..0000000000 --- a/libs/ardour/lv2ext/lv2_persist.h +++ /dev/null @@ -1,228 +0,0 @@ -/* - Copyright 2010-2011 David Robillard - Copyright 2010 Leonard Ritter - - This header is free software; you can redistribute it and/or modify it - under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This header 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 Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with this header; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA -*/ - -/** - @file - C API for the LV2 Persist extension . -*/ - -#ifndef LV2_PERSIST_H -#define LV2_PERSIST_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define LV2_PERSIST_URI "http://lv2plug.in/ns/ext/persist" - -/** - Flags describing value characteristics. - - These flags are used along with the value's type URI to determine how to - (de-)serialise the value data, or whether it is even possible to do so. -*/ -typedef enum { - - /** - Plain Old Data. - - Values with this flag contain no references to non-persistent or - non-global resources (e.g. pointers, handles, local paths, etc.). It is - safe to copy POD values with a simple memcpy and store them for use at - any time in the future on a machine with a compatible architecture - (e.g. the same endianness and alignment). - - Implementations MUST NOT attempt to copy or serialise a non-POD value if - they do not understand its type (and thus know how to correctly do so). - */ - LV2_PERSIST_IS_POD = 1, - - /** - Portable (architecture independent) data. - - Values with this flag are in a format that is usable on any - architecture, i.e. if the value is saved on one machine it can safely be - restored on another machine regardless of endianness, alignment, etc. - */ - LV2_PERSIST_IS_PORTABLE = 1 << 1 - -} LV2_Persist_Flags; - -/** - A host-provided function to store a plugin instance property. - @param callback_data Must be the callback_data passed to LV2_Persist.save(). - @param key The key (predicate) to store @a value under (URI mapped integer). - @param value Pointer to the value (object) to be stored. - @param size The size of the data at @a value in bytes. - @param type The type of @a value (URI). - @param flags LV2_Persist_Flags for @a value. - @return 0 on success, otherwise a non-zero error code. - - The host passes a callback of this type to LV2_Persist.save(). This callback - is called repeatedly by the plugin within LV2_Persist.save() to store all - the statements that describe its current state. - - The host MAY fail to store a property if the type is not understood and is - not LV2_PERSIST_IS_POD and/or LV2_PERSIST_IS_PORTABLE. Implementations are - encouraged to use POD and portable values (e.g. string literals) wherever - possible, and use common types (e.g. types from - http://lv2plug.in/ns/ext/atom) regardless, since hosts are likely to already - contain the necessary implementation. - - Note that @a size MUST be > 0, and @a value MUST point to a valid region of - memory @a size bytes long (this is required to make restore unambiguous). - - The plugin MUST NOT attempt to use this function outside of the - LV2_Persist.restore() context. -*/ -typedef int (*LV2_Persist_Store_Function)( - void* callback_data, - uint32_t key, - const void* value, - size_t size, - uint32_t type, - uint32_t flags); - -/** - A host-provided function to retrieve a property. - @param callback_data Must be the callback_data passed to LV2_Persist.restore(). - @param key The key (predicate) of the property to retrieve (URI). - @param size (Output) If non-NULL, set to the size of the restored value. - @param type (Output) If non-NULL, set to the type of the restored value. - @param flags (Output) If non-NULL, set to the LV2_Persist_Flags for - the returned value. - @return A pointer to the restored value (object), or NULL if no value - has been stored under @a key. - - A callback of this type is passed by the host to LV2_Persist.restore(). This - callback is called repeatedly by the plugin within LV2_Persist.restore() to - retrieve any properties it requires to restore its state. - - The returned value MUST remain valid until LV2_Persist.restore() returns. - - The plugin MUST NOT attempt to use this function, or any value returned from - it, outside of the LV2_Persist.restore() context. Returned values MAY be - copied for later use if necessary, assuming the plugin knows how to do so - correctly (e.g. the value is POD, or the plugin understands the type). -*/ -typedef const void* (*LV2_Persist_Retrieve_Function)( - void* callback_data, - uint32_t key, - size_t* size, - uint32_t* type, - uint32_t* flags); - -/** - Persist Extension Data. - - When the plugin's extension_data is called with argument LV2_PERSIST_URI, - the plugin MUST return an LV2_Persist structure, which remains valid for the - lifetime of the plugin. - - The host can use the contained function pointers to save and restore the - state of a plugin instance at any time (provided the threading restrictions - for the given function are met). - - The typical use case is to save the plugin's state when a project is saved, - and to restore the state when a project has been loaded. Other uses are - possible (e.g. cloning plugin instances or taking a snapshot of plugin - state). - - Stored data is only guaranteed to be compatible between instances of plugins - with the same URI (i.e. if a change to a plugin would cause a fatal error - when restoring state saved by a previous version of that plugin, the plugin - URI MUST change just as it must when ports change incompatibly). Plugin - authors should consider this possibility, and always store sensible data - with meaningful types to avoid such compatibility issues in the future. -*/ -typedef struct _LV2_Persist { - - /** - Save plugin state using a host-provided @a store callback. - - @param instance The instance handle of the plugin. - @param store The host-provided store callback. - @param callback_data An opaque pointer to host data, e.g. the map or - file where the values are to be stored. If @a store is called, - this MUST be passed as its callback_data parameter. - - The plugin is expected to store everything necessary to completely - restore its state later (possibly much later, in a different process, on - a completely different machine, etc.) - - The @a callback_data pointer and @a store function MUST NOT be used - beyond the scope of save(). - - This function has its own special threading class: it may not be called - concurrently with any "Instantiation" function, but it may be called - concurrently with functions in any other class, unless the definition of - that class prohibits it (e.g. it may not be called concurrently with a - "Discovery" function, but it may be called concurrently with an "Audio" - function. The plugin is responsible for any locking or lock-free - techniques necessary to make this possible. - - Note that in the simple case where state is only modified by restore(), - there are no synchronization issues since save() is never called - concurrently with restore() (though run() may read it during a save). - - Plugins that dynamically modify state while running, however, must take - care to do so in such a way that a concurrent call to save() will save a - consistent representation of plugin state for a single instant in time. - */ - void (*save)(LV2_Handle instance, - LV2_Persist_Store_Function store, - void* callback_data); - - /** - Restore plugin state using a host-provided @a retrieve callback. - - @param instance The instance handle of the plugin. - @param retrieve The host-provided retrieve callback. - @param callback_data An opaque pointer to host data, e.g. the map or - file from which the values are to be restored. If @a retrieve is - called, this MUST be passed as its callback_data parameter. - - The plugin MAY assume a restored value was set by a previous call to - LV2_Persist.save() by a plugin with the same URI. - - The plugin MUST gracefully fall back to a default value when a value can - not be retrieved. This allows the host to reset the plugin state with an - empty map. - - The @a callback_data pointer and @a store function MUST NOT be used - beyond the scope of restore(). - - This function is in the "Instantiation" threading class as defined by - LV2. This means it MUST NOT be called concurrently with any other - function on the same plugin instance. - */ - void (*restore)(LV2_Handle instance, - LV2_Persist_Retrieve_Function retrieve, - void* callback_data); - -} LV2_Persist; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* LV2_PERSIST_H */ diff --git a/libs/ardour/lv2ext/lv2_uri_map.h b/libs/ardour/lv2ext/lv2_uri_map.h deleted file mode 100644 index 4066a2f468..0000000000 --- a/libs/ardour/lv2ext/lv2_uri_map.h +++ /dev/null @@ -1,88 +0,0 @@ -/* lv2_uri_map.h - C header file for the LV2 URI Map extension. - * - * Copyright (C) 2008 David Robillard - * - * This header is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This header 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this header; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA - */ - -#ifndef LV2_URI_MAP_H -#define LV2_URI_MAP_H - -#define LV2_URI_MAP_URI "http://lv2plug.in/ns/ext/uri-map" - -#include - -/** @file - * This header defines the LV2 URI Map extension with the URI - * (preferred prefix 'lv2urimap'). - * - * This extension defines a simple mechanism for plugins to map URIs to - * integers, usually for performance reasons (e.g. processing events - * typed by URIs in real time). The expected use case is for plugins to - * map URIs to integers for things they 'understand' at instantiation time, - * and store those values for use in the audio thread without doing any string - * comparison. This allows the extensibility of RDF with the performance of - * integers (or centrally defined enumerations). - */ - - -/** Opaque pointer to host data. */ -typedef void* LV2_URI_Map_Callback_Data; - - -/** The data field of the LV2_Feature for this extension. - * - * To support this feature the host must pass an LV2_Feature struct to the - * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-map" - * and data pointed to an instance of this struct. - */ -typedef struct { - - /** Opaque pointer to host data. - * - * The plugin MUST pass this to any call to functions in this struct. - * Otherwise, it must not be interpreted in any way. - */ - LV2_URI_Map_Callback_Data callback_data; - - /** Get the numeric ID of a URI from the host. - * - * @param callback_data Must be the callback_data member of this struct. - * @param map The 'context' of this URI. Certain extensions may define a - * URI that must be passed here with certain restrictions on the - * return value (e.g. limited range). This value may be NULL if - * the plugin needs an ID for a URI in general. - * @param uri The URI to be mapped to an integer ID. - * - * This function is referentially transparent - any number of calls with - * the same arguments is guaranteed to return the same value over the life - * of a plugin instance (though the same URI may return different values - * with a different map parameter). However, this function is not - * necessarily very fast: plugins should cache any IDs they might need in - * performance critical situations. - * The return value 0 is reserved and means an ID for that URI could not - * be created for whatever reason. Extensions may define more precisely - * what this means, but in general plugins should gracefully handle 0 - * and consider whatever they wanted the URI for "unsupported". - */ - uint32_t (*uri_to_id)(LV2_URI_Map_Callback_Data callback_data, - const char* map, - const char* uri); - -} LV2_URI_Map_Feature; - - -#endif // LV2_URI_MAP_H - diff --git a/libs/ardour/lv2ext/lv2_uri_unmap.h b/libs/ardour/lv2ext/lv2_uri_unmap.h deleted file mode 100644 index d6cb90039a..0000000000 --- a/libs/ardour/lv2ext/lv2_uri_unmap.h +++ /dev/null @@ -1,81 +0,0 @@ -/* lv2_uri_unmap.h - C header file for the LV2 URI Unmap extension. - * - * Copyright (C) 2010 David Robillard - * - * This header is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This header 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 Lesser General Public - * License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this header; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 01222-1307 USA - */ - -/** @file - * C header for the LV2 URI Map extension . - */ - -#ifndef LV2_URI_UNMAP_H -#define LV2_URI_UNMAP_H - -#define LV2_URI_UNMAP_URI "http://lv2plug.in/ns/ext/uri-unmap" - -#include - - -/** Opaque pointer to host data. */ -typedef void* LV2_URI_Unmap_Callback_Data; - - -/** The data field of the LV2_Feature for the URI Unmap extension. - * - * To support this extension the host must pass an LV2_Feature struct to the - * plugin's instantiate method with URI "http://lv2plug.in/ns/ext/uri-unmap" - * and data pointed to an instance of this struct. - */ -typedef struct { - - /** Opaque pointer to host data. - * - * The plugin MUST pass this to any call to functions in this struct. - * Otherwise, it must not be interpreted in any way. - */ - LV2_URI_Unmap_Callback_Data callback_data; - - /** Get the numeric ID of a URI from the host. - * - * @param callback_data Must be the callback_data member of this struct. - * @param map The 'context' used to map this URI. - * @param id The URI ID to unmap. - * @return The string form of @a id, or NULL on error. - * - * The @a id MUST be a value previously returned from - * LV2_Uri_Map_Feature.uri_to_id. - * - * The returned string is owned by the host and MUST NOT be freed by - * the plugin or stored for a long period of time (e.g. across run - * invocations) without copying. - * - * This function is referentially transparent - any number of calls with - * the same arguments is guaranteed to return the same value over the life - * of a plugin instance (though the same ID may return different values - * with a different map parameter). - * - * This function may be called from any non-realtime thread, possibly - * concurrently (hosts may simply use a mutex to meet these requirements). - */ - const char* (*id_to_uri)(LV2_URI_Unmap_Callback_Data callback_data, - const char* map, - uint32_t id); - -} LV2_URI_Unmap_Feature; - - -#endif /* LV2_URI_UNMAP_H */ - -- cgit v1.2.3