[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-360-g7c7133e

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Jan 21 17:24:42 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  bb23932e9a95f4b87d305f043f52fadd176c80bc (commit)

- Log -----------------------------------------------------------------
7c7133e... NetBSD sometimes doesn't know SNDCTL_DSP_GETODELAY
cef5f48... make rtstutter use pa_ncpus()
4dc1916... add API pa_ncpus()
c0e4e5a... NetBSD doesn't know getgrnam_r()/getpwnam_r()
61075a7... NetBSD doesn't know ENOLINK
ca6b791... It is more portable to assume that SO_RCVBUF/SO_SNDBUF takes and int instead of a size_t
8d89ccd... NetBSD specific atomic operation implementation
cc425ed... NetBSD doesn't know RLIMIT_AS
75eeea6... NetBSD needs to include sys/uio.h for some socket functions
-----------------------------------------------------------------------

Summary of changes:
 configure.ac                 |  136 ++++++++++++++++++++++++-----------------
 src/daemon/main.c            |    4 +
 src/modules/oss/module-oss.c |   23 +++++++-
 src/modules/oss/oss-util.c   |    4 +
 src/modules/rtp/rtp.c        |    4 +
 src/modules/rtp/sap.c        |    4 +
 src/pulsecore/atomic.h       |   73 ++++++++++++++++++++++
 src/pulsecore/core-util.c    |   60 ++++++++++++++++---
 src/pulsecore/core-util.h    |    2 +
 src/pulsecore/socket-util.c  |    8 ++-
 src/tests/rtstutter.c        |    3 +-
 11 files changed, 251 insertions(+), 70 deletions(-)

-----------------------------------------------------------------------

commit 75eeea65bd7007587a2465f014cacc9472f10bde
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 01:37:19 2009 +0100

    NetBSD needs to include sys/uio.h for some socket functions
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/configure.ac b/configure.ac
index 1d891b7..57b3d92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -246,7 +246,7 @@ AC_HEADER_STDC
 AC_CHECK_HEADERS([arpa/inet.h glob.h grp.h netdb.h netinet/in.h \
     netinet/in_systm.h netinet/tcp.h poll.h pwd.h sched.h \
     sys/mman.h sys/resource.h sys/select.h sys/socket.h sys/wait.h \
-    syslog.h sys/dl.h dlfcn.h linux/sockios.h])
+    sys/uio.h syslog.h sys/dl.h dlfcn.h linux/sockios.h])
 AC_CHECK_HEADERS([netinet/ip.h], [], [],
 		 [#include <sys/types.h>
 		  #if HAVE_NETINET_IN_H
diff --git a/src/modules/rtp/rtp.c b/src/modules/rtp/rtp.c
index 8835101..c09c321 100644
--- a/src/modules/rtp/rtp.c
+++ b/src/modules/rtp/rtp.c
@@ -35,6 +35,10 @@
 #include <sys/filio.h>
 #endif
 
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
 #include <pulsecore/core-error.h>
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
diff --git a/src/modules/rtp/sap.c b/src/modules/rtp/sap.c
index b0c95aa..7764f7b 100644
--- a/src/modules/rtp/sap.c
+++ b/src/modules/rtp/sap.c
@@ -38,6 +38,10 @@
 #include <sys/filio.h>
 #endif
 
+#ifdef HAVE_SYS_UIO_H
+#include <sys/uio.h>
+#endif
+
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/core-error.h>

commit cc425ed260bdaa94ba5a7369efcb7bbe630a8c05
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 01:39:54 2009 +0100

    NetBSD doesn't know RLIMIT_AS
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/daemon/main.c b/src/daemon/main.c
index b01689f..68e64c1 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -302,7 +302,9 @@ static void set_all_rlimits(const pa_daemon_conf *conf) {
 #ifdef RLIMIT_MEMLOCK
     set_one_rlimit(&conf->rlimit_memlock, RLIMIT_MEMLOCK, "RLIMIT_MEMLOCK");
 #endif
+#ifdef RLIMIT_AS
     set_one_rlimit(&conf->rlimit_as, RLIMIT_AS, "RLIMIT_AS");
+#endif
 #ifdef RLIMIT_LOCKS
     set_one_rlimit(&conf->rlimit_locks, RLIMIT_LOCKS, "RLIMIT_LOCKS");
 #endif

commit 8d89ccdcf2d3aed41688a2933ebc58942e93bb45
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 01:52:35 2009 +0100

    NetBSD specific atomic operation implementation
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/configure.ac b/configure.ac
index 57b3d92..568e580 100644
--- a/configure.ac
+++ b/configure.ac
@@ -129,16 +129,31 @@ AC_ARG_ENABLE([atomic-arm-memory-barrier],
             esac
         ],)
 
+AC_ARG_ENABLE([netbsd-atomic-ops],
+    AS_HELP_STRING([--enable-netbsd-atomic-ops],[Use the native NetBSD atomic_ops implementation]),
+        [
+            case "${enableval}" in
+                yes) atomic_netbsd_helpers=yes ;;
+                no) atomic_netbsd_helpers=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --enable-netbsd-atomic-ops) ;;
+            esac
+        ],
+        [atomic_netbsd_helpers=auto])
+
 AC_MSG_CHECKING([target operating system])
 case $host in
