annotate test/quick-test.cpp @ 176:eaf46e7647a0 tip master

Update for latest Emscripten - Pointer_stringify has apparently been deprecated for a while, and was removed in v1.38.27
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 27 Feb 2019 11:29:53 +0000
parents 5d4727387c93
children
rev   line source
c@117 1
c@117 2 #include <iostream>
c@117 3 #include <dlfcn.h>
c@117 4
c@117 5 using namespace std;
c@117 6
c@117 7 int main(int, char **)
c@117 8 {
cannam@147 9 string example = "../examples/vamp-example-plugins/VampExamplePlugins.so";
c@117 10
c@117 11 void *lib = dlopen(example.c_str(), RTLD_LAZY | RTLD_LOCAL);
c@117 12 if (!lib) {
c@117 13 cerr << "failed to open " + example + ": " << dlerror() << endl;
c@117 14 return 1;
c@117 15 }
c@117 16
c@117 17 typedef const char *(*RequestFn)(const char *);
c@117 18 RequestFn reqFn = (RequestFn)dlsym(lib, "piperRequestJson");
c@117 19 if (!reqFn) {
c@117 20 cerr << "failed to find request function in " +
c@117 21 example + ": " << dlerror() << endl;
c@117 22 return 1;
c@117 23 }
c@117 24
c@117 25 typedef void (*FreeFn)(const char *);
c@117 26 FreeFn freeFn = (FreeFn)dlsym(lib, "piperFreeJson");
c@117 27 if (!freeFn) {
c@117 28 cerr << "failed to find free function in " +
c@117 29 example + ": " << dlerror() << endl;
c@117 30 return 1;
c@117 31 }
c@117 32
c@117 33 string listRequest = "{\"method\": \"list\"}";
c@117 34 const char *listResponse = reqFn(listRequest.c_str());
c@117 35 cout << listResponse << endl;
c@117 36 freeFn(listResponse);
c@117 37
c@117 38 string loadRequest = "{\"method\":\"load\",\"params\": {\"key\":\"vamp-example-plugins:powerspectrum\",\"inputSampleRate\":44100,\"adapterFlags\":[\"AdaptAllSafe\"]}}";
c@117 39 const char *loadResponse = reqFn(loadRequest.c_str());
c@117 40 cout << loadResponse << endl;
c@117 41 freeFn(loadResponse);
c@117 42
cannam@147 43 string configRequest = "{\"method\":\"configure\",\"params\":{\"handle\":1,\"configuration\":{\"framing\":{\"blockSize\":8,\"stepSize\": 8},\"channelCount\":1}}}";
c@117 44 const char *configResponse = reqFn(configRequest.c_str());
c@117 45 cout << configResponse << endl;
c@117 46 freeFn(configResponse);
c@117 47
c@117 48 string processRequest = "{\"method\":\"process\",\"id\": 6,\"params\":{\"handle\":1,\"processInput\":{\"timestamp\":{\"s\":0,\"n\":0},\"inputBuffers\":[[0,1,0,-1,0,1,0,-1]]}}}";
c@117 49 const char *processResponse = reqFn(processRequest.c_str());
c@117 50 cout << processResponse << endl;
c@117 51 freeFn(processResponse);
c@117 52
c@117 53 string b64processRequest = "{\"method\":\"process\",\"params\":{\"handle\":1,\"processInput\":{\"timestamp\":{\"s\":0,\"n\":0},\"inputBuffers\":[\"AAAAAAAAgD8AAAAAAACAvwAAAAAAAIA/AAAAAAAAgL8\"]}}}";
c@117 54 const char *b64processResponse = reqFn(b64processRequest.c_str());
c@117 55 cout << b64processResponse << endl;
c@117 56 freeFn(b64processResponse);
c@117 57
c@117 58 string finishRequest = "{\"method\":\"finish\",\"params\":{\"handle\":1}}";
c@117 59 const char *finishResponse = reqFn(finishRequest.c_str());
c@117 60 cout << finishResponse << endl;
c@117 61 freeFn(finishResponse);
cannam@147 62
cannam@147 63 return 0;
c@117 64 }
c@117 65