]> code.delx.au - pulseaudio/commitdiff
Merge branch 'master' into dbus-work
authorTanu Kaskinen <tanuk@iki.fi>
Mon, 29 Jun 2009 15:55:12 +0000 (18:55 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Mon, 29 Jun 2009 15:55:12 +0000 (18:55 +0300)
12 files changed:
configure.ac
m4/attributes.m4
src/Makefile.am
src/daemon/main.c
src/modules/module-solaris.c
src/pulse/thread-mainloop.c
src/pulsecore/asyncq.c
src/pulsecore/core-util.c
src/pulsecore/rtpoll.c
src/pulsecore/shm.c
src/tests/ipacl-test.c
src/tests/mix-test.c

index 185f13bbab6f5a2780749c27055dd5a44c04f4a3..7e83a9c96407ec8392bedbb0e52d1151a5c1fa29 100644 (file)
@@ -99,11 +99,7 @@ if test "x$M4" = xno ; then
 fi
 
 dnl Compiler flags
-DESIRED_FLAGS="-Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option"
-
-for flag in $DESIRED_FLAGS ; do
-  CC_CHECK_CFLAGS([$flag], [CFLAGS="$CFLAGS $flag"])
-done
+CC_CHECK_CFLAGS_APPEND([-Wall -W -Wextra -pipe -Wno-long-long -Winline -Wvla -Wno-overlength-strings -Wunsafe-loop-optimizations -Wundef -Wformat=2 -Wlogical-op -Wsign-compare -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wpointer-arith -Winit-self -Wdeclaration-after-statement -Wfloat-equal -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-declarations -Wmissing-noreturn -Wshadow -Wendif-labels -Wcast-align -Wstrict-aliasing=2 -Wwrite-strings -Wno-unused-parameter -ffast-math -Wp,-D_FORTIFY_SOURCE=2 -fno-common -fdiagnostics-show-option])
 
 dnl Linker flags.
 dnl Check whether the linker supports the -version-script option.
@@ -116,6 +112,11 @@ CC_CHECK_LDFLAGS([${tmp_ldflag}],
     [VERSIONING_LDFLAGS='-Wl,-version-script=$(srcdir)/map-file'])
 AC_SUBST([VERSIONING_LDFLAGS])
 
+dnl Check for the proper way to build libraries that have no undefined
+dnl symbols; on some hosts this needs to be avoided but the macro
+dnl takes care of it.
+CC_NOUNDEFINED
+
 dnl Check whether to build tests by default (as compile-test) or not
 AC_ARG_ENABLE([default-build-tests],
     AS_HELP_STRING([--disable-default-build-tests], [Build test programs only during make check]))
@@ -276,7 +277,7 @@ AC_CHECK_HEADER([ltdl.h],
     [LIBLTDL=])
 
 AS_IF([test "x$LIBLTDL" = "x"],
-    [AC_MSG_ERROR([Unable to find libltdl.])])
+    [AC_MSG_ERROR([Unable to find libltdl version 2. Makes sure you have libtool 2.2 or later installed.])])
 AC_SUBST([LIBLTDL])
 
 #### Determine build environment ####
index 65f837885fb759275e4b65cb71ce13d16f29368d..28fac277b1721de428853b1a8633b0914b7cd466 100644 (file)
@@ -1,6 +1,6 @@
 dnl Macros to check the presence of generic (non-typed) symbols.
-dnl Copyright (c) 2006-2007 Diego Pettenò <flameeyes@gmail.com>
-dnl Copyright (c) 2006-2007 xine project
+dnl Copyright (c) 2006-2008 Diego Pettenò <flameeyes@gmail.com>
+dnl Copyright (c) 2006-2008 xine project
 dnl
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -32,6 +32,9 @@ dnl distribute a modified version of the Autoconf Macro, you may extend
 dnl this special exception to the GPL to apply to your modified version as
 dnl well.
 