-    	*-*-linux*)
-	    AC_MSG_RESULT([linux])
-	    pulse_target_os=linux
-    	;;
-	*)
-	    AC_MSG_RESULT([unknown])
-	    pulse_target_os=unknown
-	;;
+        *-*-linux*)
+            AC_MSG_RESULT([linux])
+            pulse_target_os=linux
+        ;;
+        *-*-netbsd*)
+            AC_MSG_RESULT([netbsd])
+            pulse_target_os=netbsd
+        ;;
+        *)
+            AC_MSG_RESULT([unknown])
+            pulse_target_os=unknown
+        ;;
 esac
 
 # If everything else fails use libatomic_ops
@@ -160,42 +175,48 @@ else
     AC_MSG_CHECKING([architecture for native atomic operations])
     case $host_cpu in
         arm*)
-	    AC_MSG_RESULT([arm])
-	    AC_MSG_CHECKING([whether we can use Linux kernel helpers])
-	    # The Linux kernel helper functions have been there since 2.6.16. However
-  	    # compile time checking for kernel version in cross compile environment
-	    # (which is usually the case for arm cpu) is tricky (or impossible).
-	    if test "x$pulse_target_os" = "xlinux" && test "x$atomic_arm_linux_helpers" != "xno"; then
-	        AC_MSG_RESULT([yes])
-        	AC_DEFINE_UNQUOTED(ATOMIC_ARM_LINUX_HELPERS, 1, [special arm linux implementation])
-    		need_libatomic_ops=no
-	    else
-	       AC_MSG_RESULT([no])
-	       AC_CACHE_CHECK([compiler support for arm inline asm atomic operations],
-	         pulseaudio_cv_support_arm_atomic_ops,
-		 [AC_COMPILE_IFELSE(
-		    AC_LANG_PROGRAM([],
-		      [[volatile int a=0;
-	                int o=0, n=1, r;
-	                asm volatile ("ldrex	%0, [%1]\n"
-		        	 	 "subs	%0, %0, %2\n"
-		        	 	 "strexeq %0, %3, [%1]\n"
-		        	 	 : "=&r" (r)
-		        	 	 : "r" (&a), "Ir" (o), "r" (n)
-		        	 	 : "cc");
+            AC_MSG_RESULT([arm])
+            AC_MSG_CHECKING([whether we can use Linux kernel helpers])
+            # The Linux kernel helper functions have been there since 2.6.16. However
+            # compile time checking for kernel version in cross compile environment
+            # (which is usually the case for arm cpu) is tricky (or impossible).
+            if test "x$pulse_target_os" = "xlinux" && test "x$atomic_arm_linux_helpers" != "xno"; then
+                AC_MSG_RESULT([yes])
+                AC_DEFINE_UNQUOTED(ATOMIC_ARM_LINUX_HELPERS, 1, [special arm linux implementation])
+                need_libatomic_ops=no
+            else
+               AC_MSG_RESULT([no])
+               AC_CACHE_CHECK([compiler support for arm inline asm atomic operations],
+                 pulseaudio_cv_support_arm_atomic_ops,
+                 [AC_COMPILE_IFELSE(
+                    AC_LANG_PROGRAM([],
+                      [[volatile int a=0;
+                        int o=0, n=1, r;
+                        asm volatile ("ldrex    %0, [%1]\n"
+                                         "subs  %0, %0, %2\n"
+                                         "strexeq %0, %3, [%1]\n"
+                                         : "=&r" (r)
+                                         : "r" (&a), "Ir" (o), "r" (n)
+                                         : "cc");
                         return (a==1 ? 0 : -1);
-		      ]]),
-		    [pulseaudio_cv_support_arm_atomic_ops=yes],
-		    [pulseaudio_cv_support_arm_atomic_ops=no])
-		 ])
-	       AS_IF([test "$pulseaudio_cv_support_arm_atomic_ops" = "yes"], [
-	       	   AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARMv6 instructions.])
-		   need_libatomic_ops=no
-	         ])
-	   fi
-      	;;
+                      ]]),
+                    [pulseaudio_cv_support_arm_atomic_ops=yes],
+                    [pulseaudio_cv_support_arm_atomic_ops=no])
+                 ])
+               AS_IF([test "$pulseaudio_cv_support_arm_atomic_ops" = "yes"], [
+                   AC_DEFINE([ATOMIC_ARM_INLINE_ASM], 1, [Have ARMv6 instructions.])
+                   need_libatomic_ops=no
+                 ])
+           fi
+        ;;
         *)
