From 0153919a422e7a520c38f9cd01e9a079f73c80fd Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 18 Feb 2007 23:38:47 +0000 Subject: Removed private_types.h (and all exposure of types that shouldn't have been exposed). git-svn-id: http://svn.drobilla.net/lad/slv2@316 a436a847-0d15-0410-975c-d299462d15a1 --- slv2/Makefile.am | 1 - slv2/plugininstance.h | 57 +++++++++++++++++++----------------- slv2/private_types.h | 81 --------------------------------------------------- slv2/types.h | 1 - src/Makefile.am | 1 + src/plugin.c | 2 +- src/plugininstance.c | 21 ++++++++----- src/pluginlist.c | 2 +- src/private_types.h | 67 ++++++++++++++++++++++++++++++++++++++++++ src/query.c | 2 +- 10 files changed, 115 insertions(+), 120 deletions(-) delete mode 100644 slv2/private_types.h create mode 100644 src/private_types.h diff --git a/slv2/Makefile.am b/slv2/Makefile.am index 8ce74f2..d2b863e 100644 --- a/slv2/Makefile.am +++ b/slv2/Makefile.am @@ -3,7 +3,6 @@ slv2includedir = $(includedir)/slv2 slv2include_HEADERS = \ lv2.h \ types.h \ - private_types.h \ slv2.h \ library.h \ plugin.h \ diff --git a/slv2/plugininstance.h b/slv2/plugininstance.h index 1b475c2..e704383 100644 --- a/slv2/plugininstance.h +++ b/slv2/plugininstance.h @@ -26,12 +26,17 @@ extern "C" { #include #include #include -#include #include #include +typedef struct _InstanceImpl* SLV2InstanceImpl; -typedef const struct _Instance SLV2Instance; +/** Instance of a plugin */ +typedef struct _Instance { + const LV2_Descriptor* lv2_descriptor; + LV2_Handle lv2_handle; + SLV2InstanceImpl pimpl; ///< Opaque +} SLV2Instance; /** \defgroup lib Plugin Instance - Shared library access @@ -47,7 +52,7 @@ typedef const struct _Instance SLV2Instance; /** Instantiate a plugin. * * The returned object represents shared library objects loaded into memory, - * it must be cleaned up with slv2instance_free when no longer + * it must be cleaned up with slv2_instance_free when no longer * needed. * * \a plugin is not modified or directly referenced by the returned object @@ -84,9 +89,9 @@ static inline const char* slv2_instance_get_uri(SLV2Instance* instance) { assert(instance); - assert(instance->descriptor); + assert(instance->lv2_descriptor); - return instance->descriptor->URI; + return instance->lv2_descriptor->URI; } @@ -101,10 +106,10 @@ slv2_instance_connect_port(SLV2Instance* instance, void* data_location) { assert(instance); - assert(instance->descriptor); - assert(instance->descriptor->connect_port); + assert(instance->lv2_descriptor); + assert(instance->lv2_descriptor->connect_port); - instance->descriptor->connect_port + instance->lv2_descriptor->connect_port (instance->lv2_handle, port_index, data_location); } @@ -112,23 +117,23 @@ slv2_instance_connect_port(SLV2Instance* instance, /** Activate a plugin instance. * * This resets all state information in the plugin, except for port data - * locations (as set by slv2instance_connect_port). This MUST be called - * before calling slv2instance_run. + * locations (as set by slv2_instance_connect_port). This MUST be called + * before calling slv2_instance_run. */ static inline void slv2_instance_activate(SLV2Instance* instance) { assert(instance); - assert(instance->descriptor); + assert(instance->lv2_descriptor); - if (instance->descriptor->activate) - instance->descriptor->activate(instance->lv2_handle); + if (instance->lv2_descriptor->activate) + instance->lv2_descriptor->activate(instance->lv2_handle); } -/** Run \a instance for \a sample_count frames. +/** Run @a instance for @a sample_count frames. * - * If the hint lv2:realtimeSafe is set for this plugin, this function is + * If the hint lv2:hardRtCapable is set for this plugin, this function is * guaranteed not to block. */ static inline void @@ -136,11 +141,11 @@ slv2_instance_run(SLV2Instance* instance, uint32_t sample_count) { assert(instance); - assert(instance->descriptor); + assert(instance->lv2_descriptor); assert(instance->lv2_handle), - assert(instance->descriptor->run); + assert(instance->lv2_descriptor->run); - instance->descriptor->run(instance->lv2_handle, sample_count); + instance->lv2_descriptor->run(instance->lv2_handle, sample_count); } @@ -153,18 +158,18 @@ static inline void slv2_instance_deactivate(SLV2Instance* instance) { assert(instance); - assert(instance->descriptor); + assert(instance->lv2_descriptor); assert(instance->lv2_handle); - if (instance->descriptor->deactivate) - instance->descriptor->deactivate(instance->lv2_handle); + if (instance->lv2_descriptor->deactivate) + instance->lv2_descriptor->deactivate(instance->lv2_handle); } /** Get the LV2_Descriptor of the plugin instance. * * Normally hosts should not need to access the LV2_Descriptor directly, - * use the slv2instance_* functions. + * use the slv2_instance_* functions. * * The returned descriptor is shared and must not be deleted. */ @@ -172,16 +177,16 @@ static inline const LV2_Descriptor* slv2_instance_get_descriptor(SLV2Instance* instance) { assert(instance); - assert(instance->descriptor); + assert(instance->lv2_descriptor); - return instance->descriptor; + return instance->lv2_descriptor; } /** Get the LV2_Handle of the plugin instance. * * Normally hosts should not need to access the LV2_Handle directly, - * use the slv2instance_* functions. + * use the slv2_instance_* functions. * * The returned handle is shared and must not be deleted. */ @@ -189,7 +194,7 @@ static inline LV2_Handle slv2_instance_get_handle(SLV2Instance* instance) { assert(instance); - assert(instance->descriptor); + assert(instance->lv2_descriptor); return instance->lv2_handle; } diff --git a/slv2/private_types.h b/slv2/private_types.h deleted file mode 100644 index 906d89c..0000000 --- a/slv2/private_types.h +++ /dev/null @@ -1,81 +0,0 @@ -/* SLV2 - * Copyright (C) 2007 Dave Robillard - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This library is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef __SLV2_PRIVATE_TYPES_H__ -#define __SLV2_PRIVATE_TYPES_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include -#include - - -/* @file private_types.h - * - * If you're a user of SLV2, stop reading this RIGHT NOW :) - * Unfortunately it needs to be exposed to allow inlining of some things that - * really need to be inlined, but these are opaque types. - * - * DO NOT WRITE CODE THAT DEPENDS ON DEFINITIONS IN THIS FILE - */ - - -/** Record of an installed/available plugin. - * - * A simple reference to a plugin somewhere on the system. This just holds - * paths of relevant files, the actual data therein isn't loaded into memory. - */ -struct _Plugin { - char* plugin_uri; - char* bundle_url; // Bundle directory plugin was loaded from - raptor_sequence* data_uris; // rdfs::seeAlso - char* lib_uri; // lv2:binary -}; - - -/** Instance of a plugin (private type) */ -struct _Instance { - // FIXME: copy plugin here for convenience? - //struct LV2Plugin* plugin; - const LV2_Descriptor* descriptor; - void* lib_handle; - LV2_Handle lv2_handle; -}; - - -/** List of references to plugins available for loading (private type) */ -struct _PluginList { - size_t num_plugins; - struct _Plugin** plugins; -}; - - -/** An ordered, indexable collection of strings. */ -//typedef raptor_sequence* SLV2Strings; - - -#ifdef __cplusplus -} -#endif - -#endif /* __SLV2_PRIVATE_TYPES_H__ */ - diff --git a/slv2/types.h b/slv2/types.h index b1b115c..dd7480c 100644 --- a/slv2/types.h +++ b/slv2/types.h @@ -22,7 +22,6 @@ #include #include #include -//#include #ifdef __cplusplus extern "C" { diff --git a/src/Makefile.am b/src/Makefile.am index 43aa62a..02520e1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -5,6 +5,7 @@ lib_LTLIBRARIES = libslv2.la libslv2_la_LIBADD = @RASQAL_LIBS@ libslv2_la_SOURCES = \ + private_types.h \ util.h \ plugin.c \ query.c \ diff --git a/src/plugin.c b/src/plugin.c index d3710a4..6571326 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -22,12 +22,12 @@ #include #include #include -#include #include #include #include #include #include +#include "private_types.h" SLV2Plugin* diff --git a/src/plugininstance.c b/src/plugininstance.c index ed8abc7..13a659a 100644 --- a/src/plugininstance.c +++ b/src/plugininstance.c @@ -21,11 +21,11 @@ #include #include #include -#include #include #include #include #include +#include "private_types.h" SLV2Instance* @@ -81,9 +81,12 @@ slv2_plugin_instantiate(const SLV2Plugin* plugin, result = malloc(sizeof(struct _Instance)); /*result->plugin = malloc(sizeof(struct _Plugin)); memcpy(result->plugin, plugin, sizeof(struct _Plugin));*/ - result->descriptor = ld; - result->lib_handle = lib; + result->lv2_descriptor = ld; result->lv2_handle = ld->instantiate(ld, sample_rate, (char*)bundle_path, host_features); + struct _InstanceImpl* impl = malloc(sizeof(struct _InstanceImpl)); + impl->lib_handle = lib; + result->pimpl = impl; + break; } } @@ -101,7 +104,7 @@ slv2_plugin_instantiate(const SLV2Plugin* plugin, // "Connect" all ports to NULL (catches bugs) for (uint32_t i=0; i < slv2_plugin_get_num_ports(plugin); ++i) - result->descriptor->connect_port(result->lv2_handle, i, NULL); + result->lv2_descriptor->connect_port(result->lv2_handle, i, NULL); if (local_host_features) free(host_features); @@ -114,10 +117,12 @@ void slv2_instance_free(SLV2Instance* instance) { struct _Instance* i = (struct _Instance*)instance; - i->descriptor->cleanup(i->lv2_handle); - i->descriptor = NULL; - dlclose(i->lib_handle); - i->lib_handle = NULL; + i->lv2_descriptor->cleanup(i->lv2_handle); + i->lv2_descriptor = NULL; + dlclose(i->pimpl->lib_handle); + i->pimpl->lib_handle = NULL; + free(i->pimpl); + i->pimpl = NULL; free(i); } diff --git a/src/pluginlist.c b/src/pluginlist.c index f030713..d6c1665 100644 --- a/src/pluginlist.c +++ b/src/pluginlist.c @@ -24,12 +24,12 @@ #include #include #include -#include #include #include #include #include #include +#include "private_types.h" /* not exposed */ diff --git a/src/private_types.h b/src/private_types.h new file mode 100644 index 0000000..0d755f8 --- /dev/null +++ b/src/private_types.h @@ -0,0 +1,67 @@ +/* SLV2 + * Copyright (C) 2007 Dave Robillard + * + * This library is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This library is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __SLV2_PRIVATE_TYPES_H__ +#define __SLV2_PRIVATE_TYPES_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + + +/** Record of an installed/available plugin. + * + * A simple reference to a plugin somewhere on the system. This just holds + * paths of relevant files, the actual data therein isn't loaded into memory. + */ +struct _Plugin { + char* plugin_uri; + char* bundle_url; // Bundle directory plugin was loaded from + raptor_sequence* data_uris; // rdfs::seeAlso + char* lib_uri; // lv2:binary +}; + + +/** Pimpl portion of SLV2Instance */ +struct _InstanceImpl { + void* lib_handle; +}; + + +/** List of references to plugins available for loading (private type) */ +struct _PluginList { + size_t num_plugins; + struct _Plugin** plugins; +}; + + +/** An ordered, indexable collection of strings. */ +//typedef raptor_sequence* SLV2Strings; + + +#ifdef __cplusplus +} +#endif + +#endif /* __SLV2_PRIVATE_TYPES_H__ */ + diff --git a/src/query.c b/src/query.c index fa3b22b..617b1df 100644 --- a/src/query.c +++ b/src/query.c @@ -24,7 +24,7 @@ #include #include #include -#include +#include "private_types.h" char* -- cgit v1.2.1