Rename a pipe method, add docs
[carla.git] / source / tests.old / carla-uhe-test.c
blob04ae2e094d980ba3e42a09a3c204685ad6ea33ee
2 #include "CarlaHost.h"
4 #include <dlfcn.h>
5 #include <signal.h>
6 #include <stdbool.h>
7 #include <stdio.h>
8 #include <unistd.h>
10 // --------------------------------------------------------------------------------------------------------
12 static volatile bool term = false;
14 static void signalHandler(int sig)
16 switch (sig)
18 case SIGINT:
19 case SIGTERM:
20 term = true;
21 break;
25 // --------------------------------------------------------------------------------------------------------
27 typedef bool (*carla_engine_init_func)(const char* driverName, const char* clientName);
28 typedef void (*carla_engine_idle_func)(void);
29 typedef bool (*carla_is_engine_running_func)(void);
30 typedef bool (*carla_engine_close_func)(void);
31 typedef bool (*carla_add_plugin_func)(BinaryType btype, PluginType ptype,
32 const char* filename, const char* name, const char* label, int64_t uniqueId,
33 const void* extraPtr, uint options);
34 typedef const char* (*carla_get_last_error_func)(void);
36 int main(void)
38 void* lib = dlopen("/home/falktx/FOSS/GIT-mine/falkTX/Carla/bin/libcarla_standalone2.so", RTLD_NOW|RTLD_GLOBAL);
40 if (!lib)
42 printf("Failed to load carla lib\n");
43 return 1;
46 const carla_engine_init_func carla_engine_init = dlsym(lib, "carla_engine_init");
47 const carla_engine_idle_func carla_engine_idle = dlsym(lib, "carla_engine_idle");
48 const carla_is_engine_running_func carla_is_engine_running = dlsym(lib, "carla_is_engine_running");
49 const carla_engine_close_func carla_engine_close = dlsym(lib, "carla_engine_close");
50 const carla_add_plugin_func carla_add_plugin = dlsym(lib, "carla_add_plugin");
51 const carla_get_last_error_func carla_get_last_error = dlsym(lib, "carla_get_last_error");
53 if (! carla_engine_init("JACK", "Carla-uhe-test"))
55 printf("Engine failed to initialize, possible reasons:\n%s\n", carla_get_last_error());
56 return 1;
59 if (! carla_add_plugin(BINARY_NATIVE, PLUGIN_VST2, "/home/falktx/.vst/u-he/ACE.64.so", "", "", 0, NULL, 0))
61 printf("Failed to load plugin, possible reasons:\n%s\n", carla_get_last_error());
62 carla_engine_close();
63 return 1;
66 signal(SIGINT, signalHandler);
67 signal(SIGTERM, signalHandler);
69 while (carla_is_engine_running() && ! term)
71 carla_engine_idle();
72 sleep(1);
75 carla_engine_close();
77 return 0;
80 // --------------------------------------------------------------------------------------------------------