-	    AC_MSG_RESULT([unknown])
+            if test "x$pulse_target_os" = "xnetbsd" && test "x$atomic_netbsd_helpers" = "xyes"; then
+                AC_MSG_RESULT([yes])
+                AC_DEFINE_UNQUOTED(NETBSD_ATOMIC_OPS, 1, [netbsd implementation])
+                need_libatomic_ops=no
+            else
+                AC_MSG_RESULT([unknown])
+            fi
         ;;
     esac
 fi
@@ -225,11 +246,11 @@ LTDL_INIT([convenience recursive])
 os_is_win32=0
 
 case "$host_os" in
-	mingw*)
+        mingw*)
         AC_DEFINE([OS_IS_WIN32], 1, [Build target is Windows.])
         os_is_win32=1
-		;;
-	esac
+                ;;
+        esac
 
 AM_CONDITIONAL(OS_IS_WIN32, test "x$os_is_win32" = "x1")
 
@@ -248,14 +269,14 @@ AC_CHECK_HEADERS([arpa/inet.h glob.h grp.h netdb.h netinet/in.h \
     sys/mman.h sys/resource.h sys/select.h sys/socket.h sys/wait.h \
     sys/uio.h syslog.h sys/dl.h dlfcn.h linux/sockios.h])
 AC_CHECK_HEADERS([netinet/ip.h], [], [],
-		 [#include <sys/types.h>
-		  #if HAVE_NETINET_IN_H
-		  # include <netinet/in.h>
-		  #endif
-		  #if HAVE_NETINET_IN_SYSTM_H
-		  # include <netinet/in_systm.h>
-		  #endif
-		 ])
+                 [#include <sys/types.h>
+                  #if HAVE_NETINET_IN_H
+                  # include <netinet/in.h>
+                  #endif
+                  #if HAVE_NETINET_IN_SYSTM_H
+                  # include <netinet/in_systm.h>
+                  #endif
+                 ])
 AC_CHECK_HEADERS([regex.h], [HAVE_REGEX=1], [HAVE_REGEX=0])
 AC_CHECK_HEADERS([sys/un.h], [HAVE_AF_UNIX=1], [HAVE_AF_UNIX=0])
 
