Quoting Luca Barbato (2016-03-27 20:52:24) > From: Josh de Kock <[email protected]> > > Previously, with JACK installed, the configure script would enabled the > JACK indev; this broke on Mac OS X due to a incomplete pthreads > implementation. Some simple macros to map libdispatch to pthreads if on > OS X. > > Signed-off-by: Luca Barbato <[email protected]> > --- > > Now with an inline function, I avoided libav-specific macros on purpose. > > Makefile | 2 +- > compat/dispatch_semaphore.h | 42 ++++++++++++++++++++++++++++++++++++++++++ > configure | 7 ++++++- > libavdevice/jack.c | 5 +++++ > 4 files changed, 54 insertions(+), 2 deletions(-) > create mode 100644 compat/dispatch_semaphore.h > > diff --git a/Makefile b/Makefile > index 7b1e550..9ffce89 100644 > --- a/Makefile > +++ b/Makefile > @@ -104,7 +104,7 @@ FFLIBS := avutil > > DATA_FILES := $(wildcard $(SRC_PATH)/presets/*.avpreset) > > -SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h > +SKIPHEADERS = cmdutils_common_opts.h compat/w32pthreads.h > compat/dispatch_semaphore.h > > include $(SRC_PATH)/common.mak > > diff --git a/compat/dispatch_semaphore.h b/compat/dispatch_semaphore.h > new file mode 100644 > index 0000000..6fe21f1 > --- /dev/null > +++ b/compat/dispatch_semaphore.h > @@ -0,0 +1,42 @@ > +/* > + * This file is part of Libav. > + * > + * Libav is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * Libav is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with Libav; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#ifndef COMPAT_DISPATCH_SEMAPHORE_H > +#define COMPAT_DISPATCH_SEMAPHORE_H > + > +#include <dispatch/dispatch.h> > +#include <errno.h> > + > +#define sem_t dispatch_semaphore_t > +#define sem_post(psem) dispatch_semaphore_signal(*psem) > +#define sem_wait(psem) dispatch_semaphore_wait(*psem, > DISPATCH_TIME_FOREVER) > +#define sem_timedwait(psem, val) dispatch_semaphore_wait(*psem, > dispatch_walltime(val, 0)) > +#define sem_destroy(psem) dispatch_release(*psem) > + > +static inline int compat_sem_init(dispatch_semaphore_t *psem, > + int unused, int val) > +{ > + int ret = !!(*psem = dispatch_semaphore_create(val)) - 1; > + if (ret < 0) > + errno = ENOMEM; > + return ret; > +} > + > +#define sem_init compat_sem_init > + > +#endif /* COMPAT_DISPATCH_SEMAPHORE_H */ > diff --git a/configure b/configure > index a68a5d7..86f6ff0 100755 > --- a/configure > +++ b/configure > @@ -1447,6 +1447,7 @@ BUILTIN_LIST=" > MemoryBarrier > mm_empty > rdtsc > + sem_timedwait > sync_val_compare_and_swap > " > HAVE_LIST_CMDLINE=" > @@ -1467,6 +1468,7 @@ HEADERS_LIST=" > arpa_inet_h > cdio_paranoia_h > cdio_paranoia_paranoia_h > + dispatch_dispatch_h > dev_bktr_ioctl_bt848_h > dev_bktr_ioctl_meteor_h > dev_ic_bt8xx_h > @@ -2290,7 +2292,8 @@ bktr_indev_deps_any="dev_bktr_ioctl_bt848_h > machine_ioctl_bt848_h dev_video_bktr > dv1394_indev_deps="dv1394" > dv1394_indev_select="dv_demuxer" > fbdev_indev_deps="linux_fb_h" > -jack_indev_deps="jack_jack_h pthreads" > +jack_indev_deps="jack_jack_h" > +jack_indev_deps_any="sem_timedwait dispatch_dispatch_h" > libcdio_indev_deps="libcdio" > libdc1394_indev_deps="libdc1394" > oss_indev_deps_any="soundcard_h sys_soundcard_h" > @@ -3737,6 +3740,7 @@ case $target_os in > enabled x86_64 && objformat="macho64" > enabled_any pic shared || > { check_cflags -mdynamic-no-pic && add_asflags -mdynamic-no-pic; > } > + check_header dispatch/dispatch.h > ;; > msys*) > die "Native MSYS builds are discouraged, please use the MINGW > environment."; > @@ -4373,6 +4377,7 @@ fi > check_builtin atomic_cas_ptr atomic.h "void **ptr; void *oldval, *newval; > atomic_cas_ptr(ptr, oldval, newval)" > check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()" > check_builtin MemoryBarrier windows.h "MemoryBarrier()" > +check_builtin sem_timedwait semaphore.h "sem_t *s; sem_init(s,0,0); > sem_timedwait(s,0); sem_destroy(s)" -lpthread > check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; > __sync_val_compare_and_swap(ptr, oldval, newval)" > > case "$custom_allocator" in > diff --git a/libavdevice/jack.c b/libavdevice/jack.c > index 0b4deee..7687cf7 100644 > --- a/libavdevice/jack.c > +++ b/libavdevice/jack.c > @@ -21,7 +21,12 @@ > */ > > #include "config.h" > +#if HAVE_DISPATCH_DISPATCH_H > +#include "compat/dispatch_semaphore.h" > +#else > #include <semaphore.h> > +#endif
Just override the native one. See e.g. compat/float/limits.h That way the actual libav code doesn't need to know about this issue at all. -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
