Mercurial > hg > vamp-plugin-sdk
comparison vamp-hostsdk/host-c.h @ 393:632c662e95e7 vh
Small test program & some changes to support it
author | Chris Cannam |
---|---|
date | Wed, 20 May 2015 17:46:17 +0100 |
parents | 93683cf9fce3 |
children |
comparison
equal
deleted
inserted
replaced
392:f4e07ae2725a | 393:632c662e95e7 |
---|---|
35 */ | 35 */ |
36 | 36 |
37 /* | 37 /* |
38 This file defines a low-level API for enumerating and loading | 38 This file defines a low-level API for enumerating and loading |
39 plugin libraries using C calling conventions. It could be used in | 39 plugin libraries using C calling conventions. It could be used in |
40 C programs or in languages with C-compatible foreign-function | 40 C programs, or in languages with C-compatible foreign-function |
41 interfaces. | 41 interfaces. Note that this works by calling to the C++ Vamp host |
42 SDK, so any program using this interface must still link against | |
43 the rest of the Vamp plugin library and the C++ standard library. | |
42 | 44 |
43 This is not the simplest or easiest interface for hosting Vamp | 45 This is not the simplest or easiest interface for hosting Vamp |
44 plugins -- if you have the capability to use the C++ API, please | 46 plugins -- if you have the capability to use the C++ API, please |
45 do that instead. (Most programs should not even include this | 47 do that instead. (Most programs should not even include this |
46 header.) | 48 header.) |
53 string) plus a method to load a single plugin based on its key | 55 string) plus a method to load a single plugin based on its key |
54 (obtaining an instance of class Plugin). With the C++ interface | 56 (obtaining an instance of class Plugin). With the C++ interface |
55 you go straight from the key to a live instance of the plugin. The | 57 you go straight from the key to a live instance of the plugin. The |
56 PluginLoader also provides various facilities to adapt the plugin | 58 PluginLoader also provides various facilities to adapt the plugin |
57 based on your requirements (e.g. to do time- to frequency-domain | 59 based on your requirements (e.g. to do time- to frequency-domain |
58 conversion for its input). | 60 conversion for you if the plugin requires it). |
59 | 61 |
60 This low-level C interface, on the other hand, deals only in | 62 This low-level C interface, on the other hand, deals only in |
61 plugin libraries and static descriptors, not in plugin | 63 plugin libraries and static descriptors, not in plugin |
62 instances. You can enumerate the installed libraries, getting just | 64 instances. You can enumerate the installed libraries, getting just |
63 the base .soname of each library. Then you can retrieve each of | 65 the base .soname of each library. Then you can retrieve each of |
64 the raw C plugin descriptors from a library, and use the | 66 the raw C plugin descriptors from a library, and use the |
65 descriptor (whose interface is defined in vamp/vamp.h) to | 67 descriptor (whose interface is defined in vamp/vamp.h) to |
66 instantiate the plugin. So this header corresponds to the first | 68 instantiate the plugin. |
67 part of the PluginLoader class interface (finding and loading | 69 |
68 plugin libraries and retrieving plugin descriptors from them) but | 70 So this header corresponds to the first part of the PluginLoader |
69 does not do any of the rest (instantiating and adapting the | 71 class interface: finding and loading plugin libraries and |
70 plugins themselves), which may mean the resulting plugin is | 72 retrieving plugin descriptors from them. But it does not do any of |
71 relatively hard to use compared to that provided by the | 73 the rest, i.e. instantiating and adapting the plugins themselves. |
72 PluginLoader API. | 74 Although this makes the API appear very simple, it means the |
75 resulting plugins are relatively hard to use compared to those | |
76 obtained by the PluginLoader API. There is no way to get to the | |
77 full C++ abstraction using this API. | |
73 | 78 |
74 This API is not thread-safe; use it from a single application | 79 This API is not thread-safe; use it from a single application |
75 thread, or guard access to it with a mutex. | 80 thread, or guard access to it with a mutex. |
76 | 81 |
77 This header was introduced in version 2.6 of the Vamp plugin SDK. | 82 This header was introduced in version 2.6 of the Vamp plugin SDK. |
101 * index, in the range 0..(vhGetLibraryCount()-1). | 106 * index, in the range 0..(vhGetLibraryCount()-1). |
102 */ | 107 */ |
103 extern const char *vhGetLibraryName(int library); | 108 extern const char *vhGetLibraryName(int library); |
104 | 109 |
105 /** | 110 /** |
106 * Load a plugin library given its library name, that is, the base | 111 * Return the library index for the given library name, or -1 if the |
107 * soname as returned by vhGetLibraryName. If the library cannot be | 112 * name is not known. |
113 */ | |
114 extern int vhGetLibraryIndex(const char *name); | |
115 | |
116 /** | |
117 * Load the library with the given index. If the library cannot be | |
108 * loaded for any reason, the return value is 0; otherwise it is an | 118 * loaded for any reason, the return value is 0; otherwise it is an |
109 * opaque pointer suitable for passing to other functions in this API. | 119 * opaque pointer suitable for passing to other functions in this API. |
110 */ | 120 */ |
111 extern vhLibrary vhLoadLibrary(const char *libraryName); | 121 extern vhLibrary vhLoadLibrary(int library); |
112 | 122 |
113 /** | 123 /** |
114 * Return the number of Vamp plugins in the given library. | 124 * Return the number of Vamp plugins in the given library. |
115 */ | 125 */ |
116 extern int vhGetPluginCount(vhLibrary library); | 126 extern int vhGetPluginCount(vhLibrary library); |
117 | 127 |
118 /** | 128 /** |
119 * Return a Vamp plugin descriptor for a plugin in a given | 129 * Return a Vamp plugin descriptor for a plugin in a given |
120 * library. (This simply calls the vampGetPluginDescriptor function in | 130 * library. This simply calls the vampGetPluginDescriptor function in |
121 * that library with the given plugin index and returns the result.) | 131 * that library with the given plugin index and returns the |
132 * result. See vamp/vamp.h for details about the plugin descriptor. | |
122 */ | 133 */ |
123 extern const VampPluginDescriptor *vhGetPluginDescriptor(vhLibrary library, | 134 extern const VampPluginDescriptor *vhGetPluginDescriptor(vhLibrary library, |
124 int plugin); | 135 int plugin); |
125 | 136 |
126 /** | 137 /** |