diff options
author | David Robillard <d@drobilla.net> | 2012-02-09 23:23:54 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-02-09 23:23:54 +0000 |
commit | 7e5bf17f9e14b4a24346c402bf5fcf88772c50f3 (patch) | |
tree | d8784b58128f9c640ad637ddf4ecfc88efe45691 /plugins/eg-sampler.lv2/sampler.c | |
parent | 3d8a2bef05f69eff154ad350db4be897f6d3edfa (diff) | |
download | lv2-7e5bf17f9e14b4a24346c402bf5fcf88772c50f3.tar.xz |
Portability fixes (plugins work on OSX).
Diffstat (limited to 'plugins/eg-sampler.lv2/sampler.c')
-rw-r--r-- | plugins/eg-sampler.lv2/sampler.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/plugins/eg-sampler.lv2/sampler.c b/plugins/eg-sampler.lv2/sampler.c index 5292aee..8ee2c05 100644 --- a/plugins/eg-sampler.lv2/sampler.c +++ b/plugins/eg-sampler.lv2/sampler.c @@ -41,14 +41,14 @@ #include <sndfile.h> -#include <semaphore.h> - #include "lv2/lv2plug.in/ns/ext/atom/atom-helpers.h" #include "lv2/lv2plug.in/ns/ext/message/message.h" #include "lv2/lv2plug.in/ns/ext/state/state.h" #include "lv2/lv2plug.in/ns/ext/urid/urid.h" #include "lv2/lv2plug.in/ns/lv2core/lv2.h" +#include "zix/sem.h" + #include "./uris.h" #define STRING_BUF 8192 @@ -73,7 +73,7 @@ typedef struct { /* Sample */ SampleFile* samp; SampleFile* pending_samp; - sem_t signal; + ZixSem signal; int pending_sample_ready; /* Ports */ @@ -142,12 +142,10 @@ worker_thread_main(void* arg) { Sampler* plugin = (Sampler*)arg; + /* TODO: This thread never exits cleanly */ while (true) { /* Wait for run() to signal that we need to load a sample */ - if (sem_wait(&plugin->signal)) { - fprintf(stderr, "Odd, sem_wait failed...\n"); - continue; - } + zix_sem_wait(&plugin->signal); /* Then load it */ handle_load_sample(plugin); @@ -162,7 +160,7 @@ cleanup(LV2_Handle instance) Sampler* plugin = (Sampler*)instance; pthread_cancel(plugin->worker_thread); pthread_join(plugin->worker_thread, 0); - sem_destroy(&plugin->signal); + zix_sem_destroy(&plugin->signal); free(plugin->samp->data); free(plugin->pending_samp->data); @@ -212,7 +210,7 @@ instantiate(const LV2_Descriptor* descriptor, memset(&plugin->uris, 0, sizeof(plugin->uris)); /* Create signal for waking up worker thread */ - if (sem_init(&plugin->signal, 0, 0)) { + if (zix_sem_init(&plugin->signal, 0)) { fprintf(stderr, "Could not initialize semaphore.\n"); goto fail; } @@ -309,7 +307,7 @@ run(LV2_Handle instance, char* str = (char*)LV2_ATOM_BODY(filename); fprintf(stderr, "Request to load %s\n", str); memcpy(plugin->pending_samp->filepath, str, filename->size); - sem_post(&plugin->signal); + zix_sem_post(&plugin->signal); } else { fprintf(stderr, "Unknown message type %d\n", obj->id); } |