@@ -275,6 +296,9 @@ AC_CHECK_HEADERS([sys/filio.h])
 # Windows
 AC_CHECK_HEADERS([windows.h winsock2.h ws2tcpip.h])
 
+# NetBSD
+AC_CHECK_HEADERS([sys/atomic.h])
+
 # Other
 AC_CHECK_HEADERS([sys/ioctl.h])
 AC_CHECK_HEADERS([byteswap.h])
diff --git a/src/pulsecore/atomic.h b/src/pulsecore/atomic.h
index 9c58c66..6e33a0e 100644
--- a/src/pulsecore/atomic.h
+++ b/src/pulsecore/atomic.h
@@ -107,6 +107,79 @@ static inline pa_bool_t pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, v
     return __sync_bool_compare_and_swap(&a->value, (long) old_p, (long) new_p);
 }
 
+#elif defined(__NetBSD__) && defined(HAVE_SYS_ATOMIC_H)
+
+/* NetBSD 5.0+ atomic_ops(3) implementation */
+
+#include <sys/atomic.h>
+
+typedef struct pa_atomic {
+    volatile unsigned int value;
+} pa_atomic_t;
+
+#define PA_ATOMIC_INIT(v) { .value = (unsigned int) (v) }
+
+static inline int pa_atomic_load(const pa_atomic_t *a) {
+    membar_sync();
+    return (int) a->value;
+}
+
+static inline void pa_atomic_store(pa_atomic_t *a, int i) {
+    a->value = (unsigned int) i;
+    membar_sync();
+}
+
+/* Returns the previously set value */
+static inline int pa_atomic_add(pa_atomic_t *a, int i) {
+    int nv = (int) atomic_add_int_nv(&a->value, i);
+    return nv - i;
+}
+
+/* Returns the previously set value */
+static inline int pa_atomic_sub(pa_atomic_t *a, int i) {
+    int nv = (int) atomic_add_int_nv(&a->value, -i);
+    return nv + i;
+}
+
+/* Returns the previously set value */
+static inline int pa_atomic_inc(pa_atomic_t *a) {
+    int nv = (int) atomic_inc_uint_nv(&a->value);
+    return nv - 1;
+}
+
+/* Returns the previously set value */
+static inline int pa_atomic_dec(pa_atomic_t *a) {
+    int nv = (int) atomic_dec_uint_nv(&a->value);
+    return nv + 1;
+}
+
+/* Returns TRUE when the operation was successful. */
+static inline pa_bool_t pa_atomic_cmpxchg(pa_atomic_t *a, int old_i, int new_i) {
+    unsigned int r = atomic_cas_uint(&a->value, (unsigned int) old_i, (unsigned int) new_i);
+    return (int) r == old_i;
+}
+
+typedef struct pa_atomic_ptr {
+    volatile void *value;
+} pa_atomic_ptr_t;
+
+#define PA_ATOMIC_PTR_INIT(v) { .value = (v) }
+
+static inline void* pa_atomic_ptr_load(const pa_atomic_ptr_t *a) {
+    membar_sync();
+    return (void *) a->value;
+}
+
+static inline void pa_atomic_ptr_store(pa_atomic_ptr_t *a, void *p) {
+    a->value = p;
+    membar_sync();
+}
+
+static inline pa_bool_t pa_atomic_ptr_cmpxchg(pa_atomic_ptr_t *a, void *old_p, void* new_p) {
+    void *r = atomic_cas_ptr(&a->value, old_p, new_p);
+    return r == old_p;
+}
+
 #elif defined(__GNUC__) && (defined(__amd64__) || defined(__x86_64__))
 
 #warn "The native atomic operations implementation for AMD64 has not been tested thoroughly. libatomic_ops is known to not work properly on AMD64 and your gcc version is too old for the gcc-builtin atomic ops support. You have three options now: test the native atomic operations implementation for AMD64, fix libatomic_ops, or upgrade your GCC."

