Skip to content

Commit

Permalink
Hopefully fix multithreading on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ktmf01 committed Jul 10, 2023
1 parent acac9e8 commit d7c053e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libFLAC/stream_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,18 @@
#endif
#ifdef HAVE_PTHREAD
#include <pthread.h>
#ifdef __APPLE__
/* Mac does have sem_init, but it doesn't work */
#include <dispatch/dispatch.h>
typedef dispatch_semaphore_t sem_t;
#define sem_init(sem,x,val) ((*sem = dispatch_semaphore_create(val)) == NULL)
#define sem_post(sem) dispatch_semaphore_signal(*sem)
#define sem_wait(sem) dispatch_semaphore_wait(*sem, DISPATCH_TIME_FOREVER)
#define sem_destroy(sem) dispatch_release(*sem)
#else
#include <semaphore.h>
#endif
#endif
#include "share/compat.h"
#include "FLAC/assert.h"
#include "FLAC/stream_decoder.h"
Expand Down

0 comments on commit d7c053e

Please sign in to comment.