diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-06-11 19:15:09 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2012-06-11 19:15:09 +0200 |
commit | fa10bccb322dedee6b72d6f8c1834de8b194d3ca (patch) | |
tree | e3ffaecb550be05abc3eabb3ac812d75e351e17d | |
parent | 30d7235c2ceda6d549438a9204b60a0e1f9186de (diff) |
Port to new LV2 state interface. Use new lv2-1.0 header files (from system) and remove local copies of same.
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | lv2/drumgizmo.ttl | 10 | ||||
-rw-r--r-- | lv2/event-helpers.h | 243 | ||||
-rw-r--r-- | lv2/input_lv2.h | 2 | ||||
-rw-r--r-- | lv2/lv2.cc | 102 | ||||
-rw-r--r-- | lv2/lv2_data_access.h | 59 | ||||
-rw-r--r-- | lv2/lv2_gui.cc | 7 | ||||
-rw-r--r-- | lv2/lv2_gui.h | 3 | ||||
-rw-r--r-- | lv2/lv2_instance-access.h | 38 | ||||
-rw-r--r-- | lv2/lv2_instance.h | 9 | ||||
-rw-r--r-- | lv2/lv2_persist.h | 231 | ||||
-rw-r--r-- | lv2/lv2_state.h | 354 | ||||
-rw-r--r-- | lv2/lv2_ui.h | 372 | ||||
-rw-r--r-- | lv2/lv2_uri_map.h | 86 |
14 files changed, 112 insertions, 1406 deletions
diff --git a/configure.in b/configure.in index 8222e9e..cf2cb51 100644 --- a/configure.in +++ b/configure.in @@ -33,7 +33,7 @@ if test "x$enable_lv2" = "xyes"; then dnl ====================== dnl Check for lv2core dnl ====================== - PKG_CHECK_MODULES(LV2, lv2core >= 4.1) + PKG_CHECK_MODULES(LV2, lv2 >= 1.0) else AC_MSG_RESULT([*** LV2 plugin will not be compiled ***]) enable_lv2=no diff --git a/lv2/drumgizmo.ttl b/lv2/drumgizmo.ttl index 73af11e..93d2d92 100644 --- a/lv2/drumgizmo.ttl +++ b/lv2/drumgizmo.ttl @@ -13,9 +13,9 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -@prefix doap: <http://usefulinc.com/ns/doap#> . -@prefix foaf: <http://xmlns.com/foaf/0.1/> . -@prefix lv2: <http://lv2plug.in/ns/lv2core#> . +@prefix doap: <http://usefulinc.com/ns/doap#> . +@prefix foaf: <http://xmlns.com/foaf/0.1/> . +@prefix lv2: <http://lv2plug.in/ns/lv2core#> . @prefix lv2ev: <http://lv2plug.in/ns/ext/event#> . @prefix uiext: <http://lv2plug.in/ns/extensions/ui#> . @prefix state: <http://lv2plug.in/ns/ext/state#> . @@ -31,8 +31,8 @@ doap:license <http://opensource.org/licenses/gpl-3.0> ; lv2:optionalFeature <http://lv2plug.in/ns/ext/uri-map> ; lv2:optionalFeature <http://lv2plug.in/ns/ext/event> ; - lv2:extensionData state:Interface ; - lv2:port [ + lv2:extensionData state:interface ; +lv2:port [ a lv2:InputPort , lv2ev:EventPort ; lv2ev:supportsEvent <http://lv2plug.in/ns/ext/midi#MidiEvent> ; diff --git a/lv2/event-helpers.h b/lv2/event-helpers.h deleted file mode 100644 index fb7de65..0000000 --- a/lv2/event-helpers.h +++ /dev/null @@ -1,243 +0,0 @@ -/* lv2_event_helpers.h - Helper functions for the LV2 events extension. - * - * Copyright (C) 2008-2009 David Robillard <http://drobilla.net> - * - * 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 <stdint.h> -#include <stdbool.h> -#include <string.h> -#include <stdlib.h> -#include <assert.h> -#include "lv2_event.h" - -/** @file - * Helper functions for the LV2 Event extension - * <http://lv2plug.in/ns/ext/event>. - * - * 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 @a 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 @a 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/lv2/input_lv2.h b/lv2/input_lv2.h index d6d4727..00e0b51 100644 --- a/lv2/input_lv2.h +++ b/lv2/input_lv2.h @@ -30,7 +30,7 @@ #include <audioinputengine.h> #include <midimapper.h> -#include "event-helpers.h" +#include <lv2/lv2plug.in/ns/ext/event/event-helpers.h> class InputLV2 : public AudioInputEngine { public: @@ -24,12 +24,11 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <lv2.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> #include <stdlib.h> #include "lv2_gui.h" -#include "lv2_state.h" #include "lv2_instance.h" @@ -49,10 +48,10 @@ static DrumGizmo *dg_get_pci(LV2_Handle instance) return dglv2->dg; } - /* * Stuff to save/restore plugin state. */ +/* void dg_save(LV2_Handle instance, LV2_State_Store_Function store, void* callback_data, @@ -98,7 +97,88 @@ void dg_restore(LV2_Handle instance, dglv2->in->loadMidiMap(dglv2->dg->midimapfile); } +*/ +LV2_State_Status +dg_save(LV2_Handle instance, + LV2_State_Store_Function store, + LV2_State_Handle handle, + uint32_t flags, + const LV2_Feature *const * features) +{ + DGLV2 *dglv2 = (DGLV2 *)instance; + printf("dg_save\n"); + std::string config = dglv2->dg->configString(); + printf("%s\n", config.c_str()); + + store(handle, + dglv2->urimap->uri_to_id(dglv2->urimap->callback_data, + NULL, NS_DG "config"), + config.c_str(), + config.length() + 1, // Careful! Need space for terminator + dglv2->urimap->uri_to_id(dglv2->urimap->callback_data, + NULL, NS_ATOM "String"), + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); +/* + MyPlugin* plugin = (MyPlugin*)instance; + const char* greeting = plugin->state.greeting; + + store(handle, + plugin->uris.my_greeting, + greeting, + strlen(greeting) + 1, // Careful! Need space for terminator + plugin->uris.atom_String, + LV2_STATE_IS_POD | LV2_STATE_IS_PORTABLE); +*/ + printf("dg_save\n"); + return LV2_STATE_SUCCESS; +} + +LV2_State_Status +dg_restore(LV2_Handle instance, + LV2_State_Retrieve_Function retrieve, + LV2_State_Handle handle, + uint32_t flags, + const LV2_Feature *const * features) +{ + DGLV2 *dglv2 = (DGLV2 *)instance; + printf("dg_restore\n"); + + size_t size; + uint32_t type; + // uint32_t flags; + + const char* data = + (const char*)retrieve(handle, + dglv2->urimap->uri_to_id(dglv2->urimap->callback_data, + NULL, NS_DG "config"), + &size, &type, &flags); + std::string config; + config.append(data, size - 1); + dglv2->dg->setConfigString(config); + + dglv2->in->loadMidiMap(dglv2->dg->midimapfile); + + /* + MyPlugin* plugin = (MyPlugin*)instance; + + size_t size; + uint32_t type; + uint32_t flags; + const char* greeting = retrieve( + handle, plugin->uris.my_greeting, &size, &type, &flags); + + if (greeting) { + free(plugin->state->greeting); + plugin->state->greeting = strdup(greeting); + } else { + plugin->state->greeting = strdup(DEFAULT_GREETING); + } + */ + printf("dg_restore\n"); + + return LV2_STATE_SUCCESS; +} static LV2_State_Interface dg_persist = { dg_save, @@ -154,6 +234,9 @@ LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor, if (!strcmp(features[i]->URI, LV2_URI_MAP_URI)) { dglv2->urimap = (LV2_URI_Map_Feature*)features[i]->data; } + if (!strcmp(features[i]->URI, LV2_STATE__makePath)) { + dglv2->makepath = (LV2_State_Make_Path*)features[i]->data; + } } dg_descriptor.get_pci = dg_get_pci; @@ -164,6 +247,14 @@ LV2_Handle instantiate(const struct _LV2_Descriptor *descriptor, dglv2->buffer = NULL; dglv2->buffer_size = 0; + /* + char* path = dglv2->makepath->path(dglv2->makepath->handle, + "hello.txt"); + FILE* myfile = fopen(path, "w"); + fprintf(myfile, "world"); + fclose(myfile); + */ + dglv2->dg = new DrumGizmo(dglv2->out, dglv2->in); // dglv2->dg->loadkit(getenv("DRUMGIZMO_DRUMKIT")); // dglv2->dg->init(true); @@ -280,7 +371,6 @@ void run(LV2_Handle instance, printf("(Re)allocate buffer: %d samples\n", dglv2->buffer_size); } */ - dglv2->dg->run(pos, dglv2->buffer, sample_count); pos += sample_count; @@ -353,9 +443,7 @@ const void* extension_data(const char *uri) printf("extension_data(%s)\n", uri); if(!strcmp(uri, PLUGIN_INSTANCE_URI)) return &dg_descriptor; - if(!strcmp(uri, "http://lv2plug.in/ns/ext/state#Interface")) { - return &dg_persist; - } + if(!strcmp(uri, LV2_STATE__interface)) return &dg_persist; return NULL; } diff --git a/lv2/lv2_data_access.h b/lv2/lv2_data_access.h deleted file mode 100644 index d6403b4..0000000 --- a/lv2/lv2_data_access.h +++ /dev/null @@ -1,59 +0,0 @@ -/* lv2_data_access.h - C header file for the LV2 Data Access extension. - * Copyright (C) 2008 Dave Robillard <dave@drobilla.net> - * - * 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_DATA_ACCESS_H -#define LV2_DATA_ACCESS_H - -#define LV2_DATA_ACCESS_URI "http://lv2plug.in/ns/ext/data-access" - - -/** @file - * This header defines the LV2 Extension Data extension with the URI - * <http://lv2plug.in/ns/ext/data-access>. - * - * This extension defines a method for (e.g.) plugin UIs to have (possibly - * marshalled) access to the extension_data function on a plugin instance. - */ - - -/** The data field of the LV2_Feature for this extension. - * - * To support this feature the host must pass an LV2_Feature struct to the - * instantiate method with URI "http://lv2plug.in/ns/ext/data-access" - * and data pointed to an instance of this struct. - */ -typedef struct { - - /** A pointer to a method the UI can call to get data (of a type specified - * by some other extension) from the plugin. - * - * This call never is never guaranteed to return anything, UIs should - * degrade gracefully if direct access to the plugin data is not possible - * (in which case this function will return NULL). - * - * This is for access to large data that can only possibly work if the UI - * and plugin are running in the same process. For all other things, use - * the normal LV2 UI communication system. - */ - const void* (*data_access)(const char* uri); - -} LV2_Extension_Data_Feature; - - -#endif // LV2_DATA_ACCESS_H - diff --git a/lv2/lv2_gui.cc b/lv2/lv2_gui.cc index de5e566..5524a76 100644 --- a/lv2/lv2_gui.cc +++ b/lv2/lv2_gui.cc @@ -24,17 +24,16 @@ * along with DrumGizmo; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#include <lv2.h> - #include "lv2_gui.h" -#include "lv2_ui.h" #include <stdio.h> #include <string.h> +#include <lv2/lv2plug.in/ns/ext/instance-access/instance-access.h> +#include <lv2/lv2plug.in/ns/extensions/ui/ui.h> + #include "lv2_instance.h" -#include "lv2_instance-access.h" // From: http://codesearch.google.com/#50sg5qT6WNE/src/lv2_ui_dssi.c // git://repo.or.cz/nekobee.git/src/lv2_ui_dssi.c diff --git a/lv2/lv2_gui.h b/lv2/lv2_gui.h index aef2127..2857445 100644 --- a/lv2/lv2_gui.h +++ b/lv2/lv2_gui.h @@ -27,7 +27,8 @@ #ifndef __DRUMGIZMO_LV2_GUI_H__ #define __DRUMGIZMO_LV2_GUI_H__ -#include "lv2_data_access.h" +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> +#include <lv2/lv2plug.in/ns/ext/data-access/data-access.h> #define PLUGIN_INSTANCE_URI "http://drumgizmo.org/ns/drumgizmo-plugin-instance" diff --git a/lv2/lv2_instance-access.h b/lv2/lv2_instance-access.h deleted file mode 100644 index 7e18ee4..0000000 --- a/lv2/lv2_instance-access.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - LV2 Instance Access Extension - Copyright 2008-2011 David Robillard <http://drobilla.net> - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#ifndef LV2_INSTANCE_ACCESS_H -#define LV2_INSTANCE_ACCESS_H - -#define LV2_INSTANCE_ACCESS_URI "http://lv2plug.in/ns/ext/instance-access" - - -/** @file - * C header for the LV2 Instance Access extension - * <http://lv2plug.in/ns/ext/instance-access>. - * - * This extension defines a method for (e.g.) plugin UIs to get a direct - * handle to an LV2 plugin instance (LV2_Handle), if possible. - * - * To support this feature the host must pass an LV2_Feature struct to the - * UI instantiate method with URI "http://lv2plug.in/ns/ext/instance-access" - * and data pointed directly to the LV2_Handle of the plugin instance. - */ - - -#endif /* LV2_INSTANCE_ACCESS_H */ - diff --git a/lv2/lv2_instance.h b/lv2/lv2_instance.h index 2619e5e..b4772f6 100644 --- a/lv2/lv2_instance.h +++ b/lv2/lv2_instance.h @@ -27,22 +27,23 @@ #ifndef __DRUMGIZMO_LV2_INSTANCE_H__ #define __DRUMGIZMO_LV2_INSTANCE_H__ -#include <lv2.h> +#include <lv2/lv2plug.in/ns/lv2core/lv2.h> +#include <lv2/lv2plug.in/ns/ext/state/state.h> +#include <lv2/lv2plug.in/ns/ext/uri-map/uri-map.h> #include "input_lv2.h" #include "output_lv2.h" #include <drumgizmo.h> -#include "lv2_uri_map.h" - typedef struct { InputLV2 *in; OutputLV2 *out; DrumGizmo *dg; sample_t *buffer; size_t buffer_size; - LV2_URI_Map_Feature* urimap; + LV2_URI_Map_Feature *urimap; + LV2_State_Make_Path *makepath; } DGLV2; #endif/*__DRUMGIZMO_LV2_INSTANCE_H__*/ diff --git a/lv2/lv2_persist.h b/lv2/lv2_persist.h deleted file mode 100644 index 69f1181..0000000 --- a/lv2/lv2_persist.h +++ /dev/null @@ -1,231 +0,0 @@ -/* - Copyright 2010-2011 David Robillard <http://drobilla.net> - Copyright 2010 Leonard Ritter <paniq@paniq.org> - - 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 <http://lv2plug.in/ns/ext/persist>. -*/ - -#ifndef LV2_PERSIST_H -#define LV2_PERSIST_H - -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> - -#include "lv2/lv2plug.in/ns/lv2core/lv2.h" - -#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 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/lv2/lv2_state.h b/lv2/lv2_state.h deleted file mode 100644 index 3d39012..0000000 --- a/lv2/lv2_state.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - Copyright 2010-2011 David Robillard <http://drobilla.net> - Copyright 2010 Leonard Ritter <paniq@paniq.org> - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -/** - @file - C API for the LV2 State extension <http://lv2plug.in/ns/ext/state>. -*/ - -#ifndef LV2_STATE_H -#define LV2_STATE_H - -#include <stdbool.h> -#include <stddef.h> -#include <stdint.h> - -#include "lv2/lv2plug.in/ns/lv2core/lv2.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define LV2_STATE_URI "http://lv2plug.in/ns/ext/state" - -#define LV2_STATE_INTERFACE_URI LV2_STATE_URI "#Interface" -#define LV2_STATE_PATH_URI LV2_STATE_URI "#Path" -#define LV2_STATE_MAP_PATH_URI LV2_STATE_URI "#pathMap" -#define LV2_STATE_MAKE_PATH_URI LV2_STATE_URI "#newPath" - -typedef void* LV2_State_Handle; -typedef void* LV2_State_Map_Path_Handle; -typedef void* LV2_State_Make_Path_Handle; - -/** - 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-stateent 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_STATE_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_STATE_IS_PORTABLE = 1 << 1, - - /** - Native data. - - This flag is used by the host to indicate that the saved data is only - going to be used locally in the currently running process (e.g. for - instance duplication or snapshots), so the plugin should use the most - efficient representation possible and not worry about serialisation - and portability. - */ - LV2_STATE_IS_NATIVE = 1 << 2 - -} LV2_State_Flags; - -/** - A host-provided function to store a property. - @param handle Must be the handle passed to LV2_State_Interface.save(). - @param key The key (predicate) to store @c value under (URI mapped integer). - @param value Pointer to the value (object) to be stored. - @param size The size of the data at @c value in bytes. - @param type The type of @c value (URI). - @param flags LV2_State_Flags for @c value. - @return 0 on success, otherwise a non-zero error code. - - The host passes a callback of this type to LV2_State_Interface.save(). This callback - is called repeatedly by the plugin within LV2_State_Interface.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_STATE_IS_POD and/or LV2_STATE_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 @c size MUST be > 0, and @c value MUST point to a valid region of - memory @c size bytes long (this is required to make restore unambiguous). - - The plugin MUST NOT attempt to use this function outside of the - LV2_State_Interface.restore() context. -*/ -typedef int (*LV2_State_Store_Function)(LV2_State_Handle handle, - uint32_t key, - const void* value, - size_t size, - uint32_t type, - uint32_t flags); - -/** - A host-provided function to retrieve a property. - @param handle Must be the handle passed to - LV2_State_Interface.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_State_Flags for - the returned value. - @return A pointer to the restored value (object), or NULL if no value - has been stored under @c key. - - A callback of this type is passed by the host to - LV2_State_Interface.restore(). This callback is called repeatedly by the - plugin within LV2_State_Interface.restore() to retrieve any properties it - requires to restore its state. - - The returned value MUST remain valid until LV2_State_Interface.restore() - returns. - - The plugin MUST NOT attempt to use this function, or any value returned from - it, outside of the LV2_State_Interface.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_State_Retrieve_Function)(LV2_State_Handle handle, - uint32_t key, - size_t* size, - uint32_t* type, - uint32_t* flags); - -/** - State Extension Data. - - When the plugin's extension_data is called with argument LV2_STATE_URI, - the plugin MUST return an LV2_State 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_State_Interface { - - /** - Save plugin state using a host-provided @c store callback. - - @param instance The instance handle of the plugin. - @param store The host-provided store callback. - @param handle An opaque pointer to host data, e.g. the map or - file where the values are to be stored. If @c store is called, this MUST - be passed as its handle parameter. - @param flags Flags describing desires properties of this save. The - plugin SHOULD use these values to determine the most appropriate and/or - efficient serialisation, but is not required to do so. - @param features Extensible parameter for passing any additional - features to be used for this save. - - 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 @c handle pointer and @c 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_State_Store_Function store, - LV2_State_Handle handle, - uint32_t flags, - const LV2_Feature *const * features); - - - /** - Restore plugin state using a host-provided @c retrieve callback. - - @param instance The instance handle of the plugin. - @param retrieve The host-provided retrieve callback. - @param handle An opaque pointer to host data, e.g. the map or - file from which the values are to be restored. If @c retrieve is - called, this MUST be passed as its handle parameter. - @param flags Currently unused. - @param features Extensible parameter for passing any additional - features to be used for this restore. - - The plugin MAY assume a restored value was set by a previous call to - LV2_State_Interface.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 @c handle pointer and @c 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_State_Retrieve_Function retrieve, - LV2_State_Handle handle, - uint32_t flags, - const LV2_Feature *const * features); - -} LV2_State_Interface; - -/** - Feature data for state:pathMap (LV2_STATE_MAP_PATH_URI). -*/ -typedef struct { - - /** - Opaque host data. - */ - LV2_State_Map_Path_Handle handle; - - /** - Map an absolute path to an abstract path for use in plugin state. - @param handle MUST be the @a handle 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 files 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 - elsewhere). Plugins MUST NOT make any assumptions about abstract paths - except that they can be mapped back to an absolute path using @ref - absolute_path. - - This function may only be called within the context of - LV2_State_Interface.save() or LV2_State_Interface.restore(). The caller - is responsible for freeing the returned value. - */ - char* (*abstract_path)(LV2_State_Map_Path_Handle handle, - const char* absolute_path); - - /** - Map an abstract path from plugin state to an absolute path. - @param handle MUST be the @a handle 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_State_Interface.save() or LV2_State_Interface.restore(). The caller - is responsible for freeing the returned value. - */ - char* (*absolute_path)(LV2_State_Map_Path_Handle handle, - const char* abstract_path); - -} LV2_State_Map_Path; - -/** - Feature data for state:makePath (@ref LV2_STATE_MAKE_PATH_URI). -*/ -typedef struct { - - /** - Opaque host data. - */ - LV2_State_Make_Path_Handle handle; - - /** - Return a path the plugin may use to create a new file. - @param handle MUST be the @a handle member of this struct. - @param path The path of the new file relative to a namespace unique - to this plugin instance. - @return The absolute path to use for the new file. - - This function can be used by plugins to create files and directories, - either at state saving time (if this feature is passed to - LV2_State_Interface.save()) or any time (if this feature is passed to - LV2_Descriptor.instantiate()). - - The host must do whatever is necessary for the plugin to be able to - create a file at the returned path (e.g. using fopen), including - creating any leading directories. - - If this function is passed to LV2_Descriptor.instantiate(), it may be - called from any non-realtime context. If it is passed to - LV2_State_Interface.save(), it may only be called within the dynamic - scope of that function call. - - The caller is responsible for freeing the returned value with free(). - */ - char* (*path)(LV2_State_Make_Path_Handle handle, - const char* path); - -} LV2_State_Make_Path; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* LV2_STATE_H */ diff --git a/lv2/lv2_ui.h b/lv2/lv2_ui.h deleted file mode 100644 index 4be2c24..0000000 --- a/lv2/lv2_ui.h +++ /dev/null @@ -1,372 +0,0 @@ -/************************************************************************
- *
- * In-process UI extension for LV2
- *
- * Copyright (C) 2006-2008 Lars Luthman <lars.luthman@gmail.com>
- *
- * Based on lv2.h, which was
- *
- * Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
- * Stefan Westerfeld
- * Copyright (C) 2006 Steve Harris, Dave 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.1 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
- * USA.
- *
- ***********************************************************************/
-
-/** @file
- This extension defines an interface that can be used in LV2 plugins and
- hosts to create UIs for plugins. The UIs are plugins that reside in
- shared object files in an LV2 bundle and are referenced in the RDF data
- using the triples (Turtle shown)
-<pre>
- @@prefix uiext: <http://lv2plug.in/ns/extensions/ui#> .
- <http://my.plugin> uiext:ui <http://my.pluginui> .
- <http://my.plugin> a uiext:GtkUI .
- <http://my.pluginui> uiext:binary <myui.so> .
-</pre>
- where <http://my.plugin> is the URI of the plugin, <http://my.pluginui> is
- the URI of the plugin UI and <myui.so> is the relative URI to the shared
- object file. While it is possible to have the plugin UI and the plugin in
- the same shared object file it is probably a good idea to keep them
- separate so that hosts that don't want UIs don't have to load the UI code.
- A UI MUST specify its class in the RDF data, in this case uiext:GtkUI. The
- class defines what type the UI is, e.g. what graphics toolkit it uses.
- There are no UI classes defined in this extension, those are specified
- separately (and anyone can define their own).
-
- (Note: the prefix above is used throughout this file for the same URI)
-
- It's entirely possible to have multiple UIs for the same plugin, or to have
- the UI for a plugin in a different bundle from the actual plugin - this
- way people other than the plugin author can write plugin UIs independently
- without editing the original plugin bundle.
-
- Note that the process that loads the shared object file containing the UI
- code and the process that loads the shared object file containing the
- actual plugin implementation does not have to be the same. There are many
- valid reasons for having the plugin and the UI in different processes, or
- even on different machines. This means that you can _not_ use singletons
- and global variables and expect them to refer to the same objects in the
- UI and the actual plugin. The function callback interface defined in this
- header is all you can expect to work.
-
- Since the LV2 specification itself allows for extensions that may add
- new types of data and configuration parameters that plugin authors may
- want to control with a UI, this extension allows for meta-extensions that
- can extend the interface between the UI and the host. These extensions
- mirror the extensions used for plugins - there are required and optional
- "features" that you declare in the RDF data for the UI as
-<pre>
- <http://my.pluginui> uiext:requiredFeature <http://my.feature> .
- <http://my.pluginui> uiext:optionalFeature <http://my.feature> .
-</pre>
- These predicates have the same semantics as lv2:requiredFeature and
- lv2:optionalFeature - if a UI is declaring a feature as required, the
- host is NOT allowed to load it unless it supports that feature, and if it
- does support a feature (required or optional) it MUST pass that feature's
- URI and any additional data (specified by the meta-extension that defines
- the feature) in a LV2_Feature struct (as defined in lv2.h) to the UI's
- instantiate() function.
-
- These features may be used to specify how to pass data between the UI
- and the plugin port buffers - see LV2UI_Write_Function for details.
-
- There are four features defined in this extension that hosts may want to
- implement:
-
-<pre>
- uiext:makeResident
-</pre>
- If this feature is required by a UI the host MUST NEVER unload the shared
- library containing the UI implementation during the lifetime of the host
- process (e.g. never calling dlclose() on Linux). This feature may be
- needed by e.g. a Gtk UI that registers its own Glib types using
- g_type_register_static() - if it gets unloaded and then loaded again the
- type registration will break, since there is no way to unregister the
- types when the library is unloaded. The data pointer in the LV2_Feature
- for this feature should always be set to NULL.
-
-<pre>
- uiext:makeSONameResident
-</pre>
- This feature is ELF specific - it should only be used by UIs that
- use the ELF file format for the UI shared object files (e.g. on Linux).
- If it is required by an UI the UI should also list a number of SO names
- (shared object names) for libraries that the UI shared object
- depends on and that may not be unloaded during the lifetime of the host
- process, using the predicate @c uiext:residentSONames, like this:
-<pre>
- <http://my.pluginui> uiext:residentSONames "libgtkmm-2.4.so.1", "libfoo.so.0"
-</pre>
- The host MUST then make sure that the shared libraries with the given ELF
- SO names are not unloaded when the plugin UI is, but stay loaded during
- the entire lifetime of the host process. On Linux this can be accomplished
- by calling dlopen() on the shared library file with that SO name and never
- calling a matching dlclose(). However, if a plugin UI requires the
- @c uiext:makeSONameResident feature, it MUST ALWAYS be safe for the host to
- just never unload the shared object containing the UI implementation, i.e.
- act as if the UI required the @c uiext:makeResident feature instead. Thus
- the host only needs to find the shared library files corresponding to the
- given SO names if it wants to save RAM by unloading the UI shared object
- file when it is no longer needed. The data pointer for the LV2_Feature for
- this feature should always be set to NULL.
-
-<pre>
- uiext:noUserResize
-</pre>
- If an UI requires this feature it indicates that it does not make sense
- to let the user resize the main widget, and the host should prevent that.
- This feature may not make sense for all UI types. The data pointer for the
- LV2_Feature for this feature should always be set to NULL.
-
-<pre>
- uiext:fixedSize
-</pre>
- If an UI requires this feature it indicates the same thing as
- uiext:noUserResize, and additionally it means that the UI will not resize
- the main widget on its own - it will always remain the same size (e.g. a
- pixmap based GUI). This feature may not make sense for all UI types.
- The data pointer for the LV2_Feature for this feature should always be set
- to NULL.
-
-
- UIs written to this specification do not need to be threadsafe - the
- functions defined below may only be called in the same thread as the UI
- main loop is running in.
-
- Note that this UI extension is NOT a lv2:Feature. There is no way for a
- plugin to know whether the host that loads it supports UIs or not, and
- the plugin must ALWAYS work without the UI (although it may be rather
- useless unless it has been configured using the UI in a previous session).
-
- A UI does not have to be a graphical widget, it could just as well be a
- server listening for OSC input or an interface to some sort of hardware
- device, depending on the RDF class of the UI.
-*/
-
-#ifndef LV2_UI_H
-#define LV2_UI_H
-
-#include <lv2.h>
-
-#define LV2_UI_URI "http://lv2plug.in/ns/extensions/ui"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/** A pointer to some widget or other type of UI handle.
- The actual type is defined by the type URI of the UI.
- All the functionality provided by this extension is toolkit
- independent, the host only needs to pass the necessary callbacks and
- display the widget, if possible. Plugins may have several UIs, in various
- toolkits. */
-typedef void* LV2UI_Widget;
-
-
-/** This handle indicates a particular instance of a UI.
- It is valid to compare this to NULL (0 for C++) but otherwise the
- host MUST not attempt to interpret it. The UI plugin may use it to
- reference internal instance data. */
-typedef void* LV2UI_Handle;
-
-
-/** This handle indicates a particular plugin instance, provided by the host.
- It is valid to compare this to NULL (0 for C++) but otherwise the
- UI plugin MUST not attempt to interpret it. The host may use it to
- reference internal plugin instance data. */
-typedef void* LV2UI_Controller;
-
-
-/** This is the type of the host-provided function that the UI can use to
- send data to a plugin's input ports. The @c buffer parameter must point
- to a block of data, @c buffer_size bytes large. The contents of this buffer
- and what the host should do with it depends on the value of the @c format
- parameter.
-
- The @c format parameter should either be 0 or a numeric ID for a "Transfer
- mechanism". Transfer mechanisms are Features and may be defined in
- meta-extensions. They specify how to translate the data buffers passed
- to this function to input data for the plugin ports. If a UI wishes to
- write data to an input port, it must list a transfer mechanism Feature
- for that port's class as an optional or required feature (depending on
- whether the UI will work without being able to write to that port or not).
- The only exception is when the UI wants to write single float values to
- input ports of the class lv2:ControlPort, in which case @c buffer_size
- should always be 4, the buffer should always contain a single IEEE-754
- float, and @c format should be 0.
-
- The numeric IDs for the transfer mechanisms are provided by a
- URI-to-integer mapping function provided by the host, using the URI Map
- feature <http://lv2plug.in/ns/ext/uri-map> with the map URI
- "http://lv2plug.in/ns/extensions/ui". Thus a UI that requires transfer
- mechanism features also requires the URI Map feature, but this is
- implicit - the UI does not have to list the URI map feature as a required
- or optional feature in it's RDF data.
-
- An UI MUST NOT pass a @c format parameter value (except 0) that has not
- been returned by the host-provided URI mapping function for a
- host-supported transfer mechanism feature URI.
-
- The UI MUST NOT try to write to a port for which there is no specified
- transfer mechanism, or to an output port. The UI is responsible for
- allocating the buffer and deallocating it after the call.
-*/
-typedef void (*LV2UI_Write_Function)(LV2UI_Controller controller,
- uint32_t port_index,
- uint32_t buffer_size,
- uint32_t format,
- const void* buffer);
-
-
-/** This struct contains the implementation of an UI. A pointer to an
- object of this type is returned by the lv2ui_descriptor() function.
-*/
-typedef struct _LV2UI_Descriptor {
-
- /** The URI for this UI (not for the plugin it controls). */
- const char* URI;
-
- /** Create a new UI object and return a handle to it. This function works
- similarly to the instantiate() member in LV2_Descriptor.
-
- @param descriptor The descriptor for the UI that you want to instantiate.
- @param plugin_uri The URI of the plugin that this UI will control.
- @param bundle_path The path to the bundle containing the RDF data file
- that references this shared object file, including the
- trailing '/'.
- @param write_function A function provided by the host that the UI can
- use to send data to the plugin's input ports.
- @param controller A handle for the plugin instance that should be passed
- as the first parameter of @c write_function.
- @param widget A pointer to an LV2UI_Widget. The UI will write a
- widget pointer to this location (what type of widget
- depends on the RDF class of the UI) that will be the
- main UI widget.
- @param features An array of LV2_Feature pointers. The host must pass
- all feature URIs that it and the UI supports and any
- additional data, just like in the LV2 plugin
- instantiate() function. Note that UI features and plugin
- features are NOT necessarily the same, they just share
- the same data structure - this will probably not be the
- same array as the one the plugin host passes to a
- plugin.
- */
- LV2UI_Handle (*instantiate)(const struct _LV2UI_Descriptor* descriptor,
- const char* plugin_uri,
- const char* bundle_path,
- LV2UI_Write_Function write_function,
- LV2UI_Controller controller,
- LV2UI_Widget* widget,
- const LV2_Feature* const* features);
-
-
- /** Destroy the UI object and the associated widget. The host must not try
- to access the widget after calling this function.
- */
- void (*cleanup)(LV2UI_Handle ui);
-
- /** Tell the UI that something interesting has happened at a plugin port.
- What is interesting and how it is written to the buffer passed to this
- function is defined by the @c format parameter, which has the same
- meaning as in LV2UI_Write_Function. The only exception is ports of the
- class lv2:ControlPort, for which this function should be called
- when the port value changes (it does not have to be called for every
- single change if the host's UI thread has problems keeping up with
- the thread the plugin is running in), @c buffer_size should be 4 and the
- buffer should contain a single IEEE-754 float. In this case the @c format
- parameter should be 0.
-
- By default, the host should only call this function for input ports of
- the lv2:ControlPort class. However, the default setting can be modified
- by using the following URIs in the UI's RDF data:
- <pre>
- uiext:portNotification
- uiext:noPortNotification
- uiext:plugin
- uiext:portIndex
- </pre>
- For example, if you want the UI with uri
- <code><http://my.pluginui></code> for the plugin with URI
- <code><http://my.plugin></code> to get notified when the value of the
- output control port with index 4 changes, you would use the following
- in the RDF for your UI:
- <pre>
- <http://my.pluginui> uiext:portNotification [ uiext:plugin <http://my.plugin> ;
- uiext:portIndex 4 ] .
- </pre>
- and similarly with <code>uiext:noPortNotification</code> if you wanted
- to prevent notifications for a port for which it would be on by default
- otherwise. The UI is not allowed to request notifications for ports of
- types for which no transfer mechanism is specified, if it does it should
- be considered broken and the host should not load it.
-
- The @c buffer is only valid during the time of this function call, so if
- the UI wants to keep it for later use it has to copy the contents to an
- internal buffer.
-
- This member may be set to NULL if the UI is not interested in any
- port events.
- */
- void (*port_event)(LV2UI_Handle ui,
- uint32_t port_index,
- uint32_t buffer_size,
- uint32_t format,
- const void* buffer);
-
- /** Returns a data structure associated with an extension URI, for example
- a struct containing additional function pointers. Avoid returning
- function pointers directly since standard C++ has no valid way of
- casting a void* to a function pointer. This member may be set to NULL
- if the UI is not interested in supporting any extensions. This is similar
- to the extension_data() member in LV2_Descriptor.
- */
- const void* (*extension_data)(const char* uri);
-
-} LV2UI_Descriptor;
-
-
-
-/** A plugin UI programmer must include a function called "lv2ui_descriptor"
- with the following function prototype within the shared object
- file. This function will have C-style linkage (if you are using
- C++ this is taken care of by the 'extern "C"' clause at the top of
- the file). This function will be accessed by the UI host using the
- @c dlsym() function and called to get a LV2UI_UIDescriptor for the
- wanted plugin.
-
- Just like lv2_descriptor(), this function takes an index parameter. The
- index should only be used for enumeration and not as any sort of ID number -
- the host should just iterate from 0 and upwards until the function returns
- NULL or a descriptor with an URI matching the one the host is looking for.
-*/
-const LV2UI_Descriptor* lv2ui_descriptor(uint32_t index);
-
-
-/** This is the type of the lv2ui_descriptor() function. */
-typedef const LV2UI_Descriptor* (*LV2UI_DescriptorFunction)(uint32_t index);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
diff --git a/lv2/lv2_uri_map.h b/lv2/lv2_uri_map.h deleted file mode 100644 index 93571d5..0000000 --- a/lv2/lv2_uri_map.h +++ /dev/null @@ -1,86 +0,0 @@ -/* lv2_uri_map.h - C header file for the LV2 URI Map extension. - * - * Copyright (C) 2008-2009 David Robillard <http://drobilla.net> - * - * 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 <http://lv2plug.in/ns/ext/uri-map>. - * - * 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). - */ - -#ifndef LV2_URI_MAP_H -#define LV2_URI_MAP_H - -#define LV2_URI_MAP_URI "http://lv2plug.in/ns/ext/uri-map" - -#include <stdint.h> - - -/** 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 */ |