Mercurial > hg > vamp-plugin-sdk
comparison src/vamp-hostsdk/host-c.cpp @ 393:632c662e95e7 vh
Small test program & some changes to support it
author | Chris Cannam |
---|---|
date | Wed, 20 May 2015 17:46:17 +0100 |
parents | 06988ce35ff0 |
children |
comparison
equal
deleted
inserted
replaced
392:f4e07ae2725a | 393:632c662e95e7 |
---|---|
72 { | 72 { |
73 initFilenames(); | 73 initFilenames(); |
74 return int(files.size()); | 74 return int(files.size()); |
75 } | 75 } |
76 | 76 |
77 const char *vhGetLibraryName(int library) | 77 const char *vhGetLibraryName(int index) |
78 { | 78 { |
79 initFilenames(); | 79 initFilenames(); |
80 if (library < int(files.size())) { | 80 if (index >= 0 && index < int(files.size())) { |
81 return cnames[files[library]]; | 81 return cnames[files[index]]; |
82 } | 82 } |
83 else return 0; | 83 else return 0; |
84 } | 84 } |
85 | 85 |
86 vhLibrary vhLoadLibrary(const char *libraryName) | 86 int vhGetLibraryIndex(const char *name) |
87 { | 87 { |
88 for (size_t i = 0; i < files.size(); ++i) { | 88 for (size_t i = 0; i < files.size(); ++i) { |
89 | 89 if (Files::lcBasename(name) == Files::lcBasename(files[i])) { |
90 if (Files::lcBasename(libraryName) == Files::lcBasename(files[i])) { | 90 return i; |
91 | |
92 string fullPath = files[i]; | |
93 void *lib = Files::loadLibrary(fullPath); | |
94 | |
95 if (!lib) return 0; | |
96 | |
97 VampGetPluginDescriptorFunction func = | |
98 (VampGetPluginDescriptorFunction)Files::lookupInLibrary | |
99 (lib, "vampGetPluginDescriptor"); | |
100 if (!func) { | |
101 cerr << "vhLoadLibrary: No vampGetPluginDescriptor function found in library \"" | |
102 << fullPath << "\"" << endl; | |
103 Files::unloadLibrary(lib); | |
104 return 0; | |
105 } | |
106 | |
107 vhLibrary_t *vhl = new vhLibrary_t(lib, func); | |
108 while (vhl->func(VAMP_API_VERSION, vhl->nplugins)) { | |
109 ++vhl->nplugins; | |
110 } | |
111 return vhl; | |
112 } | 91 } |
113 } | 92 } |
93 return -1; | |
94 } | |
114 | 95 |
115 return 0; | 96 vhLibrary vhLoadLibrary(int index) |
97 { | |
98 initFilenames(); | |
99 if (index < 0 || index >= int(files.size())) { | |
100 return 0; | |
101 } | |
102 | |
103 string fullPath = files[index]; | |
104 void *lib = Files::loadLibrary(fullPath); | |
105 | |
106 if (!lib) return 0; | |
107 | |
108 VampGetPluginDescriptorFunction func = | |
109 (VampGetPluginDescriptorFunction)Files::lookupInLibrary | |
110 (lib, "vampGetPluginDescriptor"); | |
111 if (!func) { | |
112 cerr << "vhLoadLibrary: No vampGetPluginDescriptor function found in library \"" | |
113 << fullPath << "\"" << endl; | |
114 Files::unloadLibrary(lib); | |
115 return 0; | |
116 } | |
117 | |
118 vhLibrary_t *vhl = new vhLibrary_t(lib, func); | |
119 while (vhl->func(VAMP_API_VERSION, vhl->nplugins)) { | |
120 ++vhl->nplugins; | |
121 } | |
122 return vhl; | |
116 } | 123 } |
117 | 124 |
118 int vhGetPluginCount(vhLibrary library) | 125 int vhGetPluginCount(vhLibrary library) |
119 { | 126 { |
120 vhLibrary_t *vhl = static_cast<vhLibrary_t *>(library); | 127 vhLibrary_t *vhl = static_cast<vhLibrary_t *>(library); |