c@71: c@71: #include c@71: #include c@71: c@71: using namespace std; c@71: c@71: int main(int argc, char **argv) c@71: { c@71: string example = "./example.so"; c@71: c@71: void *lib = dlopen(example.c_str(), RTLD_LAZY | RTLD_LOCAL); c@71: if (!lib) { c@71: cerr << "failed to open " + example + ": " << dlerror() << endl; c@71: return 1; c@71: } c@71: c@71: typedef const char *(*RequestFn)(const char *); c@71: RequestFn reqFn = (RequestFn)dlsym(lib, "vampipeRequestJson"); c@71: if (!reqFn) { c@71: cerr << "failed to find request function in " + c@71: example + ": " << dlerror() << endl; c@71: return 1; c@71: } c@71: c@71: typedef void (*FreeFn)(const char *); c@71: FreeFn freeFn = (FreeFn)dlsym(lib, "vampipeFreeJson"); c@71: if (!freeFn) { c@71: cerr << "failed to find free function in " + c@71: example + ": " << dlerror() << endl; c@71: return 1; c@71: } c@71: c@71: string listRequest = "{\"type\": \"list\"}"; c@71: const char *listResponse = reqFn(listRequest.c_str()); c@71: cout << listResponse << endl; c@71: freeFn(listResponse); c@73: c@73: string loadRequest = "{\"type\":\"load\",\"content\": {\"pluginKey\":\"vamp-example-plugins:zerocrossing\",\"inputSampleRate\":44100,\"adapterFlags\":[\"AdaptAllSafe\"]}}"; c@73: const char *loadResponse = reqFn(loadRequest.c_str()); c@73: cout << loadResponse << endl; c@73: freeFn(loadResponse); c@71: } c@71: