summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTanu Kaskinen <tanuk@iki.fi>2009-06-29 18:55:12 +0300
committerTanu Kaskinen <tanuk@iki.fi>2009-06-29 18:55:12 +0300
commitc266595058416b4b776890dadf3ad827787f4e7e (patch)
treebfedd08b4579c33b62d42da88498b6c26088b88e
parent0bc538b08ca5c4efea86700cb6c4685da3f34345 (diff)
parent1ca76031092ab07682843fd70607696f6af7216f (diff)
Merge branch 'master' into dbus-work
-rw-r--r--configure.ac13
-rw-r--r--m4/attributes.m459
-rw-r--r--src/Makefile.am9
-rw-r--r--src/daemon/main.c1
-rw-r--r--src/modules/module-solaris.c3
-rw-r--r--src/pulse/thread-mainloop.c4
-rw-r--r--src/pulsecore/asyncq.c18
-rw-r--r--src/pulsecore/core-util.c20
-rw-r--r--src/pulsecore/rtpoll.c8
-rw-r--r--src/pulsecore/shm.c5
-rw-r--r--src/tests/ipacl-test.c6
-rw-r--r--src/tests/mix-test.c95
12 files changed, 155 insertions, 86 deletions
diff --git a/configure.ac b/configure.ac
index 185f13bb..7e83a9c9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 ####
diff --git a/m4/attributes.m4 b/m4/attributes.m4
index 65f83788..28fac277 100644
--- a/m4/attributes.m4
+++ b/m4/attributes.m4
@@ -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
diff --git a/src/Makefile.am b/src/Makefile.am
index b1bc4976..6cddb83a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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
diff --git a/src/daemon/main.c b/src/daemon/main.c
index c1730b70..61b0c840 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -37,6 +37,7 @@
#include <unistd.h>
#include <locale.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <liboil/liboil.h>
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 08fe6f58..0920d25e 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -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 */
diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c
index c77cc64e..6916d867 100644
--- a/src/pulse/thread-mainloop.c
+++ b/src/pulse/thread-mainloop.c
@@ -24,6 +24,10 @@
#include <config.h>
#endif
+#ifndef OS_IS_WIN32
+#include <pthread.h>
+#endif
+
#include <signal.h>
#include <stdio.h>
diff --git a/src/pulsecore/asyncq.c b/src/pulsecore/asyncq.c
index 67f661fe..072ef02c 100644
--- a/src/pulsecore/asyncq.c
+++ b/src/pulsecore/asyncq.c
@@ -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"); */
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 4550344f..04e7eb24 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -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"))) {
diff --git a/src/pulsecore/rtpoll.c b/src/pulsecore/rtpoll.c
index 5cbec321..42708a8a 100644
--- a/src/pulsecore/rtpoll.c
+++ b/src/pulsecore/rtpoll.c
@@ -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
diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c
index fab2b3b6..6e428426 100644
--- a/src/pulsecore/shm.c
+++ b/src/pulsecore/shm.c
@@ -39,6 +39,11 @@
#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>
diff --git a/src/tests/ipacl-test.c b/src/tests/ipacl-test.c
index f89665cd..57b70685 100644
--- a/src/tests/ipacl-test.c
+++ b/src/tests/ipacl-test.c
@@ -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;
diff --git a/src/tests/mix-test.c b/src/tests/mix-test.c
index ac4b57b5..c7a30d67 100644
--- a/src/tests/mix-test.c
+++ b/src/tests/mix-test.c
@@ -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;
}