commit 43edca7ee8fd9853425ce5cc4e093da7f3d05252
parent bb9370f4c469dcfab169718b77811b0b65bffba3
Author: Alexandre Bique <bique.alexandre@gmail.com>
Date: Wed, 12 Oct 2016 08:54:28 +0200
Remove tools and cmake
Diffstat:
9 files changed, 0 insertions(+), 886 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
@@ -1,9 +0,0 @@
-cmake_minimum_required(VERSION 2.6)
-project(CLAP C CXX)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
-
-include_directories(include)
-add_subdirectory(tools)
-add_subdirectory(examples)
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
@@ -1,5 +0,0 @@
-add_subdirectory(clap-info)
-
-# commenting the following because they are currently broken
-# add_subdirectory(clap-alsa-host)
-# add_subdirectory(clap-jack-host)
diff --git a/tools/clap-alsa-host/CMakeLists.txt b/tools/clap-alsa-host/CMakeLists.txt
@@ -1,2 +0,0 @@
-add_executable(clap-alsa-host clap-alsa-host.c)
-target_link_libraries(clap-alsa-host asound dl m)
diff --git a/tools/clap-alsa-host/clap-alsa-host.c b/tools/clap-alsa-host/clap-alsa-host.c
@@ -1,382 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include <clap/clap.h>
-#include <clap/helpers/midi-parser.h>
-#include <clap/ext/gui.h>
-#include <clap/ext/state.h>
-
-#include <alsa/asoundlib.h>
-
-#define SAMPLES_COUNT 512
-#define SAMPLE_RATE 48000
-
-struct clap_alsa_host
-{
- /* clap */
- struct clap_host host;
- struct clap_plugin *plugin;
- void *library_handle;
-
- /* host */
- uint32_t sample_rate;
- uint64_t steady_time;
-
- /* alsa */
- snd_pcm_t *pcm;
- snd_seq_t *seq;
- int seq_port;
-
- /* buffers */
- float out[2][SAMPLES_COUNT];
-
- /* config */
- const char *state_path;
-
- /* state */
- bool quit;
-};
-
-struct clap_alsa_host *g_app = NULL;
-
-static void deinitialize(struct clap_alsa_host *app);
-
-static void host_events(struct clap_host *host,
- struct clap_plugin *plugin,
- struct clap_event *events)
-{
-}
-
-static void *host_extension(struct clap_host *host, const char *extension_id)
-{
- return NULL;
-}
-
-static void host_log(struct clap_host *host,
- struct clap_plugin *plugin,
- enum clap_log_severity severity,
- const char *msg)
-{
- const char *severities[] = {
- "debug",
- "info",
- "warning",
- "error",
- "fatal",
- };
-
- fprintf(stdout, "[%s] %s\n", severities[severity], msg);
-}
-
-static uint32_t host_attribute(struct clap_host *host,
- const char *attr,
- char *buffer,
- uint32_t size)
-{
- return 0;
-}
-
-bool convert_seq_event(snd_seq_event_t *seq_ev, struct clap_event *clap_ev)
-{
- switch (seq_ev->type)
- {
- case SND_SEQ_EVENT_NOTEON:
- clap_ev->type = CLAP_EVENT_NOTE_ON;
- clap_ev->note.key = seq_ev->data.note.note;
- clap_ev->note.velocity = seq_ev->data.note.velocity;
- clap_ev->note.pitch = clap_midi_pitches[clap_ev->note.key];
- return true;
-
- case SND_SEQ_EVENT_NOTEOFF:
- clap_ev->type = CLAP_EVENT_NOTE_OFF;
- clap_ev->note.key = seq_ev->data.note.note;
- clap_ev->note.velocity = seq_ev->data.note.velocity;
- clap_ev->note.pitch = clap_midi_pitches[clap_ev->note.key];
- return true;
-
- default:
- return false;
- }
-}
-
-int process(struct clap_alsa_host *app)
-{
- float *in[2] = { NULL, NULL };
- float *out[2] = { app->out[0], app->out[1] };
-
- struct clap_process p;
- p.steady_time = app->steady_time;
- p.events = NULL;
- // XXX add time info
-
- /* convert midi events */
- struct clap_event *last_event = NULL;
- snd_seq_event_t *seq_ev = NULL;
- while (snd_seq_event_input(app->seq, &seq_ev) >= 0) {
- if (!seq_ev)
- break;
-
- struct clap_event *event = calloc(1, sizeof (*event));
- if (!event)
- break;
-
- if (convert_seq_event(seq_ev, event))
- {
- if (last_event)
- last_event->next = event;
- else
- p.events = event;
- last_event = event;
- }
- else
- {
- free(event);
- }
-
- snd_seq_free_event(seq_ev);
- }
-
- /* process */
- app->plugin->process(app->plugin, &p);
-
- void *buffs[2] = { out[0], out[1] };
- int err = snd_pcm_writen(app->pcm, buffs, SAMPLES_COUNT);
- if (err < 0)
- fprintf(stderr, "snd_pcm_writen: %s\n", snd_strerror(err));
-
- /* release events */
- while (p.events) {
- struct clap_event *next = p.events->next;
- free(p.events);
- p.events = next;
- }
-
- app->steady_time += SAMPLES_COUNT;
- return 0;
-}
-
-void shutdown(void *arg)
-{
-}
-
-static bool initialize(struct clap_alsa_host *app,
- const char *device,
- const char *plugin_path,
- uint32_t plugin_index)
-{
- snd_pcm_hw_params_t *hwparams;
- int err;
-
- app->quit = false;
-
- /* alsa/pcm initialization */
- err = snd_pcm_open(&app->pcm, device, SND_PCM_STREAM_PLAYBACK, 0);
- if (err < 0) {
- fprintf(stderr, "cannot open %s: %s", device, snd_strerror(err));
- return false;
- }
-
- err = snd_pcm_set_params(app->pcm, SND_PCM_FORMAT_FLOAT,
- SND_PCM_ACCESS_RW_NONINTERLEAVED,
- 2, SAMPLE_RATE, true, 512);
-
- if (err < 0) {
- fprintf(stderr, "failed to set the pcm params: %s\n", snd_strerror(err));
- goto fail_pcm;
- }
-
- /* alsa/seq initialization */
- err = snd_seq_open(&app->seq, "default", SND_SEQ_OPEN_INPUT, SND_SEQ_NONBLOCK);
- if (err < 0) {
- fprintf(stderr, "failed to open sequencer: %s\n", snd_strerror(err));
- goto fail_pcm;
- }
-
- err = snd_seq_set_client_name(app->seq, "clap-alsa-host");
- if (err < 0) {
- fprintf(stderr, "snd_seq_set_client_name: %s\n", snd_strerror(err));
- goto fail_seq;
- }
-
- app->seq_port = snd_seq_create_simple_port(
- app->seq, "port",
- SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ|
- SND_SEQ_PORT_CAP_WRITE|SND_SEQ_PORT_CAP_SUBS_WRITE,
- SND_SEQ_PORT_TYPE_MIDI_GENERIC);
- if (app->seq_port < 0) {
- fprintf(stderr, "snd_seq_create_simple_port: %s\n", snd_strerror(app->seq_port));
- goto fail_seq;
- }
-
- /* host initialization */
- app->host.clap_version = CLAP_VERSION;
- app->host.events = host_events;
- app->host.steady_time = &app->steady_time;
- app->host.extension = host_extension;
- app->host.get_attribute = host_attribute;
- app->host.log = host_log;
- app->steady_time = 0;
- app->sample_rate = SAMPLE_RATE;
-
- /* plugin initialization */
- app->library_handle = dlopen(plugin_path, RTLD_NOW | RTLD_LOCAL);
- if (!app->library_handle) {
- fprintf(stderr, "failed to load %s: %s\n", plugin_path, dlerror());
- goto fail_seq;
- }
-
- union {
- void *ptr;
- clap_create_f clap_create;
- } symbol;
-
- symbol.ptr = dlsym(app->library_handle, "clap_create");
- if (!symbol.ptr) {
- fprintf(stderr, "symbol not found: clap_create\n");
- goto fail_dlclose;
- }
-
- uint32_t plugin_count;
- app->plugin = symbol.clap_create(plugin_index, &app->host, app->sample_rate, &plugin_count);
- if (!app->plugin) {
- fprintf(stderr, "failed to create plugin\n");
- goto fail_dlclose;
- }
-
- return true;
-
-fail_dlclose:
- dlclose(app->library_handle);
-fail_seq:
- snd_seq_close(app->seq);
-fail_pcm:
- snd_pcm_close(app->pcm);
- return false;
-}
-
-static void load_state(struct clap_alsa_host *app)
-{
- struct stat st;
- struct clap_plugin_state *state = app->plugin->extension(
- app->plugin, CLAP_EXT_STATE);
-
- if (!state)
- return;
-
- if (!app->state_path)
- return;
-
- int fd = open(app->state_path, O_RDONLY);
- if (fd < 0)
- return;
-
- if (fstat(fd, &st)) {
- close(fd);
- return;
- }
-
- void *mem = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (mem == MAP_FAILED) {
- close(fd);
- return;
- }
-
- state->restore(app->plugin, mem, st.st_size);
-
- munmap(mem, st.st_size);
- close(fd);
-}
-
-static void save_state(struct clap_alsa_host *app)
-{
- struct clap_plugin_state *state = app->plugin->extension(
- app->plugin, CLAP_EXT_STATE);
-
- if (!state) {
- fprintf(stdout, "no state extension\n");
- return;
- }
-
- if (!app->state_path) {
- fprintf(stdout, "no state path\n");
- return;
- }
-
- void *buffer = NULL;
- uint32_t size = 0;
- if (!state->save(app->plugin, &buffer, &size)) {
- fprintf(stdout, "failed to save the state\n");
- return;
- }
-
- int fd = open(app->state_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd < 0) {
- fprintf(stdout, "open(%s): %m\n", app->state_path);
- return;
- }
-
- write(fd, buffer, size);
- close(fd);
-}
-
-static void deinitialize(struct clap_alsa_host *app)
-{
- /* clap */
- save_state(app);
- app->plugin->deactivate(app->plugin);
- app->plugin->destroy(app->plugin);
- dlclose(app->library_handle);
-
- /* alsa */
- snd_pcm_close(app->pcm);
-}
-
-void sig_int(int sig)
-{
- g_app->quit = true;
-}
-
-int main(int argc, char **argv)
-{
- static struct clap_alsa_host app;
-
- g_app = &app;
-
- signal(SIGINT, sig_int);
-
- if (argc < 3) {
- fprintf(stderr, "usage: %s plugin.so index [state]\n", argv[0]);
- return 2;
- }
-
- if (!initialize(&app, "plug:default", argv[1], atoi(argv[2])))
- return 1;
-
- if (!app.plugin->activate(app.plugin)) {
- fprintf(stderr, "can't activate the plugin\n");
- return 1;
- }
-
- if (argc == 4) {
- app.state_path = argv[3];
- load_state(&app);
- } else
- app.state_path = NULL;
-
- struct clap_plugin_gui *gui = app.plugin->extension(app.plugin, CLAP_EXT_GUI);
- if (gui)
- gui->open(app.plugin);
-
- while (!app.quit)
- process(&app);
-
- deinitialize(&app);
- return 0;
-}
diff --git a/tools/clap-info/.gitignore b/tools/clap-info/.gitignore
@@ -1 +0,0 @@
-clap-info
diff --git a/tools/clap-info/CMakeLists.txt b/tools/clap-info/CMakeLists.txt
@@ -1,2 +0,0 @@
-add_executable(clap-info clap-info.c)
-target_link_libraries(clap-info dl)
diff --git a/tools/clap-info/clap-info.c b/tools/clap-info/clap-info.c
@@ -1,145 +0,0 @@
-#include <stdio.h>
-#include <dlfcn.h>
-
-#include <clap/clap.h>
-#include <clap/ext/params.h>
-
-static void *host_extension(struct clap_host *host, const char *extension_id)
-{
- return NULL;
-}
-
-static void initialize_host(struct clap_host *host)
-{
- static int64_t steady_time = 0;
-
- host->clap_version = CLAP_VERSION;
- host->extension = host_extension;
-}
-
-static void print_attr(struct clap_plugin *plugin)
-{
- char buffer[256];
-
-#define prt_attr(Attr) \
- do { \
- int size = plugin->get_attribute( \
- plugin, CLAP_ATTR_##Attr, buffer, sizeof (buffer)); \
- if (size > 0) \
- fprintf(stdout, " %s: %s\n", CLAP_ATTR_##Attr, buffer); \
- } while (0)
-
- fprintf(stdout, "Attributes:\n");
- prt_attr(ID);
- prt_attr(NAME);
- prt_attr(DESCRIPTION);
- prt_attr(MANUFACTURER);
- prt_attr(VERSION);
- prt_attr(URL);
- prt_attr(SUPPORT);
- prt_attr(LICENSE);
- prt_attr(CATEGORIES);
- prt_attr(TYPE);
- prt_attr(CHUNK_SIZE);
- prt_attr(SUPPORTS_TUNING);
- prt_attr(SUPPORTS_IN_PLACE_PROCESSING);
- prt_attr(IS_REMOTE_PROCESSING);
-
- fprintf(stdout, "-------------------\n");
-
-#undef print_attr
-}
-
-static void print_params(struct clap_plugin *plugin)
-{
- struct clap_plugin_params *params = plugin->extension(plugin, CLAP_EXT_PARAMS);
-
- if (!params) {
- fprintf(stdout, "no parameter extension\n");
- return;
- }
-
- int32_t count = params->count(plugin);
- fprintf(stdout, "parameters count: %d\n", count);
-
- struct clap_param param;
- for (int32_t i = 0; i < count; ++i) {
- if (!params->get_param(plugin, i, ¶m))
- continue;
-
- fprintf(stdout, " => {id: %s, name: %s, desc: %s, display: %s, "
- "is_per_note: %d, is_used: %d, is_periodic: %d",
- param.id, param.name, param.desc, param.display,
- param.is_per_note, param.is_used, param.is_periodic);
-
- switch (param.type) {
- case CLAP_PARAM_FLOAT:
- fprintf(stdout, ", type: float, value: %f, min: %f, max: %f, default: %f",
- param.value.f, param.min.f, param.max.f, param.deflt.f);
- break;
-
- case CLAP_PARAM_INT:
- fprintf(stdout, ", type: int, value: %d, min: %d, max: %d, default: %d",
- param.value.i, param.min.i, param.max.i, param.deflt.i);
- break;
-
- case CLAP_PARAM_ENUM:
- fprintf(stdout, ", type: enum, value: %d, min: %d, max: %d, default: %d",
- param.value.i, param.min.i, param.max.i, param.deflt.i);
- break;
-
- case CLAP_PARAM_BOOL:
- fprintf(stdout, ", type: bool, value: %d, min: %d, max: %d, default: %d",
- param.value.i, param.min.i, param.max.i, param.deflt.i);
- break;
- }
-
- fprintf(stdout, "}\n");
- }
-
- fprintf(stdout, "-------------------\n");
-}
-
-int main(int argc, char **argv)
-{
- struct clap_host host;
- initialize_host(&host);
-
- void * handle = dlopen(argv[1], RTLD_NOW | RTLD_LOCAL);
- if (!handle) {
- fprintf(stderr, "failed to load %s: %s\n", argv[1], dlerror());
- return 1;
- }
-
- union {
- void *ptr;
- clap_create_f clap_create;
- } symbol;
-
- symbol.ptr = dlsym(handle, "clap_create");
- if (!symbol.ptr) {
- fprintf(stderr, "symbol not found: clap_create\n");
- return 1;
- }
-
- int32_t plugin_count = -1;
- for (int32_t index = 0; index < plugin_count; ++index) {
- struct clap_plugin *plugin = symbol.clap_create(
- index, &host, 48000, &plugin_count);
-
- if (!plugin) {
- fprintf(stderr, "failed to create plugin index %d\n", index);
- continue;
- }
-
- print_attr(plugin);
- print_params(plugin);
-
- // destroy the plugin
- plugin->destroy(plugin);
- }
-
- dlclose(handle);
-
- return 0;
-}
diff --git a/tools/clap-jack-host/CMakeLists.txt b/tools/clap-jack-host/CMakeLists.txt
@@ -1,2 +0,0 @@
-add_executable(clap-jack-host clap-jack-host.c)
-target_link_libraries(clap-jack-host jack dl m)
diff --git a/tools/clap-jack-host/clap-jack-host.c b/tools/clap-jack-host/clap-jack-host.c
@@ -1,338 +0,0 @@
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/mman.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <dlfcn.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <signal.h>
-
-#include <clap/clap.h>
-#include <clap/helpers/midi-parser.h>
-#include <clap/ext/gui.h>
-#include <clap/ext/state.h>
-
-#include <jack/jack.h>
-#include <jack/midiport.h>
-
-struct clap_jack_host
-{
- /* clap */
- struct clap_host host;
- struct clap_plugin *plugin;
- void *library_handle;
-
- /* host */
- int32_t sample_rate;
- int64_t steady_time;
-
- /* jack */
- jack_client_t *client;
- jack_port_t *input_ports[2];
- jack_port_t *output_ports[2];
- jack_port_t *midi_in;
-
- /* config */
- const char *state_path;
-
- /* state */
- bool quit;
-};
-
-struct clap_jack_host *g_app = NULL;
-
-static void deinitialize(struct clap_jack_host *app);
-
-static void host_events(struct clap_host *host,
- struct clap_plugin *plugin,
- struct clap_event *events)
-{
-}
-
-static void *host_extension(struct clap_host *host, const char *extension_id)
-{
- return NULL;
-}
-
-static void host_log(struct clap_host *host,
- struct clap_plugin *plugin,
- enum clap_log_severity severity,
- const char *msg)
-{
- const char *severities[] = {
- "debug",
- "info",
- "warning",
- "error",
- "fatal",
- };
-
- fprintf(stdout, "[%s] %s\n", severities[severity], msg);
-}
-
-static int32_t host_attribute(struct clap_host *host,
- const char *attr,
- char *buffer,
- int32_t size)
-{
- return 0;
-}
-
-int process(jack_nframes_t nframes, void *arg)
-{
- struct clap_jack_host *app = arg;
-
- /* get jack ports */
- jack_default_audio_sample_t *in[2], *out[2];
- for (int i = 0; i < 2; ++i) {
- in[i] = jack_port_get_buffer(app->input_ports[i], nframes);
- out[i] = jack_port_get_buffer(app->output_ports[i], nframes);
- }
- void *midi_in_buf = jack_port_get_buffer(app->midi_in, nframes);
- int32_t midi_in_count = jack_midi_get_event_count(midi_in_buf);
-
- struct clap_process p;
- p.samples_count = nframes;
- p.steady_time = app->steady_time;
- // XXX add time info
-
- /* convert midi events */
- p.events = NULL;
- struct clap_event *last_event = NULL;
- for (int32_t i = 0; i < midi_in_count; ++i) {
- jack_midi_event_t midi;
- jack_midi_event_get(&midi, midi_in_buf, i);
-
- struct clap_event *event = calloc(1, sizeof (*event));
- if (!event)
- break;
- if (last_event)
- last_event->next = event;
- else
- p.events = event;
- last_event = event;
-
- clap_midi_convert(midi.buffer, midi.size, event);
- event->steady_time = app->steady_time + midi.time;
- }
-
- /* process */
- app->plugin->process(app->plugin, &p);
-
- /* release events */
- while (p.events) {
- struct clap_event *next = p.events->next;
- free(p.events);
- p.events = next;
- }
-
- app->steady_time += nframes;
- return 0;
-}
-
-void shutdown(void *arg)
-{
-}
-
-static bool initialize(struct clap_jack_host *app,
- const char *plugin_path,
- int32_t plugin_index)
-{
- app->quit = false;
-
- /* jack */
- jack_status_t jack_status;
- app->client = jack_client_open("clap-host", JackNullOption, &jack_status, NULL);
- if (app->client == NULL) {
- fprintf(stderr, "jack_client_open() failed, status: %d\n", jack_status);
- return false;
- }
-
- jack_set_process_callback(app->client, process, app);
- jack_on_shutdown(app->client, shutdown, app);
- app->input_ports[0] = jack_port_register(app->client, "input left",
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsInput, 0);
- app->input_ports[1] = jack_port_register(app->client, "input right",
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsInput, 0);
- app->output_ports[0] = jack_port_register(app->client, "output left",
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsOutput, 0);
- app->output_ports[1] = jack_port_register(app->client, "output right",
- JACK_DEFAULT_AUDIO_TYPE,
- JackPortIsOutput, 0);
- app->midi_in = jack_port_register(app->client, "midi in", JACK_DEFAULT_MIDI_TYPE,
- JackPortIsInput, 0);
-
- printf("engine sample rate: %"PRIu32"\n", jack_get_sample_rate(app->client));
-
- /* host initialization */
- app->host.clap_version = CLAP_VERSION;
- app->host.events = host_events;
- app->host.steady_time = &app->steady_time;
- app->host.extension = host_extension;
- app->host.get_attribute = host_attribute;
- app->host.log = host_log;
- app->steady_time = 0;
- app->sample_rate = jack_get_sample_rate(app->client);
-
- /* plugin initialization */
- app->library_handle = dlopen(plugin_path, RTLD_NOW | RTLD_LOCAL);
- if (!app->library_handle) {
- fprintf(stderr, "failed to load %s: %s\n", plugin_path, dlerror());
- goto fail_jack;
- }
-
- union {
- void *ptr;
- clap_create_f clap_create;
- } symbol;
-
- symbol.ptr = dlsym(app->library_handle, "clap_create");
- if (!symbol.ptr) {
- fprintf(stderr, "symbol not found: clap_create\n");
- goto fail_dlclose;
- }
-
- int32_t plugin_count;
- app->plugin = symbol.clap_create(plugin_index, &app->host, app->sample_rate, &plugin_count);
- if (!app->plugin) {
- fprintf(stderr, "failed to create plugin\n");
- goto fail_dlclose;
- }
-
- return true;
-
-fail_dlclose:
- dlclose(app->library_handle);
-fail_jack:
- jack_client_close(app->client);
- return false;
-}
-
-static void load_state(struct clap_jack_host *app)
-{
- struct stat st;
- struct clap_plugin_state *state = app->plugin->extension(
- app->plugin, CLAP_EXT_STATE);
-
- if (!state)
- return;
-
- if (!app->state_path)
- return;
-
- int fd = open(app->state_path, O_RDONLY);
- if (fd < 0)
- return;
-
- if (fstat(fd, &st)) {
- close(fd);
- return;
- }
-
- void *mem = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
- if (mem == MAP_FAILED) {
- close(fd);
- return;
- }
-
- state->restore(app->plugin, mem, st.st_size);
-
- munmap(mem, st.st_size);
- close(fd);
-}
-
-static void save_state(struct clap_jack_host *app)
-{
- struct clap_plugin_state *state = app->plugin->extension(
- app->plugin, CLAP_EXT_STATE);
-
- if (!state) {
- fprintf(stdout, "no state extension\n");
- return;
- }
-
- if (!app->state_path) {
- fprintf(stdout, "no state path\n");
- return;
- }
-
- void *buffer = NULL;
- int32_t size = 0;
- if (!state->save(app->plugin, &buffer, &size)) {
- fprintf(stdout, "failed to save the state\n");
- return;
- }
-
- int fd = open(app->state_path, O_WRONLY | O_CREAT | O_TRUNC, 0644);
- if (fd < 0) {
- fprintf(stdout, "open(%s): %m\n", app->state_path);
- return;
- }
-
- write(fd, buffer, size);
- close(fd);
-}
-
-static void deinitialize(struct clap_jack_host *app)
-{
- /* clap */
- save_state(app);
- app->plugin->deactivate(app->plugin);
- app->plugin->destroy(app->plugin);
- dlclose(app->library_handle);
-
- /* jack */
- jack_client_close(app->client);
-}
-
-void sig_int(int sig)
-{
- g_app->quit = true;
-}
-
-int main(int argc, char **argv)
-{
- struct clap_jack_host app;
-
- g_app = &app;
-
- signal(SIGINT, sig_int);
-
- if (argc < 3) {
- fprintf(stderr, "usage: %s plugin.so index [state]\n", argv[0]);
- return 2;
- }
-
- if (!initialize(&app, argv[1], atoi(argv[2])))
- return 1;
-
- if (!app.plugin->activate(app.plugin)) {
- fprintf(stderr, "can't activate the plugin\n");
- return 1;
- }
-
- if (argc == 4) {
- app.state_path = argv[3];
- load_state(&app);
- } else
- app.state_path = NULL;
-
- struct clap_plugin_gui *gui = app.plugin->extension(app.plugin, CLAP_EXT_GUI);
- if (gui)
- gui->open(app.plugin);
-
- if (jack_activate(app.client)) {
- fprintf(stderr, "can't activate jack.\n");
- return 1;
- }
-
- // wait until application closes
- sleep(-1);
-
- deinitialize(&app);
- return 0;
-}