Update of /cvsroot/pure-data/externals/tb/sndfiler/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12804/src
Modified Files:
sndfiler.c
Log Message:
better fixes for OSX (use kernel functions)
Index: sndfiler.c
===================================================================
RCS file: /cvsroot/pure-data/externals/tb/sndfiler/src/sndfiler.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** sndfiler.c 19 Jan 2006 21:02:12 -0000 1.6
--- sndfiler.c 19 Jan 2006 22:21:01 -0000 1.7
***************
*** 45,48 ****
--- 45,49 ----
#include "m_pd.h"
#include "m_fifo.h"
+
#include "pthread.h"
#include "semaphore.h"
***************
*** 69,72 ****
--- 70,85 ----
#endif /* _POSIX_MEMLOCK */
+ #ifdef __APPLE__
+ #include <mach/semaphore.h>
+ #define SEM_T semaphore_t
+ #define SEM_INIT(s) (semaphore_create(mach_task_self(),&s,SYNC_POLICY_FIFO,0) == 0)
+ #define SEM_SIGNAL(s) semaphore_signal(s)
+ #define SEM_WAIT(s) semaphore_wait(s)
+ #else
+ #define SEM_T sem_t
+ #define SEM_INIT(s) (sem_init(&s,0,0) == 0)
+ #define SEM_SIGNAL(s) sem_post(&s)
+ #define SEM_WAIT(s) sem_wait(&s)
+ #endif
/************ forward declarations **************/
***************
*** 130,134 ****
{
t_fifo* x_jobs;
! sem_t* sem;
} t_sfqueue;
--- 143,147 ----
{
t_fifo* x_jobs;
! SEM_T sem;
} t_sfqueue;
***************
*** 158,162 ****
{
t_sfprocess * me;
! sem_wait(sndfiler_queue.sem);
while (me = (t_sfprocess *)fifo_get(sndfiler_queue.x_jobs))
--- 171,175 ----
{
t_sfprocess * me;
! SEM_WAIT(sndfiler_queue.sem);
while (me = (t_sfprocess *)fifo_get(sndfiler_queue.x_jobs))
***************
*** 179,192 ****
//initialize queue
sndfiler_queue.x_jobs = fifo_init();
! #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
--- 192,199 ----
//initialize queue
sndfiler_queue.x_jobs = fifo_init();
!
! status = SEM_INIT(sndfiler_queue.sem);
! if(!status)
error("Couldn't create sndfiler semaphore: %i",status);
// initialize thread
***************
*** 234,238 ****
fifo_put(sndfiler_queue.x_jobs, process);
! sem_post(sndfiler_queue.sem);
}
--- 241,245 ----
fifo_put(sndfiler_queue.x_jobs, process);
! SEM_SIGNAL(sndfiler_queue.sem);
}
***************
*** 469,473 ****
fifo_put(sndfiler_queue.x_jobs, process);
! sem_post(sndfiler_queue.sem);
}
--- 476,480 ----
fifo_put(sndfiler_queue.x_jobs, process);
! SEM_SIGNAL(sndfiler_queue.sem);
}