From 7e5bf17f9e14b4a24346c402bf5fcf88772c50f3 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 9 Feb 2012 23:23:54 +0000 Subject: Portability fixes (plugins work on OSX). --- plugins/eg-sampler.lv2/sampler.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'plugins/eg-sampler.lv2/sampler.c') 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 -#include - #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); } -- cgit v1.2.1