+dnl Check if the flag is supported by compiler
+dnl CC_CHECK_CFLAGS_SILENT([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
 AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
   AC_CACHE_VAL(AS_TR_SH([cc_cv_cflags_$1]),
     [ac_save_CFLAGS="$CFLAGS"
@@ -46,6 +49,9 @@ AC_DEFUN([CC_CHECK_CFLAGS_SILENT], [
     [$2], [$3])
 ])
 
+dnl Check if the flag is supported by compiler (cacheable)
+dnl CC_CHECK_CFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
 AC_DEFUN([CC_CHECK_CFLAGS], [
   AC_CACHE_CHECK([if $CC supports $1 flag],
     AS_TR_SH([cc_cv_cflags_$1]),
@@ -56,6 +62,28 @@ AC_DEFUN([CC_CHECK_CFLAGS], [
     [$2], [$3])
 ])
 
+dnl CC_CHECK_CFLAG_APPEND(FLAG, [action-if-found], [action-if-not-found])
+dnl Check for CFLAG and appends them to CFLAGS if supported
+AC_DEFUN([CC_CHECK_CFLAG_APPEND], [
+  AC_CACHE_CHECK([if $CC supports $1 flag],
+    AS_TR_SH([cc_cv_cflags_$1]),
+    CC_CHECK_CFLAGS_SILENT([$1]) dnl Don't execute actions here!
+  )
+
+  AS_IF([eval test x$]AS_TR_SH([cc_cv_cflags_$1])[ = xyes],
+    [CFLAGS="$CFLAGS $1"; DEBUG_CFLAGS="$DEBUG_CFLAGS $1"; $2], [$3])
+])
+
+dnl CC_CHECK_CFLAGS_APPEND([FLAG1 FLAG2], [action-if-found], [action-if-not])
+AC_DEFUN([CC_CHECK_CFLAGS_APPEND], [
+  for flag in $1; do
+    CC_CHECK_CFLAG_APPEND($flag, [$2], [$3])
+  done
+])
+
+dnl Check if the flag is supported by linker (cacheable)
+dnl CC_CHECK_LDFLAGS([FLAG], [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
+
 AC_DEFUN([CC_CHECK_LDFLAGS], [
   AC_CACHE_CHECK([if $CC supports $1 flag],
     AS_TR_SH([cc_cv_ldflags_$1]),
@@ -63,7 +91,7 @@ AC_DEFUN([CC_CHECK_LDFLAGS], [
      LDFLAGS="$LDFLAGS $1"
      AC_LINK_IFELSE([int main() { return 1; }],
        [eval "AS_TR_SH([cc_cv_ldflags_$1])='yes'"],
-       [eval "AS_TR_SH([cc_cv_ldflags_$1])='no'"])
+       [eval "AS_TR_SH([cc_cv_ldflags_$1])="])
      LDFLAGS="$ac_save_LDFLAGS"
     ])
 
@@ -71,6 +99,31 @@ AC_DEFUN([CC_CHECK_LDFLAGS], [
     [$2], [$3])
 ])
 
+dnl define the LDFLAGS_NOUNDEFINED variable with the correct value for
+dnl the current linker to avoid undefined references in a shared object.
+AC_DEFUN([CC_NOUNDEFINED], [
+  dnl We check $host for which systems to enable this for.
+  AC_REQUIRE([AC_CANONICAL_HOST])
+
+  case $host in
+     dnl FreeBSD (et al.) does not complete linking for shared objects when pthreads
+     dnl are requested, as different implementations are present; to avoid problems
+     dnl use -Wl,-z,defs only for those platform not behaving this way.
+     *-freebsd* | *-openbsd*) ;;
+     *)
+        dnl First of all check for the --no-undefined variant of GNU ld. This allows
+        dnl for a much more readable commandline, so that people can understand what
+        dnl it does without going to look for what the heck -z defs does.
+        for possible_flags in "-Wl,--no-undefined" "-Wl,-z,defs"; do
+          CC_CHECK_LDFLAGS([$possible_flags], [LDFLAGS_NOUNDEFINED="$possible_flags"])
+         break
+        done
+       ;;
+  esac
+
+  AC_SUBST([LDFLAGS_NOUNDEFINED])
+])
+
 dnl Check for a -Werror flag or equivalent. -Werror is the GCC
 dnl and ICC flag that tells the compiler to treat all the warnings
 dnl as fatal. We usually need this option to make sure that some
index b1bc49766b95c8f541d4961dae78183ebe5bcdd7..6cddb83a69b5e23963cf40825b2f654e3736ad96 100644 (file)
@@ -99,7 +99,7 @@ WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet
 endif
 
 FOREIGN_CFLAGS = -w
-MODULE_LDFLAGS = -module -disable-static -avoid-version
+MODULE_LDFLAGS = -module -disable-static -avoid-version $(LDFLAGS_NOUNDEFINED)
 
 ###################################
 #          Extra files            #
@@ -569,7 +569,6 @@ libpulsecommon_@PA_MAJORMINORMICRO@_la_SOURCES = \
                pulsecore/core-error.c pulsecore/core-error.h \
                pulsecore/core-rtclock.c pulsecore/core-rtclock.h \
                pulsecore/core-util.c pulsecore/core-util.h \
-               pulsecore/rtkit.c pulsecore/rtkit.h \
                pulsecore/creds.h \
                pulsecore/dynarray.c pulsecore/dynarray.h \
                pulsecore/endianmacros.h \
@@ -660,7 +659,9 @@ libpulsecommon_@PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/dllmain.c
 endif
 
 if HAVE_DBUS
-libpulsecommon_@PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/dbus-util.c pulsecore/dbus-util.h
+libpulsecommon_@PA_MAJORMINORMICRO@_la_SOURCES += \
+               pulsecore/dbus-util.c pulsecore/dbus-util.h \
+               pulsecore/rtkit.c pulsecore/rtkit.h
 libpulsecommon_@PA_MAJORMINORMICRO@_la_CFLAGS += $(DBUS_CFLAGS)
 libpulsecommon_@PA_MAJORMINORMICRO@_la_LIBADD += $(DBUS_LIBS)
 endif
@@ -1457,7 +1458,7 @@ module_solaris_la_LIBADD = $(AM_LIBADD) libpulsecore-@PA_MAJORMINORMICRO@.la lib
 
 module_zeroconf_publish_la_SOURCES = modules/module-zeroconf-publish.c
 module_zeroconf_publish_la_LDFLAGS = $(MODULE_LDFLAGS)
-module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la
+module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libprotocol-native.la libpulsecore-@PA_MAJORMINORMICRO@.la libpulsecommon-@PA_MAJORMINORMICRO@.la libpulse.la
 module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 module_zeroconf_discover_la_SOURCES = modules/module-zeroconf-discover.c
index c1730b7064b0f1014828b79112a4fdf0a25cf4bc..61b0c8404ec6fd08bf44716d87c48e349e1800a6 100644 (file)
@@ -37,6 +37,7 @@
 #include <unistd.h>
 #include <locale.h>
 #include <sys/types.h>
+#include <sys/stat.h>
 
 #include <liboil/liboil.h>
 
index 08fe6f5832e67c7aecfa560ef1bcc94bf95277db..0920d25e9759c79c947bf69c9b1b5213e15bac7f 100644 (file)
@@ -46,6 +46,7 @@
 #include <pulse/xmalloc.h>
 #include <pulse/timeval.h>
 #include <pulse/util.h>
+#include <pulse/rtclock.h>
 
 #include <pulsecore/iochannel.h>
 #include <pulsecore/sink.h>
@@ -59,7 +60,6 @@
 #include <pulsecore/thread-mq.h>
 #include <pulsecore/rtpoll.h>
 #include <pulsecore/thread.h>
-#include <pulsecore/rtclock.h>
 
 #include "module-solaris-symdef.h"
 
@@ -605,7 +605,6 @@ static void thread_func(void *userdata) {
         pa_make_realtime(u->core->realtime_priority);
 
     pa_thread_mq_install(&u->thread_mq);
-    pa_rtpoll_install(u->rtpoll);
 
     for (;;) {
         /* Render some data and write it to the dsp */
index c77cc64e307ebb218ca6d07238aa7fb77712899f..6916d8671164165e569bff22f34ca1f3696bdcc9 100644 (file)
 #include <config.h>
 #endif
 
+#ifndef OS_IS_WIN32
+#include <pthread.h>
+#endif
+
 #include <signal.h>
 #include <stdio.h>
 
index 67f661fe8eb0557dab3f1e4bfe70ad9085879327..072ef02cc3a135e405200cc0c54d8bfa8b8f5a4a 100644 (file)
@@ -131,7 +131,7 @@ void pa_asyncq_free(pa_asyncq *l, pa_free_cb_t free_cb) {
     pa_xfree(l);
 }
 
-static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
+static int push(pa_asyncq*l, void *p, pa_bool_t wait_op) {
     unsigned idx;
     pa_atomic_ptr_t *cells;
 
@@ -145,7 +145,7 @@ static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
 
     if (!pa_atomic_ptr_cmpxchg(&cells[idx], NULL, p)) {
 
-        if (!wait)
+        if (!wait_op)
             return -1;
 
 /*         pa_log("sleeping on push"); */
@@ -163,14 +163,14 @@ static int push(pa_asyncq*l, void *p, pa_bool_t wait) {
     return 0;
 }
 
-static pa_bool_t flush_postq(pa_asyncq *l, pa_bool_t wait) {
+static pa_bool_t flush_postq(pa_asyncq *l, pa_bool_t wait_op) {
     struct localq *q;
 
     pa_assert(l);
 
     while ((q = l->last_localq)) {
 
-        if (push(l, q->data, wait) < 0)
+        if (push(l, q->data, wait_op) < 0)
             return FALSE;
 
         l->last_localq = q->prev;
@@ -184,13 +184,13 @@ static pa_bool_t flush_postq(pa_asyncq *l, pa_bool_t wait) {
     return TRUE;
 }
 
-int pa_asyncq_push(pa_asyncq*l, void *p, pa_bool_t wait) {
+int pa_asyncq_push(pa_asyncq*l, void *p, pa_bool_t wait_op) {
     pa_assert(l);
 
-    if (!flush_postq(l, wait))
+    if (!flush_postq(l, wait_op))
         return -1;
 
-    return push(l, p, wait);
+    return push(l, p, wait_op);
 }
 
 void pa_asyncq_post(pa_asyncq*l, void *p) {
@@ -221,7 +221,7 @@ void pa_asyncq_post(pa_asyncq*l, void *p) {
     return;
 }
 
-void* pa_asyncq_pop(pa_asyncq*l, pa_bool_t wait) {
+void* pa_asyncq_pop(pa_asyncq*l, pa_bool_t wait_op) {
     unsigned idx;
     void *ret;
     pa_atomic_ptr_t *cells;
@@ -235,7 +235,7 @@ void* pa_asyncq_pop(pa_asyncq*l, pa_bool_t wait) {
 
     if (!(ret = pa_atomic_ptr_load(&cells[idx]))) {
 
-        if (!wait)
+        if (!wait_op)
             return NULL;
 
 /*         pa_log("sleeping on pop"); */
index 4550344f713eb65e75d11128c2ed2b347da60c51..04e7eb24cafd6a5ca3bc8c6528a5a9d33008f74c 100644 (file)
@@ -43,6 +43,7 @@
 #include <regex.h>
 #include <langinfo.h>
 #include <sys/utsname.h>
+#include <sys/socket.h>
 
 #ifdef HAVE_STRTOF_L
 #include <locale.h>
@@ -1193,22 +1194,22 @@ int pa_check_in_group(gid_t g) {
   (advisory on UNIX, mandatory on Windows) */
 int pa_lock_fd(int fd, int b) {
 #ifdef F_SETLKW
-    struct flock flock;
+    struct flock f_lock;
 
     /* Try a R/W lock first */
 
-    flock.l_type = (short) (b ? F_WRLCK : F_UNLCK);
-    flock.l_whence = SEEK_SET;
-    flock.l_start = 0;
-    flock.l_len = 0;
+    f_lock.l_type = (short) (b ? F_WRLCK : F_UNLCK);
+    f_lock.l_whence = SEEK_SET;
+    f_lock.l_start = 0;
+    f_lock.l_len = 0;
 
-    if (fcntl(fd, F_SETLKW, &flock) >= 0)
+    if (fcntl(fd, F_SETLKW, &f_lock) >= 0)
         return 0;
 
     /* Perhaps the file descriptor qas opened for read only, than try again with a read lock. */
     if (b && errno == EBADF) {
-        flock.l_type = F_RDLCK;
-        if (fcntl(fd, F_SETLKW, &flock) >= 0)
+        f_lock.l_type = F_RDLCK;
+        if (fcntl(fd, F_SETLKW, &f_lock) >= 0)
             return 0;
     }
 
@@ -2238,10 +2239,9 @@ int pa_close_all(int except_fd, ...) {
 int pa_close_allv(const int except_fds[]) {
     struct rlimit rl;
     int maxfd, fd;
-    int saved_errno;
 
 #ifdef __linux__
-
+    int saved_errno;
     DIR *d;
 
     if ((d = opendir("/proc/self/fd"))) {
index 5cbec3211afb10e45071ea210f81fe41f5e7183c..42708a8a22c7bcf3df98229603c8daa9ab355c07 100644 (file)
@@ -220,7 +220,7 @@ static void reset_all_revents(pa_rtpoll *p) {
     }
 }
 
-int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) {
+int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait_op) {
     pa_rtpoll_item *i;
     int r = 0;
     struct timeval timeout;
@@ -289,7 +289,7 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) {
     memset(&timeout, 0, sizeof(timeout));
 
     /* Calculate timeout */
-    if (wait && !p->quit && p->timer_enabled) {
+    if (wait_op && !p->quit && p->timer_enabled) {
         struct timeval now;
         pa_rtclock_get(&now);
 
@@ -311,10 +311,10 @@ int pa_rtpoll_run(pa_rtpoll *p, pa_bool_t wait) {
         struct timespec ts;
         ts.tv_sec = timeout.tv_sec;
         ts.tv_nsec = timeout.tv_usec * 1000;
-        r = ppoll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? &ts : NULL, NULL);
+        r = ppoll(p->pollfd, p->n_pollfd_used, (!wait_op || p->quit || p->timer_enabled) ? &ts : NULL, NULL);
     }
 #else
-        r = poll(p->pollfd, p->n_pollfd_used, (!wait || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1);
+        r = poll(p->pollfd, p->n_pollfd_used, (!wait_op || p->quit || p->timer_enabled) ? (int) ((timeout.tv_sec*1000) + (timeout.tv_usec / 1000)) : -1);
 #endif
 
 #ifdef DEBUG_TIMING
index fab2b3b62f349f19f2c0e5b62db81406fd2c2d5e..6e4284269aa1ee5d253e105ef7716ed54d09710f 100644 (file)
 #include <sys/mman.h>
 #endif
 
+/* This is deprecated on glibc but is still used by FreeBSD */
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+# define MAP_ANONYMOUS MAP_ANON
+#endif
+
 #include <pulse/xmalloc.h>
 #include <pulse/gccmacro.h>
 
index f89665cd2bf02046b1ea9c3046f9ce89cf9e4685..57b7068560febbffa0965ad51650494da0d3f9d5 100644 (file)
@@ -91,8 +91,10 @@ int main(int argc, char *argv[]) {
     close(fd);
 
 #ifdef HAVE_IPV6
-    fd = socket(PF_INET6, SOCK_STREAM, 0);
-    assert(fd >= 0);
+    if ( (fd = socket(PF_INET6, SOCK_STREAM, 0)) < 0 ) {
+      printf("Unable to open IPv6 socket, IPv6 tests ignored");
+      return 0;
+    }
 
     memset(&sa6, 0, sizeof(sa6));
     sa6.sin6_family = AF_INET6;
index ac4b57b5b0c43fd2e91583db274c17b2bfe9780e..c7a30d67336164ea35288eaf389c3f0c6d19399a 100644 (file)
@@ -79,6 +79,16 @@ static void dump_block(const pa_sample_spec *ss, const pa_memchunk *chunk) {
             break;
         }
 
+        case PA_SAMPLE_S24NE:
+        case PA_SAMPLE_S24RE: {
+            uint8_t *u = d;
+
+            for (i = 0; i < chunk->length / pa_frame_size(ss); i++)
+               printf("0x%02x%02x%02xx ", *(u++), *(u++), *(u++));
+
+            break;
+        }
+
         case PA_SAMPLE_FLOAT32NE:
         case PA_SAMPLE_FLOAT32RE: {
             float *u = d;
@@ -113,73 +123,66 @@ static pa_memblock* generate_block(pa_mempool *pool, const pa_sample_spec *ss) {
         case PA_SAMPLE_U8:
         case PA_SAMPLE_ULAW:
         case PA_SAMPLE_ALAW: {
-            uint8_t *u = d;
+           static const uint8_t u8_samples[] =
+             { 0x00, 0xFF, 0x7F, 0x80, 0x9f,
+               0x3f, 0x01, 0xF0, 0x20, 0x21 };
 
-            u[0] = 0x00;
-            u[1] = 0xFF;
-            u[2] = 0x7F;
-            u[3] = 0x80;
-            u[4] = 0x9f;
-            u[5] = 0x3f;
-            u[6] = 0x1;
-            u[7] = 0xF0;
-            u[8] = 0x20;
-            u[9] = 0x21;
+           memcpy(d, &u8_samples[0], sizeof(u8_samples));
             break;
         }
 
         case PA_SAMPLE_S16NE:
         case PA_SAMPLE_S16RE: {
-            uint16_t *u = d;
+           static const uint16_t u16_samples[] =
+             { 0x0000, 0xFFFF, 0x7FFF, 0x8000, 0x9fff,
+               0x3fff, 0x0001, 0xF000, 0x0020, 0x0021 };
 
-            u[0] = 0x0000;
-            u[1] = 0xFFFF;
-            u[2] = 0x7FFF;
-            u[3] = 0x8000;
-            u[4] = 0x9fff;
-            u[5] = 0x3fff;
-            u[6] = 0x1;
-            u[7] = 0xF000;
-            u[8] = 0x20;
-            u[9] = 0x21;
+           memcpy(d, &u16_samples[0], sizeof(u16_samples));
             break;
         }
 
         case PA_SAMPLE_S32NE:
         case PA_SAMPLE_S32RE: {
-            uint32_t *u = d;
+           static const uint32_t u32_samples[] =
+             { 0x00000001, 0xFFFF0002, 0x7FFF0003, 0x80000004, 0x9fff0005,
+               0x3fff0006, 0x00010007, 0xF0000008, 0x00200009, 0x0021000A };
+
+           memcpy(d, &u32_samples[0], sizeof(u32_samples));
+            break;
+        }
 
-            u[0] = 0x00000001;
-            u[1] = 0xFFFF0002;
-            u[2] = 0x7FFF0003;
-            u[3] = 0x80000004;
-            u[4] = 0x9fff0005;
-            u[5] = 0x3fff0006;
-            u[6] =    0x10007;
-            u[7] = 0xF0000008;
-            u[8] =   0x200009;
-            u[9] =   0x21000A;
+        case PA_SAMPLE_S24NE:
+        case PA_SAMPLE_S24RE: {
+           /* Need to be on a byte array because they are not aligned */
+           static const uint8_t u24_samples[] =
+             { 0x00, 0x00, 0x01,
+               0xFF, 0xFF, 0x02,
+               0x7F, 0xFF, 0x03,
+               0x80, 0x00, 0x04,
+               0x9f, 0xff, 0x05,
+               0x3f, 0xff, 0x06,
+               0x01, 0x00, 0x07,
+               0xF0, 0x00, 0x08,
+               0x20, 0x00, 0x09,
+               0x21, 0x00, 0x0A };
+
+           memcpy(d, &u24_samples[0], sizeof(u24_samples));
             break;
         }
 
         case PA_SAMPLE_FLOAT32NE:
         case PA_SAMPLE_FLOAT32RE: {
             float *u = d;
+           static const float float_samples[] =
+             { 0.0f, -1.0f, 1.0f, 4711.0f, 0.222f,
+               0.33f, -.3f, 99.0f, -0.555f, -.123f };
 
-            u[0] = 0.0f;
-            u[1] = -1.0f;
-            u[2] = 1.0f;
-            u[3] = 4711.0f;
-            u[4] = 0.222f;
-            u[5] = 0.33f;
-            u[6] = -.3f;
-            u[7] = 99.0f;
-            u[8] = -0.555f;
-            u[9] = -.123f;
-
-            if (ss->format == PA_SAMPLE_FLOAT32RE)
+            if (ss->format == PA_SAMPLE_FLOAT32RE) {
                 for (i = 0; i < 10; i++)
-                    u[i] = swap_float(u[i]);
+                    u[i] = swap_float(float_samples[i]);
+           } else {
+             memcpy(d, &float_samples[0], sizeof(float_samples));
+           }
 
             break;
         }