commit ca6b79141bfa36231420b7adc6080faee5b63077
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 01:55:21 2009 +0100

    It is more portable to assume that SO_RCVBUF/SO_SNDBUF takes and int instead of a size_t
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/pulsecore/socket-util.c b/src/pulsecore/socket-util.c
index f721f69..a092002 100644
--- a/src/pulsecore/socket-util.c
+++ b/src/pulsecore/socket-util.c
@@ -202,9 +202,11 @@ void pa_make_udp_socket_low_delay(int fd) {
 }
 
 int pa_socket_set_rcvbuf(int fd, size_t l) {
+    int bufsz = (int)l;
+
     pa_assert(fd >= 0);
 
-    if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&l, sizeof(l)) < 0) {
+    if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (void*)&bufsz, sizeof(bufsz)) < 0) {
         pa_log_warn("SO_RCVBUF: %s", pa_cstrerror(errno));
         return -1;
     }
@@ -213,9 +215,11 @@ int pa_socket_set_rcvbuf(int fd, size_t l) {
 }
 
 int pa_socket_set_sndbuf(int fd, size_t l) {
+    int bufsz = (int)l;
+
     pa_assert(fd >= 0);
 
-    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&l, sizeof(l)) < 0) {
+    if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (void*)&bufsz, sizeof(bufsz)) < 0) {
         pa_log("SO_SNDBUF: %s", pa_cstrerror(errno));
         return -1;
     }

