shm: Fix compilation of shm on OSX

https://bugzilla.gnome.org/show_bug.cgi?id=689183
This commit is contained in:
Emmanuel Durand 2012-11-27 15:34:19 -05:00 committed by Sebastian Dröge
parent 13910f5154
commit 1c973536b9
3 changed files with 35 additions and 10 deletions

View file

@ -682,15 +682,24 @@ AG_GST_CHECK_FEATURE(QUICKTIME, [QuickTime wrapper], qtwrapper, [
dnl check for shm_open (for shm plugin)
translit(dnm, m, l) AM_CONDITIONAL(USE_SHM, true)
AG_GST_CHECK_FEATURE(SHM, [POSIX shared memory source and sink], shm, [
if test "x$HAVE_SYS_SOCKET_H" = "xyes"; then
AC_CHECK_LIB([rt], [shm_open],
AC_CHECK_DECL([MSG_NOSIGNAL], HAVE_SHM=yes, HAVE_SHM=no, [
#include <sys/socket.h>
]),
HAVE_SHM=no)
else
HAVE_SHM=no
fi
if test "x$HAVE_SYS_SOCKET_H" = "xyes"; then
case $host in
*-darwin* | *-macos10*)
AM_CONDITIONAL([HAVE_OSX], true)
AC_DEFINE(HAVE_OSX,[1],[Apple Mac OS X operating system detected])
HAVE_SHM=yes
;;
*)
AC_CHECK_LIB([rt], [shm_open],
AC_CHECK_DECL([MSG_NOSIGNAL], HAVE_SHM=yes, HAVE_SHM=no, [
#include <sys/socket.h>
]),
HAVE_SHM=no)
;;
esac
else
HAVE_SHM=no
fi
])
dnl check for Video CD

View file

@ -2,8 +2,14 @@ plugin_LTLIBRARIES = libgstshm.la
libgstshm_la_SOURCES = shmpipe.c shmalloc.c gstshm.c gstshmsrc.c gstshmsink.c
libgstshm_la_CFLAGS = $(GST_PLUGINS_BAD_CFLAGS) $(GST_CFLAGS) -DSHM_PIPE_USE_GLIB
libgstshm_la_LIBADD = -lrt
libgstshm_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) $(GST_BASE_LIBS)
if HAVE_OSX
libgstshm_la_LIBADD =
else
libgstshm_la_LIBADD = -lrt
endif
libgstshm_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstshmsrc.h gstshmsink.h shmpipe.h shmalloc.h

View file

@ -27,6 +27,12 @@
#include "config.h"
#endif
#ifdef HAVE_OSX
#ifndef MSG_NOSIGNAL
#define MSG_NOSIGNAL SO_NOSIGPIPE
#endif
#endif
#include "shmpipe.h"
#include <sys/types.h>
@ -278,7 +284,11 @@ sp_open_shm (char *path, int id, mode_t perms, size_t size)
if (path)
flags = O_RDONLY;
else
#ifdef HAVE_OSX
flags = O_RDWR | O_CREAT | O_EXCL;
#else
flags = O_RDWR | O_CREAT | O_TRUNC | O_EXCL;
#endif
area->shm_fd = -1;