]> git.alsa-project.org Git - alsa-lib.git/commitdiff
support building w/out System V shared memory
authorMike Frysinger <vapier@chromium.org>
Tue, 27 Oct 2015 21:28:04 +0000 (17:28 -0400)
committerTakashi Iwai <tiwai@suse.de>
Thu, 5 Nov 2015 13:37:11 +0000 (14:37 +0100)
Some systems, like Android/Bionic, do not support SysV at all.
Let the configure script detect if the header is available, and
if not, automatically disable the pieces that require it.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
configure.ac
src/pcm/pcm_mmap.c
src/shmarea.c

index 9cb861421077c701610b59d60e997ec7d619f349..bf7cd855c0afe29532dce925a1721420ec23f661 100644 (file)
@@ -295,7 +295,7 @@ fi
 AC_SUBST(ALSA_DEPLIBS)
 
 dnl Check for headers
-AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h])
+AC_CHECK_HEADERS([wordexp.h endian.h sys/endian.h sys/shm.h])
 
 dnl Check for resmgr support...
 AC_MSG_CHECKING(for resmgr support)
@@ -508,6 +508,13 @@ if test "$gcc_have_atomics" != "yes"; then
   build_pcm_meter="no"
 fi
 
+if test "$ac_cv_header_sys_shm_h" != "yes"; then
+  build_pcm_dmix="no"
+  build_pcm_dshare="no"
+  build_pcm_dsnoop="no"
+  build_pcm_shm="no"
+fi
+
 AM_CONDITIONAL([BUILD_PCM_PLUGIN], [test x$build_pcm_plugin = xyes])
 AM_CONDITIONAL([BUILD_PCM_PLUGIN_COPY], [test x$build_pcm_copy = xyes])
 AM_CONDITIONAL([BUILD_PCM_PLUGIN_LINEAR], [test x$build_pcm_linear = xyes])
@@ -594,6 +601,10 @@ for p in $ctl_plugins; do
   done
 done
 
+if test "$ac_cv_header_sys_shm_h" != "yes"; then
+  build_ctl_shm="no"
+fi
+
 AM_CONDITIONAL([BUILD_CTL_PLUGIN], [test x$build_ctl_plugin = xyes])
 AM_CONDITIONAL([BUILD_CTL_PLUGIN_SHM], [test x$build_ctl_shm = xyes])
 AM_CONDITIONAL([BUILD_CTL_PLUGIN_EXT], [test x$build_ctl_ext = xyes])
index 470bd0413ee021d72fbfa999a04ed18d04788161..5c4fbe1705eb770defa4b3fca4e17c52a9b93da2 100644 (file)
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
  */
-  
+
+#include "config.h"
 #include <stdio.h>
 #include <malloc.h>
 #include <string.h>
 #include <sys/poll.h>
 #include <sys/mman.h>
+#ifdef HAVE_SYS_SHM_H
 #include <sys/shm.h>
+#endif
 #include "pcm_local.h"
 
 void snd_pcm_mmap_appl_backward(snd_pcm_t *pcm, snd_pcm_uframes_t frames)
@@ -341,6 +344,7 @@ int snd_pcm_mmap(snd_pcm_t *pcm)
                        i->addr = ptr;
                        break;
                case SND_PCM_AREA_SHM:
+#ifdef HAVE_SYS_SHM_H
                        if (i->u.shm.shmid < 0) {
                                int id;
                                /* FIXME: safer permission? */
@@ -385,6 +389,10 @@ int snd_pcm_mmap(snd_pcm_t *pcm)
                        }
                        i->addr = ptr;
                        break;
+#else
+                       SYSERR("shm support not available");
+                       return -ENOSYS;
+#endif
                case SND_PCM_AREA_LOCAL:
                        ptr = malloc(size);
                        if (ptr == NULL) {
@@ -466,6 +474,7 @@ int snd_pcm_munmap(snd_pcm_t *pcm)
                        errno = 0;
                        break;
                case SND_PCM_AREA_SHM:
+#ifdef HAVE_SYS_SHM_H
                        if (i->u.shm.area) {
                                snd_shm_area_destroy(i->u.shm.area);
                                i->u.shm.area = NULL;
@@ -482,6 +491,10 @@ int snd_pcm_munmap(snd_pcm_t *pcm)
                                }
                        }
                        break;
+#else
+                       SYSERR("shm support not available");
+                       return -ENOSYS;
+#endif
                case SND_PCM_AREA_LOCAL:
                        free(i->addr);
                        break;
index 071f9f336f353f45acd20316cf534a8fa2067a1c..9843aa8b4f7e08384fd44ced48692053fb49d9c5 100644 (file)
  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  *
  */
-  
+
+#include "config.h"
+
+/* These funcs are only used by pcm_mmap when sys/shm.h is available. */
+#ifdef HAVE_SYS_SHM_H
+
 #include <stdio.h>
 #include <malloc.h>
 #include <string.h>
@@ -106,3 +111,5 @@ void snd_shm_area_destructor(void)
                shmdt(area->ptr);
        }
 }
+
+#endif