aboutsummaryrefslogtreecommitdiff
path: root/sndfiler
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2006-01-19 21:02:12 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:12:01 +0200
commitb65ae6220a420b3a0b1ed23d8ef0934379cebbb6 (patch)
tree1f0ae1b08b8ccb517cdcb9a07fdb046806b99d78 /sndfiler
parente97a3414a2d0609a15d7323ce53faa4b1eaad18b (diff)
fixes for OSX (doesn't have a sem_init function)
svn path=/trunk/externals/tb/; revision=4447
Diffstat (limited to 'sndfiler')
-rwxr-xr-xsndfiler/src/sndfiler.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/sndfiler/src/sndfiler.c b/sndfiler/src/sndfiler.c
index 005b75f..6d1e4c6 100755
--- a/sndfiler/src/sndfiler.c
+++ b/sndfiler/src/sndfiler.c
@@ -129,7 +129,7 @@ typedef struct _sfprocess
typedef struct _sfqueue
{
t_fifo* x_jobs;
- sem_t sem;
+ sem_t* sem;
} t_sfqueue;
typedef struct _syncdata
@@ -154,11 +154,11 @@ static t_sndfiler *sndfiler_new(void)
/* global soundfiler thread ... sleeping until signaled */
static void sndfiler_thread(void)
{
- while (1)
+ for(;;)
{
t_sfprocess * me;
- sem_wait(&sndfiler_queue.sem);
-
+ sem_wait(sndfiler_queue.sem);
+
while (me = (t_sfprocess *)fifo_get(sndfiler_queue.x_jobs))
{
(me->process)(me->x, me->argc, me->argv);
@@ -178,8 +178,17 @@ static void sndfiler_start_thread(void)
//initialize queue
sndfiler_queue.x_jobs = fifo_init();
- sem_init (&sndfiler_queue.sem,0,0);
-
+#ifdef __APPLE__
+ sndfiler_queue.sem = sem_open("sndfilerthread",O_CREAT|O_EXCL,0,0);
+ if(sndfiler_queue.sem == SEM_FAILED)
+ error("Couldn't create sndfiler semaphore: %i",errno);
+#else
+ sndfiler_queue.sem = (sem_t *)getbytes(sizeof(sem_t));
+ status = sem_init(sndfiler_queue.sem,0,0);
+ if(status != 0)
+ error("Couldn't create sndfiler semaphore: %i",status);
+#endif
+
// initialize thread
pthread_attr_init(&sf_attr);
@@ -224,7 +233,7 @@ static void sndfiler_read(t_sndfiler * x, t_symbol *s, int argc, t_atom* argv)
fifo_put(sndfiler_queue.x_jobs, process);
- sem_post(&sndfiler_queue.sem);
+ sem_post(sndfiler_queue.sem);
}
static t_int sndfiler_synchonize(t_int * w);
@@ -459,7 +468,7 @@ static void sndfiler_resize(t_sndfiler * x, t_symbol *s, int argc, t_atom* argv)
fifo_put(sndfiler_queue.x_jobs, process);
- sem_post(&sndfiler_queue.sem);
+ sem_post(sndfiler_queue.sem);
}
static void sndfiler_t_resize(t_sndfiler *y, int argc, t_atom *argv)