Mercurial > hg > vamp-plugin-load-checker
changeset 23:65b6c64992dd
If the descriptor is one of a recognised set, actually call it. This is a much more useful check against wrongly-built plugins or plugins with unavailable dependencies than just looking up the symbol
author | Chris Cannam |
---|---|
date | Wed, 16 Nov 2016 16:12:18 +0000 |
parents | 386de1be6226 |
children | 24b1d94440f5 |
files | src/helper.cpp |
diffstat | 1 files changed, 33 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/helper.cpp Thu Nov 03 16:42:46 2016 +0000 +++ b/src/helper.cpp Wed Nov 16 16:12:18 2016 +0000 @@ -139,6 +139,28 @@ else return e; } +string checkLADSPAStyleDescriptorFn(void *f) +{ + typedef const void *(*DFn)(unsigned long); + DFn fn = DFn(f); + unsigned long index = 0; + while (fn(index)) ++index; + if (index == 0) return "Library contains no plugins"; +// else cerr << "Library contains " << index << " plugin(s)" << endl; + return ""; +} + +string checkVampDescriptorFn(void *f) +{ + typedef const void *(*DFn)(unsigned int, unsigned int); + DFn fn = DFn(f); + unsigned int index = 0; + while (fn(1, index)) ++index; + if (index == 0) return "Library contains no plugins"; +// else cerr << "Library contains " << index << " plugin(s)" << endl; + return ""; +} + string check(string soname, string descriptor) { void *handle = DLOPEN(soname, RTLD_NOW | RTLD_LOCAL); @@ -152,6 +174,17 @@ " in library: " + error(); } + if (descriptor == "ladspa_descriptor") { + return checkLADSPAStyleDescriptorFn(fn); + } else if (descriptor == "dssi_descriptor") { + return checkLADSPAStyleDescriptorFn(fn); + } else if (descriptor == "vampGetPluginDescriptor") { + return checkVampDescriptorFn(fn); + } else { + cerr << "Note: no descriptor logic known for descriptor function \"" + << descriptor << "\"; not actually calling it" << endl; + } + return ""; }