commit 61075a78f7c6f1a2242e14b2fa347c5d611b1b5b
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 01:57:52 2009 +0100

    NetBSD doesn't know ENOLINK
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/modules/oss/oss-util.c b/src/modules/oss/oss-util.c
index 41092d8..f04b875 100644
--- a/src/modules/oss/oss-util.c
+++ b/src/modules/oss/oss-util.c
@@ -309,7 +309,11 @@ static int get_device_number(const char *dev) {
     int r;
 
     if (!(p = rp = pa_readlink(dev))) {
+#ifdef ENOLINK
         if (errno != EINVAL && errno != ENOLINK) {
+#else
+        if (errno != EINVAL) {
+#endif
             r = -1;
             goto finish;
         }

commit c0e4e5a86828cb63d43c56db3a37d4e2c4db7a46
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 02:15:50 2009 +0100

    NetBSD doesn't know getgrnam_r()/getpwnam_r()
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/configure.ac b/configure.ac
index 568e580..9912843 100644
--- a/configure.ac
+++ b/configure.ac
@@ -367,8 +367,8 @@ AC_CHECK_FUNCS([lrintf strtof])
 AC_FUNC_FORK
 AC_FUNC_GETGROUPS
 AC_FUNC_SELECT_ARGTYPES
-AC_CHECK_FUNCS([chmod chown clock_gettime getaddrinfo getgrgid_r \
-    getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
+AC_CHECK_FUNCS([chmod chown clock_gettime getaddrinfo getgrgid_r getgrnam_r \
+    getpwnam_r getpwuid_r gettimeofday getuid inet_ntop inet_pton mlock nanosleep \
     pipe posix_fadvise posix_madvise posix_memalign setpgid setsid shm_open \
     sigaction sleep sysconf])
 AC_CHECK_FUNCS([mkfifo], [HAVE_MKFIFO=1], [HAVE_MKFIFO=0])
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 6f31566..fcb5c42 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -935,7 +935,7 @@ static int is_group(gid_t gid, const char *name) {
 #else
     n = -1;
 #endif
-    if (n < 0)
+    if (n <= 0)
         n = 512;
 
     data = pa_xmalloc((size_t) n);
@@ -959,7 +959,7 @@ finish:
      * support getgrgid_r. */
 
     errno = 0;
-    if ((result = getgrgid(gid)) == NULL) {
+    if (!(result = getgrgid(gid))) {
         pa_log("getgrgid(%u): %s", gid, pa_cstrerror(errno));
 
         if (!errno)
@@ -1026,18 +1026,35 @@ int pa_uid_in_group(uid_t uid, const char *name) {
     char **i;
     int r = -1;
 
+#ifdef _SC_GETGR_R_SIZE_MAX
     g_n = sysconf(_SC_GETGR_R_SIZE_MAX);
+#else
+    g_n = -1;
+#endif
+    if (g_n <= 0)
+        g_n = 512;
+
     g_buf = pa_xmalloc((size_t) g_n);
 
+#ifdef _SC_GETPW_R_SIZE_MAX
     p_n = sysconf(_SC_GETPW_R_SIZE_MAX);
+#else
+    p_n = -1;
+#endif
+    if (p_n <= 0)
+        p_n = 512;
+
     p_buf = pa_xmalloc((size_t) p_n);
 
     errno = 0;
-    if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr) {
-
+#ifdef HAVE_GETGRNAM_R
+    if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr)
+#else
+    if (!(gr = getgrnam(name)))
+#endif
+    {
         if (!errno)
             errno = ENOENT;
-
         goto finish;
     }
 
@@ -1045,8 +1062,11 @@ int pa_uid_in_group(uid_t uid, const char *name) {
     for (i = gr->gr_mem; *i; i++) {
         struct passwd pwbuf, *pw;
 
-        errno = 0;
+#ifdef HAVE_GETPWNAM_R
         if (getpwnam_r(*i, &pwbuf, p_buf, (size_t) p_n, &pw) != 0 || !pw)
+#else
+        if (!(pw = getpwnam(*i)))
+#endif
             continue;
 
         if (pw->pw_uid == uid) {
@@ -1069,15 +1089,25 @@ gid_t pa_get_gid_of_group(const char *name) {
     long g_n;
     struct group grbuf, *gr;
 
+#ifdef _SC_GETGR_R_SIZE_MAX
     g_n = sysconf(_SC_GETGR_R_SIZE_MAX);
+#else
+    g_n = -1;
+#endif
+    if (g_n <= 0)
+        g_n = 512;
+
     g_buf = pa_xmalloc((size_t) g_n);
 
     errno = 0;
-    if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr) {
-
+#ifdef HAVE_GETGRNAM_R
+    if (getgrnam_r(name, &grbuf, g_buf, (size_t) g_n, &gr) != 0 || !gr)
+#else
+    if (!(gr = getgrnam(name)))
+#endif
+    {
         if (!errno)
             errno = ENOENT;
-
         goto finish;
     }
 

commit 4dc191646750a15c7f92f945816b59cd91c5728c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 02:16:53 2009 +0100

    add API pa_ncpus()

diff --git a/src/daemon/main.c b/src/daemon/main.c
index 68e64c1..f483607 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -823,6 +823,8 @@ int main(int argc, char *argv[]) {
     pa_log_debug(_("Running on host: %s"), s);
     pa_xfree(s);
 
+    pa_log_debug(_("Found %u CPUs."), pa_ncpus());
+
     pa_log_info(_("Page size is %lu bytes"), (unsigned long) PA_PAGE_SIZE);
 
 #ifdef HAVE_VALGRIND_MEMCHECK_H
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index fcb5c42..e65b179 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2541,3 +2541,15 @@ void pa_reduce(unsigned *num, unsigned *den) {
 
     pa_assert(pa_gcd(*num, *den) == 1);
 }
+
+unsigned pa_ncpus(void) {
+    long ncpus;
+
+#ifdef _SC_NPROCESSORS_CONF
+    ncpus = sysconf(_SC_NPROCESSORS_CONF);
+#else
+    ncpus = 1;
+#endif
+
+    return ncpus <= 0 ? 1 : (unsigned) ncpus;
+}
diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h
index 44b3af3..18901f4 100644
--- a/src/pulsecore/core-util.h
+++ b/src/pulsecore/core-util.h
@@ -213,4 +213,6 @@ static inline pa_bool_t pa_in_valgrind(void) {
 unsigned pa_gcd(unsigned a, unsigned b);
 void pa_reduce(unsigned *num, unsigned *den);
 
+unsigned pa_ncpus(void);
+
 #endif

commit cef5f48b501700a8202193a240e0988b52f45fc9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 22 02:20:00 2009 +0100

    make rtstutter use pa_ncpus()

diff --git a/src/tests/rtstutter.c b/src/tests/rtstutter.c
index 6b0cb8f..fc23d95 100644
--- a/src/tests/rtstutter.c
+++ b/src/tests/rtstutter.c
@@ -36,6 +36,7 @@
 
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
+#include <pulsecore/core-util.h>
 
 static int msec_lower, msec_upper;
 
@@ -106,7 +107,7 @@ int main(int argc, char*argv[]) {
 
     pa_log_notice("Creating random latencies in the range of %ims to  %ims.", msec_lower, msec_upper);
 
-    for (n = 1; n < sysconf(_SC_NPROCESSORS_CONF); n++) {
+    for (n = 1; n < pa_ncpus(); n++) {
         pthread_t t;
         pa_assert_se(pthread_create(&t, NULL, work, PA_INT_TO_PTR(n)) == 0);
     }

commit 7c7133e09ded0f3fc004737be0443eb9c4dae4c8
Author: Jared D. McNeill <jmcneill at NetBSD.org>
Date:   Thu Jan 22 02:24:04 2009 +0100

    NetBSD sometimes doesn't know SNDCTL_DSP_GETODELAY
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index f277d63..7271a08 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -71,6 +71,11 @@
 #include <pulsecore/thread-mq.h>
 #include <pulsecore/rtpoll.h>
 
+#if defined(__NetBSD__) && !defined(SNDCTL_DSP_GETODELAY)
+#include <sys/audioio.h>
+#include <sys/syscall.h>
+#endif
+
 #include "oss-util.h"
 #include "module-oss-symdef.h"
 
@@ -399,13 +404,27 @@ static pa_usec_t io_sink_get_latency(struct userdata *u) {
 
     if (u->use_getodelay) {
         int arg;
-
+#if defined(__NetBSD__) && !defined(SNDCTL_DSP_GETODELAY)
+#if defined(AUDIO_GETBUFINFO)
+        struct audio_info info;
+        if (syscall(SYS_ioctl, u->fd, AUDIO_GETBUFINFO, &info) < 0) {
+            pa_log_info("Device doesn't support AUDIO_GETBUFINFO: %s", pa_cstrerror(errno));
+            u->use_getodelay = 0;
+        } else {
+            arg = info.play.seek + info.blocksize / 2;
+            r = pa_bytes_to_usec((size_t) arg, &u->sink->sample_spec);
+        }
+#else
+        pa_log_info("System doesn't support AUDIO_GETBUFINFO");
+        u->use_getodelay = 0;
+#endif
+#else
         if (ioctl(u->fd, SNDCTL_DSP_GETODELAY, &arg) < 0) {
             pa_log_info("Device doesn't support SNDCTL_DSP_GETODELAY: %s", pa_cstrerror(errno));
             u->use_getodelay = 0;
         } else
             r = pa_bytes_to_usec((size_t) arg, &u->sink->sample_spec);
-
+#endif
     }
 
     if (!u->use_getodelay && u->use_getospace) {

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list