[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master-tx, updated. v0.9.13-198-g7ca0f38

Lennart Poettering gitmailer-noreply at 0pointer.de
Thu Jan 8 10:39:46 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-tx branch has been updated
      from  17ae579cc77c88dfc7bcf2b2c72e6678e91f28a5 (commit)

- Log -----------------------------------------------------------------
7ca0f38... run "make update-po"
6b9056c... Merge commit 'origin/master-tx'
a1a1119... build: fix missing x11 modules dependencies
7e6309c... bluetooth: Update sbc from git upstream.
d096ad7... bluetooth: add update-sbc and friends
8e200ed... build: run some tests during make check (and distcheck)
de57edd... build: Use proper -disable-static instead of removing .a
c8b3d8b... build: add atomic.h and refcnt.h to libpulsecommon
db193f1... build: introduce $SKIP_GIT for make dist (off-line or behind a proxy).
a206ac0... build: Don't include builddir, but only srcdir.
e92b0ae... build: compile libltdl directory first
dd9ca70... build: use pkg-config for X11
c245050... Prefer mixer controls with volumes over switches
e67bc1d... -Wconvert is pain, let's drop it again
81cd219... --check: Updated manpage slightly and pulseaudio --help slightly.
2f681a3... Merge commit 'vudentz/master'
78e636e... Fix typo in log message: s/Recevied/Received/
e7e6f86... Fix sending wrong codec capability length.
1a96c9b... Fix send and recv message sizes.
be49c92... Send packets with proper size.
fe2b8c3... Multicast SDP packets sent with same IP TTL as RTP packets
f24e4c1... Merge commit 'vudentz/master'
c2bd8dc... fix a gcc warning
22c3373... If we cannot open an ALSA device with SND_PCM_NO_AUTO_FORMAT retry without
7323e1a... Update module-bluetooth-device to the new ipc.
5db081a... Disable warnings for bluetooth-device-module.
03aa91d... make sure we don't hit an assert when we issue two rewind requests in a single iteration
606c9ca... Implement PA_SOURCE_MESSAGE_GET_LATENCY
10cc4ba... Use FIONREAD instead of TIOCINQ
63fc26e... Allow access("/dev/dsp", W_OK) succeed
1d2e5cb... Make sure we drop CAP_NICE if RT is not allowed
d71d79c... downgrade a few warnings
906d06b... it's better to always use the index of a module instead of the pa_module*
f5d40fa... unload tunnel modules from a new stack frame
b95539b... actually unload the modules from a new stack frame
86c6fd8... Don't store pointer to pa_module
c5b8eb7... introduce new function pa_module_unload_request_by_index
dcd498c... Fix bug walking on module list.
82f09b6... Don't hit an assert when checking for idleness
cb6a919... Load module-volume-restore and module-device-restore before all other modules
3f20a15... Pass GDBM_NOLOCK to gdbm
209a8d7... Don't mix front-center into rear channels
b8fe1b6... fix implementation of bind now ltdl loader for libtool 2.2
e4aa5f2... Fix return value of --dump-resample-methods
8977b2e... libtool 2.2 updates
7013849... Check if environ is actually set before we use it
2ee9276... Merge commit 'flameeyes/libtool-2.2'
f826ded... make shm marker architecture independant, patch from michich, closes #401
84cd233... Make sure libpulse never gets unloaded
58b53bb... a bit of pa_bool_t'ization
adc2973... Implement new flags DONT_INHIBIT_AUTO_SUSPEND and START_UNMUTED
c180cb5... bump micro version
1d978ce... Merge branch 'new-world-order'
b712e7b... make sure to use 64bit rounding even on 32bit machines when converting to pa_usec_t
3294c89... warn if ALSA wakes us up and there is actually nothing to do
6ff9c1f... don't set the volume of pacat unless it is explicitly set
a2b3d25... update map file
1cd25f1... reorder setting of AM_CFLAGS a bit
ef0cc74... a lot more build system updates
695d300... make new build logic actually work
b978d84... update map file
df6e38b... temporary commit to allow flameeyes a look
260fc50... reorder setting of AM_CFLAGS a bit
c4b3462... make the debug trap macro a proper macro in macro.h
ef9f3f6... Try to catch certain driver errors
1647191... make log meta, time, backtrace configurable using command line
496499c... Make log meta, time, backtrace configurable using config file
651a451... support changing logging parameters during runtime using the CLI
f4320d8... Support showing a backtrace on log messages
f92a814... include log.h near the end so that macro.h can be included in log.h and defines pa_bool_t properly
d4c6342... add pa_config_parse_unsigned()
c7ed771... fix arguments to format string
7fecb23... convert argument to boolean int in PA_UNLIKELY, too
519bb55... fix return value of pa_frame_aligned()
4ee5e06... implement may_move_to for ladspa/remap sinks
358824b... add new virtual function may_move_to to sink inputs/source outputs to allow modules to forbid certain connections
309bc71... fix invalid validity check
b709e1d... Make missing git-changelog.perl non-fatal
d675058... Fix spelling of privilige
d395792... always check for libtool prefix binary name to avoid confusion when using both installed and run-from-build-tree versions of PA in parallel
60c2a82... Merge commit 'vudentz/master'
d8465f2... Fix two typos that broke tunnels
5a5d288... properly remove dbus matches an filters when unloading m-b-d
65ea1a2... correctly load module-flat-volume instead of module-flat-volumes
931cbd1... Fix possible invalid read while attempting to load module-bluetooth-device.
8e3e88d... Merge commit 'coling/airtunes-0.9.13'
91b64bc... Fix a potential C++/C99 ism, add a log message on error condition
59eb649... Follow master change r34dd4a and fix shutdown when --disallow-module-loading=1 is passed
8715121... Modularise the RAOP stuff that requires OpenSSL and make it optional at compile time
c3d8bb5... Remove $Id$ lines left over from SVN
19d2831... Make module-raop-sink/discover work with 0.9.11 API
ded09d1... Implement hardware volume control. This allows near instant change of volume when controlling the hardware but the stream volume still suffers from a sizable delay.
e543e04... Implement a set volume function to expose this capability to higher layers
36f2aad... Use the new pa_namereg_make_valid_name() function.
0ff75ae... Add Lennart back in to Copyright as I copied these files from his originals and was a bit overzealous in changing things ;)
729bbaf... Automatic discovery of airtunes devices via Bonjour/Avahi.
d997420... Minor correction of help text
15e8420... Still send silence when we are not doing anything else, but also flush the buffers correctly upon recovery from suspension.
c49be78... Add some new public API functions to connect and flush.
d86fc75... Change the API of the RTSP client a bit.
19dcb52... Remove unneeded headers accidentially added in r2500.
5f527dc... Add seq and rtptime params to record/flush with a view to using these for timing and device suspension
651da7d... Minor update to copywrite (I still plan to replace this completely but in the mean time....)
7f0cf0c... Fix up a couple of values related to encoding overhead.
13bc075... A few related changes:
b93e9e8... Keep track of the memblock pointer internally and do not rely on subsequent calls to pass it back in for unref'ing
8108121... Set forgotten keyword property
6dc5e07... Set the send buffer size to prevent rendering silence in amongst our good data (this should be more sophisticated but that can wait for a glitch-free port)
6c1dd6e... Move the encoding loop around a bit such that it does not grab the data and keep it for the next loop iteration.
3767cdb... Do tidy up on disconnection.
9216684... Do not prefix internal function rtsp_exec.
eca94fe... Don't try to free stack variables.
be73d37... unref the raw data memblock before requesting more data.
cb8c5a9... Some misc fixes. consts, base64 optimisation (not that it will be with us long anyway), and c comments
4b7b7b1... Fix up IPv6 address format to enclose it in []
d195d06... Change suggested by Lennart. Do not return a memchunk, instead pass in the pointer.
e00127f... Various changes suggested by Lennart.
ec9a618... Listen to the on_close callback. This still causes asserts in the mainloop, so this is not a complete solution
899492c... Add a new callback structure to propigate when the RTSP connection dies
5eecfa2... Move the ownership of the encoded data memchunk into the raop_client.
4dd3185... Do not assert on NULL values of s. This means the connection was closed. This change somehow kills the mainloop with an assert, so I need to sort that out.
d51f594... A very rough first version of the sink.
264a1c2... Add more libraries to librtp now that it's doing a lot more.
f97c5de... Properly duplicate the hostname passed in on connect.
1fb0465... Combine pa_raop_client_new and pa_raop_client_connect (no point in having them separate)
41e31ab... Rename rtsp.{c,h} to rtsp_client.{c,h}.
e596f42... Wrap the io_callback to ensure that all data is written before asking for more.
6510d97... Use a more stateful response parser.
22e299a... Add a pa_iochannel callback for when the RAOP connection connects.
8fb58e3... Add a function for packing bits into a byte buffer. This will be needed when encoding the audio data in ALAC format.
66cf1d1... Some minor tidyup to remove code now in raop client. Still nowhere near functional.
20478a4... Add a skeleton raop client which builds on the rtsp client.
d423605... Move closer to an asynchronous structure (still some parsing code to be converted).
a0d3582... Trivial change to allocate memory using pulse methods.
a08d733... Fix svn properties and some minor indentation
27ed970... Convert the return values to fit with the rest of pulse 0 == success, < 0 == failure
405cf72... Convert to using pa_socket_client rather than using blocking IO.
ce9a41e... Use _free rather than _destroy so as not to mix naming conventions.
91edf9e... Use pa_sprintf_malloc to do simple concatenation rather than using the higher overhead of pa_strbuf
6570620... Start the raop sink. It's based on pipe sink and isn't anywhere near finished. It does however compile.
fef102e... Add a simple base64 library that will be used by the sink
4847706... Add a RTSP client impelmentation.
8c1c565... Add a small lib to interpret and produce headers as used in http style requests.
068afb3... define 0dB in PA as maximum amplification
a8dc2aa... enable flat volumes by default
2dfc265... Merge branch 'flatvol'
37b8c45... query the sink volume outside of the loop because it might be quite expensive
34f6a51... use pa_sink_set_volume() for changing the volume
b048ae9... check the maximum volume of all sink inputs instead of the average volume to avoid digital amplification in favour of attenuation
404cf74... some minor reformatting
8bc58cc... ignore sinks that do not carry decibel information
776c8de... remove $Id$
b6ccea3... add a comment that pa_sink_input_set_volume and module-flat-volume.c are related
9f4033d... if a stream comes with now sensible properties attached, use common fallback db entry.
68cc299... after calling PA_CORE_HOOK_SINK_SET_VOLUME hook, check again whether the volume changed
46f73fb... additional validity checks
e053fa0... if the channel map was modified due to PA_SINK_INPUT_FIX_CHANNELS, remap the specified volume properly
e1dbc75... use pa_channel_map_init_extend() instead of pa_channel_map_init_auto() as channel map for sink inputs/source outputs in case no map is specified
ae83483... modernize a few checks
72024cd... when the volume is changed make sure we send out a subscription event
624f220... instead of resetting virtual_volume unconditionally on initialization, do so only when no volume was set before
1e513c3... Initialize exit_idle_time to -1 instead of 0  when in system mode.
80a79b1... flat-volume thingy
4541274... volume hooks
f8197cf... Update code to use libtool 2.2. Use convenience recursive libltdl.
2da79d5... Create an m4 directory for common macros and use it.
f4e9b7d... Remove gettext macros from configure.ac, intltool is used.
4a51e1c... Bump autoconf requirement to 2.62 (latest released version).
-----------------------------------------------------------------------

Summary of changes:
 Makefile.am                                        |    6 +-
 PROTOCOL                                           |   11 +
 bootstrap.sh                                       |    2 +-
 configure.ac                                       |  153 ++--
 libpulse-browse.pc.in                              |    9 +-
 libpulse-mainloop-glib.pc.in                       |    9 +-
 libpulse-simple.pc.in                              |    9 +-
 libpulse.pc.in                                     |    9 +-
 man/pulseaudio.1.xml.in                            |    6 +-
 po/ca.po                                           |  319 +++---
 po/cs.po                                           |  455 +++++----
 po/de.po                                           |  635 +++++++-----
 po/el.po                                           |  303 +++---
 po/es.po                                           |  533 ++++++-----
 po/fi.po                                           |  128 ++--
 po/fr.po                                           |  367 ++++----
 po/pl.po                                           |    7 +-
 po/pt_BR.po                                        |  705 ++++++++------
 po/sv.po                                           |  308 +++---
 src/Makefile.am                                    | 1053 +++++++++-----------
 src/daemon/caps.c                                  |    2 +-
 src/daemon/cmdline.c                               |   29 +-
 src/daemon/cpulimit.c                              |    2 +-
 src/daemon/daemon-conf.c                           |  133 ++--
 src/daemon/daemon-conf.h                           |    5 +-
 src/daemon/daemon.conf.in                          |    3 +
 src/daemon/default.pa.in                           |    9 +-
 src/daemon/ltdl-bind-now.c                         |  110 +--
 src/daemon/main.c                                  |   58 +-
 src/map-file                                       |    4 +-
 src/modules/alsa-util.c                            |  178 +++-
 src/modules/alsa-util.h                            |    5 +-
 src/modules/bluetooth/ipc.c                        |   52 +-
 src/modules/bluetooth/ipc.h                        |  190 ++--
 src/modules/bluetooth/module-bluetooth-device.c    |  157 ++--
 src/modules/bluetooth/module-bluetooth-discover.c  |   27 +-
 src/modules/bluetooth/sbc.c                        |  537 +++++------
 src/modules/bluetooth/sbc.h                        |    4 +-
 src/modules/bluetooth/sbc_math.h                   |   16 +-
 src/modules/bluetooth/sbc_tables.h                 |  250 ++++-
 src/modules/module-alsa-sink.c                     |   59 +-
 src/modules/module-alsa-source.c                   |   59 +-
 src/modules/module-always-sink.c                   |   28 +-
 src/modules/module-device-restore.c                |    2 +-
 src/modules/module-flat-volume.c                   |  224 +++++
 src/modules/module-hal-detect.c                    |    2 +-
 src/modules/module-ladspa-sink.c                   |   11 +
 src/modules/module-pipe-sink.c                     |    4 +-
 src/modules/module-pipe-source.c                   |   30 +
 ...-zeroconf-discover.c => module-raop-discover.c} |  110 +--
 .../{module-esound-sink.c => module-raop-sink.c}   |  520 +++++-----
 src/modules/module-remap-sink.c                    |   11 +
 src/modules/module-stream-restore.c                |    4 +-
 src/modules/module-suspend-on-idle.c               |   20 +-
 src/modules/module-tunnel.c                        |    4 +-
 src/modules/module-zeroconf-discover.c             |    4 +-
 src/modules/raop/base64.c                          |  126 +++
 src/{daemon/caps.h => modules/raop/base64.h}       |   18 +-
 src/modules/raop/raop_client.c                     |  561 +++++++++++
 src/modules/raop/raop_client.h                     |   46 +
 src/modules/rtp/headerlist.c                       |  186 ++++
 .../rtclock.h => modules/rtp/headerlist.h}         |   28 +-
 src/modules/rtp/module-rtp-send.c                  |    7 +-
 src/modules/rtp/rtsp_client.c                      |  542 ++++++++++
 src/modules/rtp/rtsp_client.h                      |   73 ++
 src/pulse/def.h                                    |   20 +-
 src/pulse/stream.c                                 |   12 +-
 src/pulsecore/cli-command.c                        |  104 ++
 src/pulsecore/conf-parser.c                        |   18 +
 src/pulsecore/conf-parser.h                        |    1 +
 src/pulsecore/core.h                               |    2 +
 src/pulsecore/log.c                                |  133 +++-
 src/pulsecore/log.h                                |    7 +-
 src/pulsecore/macro.h                              |   12 +-
 src/pulsecore/module.c                             |   10 +
 src/pulsecore/module.h                             |    6 +-
 src/pulsecore/once.c                               |   11 +-
 src/pulsecore/once.h                               |    2 +-
 src/pulsecore/pid.c                                |   11 +-
 src/pulsecore/proplist-util.c                      |   35 +-
 src/pulsecore/protocol-native.c                    |   44 +-
 src/pulsecore/resampler.c                          |   96 ++-
 src/pulsecore/sample-util.c                        |    2 +-
 src/pulsecore/sample-util.h                        |    2 +-
 src/pulsecore/shm.c                                |    8 +-
 src/pulsecore/sink-input.c                         |  144 ++-
 src/pulsecore/sink-input.h                         |   22 +-
 src/pulsecore/sink.c                               |   54 +-
 src/pulsecore/sink.h                               |    6 +
 src/pulsecore/source-output.c                      |   50 +-
 src/pulsecore/source-output.h                      |   11 +-
 src/pulsecore/source.c                             |   31 +
 src/pulsecore/source.h                             |    1 +
 src/pulsecore/time-smoother.c                      |    6 +-
 src/utils/pacat.c                                  |    4 +-
 src/utils/padsp.c                                  |   10 +-
 96 files changed, 6667 insertions(+), 3685 deletions(-)
 create mode 100644 src/modules/module-flat-volume.c
 copy src/modules/{module-zeroconf-discover.c => module-raop-discover.c} (71%)
 copy src/modules/{module-esound-sink.c => module-raop-sink.c} (51%)
 create mode 100644 src/modules/raop/base64.c
 copy src/{daemon/caps.h => modules/raop/base64.h} (70%)
 create mode 100644 src/modules/raop/raop_client.c
 create mode 100644 src/modules/raop/raop_client.h
 create mode 100644 src/modules/rtp/headerlist.c
 copy src/{pulsecore/rtclock.h => modules/rtp/headerlist.h} (52%)
 create mode 100644 src/modules/rtp/rtsp_client.c
 create mode 100644 src/modules/rtp/rtsp_client.h

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

commit 4a51e1cb9f59fd2313d9bd1c93e6be40348a4fc0
Author: Diego 'Flameeyes' Pettenò <flameeyes at gmail.com>
Date:   Thu Aug 7 19:09:23 2008 +0200

    Bump autoconf requirement to 2.62 (latest released version).

diff --git a/configure.ac b/configure.ac
index 25a86a8..f149864 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
 # along with PulseAudio; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
-AC_PREREQ(2.60)
+AC_PREREQ(2.62)
 
 m4_define(PA_MAJOR, [0])
 m4_define(PA_MINOR, [9])

commit f4e9b7d778c252f514b4b457305ba310394b4060
Author: Diego 'Flameeyes' Pettenò <flameeyes at gmail.com>
Date:   Fri Aug 8 12:15:26 2008 +0200

    Remove gettext macros from configure.ac, intltool is used.
    
    When using intltool there is no need to _also_ use gettext, so remove
    gettext macros so that autoreconf does not copy them over.

diff --git a/configure.ac b/configure.ac
index f149864..6618907 100644
--- a/configure.ac
+++ b/configure.ac
@@ -440,8 +440,6 @@ AC_CHECK_FUNCS([open64])
 
 AM_ICONV
 
-AM_GNU_GETTEXT([external])
-
 IT_PROG_INTLTOOL([0.35.0])
 GETTEXT_PACKAGE=pulseaudio
 AC_SUBST([GETTEXT_PACKAGE])

commit 2da79d5ade92c476326e3167d0a56986a9d96200
Author: Diego 'Flameeyes' Pettenò <flameeyes at gmail.com>
Date:   Fri Aug 8 12:18:53 2008 +0200

    Create an m4 directory for common macros and use it.
    
    Split acinclude.m4 in multiple macro files.
    
    Let it be known to autoconf and aclocal to use the m4 directory.
    Ignore macro files copied or linked by libtool and intltool.

diff --git a/Makefile.am b/Makefile.am
index 63c04ee..facce0d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,7 @@
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 # USA.
 
-ACLOCAL_AMFLAGS = -I common
+ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST = bootstrap.sh LICENSE GPL LGPL doxygen/Makefile.am doxygen/Makefile.in doxygen/doxygen.conf.in README todo
 SUBDIRS=src doxygen man po
diff --git a/bootstrap.sh b/bootstrap.sh
index 6f060c8..e5f1ac5 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -58,7 +58,7 @@ else
 
     intltoolize --copy --force --automake
     "$LIBTOOLIZE" -c --force --ltdl
-    run_versioned aclocal "$VERSION" -I common
+    run_versioned aclocal "$VERSION" -I m4
     run_versioned autoconf 2.59 -Wall
     run_versioned autoheader 2.59
     run_versioned automake "$VERSION" --copy --foreign --add-missing
diff --git a/configure.ac b/configure.ac
index 6618907..4fa171f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -28,6 +28,7 @@ m4_define(PA_MICRO, [11])
 
 AC_INIT([pulseaudio], PA_MAJOR.PA_MINOR.PA_MICRO,[mzchyfrnhqvb (at) 0pointer (dot) net])
 AC_CONFIG_SRCDIR([src/daemon/main.c])
+AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([foreign 1.10 -Wall])
 
diff --git a/m4/.gitignore b/m4/.gitignore
new file mode 100644
index 0000000..ac5d140
--- /dev/null
+++ b/m4/.gitignore
@@ -0,0 +1,8 @@
+argz.m4
+intltool.m4
+libtool.m4
+ltdl.m4
+ltoptions.m4
+ltsugar.m4
+ltversion.m4
+lt~obsolete.m4
diff --git a/m4/acx_libwrap.m4 b/m4/acx_libwrap.m4
new file mode 100644
index 0000000..e160214
--- /dev/null
+++ b/m4/acx_libwrap.m4
@@ -0,0 +1,19 @@
+AC_DEFUN([ACX_LIBWRAP], [
+LIBWRAP_LIBS=
+saved_LIBS="$LIBS"
+LIBS="$LIBS -lwrap"
+AC_MSG_CHECKING([for tcpwrap library and headers])
+AC_LINK_IFELSE(
+AC_LANG_PROGRAM(
+[#include <tcpd.h>
+#include <syslog.h>
+int allow_severity = LOG_INFO;
+int deny_severity = LOG_WARNING;],
+[struct request_info *req;
+return hosts_access (req);]),
+[AC_DEFINE(HAVE_LIBWRAP, [], [Have tcpwrap?])
+LIBWRAP_LIBS="-lwrap"
+AC_MSG_RESULT(yes)],
+[AC_MSG_RESULT(no)])
+LIBS="$saved_LIBS"
+])
diff --git a/m4/acx_lirc.m4 b/m4/acx_lirc.m4
new file mode 100644
index 0000000..d3f8ea7
--- /dev/null
+++ b/m4/acx_lirc.m4
@@ -0,0 +1,6 @@
+AC_DEFUN([ACX_LIRC], [
+LIRC_CFLAGS=
+LIRC_LIBS=
+AC_CHECK_HEADER(lirc/lirc_client.h,[AC_CHECK_LIB(lirc_client,lirc_init,[HAVE_LIRC=1
+LIRC_LIBS=-llirc_client],HAVE_LIRC=0)],HAVE_LIRC=0)
+])
diff --git a/acinclude.m4 b/m4/acx_pthread.m4
similarity index 92%
rename from acinclude.m4
rename to m4/acx_pthread.m4
index 02c0518..cbd6bfa 100644
--- a/acinclude.m4
+++ b/m4/acx_pthread.m4
@@ -346,43 +346,3 @@ else
 fi
 AC_LANG_RESTORE
 ])dnl ACX_PTHREAD
-AC_DEFUN([AC_CHECK_DEFINE],[
-AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1_$2])dnl
-AC_CACHE_CHECK([for $1 in $2], ac_var,
-AC_TRY_COMPILE([#include <$2>],[
-  #ifdef $1
-  int ok;
-  #else
-  choke me
-  #endif
-],AS_VAR_SET(ac_var, yes),AS_VAR_SET(ac_var, no)))
-AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])dnl
-AS_VAR_POPDEF([ac_var])dnl
-])
-
-AC_DEFUN([ACX_LIBWRAP], [
-LIBWRAP_LIBS=
-saved_LIBS="$LIBS"
-LIBS="$LIBS -lwrap"
-AC_MSG_CHECKING([for tcpwrap library and headers])
-AC_LINK_IFELSE(
-AC_LANG_PROGRAM(
-[#include <tcpd.h>
-#include <syslog.h>
-int allow_severity = LOG_INFO;
-int deny_severity = LOG_WARNING;],
-[struct request_info *req;
-return hosts_access (req);]),
-[AC_DEFINE(HAVE_LIBWRAP, [], [Have tcpwrap?])
-LIBWRAP_LIBS="-lwrap"
-AC_MSG_RESULT(yes)],
-[AC_MSG_RESULT(no)])
-LIBS="$saved_LIBS"
-])
-
-AC_DEFUN([ACX_LIRC], [
-LIRC_CFLAGS=
-LIRC_LIBS=
-AC_CHECK_HEADER(lirc/lirc_client.h,[AC_CHECK_LIB(lirc_client,lirc_init,[HAVE_LIRC=1
-LIRC_LIBS=-llirc_client],HAVE_LIRC=0)],HAVE_LIRC=0)
-])
diff --git a/m4/check_define.m4 b/m4/check_define.m4
new file mode 100644
index 0000000..43edc78
--- /dev/null
+++ b/m4/check_define.m4
@@ -0,0 +1,13 @@
+AC_DEFUN([AC_CHECK_DEFINE],[
+AS_VAR_PUSHDEF([ac_var],[ac_cv_defined_$1_$2])dnl
+AC_CACHE_CHECK([for $1 in $2], ac_var,
+AC_TRY_COMPILE([#include <$2>],[
+  #ifdef $1
+  int ok;
+  #else
+  choke me
+  #endif
+],AS_VAR_SET(ac_var, yes),AS_VAR_SET(ac_var, no)))
+AS_IF([test AS_VAR_GET(ac_var) != "no"], [$3], [$4])dnl
+AS_VAR_POPDEF([ac_var])dnl
+])

commit f8197cfc4c88a16933de036544f02f31ac26b78e
Author: Diego 'Flameeyes' Pettenò <flameeyes at gmail.com>
Date:   Fri Aug 8 12:24:57 2008 +0200

    Update code to use libtool 2.2. Use convenience recursive libltdl.
    
    Also remove the code for older libtool from the daemon.

diff --git a/Makefile.am b/Makefile.am
index facce0d..b5e638b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,7 @@
 ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST = bootstrap.sh LICENSE GPL LGPL doxygen/Makefile.am doxygen/Makefile.in doxygen/doxygen.conf.in README todo
-SUBDIRS=src doxygen man po
+SUBDIRS=src doxygen man po libltdl
 
 MAINTAINERCLEANFILES =
 noinst_DATA =
diff --git a/configure.ac b/configure.ac
index 4fa171f..8bb3f8a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -244,29 +244,9 @@ else
 fi
 
 #### libtool stuff ####
-
-AC_LTDL_ENABLE_INSTALL
-AC_LIBLTDL_INSTALLABLE
-AC_LIBTOOL_DLOPEN
-AC_LIBTOOL_WIN32_DLL
-AC_PROG_LIBTOOL
-AC_SUBST(LTDLINCL)
-AC_SUBST(LIBLTDL)
-AC_CONFIG_SUBDIRS(libltdl)
-
-old_LIBS=$LIBS
-LIBS="$LIBS $LIBLTDL"
-AC_CHECK_FUNCS([lt_dlmutex_register])
-LIBS=$old_LIBS
-AC_CHECK_TYPES([struct lt_user_dlloader, lt_dladvise], , , [#include <ltdl.h>])
-
-if test "x$enable_ltdl_install" = "xno" && test "x$ac_cv_lib_ltdl_lt_dlinit" = "xno" ; then
-    AC_MSG_ERROR([[
-
-        *** Cannot find the libltdl development files.
-        *** Maybe you need to install the libltdl-dev package.
-        ]])
-fi
+LT_CONFIG_LTDL_DIR([libltdl])
+LT_INIT([dlopen win32-dll])
+LTDL_INIT([convenience recursive])
 
 #### Determine build environment ####
 
@@ -1129,6 +1109,7 @@ AM_CONDITIONAL([FORCE_PREOPEN], [test "x$FORCE_PREOPEN" = "x1"])
 
 AC_CONFIG_FILES([
 Makefile
+libltdl/Makefile
 src/Makefile
 man/Makefile
 libpulse.pc
diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c
index 4007724..6821aac 100644
--- a/src/daemon/ltdl-bind-now.c
+++ b/src/daemon/ltdl-bind-now.c
@@ -53,30 +53,6 @@
 #undef PA_BIND_NOW
 #endif
 
-#ifdef HAVE_LT_DLMUTEX_REGISTER
-
-static pa_mutex *libtool_mutex = NULL;
-
-PA_STATIC_TLS_DECLARE_NO_FREE(libtool_tls);
-
-static void libtool_lock(void) {
-    pa_mutex_lock(libtool_mutex);
-}
-
-static void libtool_unlock(void) {
-    pa_mutex_unlock(libtool_mutex);
-}
-
-static void libtool_set_error(const char *error) {
-    PA_STATIC_TLS_SET(libtool_tls, (char*) error);
-}
-
-static const char *libtool_get_error(void) {
-    return PA_STATIC_TLS_GET(libtool_tls);
-}
-
-#endif
-
 #ifdef PA_BIND_NOW
 
 /*
@@ -91,11 +67,7 @@ static const char *libtool_get_error(void) {
   to set $LT_BIND_NOW before starting the pulsaudio binary.
 */
 
-#ifndef HAVE_LT_DLADVISE
-static lt_module bind_now_open(lt_user_data d, const char *fname)
-#else
 static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise)
-#endif
 {
     lt_module m;
 
@@ -140,36 +112,13 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
 void pa_ltdl_init(void) {
 
 #ifdef PA_BIND_NOW
-# ifdef HAVE_STRUCT_LT_USER_DLLOADER
-    lt_dlloader *place;
-    static const struct lt_user_dlloader loader = {
-        .module_open = bind_now_open,
-        .module_close = bind_now_close,
-        .find_sym = bind_now_find_sym
-    };
-# else
     static const lt_dlvtable *dlopen_loader;
     static lt_dlvtable bindnow_loader;
-# endif
 #endif
 
     pa_assert_se(lt_dlinit() == 0);
 
-#ifdef HAVE_LT_DLMUTEX_REGISTER
-    pa_assert_se(libtool_mutex = pa_mutex_new(TRUE, FALSE));
-    pa_assert_se(lt_dlmutex_register(libtool_lock, libtool_unlock, libtool_set_error, libtool_get_error) == 0);
-#endif
-
 #ifdef PA_BIND_NOW
-# ifdef HAVE_STRUCT_LT_USER_DLLOADER
-
-    if (!(place = lt_dlloader_find("dlopen")))
-        place = lt_dlloader_next(NULL);
-
-    /* Add our BIND_NOW loader as the default module loader. */
-    if (lt_dlloader_add(place, &loader, "bind-now-loader") != 0)
-        pa_log_warn(_("Failed to add bind-now-loader."));
-# else
     /* Already initialised */
     if (dlopen_loader)
         return;
@@ -189,15 +138,9 @@ void pa_ltdl_init(void) {
     /* Add our BIND_NOW loader as the default module loader. */
     if (lt_dlloader_add(&bindnow_loader) != 0)
         pa_log_warn(_("Failed to add bind-now-loader."));
-# endif
 #endif
 }
 
 void pa_ltdl_done(void) {
     pa_assert_se(lt_dlexit() == 0);
-
-#ifdef HAVE_LT_DLMUTEX_REGISTER
-    pa_mutex_free(libtool_mutex);
-    libtool_mutex = NULL;
-#endif
 }

commit 45412740b8db48722234412dc0f58284d033866e
Author: Marc-Andre Lureau <marcandre.lureau at gmail.com>
Date:   Tue Oct 7 01:37:38 2008 +0300

    volume hooks
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index 3955908..f796fb9 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -49,6 +49,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SINK_UNLINK_POST,
     PA_CORE_HOOK_SINK_STATE_CHANGED,
     PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
+    PA_CORE_HOOK_SINK_SET_VOLUME,
     PA_CORE_HOOK_SOURCE_NEW,
     PA_CORE_HOOK_SOURCE_FIXATE,
     PA_CORE_HOOK_SOURCE_PUT,
@@ -65,6 +66,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SINK_INPUT_MOVE_POST,
     PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
     PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
+    PA_CORE_HOOK_SINK_INPUT_SET_VOLUME,
     PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
     PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE,
     PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 778aab5..46dcb14 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2722,7 +2722,7 @@ static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t,
     pa_tagstruct_putu32(t, s->sink->index);
     pa_tagstruct_put_sample_spec(t, &fixed_ss);
     pa_tagstruct_put_channel_map(t, &s->channel_map);
-    pa_tagstruct_put_cvolume(t, &s->volume);
+    pa_tagstruct_put_cvolume(t, pa_sink_input_get_volume(s));
     pa_tagstruct_put_usec(t, pa_sink_input_get_latency(s, &sink_latency));
     pa_tagstruct_put_usec(t, sink_latency);
     pa_tagstruct_puts(t, pa_resample_method_to_string(pa_sink_input_get_resample_method(s)));
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 4f70347..9a3c49c 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -75,7 +75,7 @@ void pa_sink_input_new_data_set_volume(pa_sink_input_new_data *data, const pa_cv
     pa_assert(data);
 
     if ((data->volume_is_set = !!volume))
-        data->volume = *volume;
+        data->volume = data->virtual_volume = *volume;
 }
 
 void pa_sink_input_new_data_set_muted(pa_sink_input_new_data *data, pa_bool_t mute) {
@@ -156,6 +156,8 @@ pa_sink_input* pa_sink_input_new(
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
     pa_return_null_if_fail(data->volume.channels == data->sample_spec.channels);
 
+    data->virtual_volume = data->volume;
+
     if (!data->muted_is_set)
         data->muted = FALSE;
 
@@ -227,7 +229,9 @@ pa_sink_input* pa_sink_input_new(
     i->sample_spec = data->sample_spec;
     i->channel_map = data->channel_map;
 
+    i->virtual_volume = data->virtual_volume;
     i->volume = data->volume;
+
     i->muted = data->muted;
 
     if (data->sync_base) {
@@ -784,17 +788,30 @@ pa_usec_t pa_sink_input_get_requested_latency(pa_sink_input *i) {
 
 /* Called from main context */
 void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume) {
+    pa_sink_input_set_volume_data data;
+
     pa_sink_input_assert_ref(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
     pa_assert(volume);
 
-    if (pa_cvolume_equal(&i->volume, volume))
+    data.sink_input = i;
+    data.virtual_volume = *volume;
+    data.volume = *volume;
+
+    if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], &data) < 0) {
         return;
+    }
 
-    i->volume = *volume;
+    if (!pa_cvolume_equal(&i->volume, &data.volume)) {
+        i->volume = data.volume;
+	pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, &data.volume, 0, NULL) == 0);
+        return;
+    }
 
-    pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, &i->volume, 0, NULL) == 0);
-    pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+    if (!pa_cvolume_equal(&i->virtual_volume, &data.virtual_volume)) {
+        i->virtual_volume = data.virtual_volume;
+        pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+    }
 }
 
 /* Called from main context */
@@ -802,7 +819,7 @@ const pa_cvolume *pa_sink_input_get_volume(pa_sink_input *i) {
     pa_sink_input_assert_ref(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
 
-    return &i->volume;
+    return &i->virtual_volume;
 }
 
 /* Called from main context */
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 7663f22..ed95fe4 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -89,6 +89,8 @@ struct pa_sink_input {
 
     pa_sink_input *sync_prev, *sync_next;
 
+    pa_cvolume virtual_volume;
+
     pa_cvolume volume;
     pa_bool_t muted;
 
@@ -218,6 +220,9 @@ typedef struct pa_sink_input_new_data {
 
     pa_sample_spec sample_spec;
     pa_channel_map channel_map;
+
+    pa_cvolume virtual_volume;
+
     pa_cvolume volume;
     pa_bool_t muted:1;
 
@@ -239,6 +244,12 @@ typedef struct pa_sink_input_move_hook_data {
     pa_sink *destination;
 } pa_sink_input_move_hook_data;
 
+typedef struct pa_sink_set_input_volume_data {
+  pa_sink_input *sink_input;
+  pa_cvolume virtual_volume;
+  pa_cvolume volume;
+} pa_sink_input_set_volume_data;
+
 /* To be called by the implementing module only */
 
 pa_sink_input* pa_sink_input_new(
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index e04fc08..d20a49d 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -843,13 +843,21 @@ pa_usec_t pa_sink_get_latency(pa_sink *s) {
 /* Called from main thread */
 void pa_sink_set_volume(pa_sink *s, const pa_cvolume *volume) {
     pa_bool_t changed;
+    pa_sink_set_volume_data data;
 
     pa_sink_assert_ref(s);
     pa_assert(PA_SINK_IS_LINKED(s->state));
     pa_assert(volume);
 
-    changed = !pa_cvolume_equal(volume, &s->volume);
-    s->volume = *volume;
+    data.sink = s;
+    data.volume = *volume;
+
+    changed = !pa_cvolume_equal(&data.volume, &s->volume);
+
+    if (changed && pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_SET_VOLUME], &data) < 0)
+        return;
+
+    s->volume = data.volume;
 
     if (s->set_volume && s->set_volume(s) < 0)
         s->set_volume = NULL;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 672bdd3..74671b4 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -206,6 +206,11 @@ void pa_sink_new_data_set_volume(pa_sink_new_data *data, const pa_cvolume *volum
 void pa_sink_new_data_set_muted(pa_sink_new_data *data, pa_bool_t mute);
 void pa_sink_new_data_done(pa_sink_new_data *data);
 
+typedef struct pa_sink_set_volume_data {
+  pa_sink *sink;
+  pa_cvolume volume;
+} pa_sink_set_volume_data;
+
 /* To be called exclusively by the sink driver, from main context */
 
 pa_sink* pa_sink_new(

commit 80a79b15df82084430b85cd4573df9ea152b3b62
Author: Marc-Andre Lureau <marcandre.lureau at gmail.com>
Date:   Tue Oct 7 01:37:39 2008 +0300

    flat-volume thingy
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/Makefile.am b/src/Makefile.am
index f277198..7487839 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1032,6 +1032,7 @@ libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore.la
 ###################################
 
 modlibexec_LTLIBRARIES += \
+		module-flat-volume.la \
 		module-cli.la \
 		module-cli-protocol-tcp.la \
 		module-simple-protocol-tcp.la \
@@ -1235,7 +1236,8 @@ SYMDEF_FILES = \
 		modules/bluetooth/module-bluetooth-device-symdef.h \
 		modules/gconf/module-gconf-symdef.h \
 		modules/module-position-event-sounds-symdef.h \
-		modules/module-console-kit-symdef.h
+		modules/module-console-kit-symdef.h \
+		modules/module-flat-volume-symdef.h
 
 EXTRA_DIST += $(SYMDEF_FILES)
 BUILT_SOURCES += $(SYMDEF_FILES)
@@ -1247,6 +1249,12 @@ $(SYMDEF_FILES): modules/module-defs.h.m4
 	$(MKDIR_P) modules/bluetooth
 	$(M4) -Dfname="$@" $< > $@
 
+# Flat volume
+
+module_flat_volume_la_SOURCES = modules/module-flat-volume.c
+module_flat_volume_la_LDFLAGS = -module -avoid-version
+module_flat_volume_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+
 # Simple protocol
 
 module_simple_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
new file mode 100644
index 0000000..1a75e97
--- /dev/null
+++ b/src/modules/module-flat-volume.c
@@ -0,0 +1,220 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+  Copyright 2004-2006, 2008 Lennart Poettering
+
+  Contact: Marc-Andre Lureau <marc-andre.lureau at nokia.com>
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <regex.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core-error.h>
+#include <pulsecore/module.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/sink-input.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
+
+#include "module-flat-volume-symdef.h"
+
+PA_MODULE_AUTHOR("Marc-Andre Lureau");
+PA_MODULE_DESCRIPTION("Flat volume");
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(TRUE);
+PA_MODULE_USAGE("");
+
+struct userdata {
+    pa_subscription *subscription;
+    pa_hook_slot *sink_input_set_volume_hook_slot;
+    pa_hook_slot *sink_input_fixate_hook_slot;
+};
+
+static void process_input_volume_change(pa_cvolume *dest_volume, const pa_cvolume *dest_virtual_volume, pa_channel_map *dest_channel_map,
+					pa_sink_input *this, pa_sink *sink) {
+    pa_sink_input *i;
+    uint32_t idx;
+    pa_cvolume max_volume, sink_volume;
+
+    pa_assert(dest_volume);
+    pa_assert(dest_virtual_volume);
+    pa_assert(dest_channel_map);
+    pa_assert(sink);
+
+    pa_log_debug("Sink input volume changed");
+
+    max_volume = *dest_virtual_volume;
+    pa_cvolume_remap(&max_volume, dest_channel_map, &sink->channel_map);
+
+    for (i = PA_SINK_INPUT(pa_idxset_first(sink->inputs, &idx)); i; i = PA_SINK_INPUT(pa_idxset_next(sink->inputs, &idx))) {
+        /* skip this sink-input if we are processing a volume change request */
+        if (this && this == i)
+            continue;
+
+        if (pa_cvolume_avg(&i->virtual_volume) > pa_cvolume_avg(&max_volume)) {
+            max_volume = i->virtual_volume;
+            pa_cvolume_remap(&max_volume, &i->channel_map, &sink->channel_map);
+        }
+    }
+
+    /* Set the master volume, and normalize inputs */
+    if (!pa_cvolume_equal(&max_volume, &sink->volume)) {
+        /* copied from pa_sink_set_volume(): need to call from here to avoid sink hooks */
+        /* alternatively, could create an extra function pa_sink_set_volume_full()? */
+        sink->volume = max_volume;
+        if (sink->set_volume && sink->set_volume(sink) < 0)
+            sink->set_volume = NULL;
+
+        if (!sink->set_volume)
+            pa_sink_set_soft_volume(sink, &max_volume);
+
+        pa_subscription_post(sink->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, sink->index);
+
+        pa_log_debug("sink = %.2f (changed)", (double)pa_cvolume_avg(&sink->volume)/PA_VOLUME_NORM);
+
+        /* Now, normalize each of the internal volume (client sink-input volume / sink master volume) */
+        for (i = PA_SINK_INPUT(pa_idxset_first(sink->inputs, &idx)); i; i = PA_SINK_INPUT(pa_idxset_next(sink->inputs, &idx))) {
+            /* skip this sink-input if we are processing a volume change request */
+            if (this && this == i)
+                continue;
+
+            sink_volume = max_volume;
+            pa_cvolume_remap(&sink_volume, &sink->channel_map, &i->channel_map);
+            pa_sw_cvolume_divide(&i->volume, &i->virtual_volume, &sink_volume);
+	    pa_log_debug("sink input { id = %d, flat = %.2f, true = %.2f }",
+			 i->index,
+			 (double)pa_cvolume_avg(&i->virtual_volume)/PA_VOLUME_NORM,
+			 (double)pa_cvolume_avg(&i->volume)/PA_VOLUME_NORM);
+	    pa_asyncmsgq_post(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, pa_xnewdup(struct pa_cvolume, &i->volume, 1), 0, NULL, pa_xfree);
+        }
+    } else
+        pa_log_debug("sink = %.2f", (double)pa_cvolume_avg(&sink->volume)/PA_VOLUME_NORM);
+
+    /* and this one */
+    {
+        sink_volume = max_volume;
+        pa_cvolume_remap(&sink_volume, &sink->channel_map, dest_channel_map);
+        pa_sw_cvolume_divide(dest_volume, dest_virtual_volume, &sink_volume);
+        pa_log_debug("caller sink input: { id = %d, flat = %.2f, true = %.2f }",
+                     this ? (int)this->index : -1,
+                     (double)pa_cvolume_avg(dest_virtual_volume)/PA_VOLUME_NORM,
+                     (double)pa_cvolume_avg(dest_volume)/PA_VOLUME_NORM);
+    }
+}
+
+static pa_hook_result_t sink_input_set_volume_hook_callback(pa_core *c, pa_sink_input_set_volume_data *this, struct userdata *u) {
+    pa_assert(this);
+    pa_assert(this->sink_input);
+
+    process_input_volume_change(&this->volume, &this->virtual_volume, &this->sink_input->channel_map,
+				this->sink_input, this->sink_input->sink);
+
+    return PA_HOOK_OK;
+}
+
+static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *core, pa_sink_input_new_data *this, struct userdata *u) {
+    pa_assert(this);
+    pa_assert(this->sink);
+
+    process_input_volume_change(&this->volume, &this->virtual_volume, &this->channel_map,
+                                NULL, this->sink);
+
+    return PA_HOOK_OK;
+}
+
+static void subscribe_callback(pa_core *core, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
+    struct userdata *u = userdata;
+    pa_sink *sink;
+    pa_sink_input *i;
+    uint32_t iidx;
+    pa_cvolume this_volume;
+
+    pa_assert(core);
+    pa_assert(u);
+
+    if (t != (PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_NEW) &&
+        t != (PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE))
+        return;
+
+    if (!(sink = pa_idxset_get_by_index(core->sinks, idx)))
+        return;
+
+    pa_log_debug("Sink volume changed");
+    pa_log_debug("sink = %.2f", (double)pa_cvolume_avg(pa_sink_get_volume(sink, FALSE)) / PA_VOLUME_NORM);
+
+    for (i = PA_SINK_INPUT(pa_idxset_first(sink->inputs, &iidx)); i; i = PA_SINK_INPUT(pa_idxset_next(sink->inputs, &iidx))) {
+        this_volume = *pa_sink_get_volume(sink, FALSE);
+        pa_cvolume_remap(&this_volume, &sink->channel_map, &i->channel_map);
+        pa_sw_cvolume_multiply(&i->virtual_volume, &i->volume, &this_volume);
+        pa_log_debug("sink input = { id = %d, flat = %.2f, true = %.2f }",
+                     i->index,
+                     (double)pa_cvolume_avg(&i->virtual_volume)/PA_VOLUME_NORM,
+                     (double)pa_cvolume_avg(&i->volume)/PA_VOLUME_NORM);
+        pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE, i->index);
+    }
+}
+
+int pa__init(pa_module*m) {
+    struct userdata *u;
+
+    pa_assert(m);
+
+    u = pa_xnew(struct userdata, 1);
+    m->userdata = u;
+
+    u->sink_input_fixate_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_FIXATE], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_fixate_hook_callback, u);
+    u->sink_input_set_volume_hook_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], PA_HOOK_LATE, (pa_hook_cb_t) sink_input_set_volume_hook_callback, u);
+
+    u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK, subscribe_callback, u);
+
+    return 0;
+}
+
+void pa__done(pa_module*m) {
+    struct userdata* u;
+
+    pa_assert(m);
+
+    if (!(u = m->userdata))
+        return;
+
+    if (u->subscription)
+      pa_subscription_free(u->subscription);
+
+    if (u->sink_input_set_volume_hook_slot)
+        pa_hook_slot_free(u->sink_input_set_volume_hook_slot);
+    if (u->sink_input_fixate_hook_slot)
+        pa_hook_slot_free(u->sink_input_fixate_hook_slot);
+
+    pa_xfree(u);
+}

commit 1e513c342059fdce3d2694bae4c649b3af88e4a0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 02:00:07 2008 +0200

    Initialize exit_idle_time to -1 instead of 0  when in system mode.
    
    Spotted by Rafał Mużyło.

diff --git a/src/daemon/main.c b/src/daemon/main.c
index fad635f..bc8bc63 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -646,9 +646,9 @@ int main(int argc, char *argv[]) {
         conf->disable_shm = TRUE;
     }
 
-    if (conf->system_instance && conf->exit_idle_time > 0) {
+    if (conf->system_instance && conf->exit_idle_time >= 0) {
         pa_log_notice(_("Running in system mode, forcibly disabling exit idle time!"));
-        conf->exit_idle_time = 0;
+        conf->exit_idle_time = -1;
     }
 
     if (conf->cmd == PA_CMD_START) {

commit 624f220aa6b9e985ac3a14a4ef08e79bf8356723
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:42:13 2008 +0200

    instead of resetting virtual_volume unconditionally on initialization, do so only when no volume was set before

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 9a3c49c..bd4d769 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -150,13 +150,16 @@ pa_sink_input* pa_sink_input_new(
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
     pa_return_null_if_fail(data->channel_map.channels == data->sample_spec.channels);
 
-    if (!data->volume_is_set)
+    if (!data->volume_is_set) {
         pa_cvolume_reset(&data->volume, data->sample_spec.channels);
+        pa_cvolume_reset(&data->virtual_volume, data->sample_spec.channels);
+    }
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
     pa_return_null_if_fail(data->volume.channels == data->sample_spec.channels);
 
-    data->virtual_volume = data->volume;
+    pa_return_null_if_fail(pa_cvolume_valid(&data->virtual_volume));
+    pa_return_null_if_fail(pa_cvolume_compatible(&data->virtual_volume.channels, &data->sample_spec));
 
     if (!data->muted_is_set)
         data->muted = FALSE;

commit 72024cda54e8951cdf937b2dccdaa2cc2eb0231f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:43:00 2008 +0200

    when the volume is changed make sure we send out a subscription event

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index bd4d769..e132580 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -801,14 +801,12 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume) {
     data.virtual_volume = *volume;
     data.volume = *volume;
 
-    if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], &data) < 0) {
+    if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], &data) < 0)
         return;
-    }
 
     if (!pa_cvolume_equal(&i->volume, &data.volume)) {
         i->volume = data.volume;
-	pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, &data.volume, 0, NULL) == 0);
-        return;
+        pa_assert_se(pa_asyncmsgq_send(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, &data.volume, 0, NULL) == 0);
     }
 
     if (!pa_cvolume_equal(&i->virtual_volume, &data.virtual_volume)) {

commit ae83483cf01b3e690bbee430fab8b7f9ee1efda8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:44:43 2008 +0200

    modernize a few checks

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index e132580..6dfbdbb 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -119,6 +119,7 @@ pa_sink_input* pa_sink_input_new(
     pa_sink_input *i;
     pa_resampler *resampler = NULL;
     char st[PA_SAMPLE_SPEC_SNPRINT_MAX], cm[PA_CHANNEL_MAP_SNPRINT_MAX];
+    pa_channel_map original_cm;
 
     pa_assert(core);
     pa_assert(data);
@@ -141,14 +142,14 @@ pa_sink_input* pa_sink_input_new(
     pa_return_null_if_fail(pa_sample_spec_valid(&data->sample_spec));
 
     if (!data->channel_map_is_set) {
-        if (data->sink->channel_map.channels == data->sample_spec.channels)
+        if (pa_channel_map_compatible(&data->sink->channel_map, &data->sample_spec))
             data->channel_map = data->sink->channel_map;
         else
             pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
     }
 
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
-    pa_return_null_if_fail(data->channel_map.channels == data->sample_spec.channels);
+    pa_return_null_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec));
 
     if (!data->volume_is_set) {
         pa_cvolume_reset(&data->volume, data->sample_spec.channels);
@@ -156,7 +157,7 @@ pa_sink_input* pa_sink_input_new(
     }
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
-    pa_return_null_if_fail(data->volume.channels == data->sample_spec.channels);
+    pa_return_null_if_fail(pa_cvolume_compatible(&data->volume.channels, &data->sample_spec));
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->virtual_volume));
     pa_return_null_if_fail(pa_cvolume_compatible(&data->virtual_volume.channels, &data->sample_spec));
@@ -796,6 +797,8 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume) {
     pa_sink_input_assert_ref(i);
     pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
     pa_assert(volume);
+    pa_assert(pa_cvolume_valid(volume));
+    pa_assert(pa_cvolume_compatible(volume, &i->sample_spec));
 
     data.sink_input = i;
     data.virtual_volume = *volume;
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index d76f6e4..6af7824 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -124,14 +124,14 @@ pa_source_output* pa_source_output_new(
     pa_return_null_if_fail(pa_sample_spec_valid(&data->sample_spec));
 
     if (!data->channel_map_is_set) {
-        if (data->source->channel_map.channels == data->sample_spec.channels)
+        if (pa_channel_map_compatible(&data->source->channel_map, &data->sample_spec))
             data->channel_map = data->source->channel_map;
         else
             pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
     }
 
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
-    pa_return_null_if_fail(data->channel_map.channels == data->sample_spec.channels);
+    pa_return_null_if_fail(pa_channel_map_compatible(&data->channel_map, &data->sample_spec));
 
     if (flags & PA_SOURCE_OUTPUT_FIX_FORMAT)
         data->sample_spec.format = data->source->sample_spec.format;

commit e1dbc75eb80aefed7e111d857d2f822702d3a730
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:45:37 2008 +0200

    use pa_channel_map_init_extend() instead of pa_channel_map_init_auto() as channel map for sink inputs/source outputs in case no map is specified

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 6dfbdbb..6ef1e93 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -145,7 +145,7 @@ pa_sink_input* pa_sink_input_new(
         if (pa_channel_map_compatible(&data->sink->channel_map, &data->sample_spec))
             data->channel_map = data->sink->channel_map;
         else
-            pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
+            pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     }
 
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 6af7824..7adc757 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -127,7 +127,7 @@ pa_source_output* pa_source_output_new(
         if (pa_channel_map_compatible(&data->source->channel_map, &data->sample_spec))
             data->channel_map = data->source->channel_map;
         else
-            pa_return_null_if_fail(pa_channel_map_init_auto(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT));
+            pa_channel_map_init_extend(&data->channel_map, data->sample_spec.channels, PA_CHANNEL_MAP_DEFAULT);
     }
 
     pa_return_null_if_fail(pa_channel_map_valid(&data->channel_map));

commit e053fa03f7c7ec161be14af28cab307d4271993b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:46:18 2008 +0200

    if the channel map was modified due to PA_SINK_INPUT_FIX_CHANNELS, remap the specified volume properly

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 6ef1e93..c65f18a 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -171,6 +171,8 @@ pa_sink_input* pa_sink_input_new(
     if (flags & PA_SINK_INPUT_FIX_RATE)
         data->sample_spec.rate = data->sink->sample_spec.rate;
 
+    original_cm = data->channel_map;
+
     if (flags & PA_SINK_INPUT_FIX_CHANNELS) {
         data->sample_spec.channels = data->sink->sample_spec.channels;
         data->channel_map = data->sink->channel_map;
@@ -180,8 +182,7 @@ pa_sink_input* pa_sink_input_new(
     pa_assert(pa_channel_map_valid(&data->channel_map));
 
     /* Due to the fixing of the sample spec the volume might not match anymore */
-    if (data->volume.channels != data->sample_spec.channels)
-        pa_cvolume_set(&data->volume, data->sample_spec.channels, pa_cvolume_avg(&data->volume));
+    pa_cvolume_remap(&data->volume, &original_cm, &data->channel_map);
 
     if (data->resample_method == PA_RESAMPLER_INVALID)
         data->resample_method = core->resample_method;

commit 46f73fb9531772e89ef7706578ba3ed2bde6c563
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:47:01 2008 +0200

    additional validity checks

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d20a49d..7e92049 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -848,6 +848,8 @@ void pa_sink_set_volume(pa_sink *s, const pa_cvolume *volume) {
     pa_sink_assert_ref(s);
     pa_assert(PA_SINK_IS_LINKED(s->state));
     pa_assert(volume);
+    pa_assert(pa_cvolume_valid(volume));
+    pa_assert(pa_cvolume_compatible(volume, &s->sample_spec));
 
     data.sink = s;
     data.volume = *volume;

commit 68cc2996cc1e0bfe53d35eafdd26ce4572a10ce9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 7 22:47:32 2008 +0200

    after calling PA_CORE_HOOK_SINK_SET_VOLUME hook, check again whether the volume changed

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 7e92049..d8d1f79 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -856,8 +856,12 @@ void pa_sink_set_volume(pa_sink *s, const pa_cvolume *volume) {
 
     changed = !pa_cvolume_equal(&data.volume, &s->volume);
 
-    if (changed && pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_SET_VOLUME], &data) < 0)
-        return;
+    if (changed) {
+        if (pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_SET_VOLUME], &data) < 0)
+            return;
+
+        changed = !pa_cvolume_equal(&data.volume, &s->volume);
+    }
 
     s->volume = data.volume;
 

commit 9f4033d1c40d6a4b81f88c45844c1da5ab0815f5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:08:51 2008 +0200

    if a stream comes with now sensible properties attached, use common
    fallback db entry.

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index fe79291..e1381a5 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -134,7 +134,7 @@ static char *get_name(pa_proplist *p, const char *prefix) {
     else if ((r = pa_proplist_gets(p, PA_PROP_MEDIA_NAME)))
         return pa_sprintf_malloc("%s-by-media-name:%s", prefix, r);
 
-    return NULL;
+    return pa_sprintf_malloc("%s-fallback:%s", prefix);
 }
 
 static struct entry* read_entry(struct userdata *u, char *name) {

commit b6ccea3064fd1081ec4d0f8103a4b37de2605485
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:10:01 2008 +0200

    add a comment that pa_sink_input_set_volume and module-flat-volume.c are related

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index c65f18a..8505c63 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -805,6 +805,10 @@ void pa_sink_input_set_volume(pa_sink_input *i, const pa_cvolume *volume) {
     data.virtual_volume = *volume;
     data.volume = *volume;
 
+    /* If you change something here, consider looking into
+     * module-flat-volume.c as well since it uses very similar
+     * code. */
+
     if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_SET_VOLUME], &data) < 0)
         return;
 

commit 776c8dec3c0df2114d5012a2089642a6677a0317
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:10:56 2008 +0200

    remove $Id$

diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
index 1a75e97..5e33928 100644
--- a/src/modules/module-flat-volume.c
+++ b/src/modules/module-flat-volume.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 

commit 8bc58cc7579bf238cd0a5ffd48d44ebc08eaf5a7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:12:15 2008 +0200

    ignore sinks that do not carry decibel information

diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
index 5e33928..3bb0c87 100644
--- a/src/modules/module-flat-volume.c
+++ b/src/modules/module-flat-volume.c
@@ -69,6 +69,9 @@ static void process_input_volume_change(pa_cvolume *dest_volume, const pa_cvolum
     pa_assert(dest_channel_map);
     pa_assert(sink);
 
+    if (!(sink->flags & PA_SINK_DECIBEL_VOLUME))
+        return;
+
     pa_log_debug("Sink input volume changed");
 
     max_volume = *dest_virtual_volume;
@@ -167,6 +170,9 @@ static void subscribe_callback(pa_core *core, pa_subscription_event_type_t t, ui
     if (!(sink = pa_idxset_get_by_index(core->sinks, idx)))
         return;
 
+    if (!(sink->flags & PA_SINK_DECIBEL_VOLUME))
+        return;
+
     pa_log_debug("Sink volume changed");
     pa_log_debug("sink = %.2f", (double)pa_cvolume_avg(pa_sink_get_volume(sink, FALSE)) / PA_VOLUME_NORM);
 

commit 404cf74332b4bee55015bfdc6ca3772c99d03f6c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:12:59 2008 +0200

    some minor reformatting

diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
index 3bb0c87..cd830c0 100644
--- a/src/modules/module-flat-volume.c
+++ b/src/modules/module-flat-volume.c
@@ -58,8 +58,13 @@ struct userdata {
     pa_hook_slot *sink_input_fixate_hook_slot;
 };
 
-static void process_input_volume_change(pa_cvolume *dest_volume, const pa_cvolume *dest_virtual_volume, pa_channel_map *dest_channel_map,
-					pa_sink_input *this, pa_sink *sink) {
+static void process_input_volume_change(
+        pa_cvolume *dest_volume,
+        const pa_cvolume *dest_virtual_volume,
+        pa_channel_map *dest_channel_map,
+        pa_sink_input *this,
+        pa_sink *sink) {
+
     pa_sink_input *i;
     uint32_t idx;
     pa_cvolume max_volume, sink_volume;
@@ -112,25 +117,24 @@ static void process_input_volume_change(pa_cvolume *dest_volume, const pa_cvolum
             sink_volume = max_volume;
             pa_cvolume_remap(&sink_volume, &sink->channel_map, &i->channel_map);
             pa_sw_cvolume_divide(&i->volume, &i->virtual_volume, &sink_volume);
-	    pa_log_debug("sink input { id = %d, flat = %.2f, true = %.2f }",
-			 i->index,
-			 (double)pa_cvolume_avg(&i->virtual_volume)/PA_VOLUME_NORM,
-			 (double)pa_cvolume_avg(&i->volume)/PA_VOLUME_NORM);
-	    pa_asyncmsgq_post(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, pa_xnewdup(struct pa_cvolume, &i->volume, 1), 0, NULL, pa_xfree);
+            pa_log_debug("sink input { id = %d, flat = %.2f, true = %.2f }",
+                         i->index,
+                         (double)pa_cvolume_avg(&i->virtual_volume)/PA_VOLUME_NORM,
+                         (double)pa_cvolume_avg(&i->volume)/PA_VOLUME_NORM);
+            pa_asyncmsgq_post(i->sink->asyncmsgq, PA_MSGOBJECT(i), PA_SINK_INPUT_MESSAGE_SET_VOLUME, pa_xnewdup(struct pa_cvolume, &i->volume, 1), 0, NULL, pa_xfree);
         }
     } else
         pa_log_debug("sink = %.2f", (double)pa_cvolume_avg(&sink->volume)/PA_VOLUME_NORM);
 
     /* and this one */
-    {
-        sink_volume = max_volume;
-        pa_cvolume_remap(&sink_volume, &sink->channel_map, dest_channel_map);
-        pa_sw_cvolume_divide(dest_volume, dest_virtual_volume, &sink_volume);
-        pa_log_debug("caller sink input: { id = %d, flat = %.2f, true = %.2f }",
-                     this ? (int)this->index : -1,
-                     (double)pa_cvolume_avg(dest_virtual_volume)/PA_VOLUME_NORM,
-                     (double)pa_cvolume_avg(dest_volume)/PA_VOLUME_NORM);
-    }
+
+    sink_volume = max_volume;
+    pa_cvolume_remap(&sink_volume, &sink->channel_map, dest_channel_map);
+    pa_sw_cvolume_divide(dest_volume, dest_virtual_volume, &sink_volume);
+    pa_log_debug("caller sink input: { id = %d, flat = %.2f, true = %.2f }",
+                 this ? (int)this->index : -1,
+                 (double)pa_cvolume_avg(dest_virtual_volume)/PA_VOLUME_NORM,
+                 (double)pa_cvolume_avg(dest_volume)/PA_VOLUME_NORM);
 }
 
 static pa_hook_result_t sink_input_set_volume_hook_callback(pa_core *c, pa_sink_input_set_volume_data *this, struct userdata *u) {
@@ -138,7 +142,7 @@ static pa_hook_result_t sink_input_set_volume_hook_callback(pa_core *c, pa_sink_
     pa_assert(this->sink_input);
 
     process_input_volume_change(&this->volume, &this->virtual_volume, &this->sink_input->channel_map,
-				this->sink_input, this->sink_input->sink);
+                                this->sink_input, this->sink_input->sink);
 
     return PA_HOOK_OK;
 }

commit b048ae9f789cdbc7540b343fb1890a86d91a505f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:13:53 2008 +0200

    check the maximum volume of all sink inputs instead of the average volume to avoid digital amplification in favour of attenuation

diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
index cd830c0..02e3ed1 100644
--- a/src/modules/module-flat-volume.c
+++ b/src/modules/module-flat-volume.c
@@ -87,7 +87,7 @@ static void process_input_volume_change(
         if (this && this == i)
             continue;
 
-        if (pa_cvolume_avg(&i->virtual_volume) > pa_cvolume_avg(&max_volume)) {
+        if (pa_cvolume_max(&i->virtual_volume) > pa_cvolume_max(&max_volume)) {
             max_volume = i->virtual_volume;
             pa_cvolume_remap(&max_volume, &i->channel_map, &sink->channel_map);
         }

commit 34f6a516b2e5fd0ca4143eed9831759fcbc89cb0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:14:25 2008 +0200

    use pa_sink_set_volume() for changing the volume

diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
index 02e3ed1..25b5707 100644
--- a/src/modules/module-flat-volume.c
+++ b/src/modules/module-flat-volume.c
@@ -95,16 +95,8 @@ static void process_input_volume_change(
 
     /* Set the master volume, and normalize inputs */
     if (!pa_cvolume_equal(&max_volume, &sink->volume)) {
-        /* copied from pa_sink_set_volume(): need to call from here to avoid sink hooks */
-        /* alternatively, could create an extra function pa_sink_set_volume_full()? */
-        sink->volume = max_volume;
-        if (sink->set_volume && sink->set_volume(sink) < 0)
-            sink->set_volume = NULL;
 
-        if (!sink->set_volume)
-            pa_sink_set_soft_volume(sink, &max_volume);
-
-        pa_subscription_post(sink->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, sink->index);
+        pa_sink_set_volume(sink, &max_volume);
 
         pa_log_debug("sink = %.2f (changed)", (double)pa_cvolume_avg(&sink->volume)/PA_VOLUME_NORM);
 

commit 37b8c45e2b4d996b328a4fc74f491498abbc9348
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:14:54 2008 +0200

    query the sink volume outside of the loop because it might be quite expensive

diff --git a/src/modules/module-flat-volume.c b/src/modules/module-flat-volume.c
index 25b5707..9bc8055 100644
--- a/src/modules/module-flat-volume.c
+++ b/src/modules/module-flat-volume.c
@@ -154,7 +154,7 @@ static void subscribe_callback(pa_core *core, pa_subscription_event_type_t t, ui
     pa_sink *sink;
     pa_sink_input *i;
     uint32_t iidx;
-    pa_cvolume this_volume;
+    pa_cvolume sink_volume;
 
     pa_assert(core);
     pa_assert(u);
@@ -172,10 +172,14 @@ static void subscribe_callback(pa_core *core, pa_subscription_event_type_t t, ui
     pa_log_debug("Sink volume changed");
     pa_log_debug("sink = %.2f", (double)pa_cvolume_avg(pa_sink_get_volume(sink, FALSE)) / PA_VOLUME_NORM);
 
+    sink_volume = *pa_sink_get_volume(sink, FALSE);
+
     for (i = PA_SINK_INPUT(pa_idxset_first(sink->inputs, &iidx)); i; i = PA_SINK_INPUT(pa_idxset_next(sink->inputs, &iidx))) {
-        this_volume = *pa_sink_get_volume(sink, FALSE);
-        pa_cvolume_remap(&this_volume, &sink->channel_map, &i->channel_map);
-        pa_sw_cvolume_multiply(&i->virtual_volume, &i->volume, &this_volume);
+        pa_cvolume si_volume;
+
+        si_volume = sink_volume;
+        pa_cvolume_remap(&si_volume, &sink->channel_map, &i->channel_map);
+        pa_sw_cvolume_multiply(&i->virtual_volume, &i->volume, &si_volume);
         pa_log_debug("sink input = { id = %d, flat = %.2f, true = %.2f }",
                      i->index,
                      (double)pa_cvolume_avg(&i->virtual_volume)/PA_VOLUME_NORM,

commit 2dfc2654832e5124f263bc7ee2718ff6913e6d46
Merge: 5925d44... 37b8c45...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 00:15:18 2008 +0200

    Merge branch 'flatvol'


commit a8dc2aaa8249972bf982fa5784b1b38972356903
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 02:00:53 2008 +0200

    enable flat volumes by default

diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
index 7032038..ae54c0a 100755
--- a/src/daemon/default.pa.in
+++ b/src/daemon/default.pa.in
@@ -72,9 +72,12 @@ load-module module-native-protocol-unix
 #load-module module-null-sink sink_name=rtp format=s16be channels=2 rate=44100 description="RTP Multicast Sink"
 #load-module module-rtp-send source=rtp.monitor
 
+### Enable flat volumes where possible
+load-module module-flat-volumes
+
 ### Automatically restore the volume of streams and devices
-load-module module-stream-restore
 load-module module-device-restore
+load-module module-stream-restore
 
 ### Automatically restore the default sink/source when changed by the user during runtime
 load-module module-default-device-restore

commit 068afb3478f96c29ba39ee9b723a9ed8a6090519
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 04:02:10 2008 +0200

    define 0dB in PA as maximum amplification

diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index 0e15da3..4044de1 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -796,7 +796,7 @@ static int sink_get_volume_cb(pa_sink *s) {
                 VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
             } else {
 
                 if ((err = snd_mixer_selem_get_playback_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
@@ -818,7 +818,7 @@ static int sink_get_volume_cb(pa_sink *s) {
             VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
 
@@ -875,6 +875,7 @@ static int sink_set_volume_cb(pa_sink *s) {
             if (u->hw_dB_supported) {
 
                 alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+                alsa_vol += u->hw_dB_max;
                 alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
                 if ((err = snd_mixer_selem_set_playback_dB(u->mixer_elem, u->mixer_map[i], alsa_vol, 1)) < 0)
@@ -883,7 +884,7 @@ static int sink_set_volume_cb(pa_sink *s) {
                 if ((err = snd_mixer_selem_get_playback_dB(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
                     goto fail;
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
 
             } else {
                 alsa_vol = to_alsa_volume(u, vol);
@@ -906,6 +907,7 @@ static int sink_set_volume_cb(pa_sink *s) {
 
         if (u->hw_dB_supported) {
             alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+            alsa_vol += u->hw_dB_max;
             alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
             if ((err = snd_mixer_selem_set_playback_dB_all(u->mixer_elem, alsa_vol, 1)) < 0)
@@ -914,7 +916,7 @@ static int sink_set_volume_cb(pa_sink *s) {
             if ((err = snd_mixer_selem_get_playback_dB(u->mixer_elem, SND_MIXER_SCHN_MONO, &alsa_vol)) < 0)
                 goto fail;
 
-            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
             alsa_vol = to_alsa_volume(u, vol);
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index 2827ecf..a743776 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -742,7 +742,7 @@ static int source_get_volume_cb(pa_source *s) {
                 VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
             } else {
 
                 if ((err = snd_mixer_selem_get_capture_volume(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
@@ -764,7 +764,7 @@ static int source_get_volume_cb(pa_source *s) {
             VALGRIND_MAKE_MEM_DEFINED(&alsa_vol, sizeof(alsa_vol));
 #endif
 
-            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->sample_spec.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
 
@@ -821,6 +821,7 @@ static int source_set_volume_cb(pa_source *s) {
             if (u->hw_dB_supported) {
 
                 alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+                alsa_vol += u->hw_dB_max;
                 alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
                 if ((err = snd_mixer_selem_set_capture_dB(u->mixer_elem, u->mixer_map[i], alsa_vol, 1)) < 0)
@@ -829,7 +830,7 @@ static int source_set_volume_cb(pa_source *s) {
                 if ((err = snd_mixer_selem_get_capture_dB(u->mixer_elem, u->mixer_map[i], &alsa_vol)) < 0)
                     goto fail;
 
-                r.values[i] = pa_sw_volume_from_dB((double) alsa_vol / 100.0);
+                r.values[i] = pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0);
 
             } else {
                 alsa_vol = to_alsa_volume(u, vol);
@@ -852,6 +853,7 @@ static int source_set_volume_cb(pa_source *s) {
 
         if (u->hw_dB_supported) {
             alsa_vol = (long) (pa_sw_volume_to_dB(vol) * 100);
+            alsa_vol += u->hw_dB_max;
             alsa_vol = PA_CLAMP_UNLIKELY(alsa_vol, u->hw_dB_min, u->hw_dB_max);
 
             if ((err = snd_mixer_selem_set_capture_dB_all(u->mixer_elem, alsa_vol, 1)) < 0)
@@ -860,7 +862,7 @@ static int source_set_volume_cb(pa_source *s) {
             if ((err = snd_mixer_selem_get_capture_dB(u->mixer_elem, SND_MIXER_SCHN_MONO, &alsa_vol)) < 0)
                 goto fail;
 
-            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) alsa_vol / 100.0));
+            pa_cvolume_set(&r, s->volume.channels, pa_sw_volume_from_dB((double) (alsa_vol - u->hw_dB_max) / 100.0));
 
         } else {
             alsa_vol = to_alsa_volume(u, vol);

commit 8c1c565c86ddeb0c2b3b89d53aed0052eca1ebbf
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Thu May 1 23:35:24 2008 +0000

    Add a small lib to interpret and produce headers as used in http style requests.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2332 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/headerlist.c b/src/modules/rtp/headerlist.c
new file mode 100644
index 0000000..9ea17ae
--- /dev/null
+++ b/src/modules/rtp/headerlist.c
@@ -0,0 +1,190 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+  Copyright 2007 Lennart Poettering
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation; either version 2.1 of the
+  License, or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <string.h>
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/hashmap.h>
+#include <pulsecore/strbuf.h>
+#include <pulsecore/core-util.h>
+
+#include "headerlist.h"
+
+struct header {
+    char *key;
+    void *value;
+    size_t nbytes;
+};
+
+#define MAKE_HASHMAP(p) ((pa_hashmap*) (p))
+#define MAKE_HEADERLIST(p) ((pa_headerlist*) (p))
+
+static void header_free(struct header *hdr) {
+    pa_assert(hdr);
+
+    pa_xfree(hdr->key);
+    pa_xfree(hdr->value);
+    pa_xfree(hdr);
+}
+
+pa_headerlist* pa_headerlist_new(void) {
+    return MAKE_HEADERLIST(pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func));
+}
+
+void pa_headerlist_free(pa_headerlist* p) {
+    struct header *hdr;
+
+    while ((hdr = pa_hashmap_steal_first(MAKE_HASHMAP(p))))
+        header_free(hdr);
+
+    pa_hashmap_free(MAKE_HASHMAP(p), NULL, NULL);
+}
+
+int pa_headerlist_puts(pa_headerlist *p, const char *key, const char *value) {
+    struct header *hdr;
+    pa_bool_t add = FALSE;
+
+    pa_assert(p);
+    pa_assert(key);
+
+    if (!(hdr = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+        hdr = pa_xnew(struct header, 1);
+        hdr->key = pa_xstrdup(key);
+        add = TRUE;
+    } else
+        pa_xfree(hdr->value);
+
+    hdr->value = pa_xstrdup(value);
+    hdr->nbytes = strlen(value)+1;
+
+    if (add)
+        pa_hashmap_put(MAKE_HASHMAP(p), hdr->key, hdr);
+
+    return 0;
+}
+
+int pa_headerlist_putsappend(pa_headerlist *p, const char *key, const char *value) {
+    struct header *hdr;
+    pa_bool_t add = FALSE;
+    pa_strbuf *buf;
+
+    pa_assert(p);
+    pa_assert(key);
+
+    buf = pa_strbuf_new();
+    if (!(hdr = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
+        hdr = pa_xnew(struct header, 1);
+        hdr->key = pa_xstrdup(key);
+        add = TRUE;
+    } else {
+        pa_strbuf_puts(buf, hdr->value);
+        pa_xfree(hdr->value);
+    }
+    pa_strbuf_puts(buf, value);
+    hdr->value = pa_strbuf_tostring_free(buf);
+    hdr->nbytes = strlen(hdr->value)+1;
+
+    if (add)
+        pa_hashmap_put(MAKE_HASHMAP(p), hdr->key, hdr);
+
+    return 0;
+}
+
+const char *pa_headerlist_gets(pa_headerlist *p, const char *key) {
+    struct header *hdr;
+
+    pa_assert(p);
+    pa_assert(key);
+
+    if (!(hdr = pa_hashmap_get(MAKE_HASHMAP(p), key)))
+        return NULL;
+
+    if (hdr->nbytes <= 0)
+        return NULL;
+
+    if (((char*) hdr->value)[hdr->nbytes-1] != 0)
+        return NULL;
+
+    if (strlen((char*) hdr->value) != hdr->nbytes-1)
+        return NULL;
+
+    return (char*) hdr->value;
+}
+
+int pa_headerlist_remove(pa_headerlist *p, const char *key) {
+    struct header *hdr;
+
+    pa_assert(p);
+    pa_assert(key);
+
+    if (!(hdr = pa_hashmap_remove(MAKE_HASHMAP(p), key)))
+        return -1;
+
+    header_free(hdr);
+    return 0;
+}
+
+const char *pa_headerlist_iterate(pa_headerlist *p, void **state) {
+    struct header *hdr;
+
+    if (!(hdr = pa_hashmap_iterate(MAKE_HASHMAP(p), state, NULL)))
+        return NULL;
+
+    return hdr->key;
+}
+
+char *pa_headerlist_to_string(pa_headerlist *p) {
+    const char *key;
+    void *state = NULL;
+    pa_strbuf *buf;
+
+    pa_assert(p);
+
+    buf = pa_strbuf_new();
+
+    while ((key = pa_headerlist_iterate(p, &state))) {
+
+        const char *v;
+
+        if ((v = pa_headerlist_gets(p, key)))
+            pa_strbuf_printf(buf, "%s: %s\r\n", key, v);
+    }
+
+    return pa_strbuf_tostring_free(buf);
+}
+
+int pa_headerlist_contains(pa_headerlist *p, const char *key) {
+    pa_assert(p);
+    pa_assert(key);
+
+    if (!(pa_hashmap_get(MAKE_HASHMAP(p), key)))
+        return 0;
+
+    return 1;
+}
diff --git a/src/modules/rtp/headerlist.h b/src/modules/rtp/headerlist.h
new file mode 100644
index 0000000..276d0e3
--- /dev/null
+++ b/src/modules/rtp/headerlist.h
@@ -0,0 +1,48 @@
+#ifndef foopulseheaderlisthfoo
+#define foopulseheaderlisthfoo
+
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+  Copyright 2007 Lennart Poettering
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation; either version 2.1 of the
+  License, or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  Lesser General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#include <pulsecore/macro.h>
+
+typedef struct pa_headerlist pa_headerlist;
+
+pa_headerlist* pa_headerlist_new(void);
+void pa_headerlist_free(pa_headerlist* p);
+
+int pa_headerlist_puts(pa_headerlist *p, const char *key, const char *value);
+int pa_headerlist_putsappend(pa_headerlist *p, const char *key, const char *value);
+
+const char *pa_headerlist_gets(pa_headerlist *p, const char *key);
+
+int pa_headerlist_remove(pa_headerlist *p, const char *key);
+
+const char *pa_headerlist_iterate(pa_headerlist *p, void **state);
+
+char *pa_headerlist_to_string(pa_headerlist *p);
+
+int pa_headerlist_contains(pa_headerlist *p, const char *key);
+
+#endif

commit 48477067ee20678a9c741da4e75dbbcdd6b01efe
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Thu May 1 23:40:19 2008 +0000

    Add a RTSP client impelmentation.
    
    I still need to adapt the header reading to move the concatenation code to the headerlist lib
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2333 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
new file mode 100644
index 0000000..3fd1ba0
--- /dev/null
+++ b/src/modules/rtp/rtsp.c
@@ -0,0 +1,472 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core-error.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/socket-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/strbuf.h>
+#include <pulsecore/poll.h>
+
+#include "rtsp.h"
+
+/*
+ * read one line from the file descriptor
+ * timeout: msec unit, -1 for infinite
+ * if CR comes then following LF is expected
+ * returned string in line is always null terminated, maxlen-1 is maximum string length
+ */
+static int pa_read_line(int fd, char *line, int maxlen, int timeout)
+{
+    int i, rval;
+    int count;
+    char ch;
+    struct pollfd pfds;
+    count = 0;
+    *line = 0;
+    pfds.events = POLLIN;
+    pfds.fd = fd;
+
+    for (i=0; i<maxlen; ++i) {
+        if (!poll(&pfds, 1, timeout))
+            return 0;
+
+        rval = read(fd, &ch, 1);
+
+        if (-1 == rval) {
+            if (EAGAIN == errno)
+                return 0;
+            //ERRMSG("%s:read error: %s\n", __func__, strerror(errno));
+            return -1;
+        }
+
+        if (0 == rval) {
+            //INFMSG("%s:disconnected on the other end\n", __func__);
+            return -1;
+        }
+
+        if ('\n' == ch) {
+            *line = 0;
+            return count;
+        }
+
+        if ('\r' == ch)
+            continue;
+
+        *line++ = ch;
+        count++;
+
+        if (count >= maxlen-1)
+            break;
+    }
+
+    *line = 0;
+    return count;
+}
+
+
+static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
+                        const char* content_type, const char* content,
+                        int expect_response,
+                        pa_headerlist* headers, pa_headerlist** response_headers) {
+    pa_strbuf* buf;
+    char* hdrs;
+    ssize_t l;
+    char response[1024];
+    int timeout;
+    char* token;
+    const char* token_state;
+    char delimiters[2];
+    char* header;
+    char* delimpos;
+
+
+    pa_assert(c);
+    pa_assert(c->url);
+
+    if (!cmd)
+        return 0;
+
+    buf = pa_strbuf_new();
+    pa_strbuf_printf(buf, "%s %s RTSP/1.0\r\nCSeq: %d\r\n", cmd, c->url, ++c->cseq);
+    if (c->session)
+        pa_strbuf_printf(buf, "Session: %s\r\n", c->session);
+
+    // Add the headers
+    if (headers) {
+        hdrs = pa_headerlist_to_string(headers);
+        pa_strbuf_puts(buf, hdrs);
+        pa_xfree(hdrs);
+    }
+
+    if (content_type && content) {
+        pa_strbuf_printf(buf, "Content-Type: %s\r\nContent-Length: %d\r\n",
+          content_type, (int)strlen(content));
+    }
+
+    pa_strbuf_printf(buf, "User-Agent: %s\r\n", c->useragent);
+
+    if (c->headers) {
+        hdrs = pa_headerlist_to_string(c->headers);
+        pa_strbuf_puts(buf, hdrs);
+        pa_xfree(hdrs);
+    }
+
+    pa_strbuf_puts(buf, "\r\n");
+
+    if (content_type && content) {
+        pa_strbuf_puts(buf, content);
+    }
+
+    // Our packet is created... now we can send it :)
+    hdrs = pa_strbuf_tostring_free(buf);
+    l = pa_write(c->fd, hdrs, strlen(hdrs), NULL);
+    pa_xfree(hdrs);
+
+    // Do we expect a response?
+    if (!expect_response)
+        return 1;
+
+    timeout = 5000;
+    if (pa_read_line(c->fd, response, sizeof(response), timeout) <= 0) {
+        //ERRMSG("%s: request failed\n",__func__);
+        return 0;
+    }
+
+    delimiters[0] = ' ';
+    delimiters[1] = '\0';
+    token_state = NULL;
+    pa_xfree(pa_split(response, delimiters, &token_state));
+    token = pa_split(response, delimiters, &token_state);
+    if (!token || strcmp(token, "200")) {
+        pa_xfree(token);
+        //ERRMSG("%s: request failed, error %s\n",__func__,token);
+        return 0;
+    }
+    pa_xfree(token);
+
+    // We want to return the headers?
+    if (!response_headers)
+    {
+        // We have no storage, so just clear out the response.
+        while (pa_read_line(c->fd, response, sizeof(response), timeout) > 0) {
+            // Reduce timeout for future requests
+            timeout = 1000;
+        }
+        return 1;
+    }
+
+    header = NULL;
+    buf = pa_strbuf_new();
+    while (pa_read_line(c->fd, response, sizeof(response), timeout) > 0) {
+        // Reduce timeout for future requests
+        timeout = 1000;
+
+        // If the first character is a space, it's a continuation header
+        if (header && ' ' == response[0]) {
+            // Add this line to the buffer (sans the space.
+            pa_strbuf_puts(buf, &(response[1]));
+            continue;
+        }
+
+        if (header) {
+            // This is not a continuation header so let's dump the full header/value into our proplist
+            pa_headerlist_puts(*response_headers, header, pa_strbuf_tostring_free(buf));
+            pa_xfree(header);
+            //header = NULL;
+            buf = pa_strbuf_new();
+        }
+
+        delimpos = strstr(response, ":");
+        if (!delimpos) {
+            //ERRMSG("%s: Request failed, bad header\n",__func__);
+            return 0;
+        }
+
+        if (strlen(delimpos) > 1) {
+            // Cut our line off so we can copy the header name out
+            *delimpos++ = '\0';
+
+            // Trim the front of any spaces
+            while (' ' == *delimpos)
+                ++delimpos;
+
+            pa_strbuf_puts(buf, delimpos);
+        } else {
+            // Cut our line off so we can copy the header name out
+            *delimpos = '\0';
+        }
+
+        // Save the header name
+        header = pa_xstrdup(response);
+    }
+    // We will have a header left from our looping itteration, so add it in :)
+    if (header) {
+        // This is not a continuation header so let's dump it into our proplist
+        pa_headerlist_puts(*response_headers, header, pa_strbuf_tostring(buf));
+    }
+    pa_strbuf_free(buf);
+
+    return 1;
+}
+
+
+pa_rtsp_context* pa_rtsp_context_new(const char* useragent) {
+    pa_rtsp_context *c;
+
+    c = pa_xnew0(pa_rtsp_context, 1);
+    c->fd = -1;
+    c->headers = pa_headerlist_new();
+
+    if (useragent)
+        c->useragent = useragent;
+    else
+        c->useragent = "PulseAudio RTSP Client";
+
+    return c;
+}
+
+
+void pa_rtsp_context_destroy(pa_rtsp_context* c) {
+    if (c) {
+        pa_xfree(c->url);
+        pa_xfree(c->session);
+        pa_xfree(c->transport);
+        pa_headerlist_free(c->headers);
+    }
+    pa_xfree(c);
+}
+
+
+int pa_rtsp_connect(pa_rtsp_context *c, const char* hostname, uint16_t port, const char* sid) {
+    struct sockaddr_in sa;
+    struct sockaddr_in name;
+    socklen_t namelen = sizeof(name);
+    struct hostent *host = NULL;
+    int r;
+
+    pa_assert(c);
+    pa_assert(hostname);
+    pa_assert(port > 0);
+    pa_assert(sid);
+
+    memset(&sa, 0, sizeof(sa));
+    sa.sin_family = AF_INET;
+    sa.sin_port = htons(port);
+
+    host = gethostbyname(hostname);
+    if (!host) {
+        unsigned int addr = inet_addr(hostname);
+        if (addr != INADDR_NONE)
+            host = gethostbyaddr((char*)&addr, 4, AF_INET);
+        if (!host)
+            return 0;
+    }
+    memcpy(&sa.sin_addr, host->h_addr, sizeof(struct in_addr));
+
+    if ((c->fd = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) {
+        pa_log("socket(): %s", pa_cstrerror(errno));
+        return 0;
+    }
+
+    // Q: is FD_CLOEXEC reqd?
+    pa_make_fd_cloexec(c->fd);
+    pa_make_tcp_socket_low_delay(c->fd);
+
+    if ((r = connect(c->fd, &sa, sizeof(struct sockaddr_in))) < 0) {
+#ifdef OS_IS_WIN32
+        if (WSAGetLastError() != EWOULDBLOCK) {
+            pa_log_debug("connect(): %d", WSAGetLastError());
+#else
+        if (errno != EINPROGRESS) {
+            pa_log_debug("connect(): %s (%d)", pa_cstrerror(errno), errno);
+#endif
+            pa_close(c->fd);
+            c->fd = -1;
+            return 0;
+        }
+    }
+
+    if (0 != getsockname(c->fd, (struct sockaddr*)&name, &namelen)) {
+        pa_close(c->fd);
+        c->fd = -1;
+        return 0;
+    }
+    memcpy(&c->local_addr, &name.sin_addr, sizeof(struct in_addr));
+    c->url = pa_sprintf_malloc("rtsp://%s/%s", inet_ntoa(name.sin_addr), sid);
+
+    return 1;
+}
+
+
+void pa_rtsp_disconnect(pa_rtsp_context *c) {
+    pa_assert(c);
+
+    if (c->fd < 0)
+      return;
+    pa_close(c->fd);
+    c->fd = -1;
+}
+
+
+const char* pa_rtsp_localip(pa_rtsp_context* c) {
+    pa_assert(c);
+
+    if (c->fd < 0)
+        return NULL;
+    return inet_ntoa(c->local_addr);
+}
+
+
+int pa_rtsp_announce(pa_rtsp_context *c, const char* sdp) {
+    pa_assert(c);
+    if (!sdp)
+        return 0;
+
+    return pa_rtsp_exec(c, "ANNOUNCE", "application/sdp", sdp, 1, NULL, NULL);
+}
+
+
+int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
+    pa_headerlist* headers;
+    pa_headerlist* rheaders;
+    char delimiters[2];
+    char* token;
+    const char* token_state;
+    const char* pc;
+
+    pa_assert(c);
+
+    headers = pa_headerlist_new();
+    rheaders = pa_headerlist_new();
+    pa_headerlist_puts(headers, "Transport", "RTP/AVP/TCP;unicast;interleaved=0-1;mode=record");
+
+    if (!pa_rtsp_exec(c, "SETUP", NULL, NULL, 1, headers, &rheaders)) {
+        pa_headerlist_free(headers);
+        pa_headerlist_free(rheaders);
+        return 0;
+    }
+    pa_headerlist_free(headers);
+
+    c->session = pa_xstrdup(pa_headerlist_gets(rheaders, "Session"));
+    c->transport = pa_xstrdup(pa_headerlist_gets(rheaders, "Transport"));
+
+    if (!c->session || !c->transport) {
+        pa_headerlist_free(rheaders);
+        return 0;
+    }
+
+    // Now parse out the server port component of the response.
+    c->port = 0;
+    delimiters[0] = ';';
+    delimiters[1] = '\0';
+    token_state = NULL;
+    while ((token = pa_split(c->transport, delimiters, &token_state))) {
+        if ((pc = strstr(token, "="))) {
+            if (0 == strncmp(token, "server_port", 11)) {
+                pa_atou(pc+1, &c->port);
+                pa_xfree(token);
+                break;
+            }
+        }
+        pa_xfree(token);
+    }
+    if (0 == c->port) {
+        // Error no server_port in response
+        pa_headerlist_free(rheaders);
+        return 0;
+    }
+
+    *response_headers = rheaders;
+    return 1;
+}
+
+
+int pa_rtsp_record(pa_rtsp_context* c) {
+    pa_headerlist* headers;
+    int rv;
+
+    pa_assert(c);
+    if (!c->session) {
+        // No seesion in progres
+        return 0;
+    }
+
+    headers = pa_headerlist_new();
+    pa_headerlist_puts(headers, "Range", "npt=0-");
+    pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
+
+    rv = pa_rtsp_exec(c, "RECORD", NULL, NULL, 1, headers, NULL);
+    pa_headerlist_free(headers);
+    return rv;
+}
+
+
+int pa_rtsp_teardown(pa_rtsp_context *c) {
+    pa_assert(c);
+
+    return pa_rtsp_exec(c, "TEARDOWN", NULL, NULL, 0, NULL, NULL);
+}
+
+
+int pa_rtsp_setparameter(pa_rtsp_context *c, const char* param) {
+    pa_assert(c);
+    if (!param)
+        return 0;
+
+    return pa_rtsp_exec(c, "SET_PARAMETER", "text/parameters", param, 1, NULL, NULL);
+}
+
+
+int pa_rtsp_flush(pa_rtsp_context *c) {
+    pa_headerlist* headers;
+    int rv;
+
+    pa_assert(c);
+
+    headers = pa_headerlist_new();
+    pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
+
+    rv = pa_rtsp_exec(c, "FLUSH", NULL, NULL, 1, headers, NULL);
+    pa_headerlist_free(headers);
+    return rv;
+}
diff --git a/src/modules/rtp/rtsp.h b/src/modules/rtp/rtsp.h
new file mode 100644
index 0000000..504f144
--- /dev/null
+++ b/src/modules/rtp/rtsp.h
@@ -0,0 +1,66 @@
+#ifndef foortsphfoo
+#define foortsphfoo
+
+/* $Id: rtp.h 1465 2007-05-29 17:24:48Z lennart $ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#include <inttypes.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netdb.h>
+
+#include <pulsecore/memblockq.h>
+#include <pulsecore/memchunk.h>
+#include <pulsecore/socket-client.h>
+
+#include "headerlist.h"
+
+typedef struct pa_rtsp_context {
+    int fd;
+    const char* useragent;
+    pa_headerlist* headers;
+    char* url;
+    uint32_t port;
+    uint32_t cseq;
+    char* session;
+    char* transport;
+    struct in_addr local_addr;
+} pa_rtsp_context;
+
+pa_rtsp_context* pa_rtsp_context_new(const char* useragent);
+void pa_rtsp_context_destroy(pa_rtsp_context* c);
+
+int pa_rtsp_connect(pa_rtsp_context* c, const char* hostname, uint16_t port, const char* sid);
+void pa_rtsp_disconnect(pa_rtsp_context* c);
+
+const char* pa_rtsp_localip(pa_rtsp_context* c);
+int pa_rtsp_announce(pa_rtsp_context* c, const char* sdp);
+
+int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers);
+int pa_rtsp_record(pa_rtsp_context* c);
+int pa_rtsp_teardown(pa_rtsp_context* c);
+
+int pa_rtsp_setparameter(pa_rtsp_context* c, const char* param);
+int pa_rtsp_flush(pa_rtsp_context* c);
+
+#endif

commit fef102e35ae4adff8ab000c628cb659c337af51d
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Thu May 1 23:43:34 2008 +0000

    Add a simple base64 library that will be used by the sink
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2334 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/base64.c b/src/modules/rtp/base64.c
new file mode 100644
index 0000000..ec9f221
--- /dev/null
+++ b/src/modules/rtp/base64.c
@@ -0,0 +1,128 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+/*
+  This file was originally inspired by a file developed by
+    Kungliga Tekniska H�gskolan
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "base64.h"
+
+static char base64_chars[] =
+    "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+
+static int pos(char c)
+{
+    char *p;
+    for (p = base64_chars; *p; p++)
+        if (*p == c)
+            return p - base64_chars;
+    return -1;
+}
+
+int pa_base64_encode(const void *data, int size, char **str)
+{
+    char *s, *p;
+    int i;
+    int c;
+    const unsigned char *q;
+
+    p = s = (char *) malloc(size * 4 / 3 + 4);
+    if (p == NULL)
+        return -1;
+    q = (const unsigned char *) data;
+    i = 0;
+    for (i = 0; i < size;) {
+        c = q[i++];
+        c *= 256;
+        if (i < size)
+            c += q[i];
+        i++;
+        c *= 256;
+        if (i < size)
+            c += q[i];
+        i++;
+        p[0] = base64_chars[(c & 0x00fc0000) >> 18];
+        p[1] = base64_chars[(c & 0x0003f000) >> 12];
+        p[2] = base64_chars[(c & 0x00000fc0) >> 6];
+        p[3] = base64_chars[(c & 0x0000003f) >> 0];
+        if (i > size)
+            p[3] = '=';
+        if (i > size + 1)
+            p[2] = '=';
+        p += 4;
+    }
+    *p = 0;
+    *str = s;
+    return strlen(s);
+}
+
+#define DECODE_ERROR 0xffffffff
+
+static unsigned int token_decode(const char *token)
+{
+    int i;
+    unsigned int val = 0;
+    int marker = 0;
+    if (strlen(token) < 4)
+        return DECODE_ERROR;
+    for (i = 0; i < 4; i++) {
+        val *= 64;
+        if (token[i] == '=')
+            marker++;
+        else if (marker > 0)
+            return DECODE_ERROR;
+        else
+            val += pos(token[i]);
+    }
+    if (marker > 2)
+        return DECODE_ERROR;
+    return (marker << 24) | val;
+}
+
+int pa_base64_decode(const char *str, void *data)
+{
+    const char *p;
+    unsigned char *q;
+
+    q = data;
+    for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) {
+        unsigned int val = token_decode(p);
+        unsigned int marker = (val >> 24) & 0xff;
+        if (val == DECODE_ERROR)
+            return -1;
+        *q++ = (val >> 16) & 0xff;
+        if (marker < 2)
+            *q++ = (val >> 8) & 0xff;
+        if (marker < 1)
+            *q++ = val & 0xff;
+    }
+    return q - (unsigned char *) data;
+}
diff --git a/src/modules/rtp/base64.h b/src/modules/rtp/base64.h
new file mode 100644
index 0000000..199c635
--- /dev/null
+++ b/src/modules/rtp/base64.h
@@ -0,0 +1,35 @@
+#ifndef foobase64hfoo
+#define foobase64hfoo
+
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+/*
+  This file was originally inspired by a file developed by
+    Kungliga Tekniska Högskolan
+*/
+
+int pa_base64_encode(const void *data, int size, char **str);
+int pa_base64_decode(const char *str, void *data);
+
+#endif

commit 6570620cc3717eb82acd19788538fda3786c7b99
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Thu May 1 23:51:45 2008 +0000

    Start the raop sink. It's based on pipe sink and isn't anywhere near finished. It does however compile.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2335 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/Makefile.am b/src/Makefile.am
index f277198..831e456 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1004,7 +1004,13 @@ libsocket_util_la_SOURCES = \
 libsocket_util_la_LDFLAGS = -avoid-version
 libsocket_util_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) libpulsecore.la
 
-librtp_la_SOURCES = modules/rtp/rtp.c modules/rtp/rtp.h modules/rtp/sdp.c modules/rtp/sdp.h modules/rtp/sap.c modules/rtp/sap.h
+librtp_la_SOURCES = \
+		modules/rtp/rtp.c modules/rtp/rtp.h \
+		modules/rtp/sdp.c modules/rtp/sdp.h \
+		modules/rtp/sap.c modules/rtp/sap.h \
+		modules/rtp/rtsp.c modules/rtp/rtsp.h \
+		modules/rtp/headerlist.c modules/rtp/headerlist.h \
+		modules/rtp/base64.c modules/rtp/base64.h
 librtp_la_LDFLAGS = -avoid-version
 librtp_la_LIBADD = $(AM_LIBADD) libpulsecore.la
 
@@ -1053,6 +1059,7 @@ modlibexec_LTLIBRARIES += \
 		module-remap-sink.la \
 		module-ladspa-sink.la \
 		module-esound-sink.la \
+		module-raop-sink.la \
 		module-tunnel-sink.la \
 		module-tunnel-source.la \
 		module-position-event-sounds.la
@@ -1199,6 +1206,7 @@ SYMDEF_FILES = \
 		modules/module-esound-compat-spawnfd-symdef.h \
 		modules/module-esound-compat-spawnpid-symdef.h \
 		modules/module-match-symdef.h \
+		modules/module-raop-sink-symdef.h \
 		modules/module-tunnel-sink-symdef.h \
 		modules/module-tunnel-source-symdef.h \
 		modules/module-null-sink-symdef.h \
@@ -1367,6 +1375,10 @@ module_match_la_SOURCES = modules/module-match.c
 module_match_la_LDFLAGS = -module -avoid-version
 module_match_la_LIBADD = $(AM_LIBADD) libpulsecore.la
 
+module_raop_sink_la_SOURCES = modules/module-raop-sink.c
+module_raop_sink_la_LDFLAGS = -module -avoid-version
+module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la
+
 module_tunnel_sink_la_SOURCES = modules/module-tunnel.c
 module_tunnel_sink_la_CFLAGS = -DTUNNEL_SINK=1 $(AM_CFLAGS)
 module_tunnel_sink_la_LDFLAGS = -module -avoid-version
diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
new file mode 100644
index 0000000..ad10d78
--- /dev/null
+++ b/src/modules/module-raop-sink.c
@@ -0,0 +1,417 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2004-2006 Lennart Poettering
+  Copyright 2008      Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <limits.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include <openssl/err.h>
+#include <openssl/rand.h>
+#include <openssl/aes.h>
+#include <openssl/rsa.h>
+#include <openssl/engine.h>
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core-error.h>
+#include <pulsecore/sink.h>
+#include <pulsecore/module.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/modargs.h>
+#include <pulsecore/log.h>
+#include <pulsecore/thread.h>
+#include <pulsecore/thread-mq.h>
+#include <pulsecore/random.h>
+#include <pulsecore/rtpoll.h>
+
+#include "rtp.h"
+#include "sdp.h"
+#include "sap.h"
+#include "rtsp.h"
+#include "base64.h"
+
+
+#include "module-raop-sink-symdef.h"
+
+#define JACK_STATUS_DISCONNECTED 0
+#define JACK_STATUS_CONNECTED 1
+
+#define JACK_TYPE_ANALOG 0
+#define JACK_TYPE_DIGITAL 1
+
+#define VOLUME_DEF -30
+#define VOLUME_MIN -144
+#define VOLUME_MAX 0
+
+
+PA_MODULE_AUTHOR("Colin Guthrie");
+PA_MODULE_DESCRIPTION("RAOP Sink (Apple Airport)");
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_USAGE(
+        "server=<address> "
+        "sink_name=<name for the sink> "
+        "format=<sample format> "
+        "channels=<number of channels> "
+        "rate=<sample rate>"
+        "channel_map=<channel map>");
+
+#define DEFAULT_SINK_NAME "airtunes"
+#define AES_CHUNKSIZE 16
+
+struct userdata {
+    pa_core *core;
+    pa_module *module;
+    pa_sink *sink;
+
+    pa_thread *thread;
+    pa_thread_mq thread_mq;
+    pa_rtpoll *rtpoll;
+
+    char *server_name;
+
+    // Encryption Related bits
+    AES_KEY aes;
+    uint8_t aes_iv[AES_CHUNKSIZE]; // initialization vector for aes-cbc
+    uint8_t aes_nv[AES_CHUNKSIZE]; // next vector for aes-cbc
+    uint8_t aes_key[AES_CHUNKSIZE]; // key for aes-cbc
+
+    pa_rtsp_context *rtsp;
+    //pa_socket_client *client;
+    pa_memchunk memchunk;
+
+    pa_rtpoll_item *rtpoll_item;
+};
+
+static const char* const valid_modargs[] = {
+    "server",
+    "rate",
+    "format",
+    "channels",
+    "sink_name",
+    "channel_map",
+    NULL
+};
+
+static int rsa_encrypt(uint8_t *text, int len, uint8_t *res) {
+    char n[] =
+        "59dE8qLieItsH1WgjrcFRKj6eUWqi+bGLOX1HL3U3GhC/j0Qg90u3sG/1CUtwC"
+        "5vOYvfDmFI6oSFXi5ELabWJmT2dKHzBJKa3k9ok+8t9ucRqMd6DZHJ2YCCLlDR"
+        "KSKv6kDqnw4UwPdpOMXziC/AMj3Z/lUVX1G7WSHCAWKf1zNS1eLvqr+boEjXuB"
+        "OitnZ/bDzPHrTOZz0Dew0uowxf/+sG+NCK3eQJVxqcaJ/vEHKIVd2M+5qL71yJ"
+        "Q+87X6oV3eaYvt3zWZYD6z5vYTcrtij2VZ9Zmni/UAaHqn9JdsBWLUEpVviYnh"
+        "imNVvYFZeCXg/IdTQ+x4IRdiXNv5hEew==";
+    char e[] = "AQAB";
+    uint8_t modules[256];
+    uint8_t exponent[8];
+    int size;
+    RSA *rsa;
+
+    rsa = RSA_new();
+    size = pa_base64_decode(n, modules);
+    rsa->n = BN_bin2bn(modules, size, NULL);
+    size = pa_base64_decode(e, exponent);
+    rsa->e = BN_bin2bn(exponent, size, NULL);
+
+    size = RSA_public_encrypt(len, text, res, rsa, RSA_PKCS1_OAEP_PADDING);
+    RSA_free(rsa);
+    return size;
+}
+
+static int aes_encrypt(struct userdata *u, uint8_t *data, int size)
+{
+    uint8_t *buf;
+    int i=0, j;
+
+    pa_assert(u);
+
+    memcpy(u->aes_nv, u->aes_iv, AES_CHUNKSIZE);
+    while (i+AES_CHUNKSIZE <= size) {
+        buf = data + i;
+        for (j=0; j<AES_CHUNKSIZE; ++j)
+            buf[j] ^= u->aes_nv[j];
+
+        AES_encrypt(buf, buf, &u->aes);
+        memcpy(u->aes_nv, buf, AES_CHUNKSIZE);
+        i += AES_CHUNKSIZE;
+    }
+    return i;
+}
+
+static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
+    struct userdata *u = PA_SINK(o)->userdata;
+
+    switch (code) {
+
+        case PA_SINK_MESSAGE_GET_LATENCY: {
+            size_t n = 0;
+            //int l;
+
+#ifdef TIOCINQ
+            /*
+            if (ioctl(u->fd, TIOCINQ, &l) >= 0 && l > 0)
+                n = (size_t) l;
+            */
+#endif
+
+            n += u->memchunk.length;
+
+            *((pa_usec_t*) data) = pa_bytes_to_usec(n, &u->sink->sample_spec);
+            break;
+        }
+    }
+
+    return pa_sink_process_msg(o, code, data, offset, chunk);
+}
+
+static void thread_func(void *userdata) {
+    struct userdata *u = userdata;
+    //int write_type = 0;
+
+    pa_assert(u);
+
+    pa_log_debug("Thread starting up");
+
+    pa_thread_mq_install(&u->thread_mq);
+    pa_rtpoll_install(u->rtpoll);
+
+    for (;;) {
+        struct pollfd *pollfd;
+        int ret;
+
+        pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+
+        /* Render some data and write it to the fifo */
+        if (u->sink->thread_info.state == PA_SINK_RUNNING && pollfd->revents) {
+            ssize_t l;
+            void *p;
+
+            if (u->memchunk.length <= 0)
+                pa_sink_render(u->sink, PIPE_BUF, &u->memchunk);
+
+            pa_assert(u->memchunk.length > 0);
+
+            p = pa_memblock_acquire(u->memchunk.memblock);
+            //l = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, u->memchunk.length, &write_type);
+            // Fake the length of the "write".
+            l = u->memchunk.length;
+            pa_memblock_release(u->memchunk.memblock);
+
+            pa_assert(l != 0);
+
+            if (l < 0) {
+
+                if (errno == EINTR)
+                    continue;
+                else if (errno != EAGAIN) {
+                    pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
+                    goto fail;
+                }
+
+            } else {
+
+                u->memchunk.index += l;
+                u->memchunk.length -= l;
+
+                if (u->memchunk.length <= 0) {
+                    pa_memblock_unref(u->memchunk.memblock);
+                    pa_memchunk_reset(&u->memchunk);
+                }
+
+                pollfd->revents = 0;
+            }
+        }
+
+        /* Hmm, nothing to do. Let's sleep */
+        pollfd->events = u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0;
+
+        if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
+            goto fail;
+
+        if (ret == 0)
+            goto finish;
+
+        pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+
+        if (pollfd->revents & ~POLLOUT) {
+            pa_log("FIFO shutdown.");
+            goto fail;
+        }
+    }
+
+fail:
+    /* If this was no regular exit from the loop we have to continue
+     * processing messages until we received PA_MESSAGE_SHUTDOWN */
+    pa_asyncmsgq_post(u->thread_mq.outq, PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL, NULL);
+    pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN);
+
+finish:
+    pa_log_debug("Thread shutting down");
+}
+
+int pa__init(pa_module*m) {
+    struct userdata *u;
+    //struct stat st;
+    pa_sample_spec ss;
+    pa_channel_map map;
+    pa_modargs *ma;
+    char *t;
+    struct pollfd *pollfd;
+
+    pa_assert(m);
+
+    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
+        pa_log("Failed to parse module arguments.");
+        goto fail;
+    }
+
+    ss = m->core->default_sample_spec;
+    if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
+        pa_log("Invalid sample format specification or channel map");
+        goto fail;
+    }
+
+    u = pa_xnew0(struct userdata, 1);
+    u->core = m->core;
+    u->module = m;
+    m->userdata = u;
+
+    // Initialise the AES encryption system
+    pa_random_seed();
+    pa_random(u->aes_iv, sizeof(u->aes_iv));
+    pa_random(u->aes_key, sizeof(u->aes_key));
+    memcpy(u->aes_nv, u->aes_iv, sizeof(u->aes_nv));
+    AES_set_encrypt_key(u->aes_key, 128, &u->aes);
+
+    pa_memchunk_reset(&u->memchunk);
+    pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
+    u->rtpoll = pa_rtpoll_new();
+    pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY, u->thread_mq.inq);
+
+    u->server_name = pa_xstrdup(pa_modargs_get_value(ma, "server", NULL));
+
+    // Open a connection to the server... this is just to connect and test....
+    /*
+    mkfifo(u->filename, 0666);
+    if ((u->fd = open(u->filename, O_RDWR|O_NOCTTY)) < 0) {
+        pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno));
+        goto fail;
+    }
+
+    pa_make_fd_cloexec(u->fd);
+    pa_make_fd_nonblock(u->fd);
+
+    if (fstat(u->fd, &st) < 0) {
+        pa_log("fstat('%s'): %s", u->filename, pa_cstrerror(errno));
+        goto fail;
+    }
+
+    if (!S_ISFIFO(st.st_mode)) {
+        pa_log("'%s' is not a FIFO.", u->filename);
+        goto fail;
+    }
+    */
+    if (!(u->sink = pa_sink_new(m->core, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
+        pa_log("Failed to create sink.");
+        goto fail;
+    }
+
+    u->sink->parent.process_msg = sink_process_msg;
+    u->sink->userdata = u;
+    u->sink->flags = PA_SINK_LATENCY;
+
+    pa_sink_set_module(u->sink, m);
+    pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
+    pa_sink_set_rtpoll(u->sink, u->rtpoll);
+    pa_sink_set_description(u->sink, t = pa_sprintf_malloc("Airtunes sink '%s'", u->server_name));
+    pa_xfree(t);
+
+    u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
+    pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+    //pollfd->fd = u->fd;
+    pollfd->events = pollfd->revents = 0;
+
+    if (!(u->thread = pa_thread_new(thread_func, u))) {
+        pa_log("Failed to create thread.");
+        goto fail;
+    }
+
+    pa_sink_put(u->sink);
+
+    pa_modargs_free(ma);
+
+    return 0;
+
+fail:
+    if (ma)
+        pa_modargs_free(ma);
+
+    pa__done(m);
+
+    return -1;
+}
+
+void pa__done(pa_module*m) {
+    struct userdata *u;
+
+    pa_assert(m);
+
+    if (!(u = m->userdata))
+        return;
+
+    if (u->sink)
+        pa_sink_unlink(u->sink);
+
+    if (u->thread) {
+        pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);
+        pa_thread_free(u->thread);
+    }
+
+    pa_thread_mq_done(&u->thread_mq);
+
+    if (u->sink)
+        pa_sink_unref(u->sink);
+
+    if (u->memchunk.memblock)
+       pa_memblock_unref(u->memchunk.memblock);
+
+    if (u->rtpoll_item)
+        pa_rtpoll_item_free(u->rtpoll_item);
+
+    if (u->rtpoll)
+        pa_rtpoll_free(u->rtpoll);
+
+    pa_xfree(u->server_name);
+    pa_xfree(u);
+}

commit 91edf9eaca3a0da83484c9c3787beff2cc7a5945
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Fri May 2 09:47:09 2008 +0000

    Use pa_sprintf_malloc to do simple concatenation rather than using the higher overhead of pa_strbuf
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2348 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/headerlist.c b/src/modules/rtp/headerlist.c
index 9ea17ae..8bdc725 100644
--- a/src/modules/rtp/headerlist.c
+++ b/src/modules/rtp/headerlist.c
@@ -92,22 +92,20 @@ int pa_headerlist_puts(pa_headerlist *p, const char *key, const char *value) {
 int pa_headerlist_putsappend(pa_headerlist *p, const char *key, const char *value) {
     struct header *hdr;
     pa_bool_t add = FALSE;
-    pa_strbuf *buf;
 
     pa_assert(p);
     pa_assert(key);
 
-    buf = pa_strbuf_new();
     if (!(hdr = pa_hashmap_get(MAKE_HASHMAP(p), key))) {
         hdr = pa_xnew(struct header, 1);
         hdr->key = pa_xstrdup(key);
+        hdr->value = pa_xstrdup(value);
         add = TRUE;
     } else {
-        pa_strbuf_puts(buf, hdr->value);
+        void *newval = (void*)pa_sprintf_malloc("%s%s", (char*)hdr->value, value);
         pa_xfree(hdr->value);
+        hdr->value = newval;
     }
-    pa_strbuf_puts(buf, value);
-    hdr->value = pa_strbuf_tostring_free(buf);
     hdr->nbytes = strlen(hdr->value)+1;
 
     if (add)

commit ce9a41ef06e0b6c619b985415ccac6f0fddd68b8
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Fri May 2 09:49:28 2008 +0000

    Use _free rather than _destroy so as not to mix naming conventions.
    
    Convert C++ comments to C.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2349 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index 3fd1ba0..6168871 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -75,12 +75,12 @@ static int pa_read_line(int fd, char *line, int maxlen, int timeout)
         if (-1 == rval) {
             if (EAGAIN == errno)
                 return 0;
-            //ERRMSG("%s:read error: %s\n", __func__, strerror(errno));
+            /*ERRMSG("%s:read error: %s\n", __func__, strerror(errno));*/
             return -1;
         }
 
         if (0 == rval) {
-            //INFMSG("%s:disconnected on the other end\n", __func__);
+            /*INFMSG("%s:disconnected on the other end\n", __func__);*/
             return -1;
         }
 
@@ -131,7 +131,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     if (c->session)
         pa_strbuf_printf(buf, "Session: %s\r\n", c->session);
 
-    // Add the headers
+    /* Add the headers */
     if (headers) {
         hdrs = pa_headerlist_to_string(headers);
         pa_strbuf_puts(buf, hdrs);
@@ -157,18 +157,18 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
         pa_strbuf_puts(buf, content);
     }
 
-    // Our packet is created... now we can send it :)
+    /* Our packet is created... now we can send it :) */
     hdrs = pa_strbuf_tostring_free(buf);
     l = pa_write(c->fd, hdrs, strlen(hdrs), NULL);
     pa_xfree(hdrs);
 
-    // Do we expect a response?
+    /* Do we expect a response? */
     if (!expect_response)
         return 1;
 
     timeout = 5000;
     if (pa_read_line(c->fd, response, sizeof(response), timeout) <= 0) {
-        //ERRMSG("%s: request failed\n",__func__);
+        /*ERRMSG("%s: request failed\n",__func__);*/
         return 0;
     }
 
@@ -179,69 +179,70 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     token = pa_split(response, delimiters, &token_state);
     if (!token || strcmp(token, "200")) {
         pa_xfree(token);
-        //ERRMSG("%s: request failed, error %s\n",__func__,token);
+        /*ERRMSG("%s: request failed, error %s\n",__func__,token);*/
         return 0;
     }
     pa_xfree(token);
 
-    // We want to return the headers?
+    /* We want to return the headers? */
     if (!response_headers)
     {
-        // We have no storage, so just clear out the response.
+        /* We have no storage, so just clear out the response. */
         while (pa_read_line(c->fd, response, sizeof(response), timeout) > 0) {
-            // Reduce timeout for future requests
+            /* Reduce timeout for future requests */
             timeout = 1000;
         }
         return 1;
     }
 
+    /* TODO: Move header reading into the headerlist. */
     header = NULL;
     buf = pa_strbuf_new();
     while (pa_read_line(c->fd, response, sizeof(response), timeout) > 0) {
-        // Reduce timeout for future requests
+        /* Reduce timeout for future requests */
         timeout = 1000;
 
-        // If the first character is a space, it's a continuation header
+        /* If the first character is a space, it's a continuation header */
         if (header && ' ' == response[0]) {
-            // Add this line to the buffer (sans the space.
+            /* Add this line to the buffer (sans the space. */
             pa_strbuf_puts(buf, &(response[1]));
             continue;
         }
 
         if (header) {
-            // This is not a continuation header so let's dump the full header/value into our proplist
+            /* This is not a continuation header so let's dump the full
+               header/value into our proplist */
             pa_headerlist_puts(*response_headers, header, pa_strbuf_tostring_free(buf));
             pa_xfree(header);
-            //header = NULL;
             buf = pa_strbuf_new();
         }
 
         delimpos = strstr(response, ":");
         if (!delimpos) {
-            //ERRMSG("%s: Request failed, bad header\n",__func__);
+            /*ERRMSG("%s: Request failed, bad header\n",__func__);*/
             return 0;
         }
 
         if (strlen(delimpos) > 1) {
-            // Cut our line off so we can copy the header name out
+            /* Cut our line off so we can copy the header name out */
             *delimpos++ = '\0';
 
-            // Trim the front of any spaces
+            /* Trim the front of any spaces */
             while (' ' == *delimpos)
                 ++delimpos;
 
             pa_strbuf_puts(buf, delimpos);
         } else {
-            // Cut our line off so we can copy the header name out
+            /* Cut our line off so we can copy the header name out */
             *delimpos = '\0';
         }
 
-        // Save the header name
+        /* Save the header name */
         header = pa_xstrdup(response);
     }
-    // We will have a header left from our looping itteration, so add it in :)
+    /* We will have a header left from our looping itteration, so add it in :) */
     if (header) {
-        // This is not a continuation header so let's dump it into our proplist
+        /* This is not a continuation header so let's dump it into our proplist */
         pa_headerlist_puts(*response_headers, header, pa_strbuf_tostring(buf));
     }
     pa_strbuf_free(buf);
@@ -266,7 +267,7 @@ pa_rtsp_context* pa_rtsp_context_new(const char* useragent) {
 }
 
 
-void pa_rtsp_context_destroy(pa_rtsp_context* c) {
+void pa_rtsp_context_free(pa_rtsp_context* c) {
     if (c) {
         pa_xfree(c->url);
         pa_xfree(c->session);
@@ -308,7 +309,7 @@ int pa_rtsp_connect(pa_rtsp_context *c, const char* hostname, uint16_t port, con
         return 0;
     }
 
-    // Q: is FD_CLOEXEC reqd?
+    /* Q: is FD_CLOEXEC reqd? */
     pa_make_fd_cloexec(c->fd);
     pa_make_tcp_socket_low_delay(c->fd);
 
@@ -395,7 +396,7 @@ int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
         return 0;
     }
 
-    // Now parse out the server port component of the response.
+    /* Now parse out the server port component of the response. */
     c->port = 0;
     delimiters[0] = ';';
     delimiters[1] = '\0';
@@ -411,7 +412,7 @@ int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
         pa_xfree(token);
     }
     if (0 == c->port) {
-        // Error no server_port in response
+        /* Error no server_port in response */
         pa_headerlist_free(rheaders);
         return 0;
     }
@@ -427,7 +428,7 @@ int pa_rtsp_record(pa_rtsp_context* c) {
 
     pa_assert(c);
     if (!c->session) {
-        // No seesion in progres
+        /* No seesion in progres */
         return 0;
     }
 
diff --git a/src/modules/rtp/rtsp.h b/src/modules/rtp/rtsp.h
index 504f144..7b3df8f 100644
--- a/src/modules/rtp/rtsp.h
+++ b/src/modules/rtp/rtsp.h
@@ -48,7 +48,7 @@ typedef struct pa_rtsp_context {
 } pa_rtsp_context;
 
 pa_rtsp_context* pa_rtsp_context_new(const char* useragent);
-void pa_rtsp_context_destroy(pa_rtsp_context* c);
+void pa_rtsp_context_free(pa_rtsp_context* c);
 
 int pa_rtsp_connect(pa_rtsp_context* c, const char* hostname, uint16_t port, const char* sid);
 void pa_rtsp_disconnect(pa_rtsp_context* c);

commit 405cf720dc5190f14eee6e2eaad51aa52ff18c62
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 4 00:43:31 2008 +0000

    Convert to using pa_socket_client rather than using blocking IO.
    
    This change requires a reference to the mainloop api be passed during initial connection.
    In addition, the passing in of the session id during connect has been deprecated. A new function pa_rtsp_set_url has been added to allow the URL to be set by external code. The concept of sid is something specific to raop, not to the rtsp client.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2360 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index 6168871..3556230 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -55,12 +55,17 @@
  * if CR comes then following LF is expected
  * returned string in line is always null terminated, maxlen-1 is maximum string length
  */
-static int pa_read_line(int fd, char *line, int maxlen, int timeout)
+static int pa_read_line(pa_iochannel* io, char *line, int maxlen, int timeout)
 {
     int i, rval;
     int count;
+    int fd;
     char ch;
     struct pollfd pfds;
+
+    pa_assert(io);
+    fd = pa_iochannel_get_recv_fd(io);
+
     count = 0;
     *line = 0;
     pfds.events = POLLIN;
@@ -159,7 +164,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
 
     /* Our packet is created... now we can send it :) */
     hdrs = pa_strbuf_tostring_free(buf);
-    l = pa_write(c->fd, hdrs, strlen(hdrs), NULL);
+    l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
     pa_xfree(hdrs);
 
     /* Do we expect a response? */
@@ -167,7 +172,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
         return 1;
 
     timeout = 5000;
-    if (pa_read_line(c->fd, response, sizeof(response), timeout) <= 0) {
+    if (pa_read_line(c->io, response, sizeof(response), timeout) <= 0) {
         /*ERRMSG("%s: request failed\n",__func__);*/
         return 0;
     }
@@ -188,7 +193,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     if (!response_headers)
     {
         /* We have no storage, so just clear out the response. */
-        while (pa_read_line(c->fd, response, sizeof(response), timeout) > 0) {
+        while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
             /* Reduce timeout for future requests */
             timeout = 1000;
         }
@@ -198,7 +203,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     /* TODO: Move header reading into the headerlist. */
     header = NULL;
     buf = pa_strbuf_new();
-    while (pa_read_line(c->fd, response, sizeof(response), timeout) > 0) {
+    while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
         /* Reduce timeout for future requests */
         timeout = 1000;
 
@@ -255,7 +260,6 @@ pa_rtsp_context* pa_rtsp_context_new(const char* useragent) {
     pa_rtsp_context *c;
 
     c = pa_xnew0(pa_rtsp_context, 1);
-    c->fd = -1;
     c->headers = pa_headerlist_new();
 
     if (useragent)
@@ -269,7 +273,11 @@ pa_rtsp_context* pa_rtsp_context_new(const char* useragent) {
 
 void pa_rtsp_context_free(pa_rtsp_context* c) {
     if (c) {
+        if (c->sc)
+            pa_socket_client_unref(c->sc);
+
         pa_xfree(c->url);
+        pa_xfree(c->localip);
         pa_xfree(c->session);
         pa_xfree(c->transport);
         pa_headerlist_free(c->headers);
@@ -278,63 +286,57 @@ void pa_rtsp_context_free(pa_rtsp_context* c) {
 }
 
 
-int pa_rtsp_connect(pa_rtsp_context *c, const char* hostname, uint16_t port, const char* sid) {
-    struct sockaddr_in sa;
-    struct sockaddr_in name;
-    socklen_t namelen = sizeof(name);
-    struct hostent *host = NULL;
-    int r;
 
+static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
+    pa_rtsp_context *c = userdata;
+    union {
+        struct sockaddr sa;
+        struct sockaddr_in in;
+        struct sockaddr_in6 in6;
+    } sa;
+    socklen_t sa_len = sizeof(sa);
+
+    pa_assert(sc);
     pa_assert(c);
-    pa_assert(hostname);
-    pa_assert(port > 0);
-    pa_assert(sid);
-
-    memset(&sa, 0, sizeof(sa));
-    sa.sin_family = AF_INET;
-    sa.sin_port = htons(port);
-
-    host = gethostbyname(hostname);
-    if (!host) {
-        unsigned int addr = inet_addr(hostname);
-        if (addr != INADDR_NONE)
-            host = gethostbyaddr((char*)&addr, 4, AF_INET);
-        if (!host)
-            return 0;
-    }
-    memcpy(&sa.sin_addr, host->h_addr, sizeof(struct in_addr));
+    pa_assert(c->sc == sc);
 
-    if ((c->fd = socket(sa.sin_family, SOCK_STREAM, 0)) < 0) {
-        pa_log("socket(): %s", pa_cstrerror(errno));
-        return 0;
-    }
+    pa_socket_client_unref(c->sc);
+    c->sc = NULL;
 
-    /* Q: is FD_CLOEXEC reqd? */
-    pa_make_fd_cloexec(c->fd);
-    pa_make_tcp_socket_low_delay(c->fd);
-
-    if ((r = connect(c->fd, &sa, sizeof(struct sockaddr_in))) < 0) {
-#ifdef OS_IS_WIN32
-        if (WSAGetLastError() != EWOULDBLOCK) {
-            pa_log_debug("connect(): %d", WSAGetLastError());
-#else
-        if (errno != EINPROGRESS) {
-            pa_log_debug("connect(): %s (%d)", pa_cstrerror(errno), errno);
-#endif
-            pa_close(c->fd);
-            c->fd = -1;
-            return 0;
+    if (!io) {
+        pa_log("Connection failed: %s", pa_cstrerror(errno));
+        return;
+    }
+    pa_assert(!c->io);
+    c->io = io;
+
+    /* Get the local IP address for use externally */
+    if (0 == getsockname(pa_iochannel_get_recv_fd(io), &sa.sa, &sa_len)) {
+        char buf[INET6_ADDRSTRLEN];
+        const char *res = NULL;
+
+        if (AF_INET == sa.sa.sa_family) {
+            res = inet_ntop(sa.sa.sa_family, &sa.in.sin_addr, buf, sizeof(buf));
+        } else if (AF_INET6 == sa.sa.sa_family) {
+            res = inet_ntop(AF_INET6, &sa.in6.sin6_addr, buf, sizeof(buf));
         }
+        if (res)
+          c->localip = pa_xstrdup(res);
     }
+}
 
-    if (0 != getsockname(c->fd, (struct sockaddr*)&name, &namelen)) {
-        pa_close(c->fd);
-        c->fd = -1;
+int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port) {
+    pa_assert(c);
+    pa_assert(mainloop);
+    pa_assert(hostname);
+    pa_assert(port > 0);
+
+    if (!(c->sc = pa_socket_client_new_string(mainloop, hostname, port))) {
+        pa_log("failed to connect to server '%s:%d'", hostname, port);
         return 0;
     }
-    memcpy(&c->local_addr, &name.sin_addr, sizeof(struct in_addr));
-    c->url = pa_sprintf_malloc("rtsp://%s/%s", inet_ntoa(name.sin_addr), sid);
 
+    pa_socket_client_set_callback(c->sc, on_connection, c);
     return 1;
 }
 
@@ -342,22 +344,25 @@ int pa_rtsp_connect(pa_rtsp_context *c, const char* hostname, uint16_t port, con
 void pa_rtsp_disconnect(pa_rtsp_context *c) {
     pa_assert(c);
 
-    if (c->fd < 0)
-      return;
-    pa_close(c->fd);
-    c->fd = -1;
+    if (c->io)
+        pa_iochannel_free(c->io);
+    c->io = NULL;
 }
 
 
 const char* pa_rtsp_localip(pa_rtsp_context* c) {
     pa_assert(c);
 
-    if (c->fd < 0)
-        return NULL;
-    return inet_ntoa(c->local_addr);
+    return c->localip;
 }
 
 
+void pa_rtsp_set_url(pa_rtsp_context* c, const char* url) {
+    pa_assert(c);
+
+    c->url = pa_xstrdup(url);
+}
+
 int pa_rtsp_announce(pa_rtsp_context *c, const char* sdp) {
     pa_assert(c);
     if (!sdp)
diff --git a/src/modules/rtp/rtsp.h b/src/modules/rtp/rtsp.h
index 7b3df8f..8d86f7b 100644
--- a/src/modules/rtp/rtsp.h
+++ b/src/modules/rtp/rtsp.h
@@ -32,28 +32,31 @@
 #include <pulsecore/memblockq.h>
 #include <pulsecore/memchunk.h>
 #include <pulsecore/socket-client.h>
+#include <pulse/mainloop-api.h>
 
 #include "headerlist.h"
 
 typedef struct pa_rtsp_context {
-    int fd;
+    pa_socket_client *sc;
+    pa_iochannel *io;
     const char* useragent;
     pa_headerlist* headers;
+    char* localip;
     char* url;
     uint32_t port;
     uint32_t cseq;
     char* session;
     char* transport;
-    struct in_addr local_addr;
 } pa_rtsp_context;
 
 pa_rtsp_context* pa_rtsp_context_new(const char* useragent);
 void pa_rtsp_context_free(pa_rtsp_context* c);
 
-int pa_rtsp_connect(pa_rtsp_context* c, const char* hostname, uint16_t port, const char* sid);
+int pa_rtsp_connect(pa_rtsp_context* c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port);
 void pa_rtsp_disconnect(pa_rtsp_context* c);
 
 const char* pa_rtsp_localip(pa_rtsp_context* c);
+void pa_rtsp_set_url(pa_rtsp_context* c, const char* url);
 int pa_rtsp_announce(pa_rtsp_context* c, const char* sdp);
 
 int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers);

commit 27ed970adf66ea27d3db47c2b0e138d3d7e0f0b3
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 4 01:01:52 2008 +0000

    Convert the return values to fit with the rest of pulse 0 == success, < 0 == failure
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2362 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index 3556230..9f4d5e4 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -129,7 +129,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     pa_assert(c->url);
 
     if (!cmd)
-        return 0;
+        return -1;
 
     buf = pa_strbuf_new();
     pa_strbuf_printf(buf, "%s %s RTSP/1.0\r\nCSeq: %d\r\n", cmd, c->url, ++c->cseq);
@@ -169,12 +169,12 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
 
     /* Do we expect a response? */
     if (!expect_response)
-        return 1;
+        return 0;
 
     timeout = 5000;
     if (pa_read_line(c->io, response, sizeof(response), timeout) <= 0) {
         /*ERRMSG("%s: request failed\n",__func__);*/
-        return 0;
+        return -1;
     }
 
     delimiters[0] = ' ';
@@ -185,7 +185,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     if (!token || strcmp(token, "200")) {
         pa_xfree(token);
         /*ERRMSG("%s: request failed, error %s\n",__func__,token);*/
-        return 0;
+        return -1;
     }
     pa_xfree(token);
 
@@ -197,7 +197,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
             /* Reduce timeout for future requests */
             timeout = 1000;
         }
-        return 1;
+        return 0;
     }
 
     /* TODO: Move header reading into the headerlist. */
@@ -225,7 +225,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
         delimpos = strstr(response, ":");
         if (!delimpos) {
             /*ERRMSG("%s: Request failed, bad header\n",__func__);*/
-            return 0;
+            return -1;
         }
 
         if (strlen(delimpos) > 1) {
@@ -252,7 +252,7 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     }
     pa_strbuf_free(buf);
 
-    return 1;
+    return 0;
 }
 
 
@@ -333,11 +333,11 @@ int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* h
 
     if (!(c->sc = pa_socket_client_new_string(mainloop, hostname, port))) {
         pa_log("failed to connect to server '%s:%d'", hostname, port);
-        return 0;
+        return -1;
     }
 
     pa_socket_client_set_callback(c->sc, on_connection, c);
-    return 1;
+    return 0;
 }
 
 
@@ -366,7 +366,7 @@ void pa_rtsp_set_url(pa_rtsp_context* c, const char* url) {
 int pa_rtsp_announce(pa_rtsp_context *c, const char* sdp) {
     pa_assert(c);
     if (!sdp)
-        return 0;
+        return -1;
 
     return pa_rtsp_exec(c, "ANNOUNCE", "application/sdp", sdp, 1, NULL, NULL);
 }
@@ -386,10 +386,10 @@ int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
     rheaders = pa_headerlist_new();
     pa_headerlist_puts(headers, "Transport", "RTP/AVP/TCP;unicast;interleaved=0-1;mode=record");
 
-    if (!pa_rtsp_exec(c, "SETUP", NULL, NULL, 1, headers, &rheaders)) {
+    if (pa_rtsp_exec(c, "SETUP", NULL, NULL, 1, headers, &rheaders)) {
         pa_headerlist_free(headers);
         pa_headerlist_free(rheaders);
-        return 0;
+        return -1;
     }
     pa_headerlist_free(headers);
 
@@ -398,7 +398,7 @@ int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
 
     if (!c->session || !c->transport) {
         pa_headerlist_free(rheaders);
-        return 0;
+        return -1;
     }
 
     /* Now parse out the server port component of the response. */
@@ -419,11 +419,11 @@ int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
     if (0 == c->port) {
         /* Error no server_port in response */
         pa_headerlist_free(rheaders);
-        return 0;
+        return -1;
     }
 
     *response_headers = rheaders;
-    return 1;
+    return 0;
 }
 
 
@@ -434,7 +434,7 @@ int pa_rtsp_record(pa_rtsp_context* c) {
     pa_assert(c);
     if (!c->session) {
         /* No seesion in progres */
-        return 0;
+        return -1;
     }
 
     headers = pa_headerlist_new();
@@ -457,7 +457,7 @@ int pa_rtsp_teardown(pa_rtsp_context *c) {
 int pa_rtsp_setparameter(pa_rtsp_context *c, const char* param) {
     pa_assert(c);
     if (!param)
-        return 0;
+        return -1;
 
     return pa_rtsp_exec(c, "SET_PARAMETER", "text/parameters", param, 1, NULL, NULL);
 }

commit a08d733fd149d3d927583bad0dc69104d08b0ceb
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 4 01:26:29 2008 +0000

    Fix svn properties and some minor indentation
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2363 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index 9f4d5e4..d844072 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -321,7 +321,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
             res = inet_ntop(AF_INET6, &sa.in6.sin6_addr, buf, sizeof(buf));
         }
         if (res)
-          c->localip = pa_xstrdup(res);
+            c->localip = pa_xstrdup(res);
     }
 }
 
diff --git a/src/modules/rtp/rtsp.h b/src/modules/rtp/rtsp.h
index 8d86f7b..181d085 100644
--- a/src/modules/rtp/rtsp.h
+++ b/src/modules/rtp/rtsp.h
@@ -1,7 +1,7 @@
 #ifndef foortsphfoo
 #define foortsphfoo
 
-/* $Id: rtp.h 1465 2007-05-29 17:24:48Z lennart $ */
+/* $Id$ */
 
 /***
   This file is part of PulseAudio.

commit a0d3582fb1bddbb8fb6a7da98bbfeb05b517088e
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue May 6 00:14:33 2008 +0000

    Trivial change to allocate memory using pulse methods.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2364 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/base64.c b/src/modules/rtp/base64.c
index ec9f221..043ef5a 100644
--- a/src/modules/rtp/base64.c
+++ b/src/modules/rtp/base64.c
@@ -33,6 +33,8 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <pulse/xmalloc.h>
+
 #include "base64.h"
 
 static char base64_chars[] =
@@ -54,9 +56,7 @@ int pa_base64_encode(const void *data, int size, char **str)
     int c;
     const unsigned char *q;
 
-    p = s = (char *) malloc(size * 4 / 3 + 4);
-    if (p == NULL)
-        return -1;
+    p = s = pa_xnew(char, size * 4 / 3 + 4);
     q = (const unsigned char *) data;
     i = 0;
     for (i = 0; i < size;) {

commit d423605bd9f5fb18b44fde5424b075c977de25ad
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue May 6 00:17:17 2008 +0000

    Move closer to an asynchronous structure (still some parsing code to be converted).
    
    Move type definition into .c file to keep it private
    Add more utility functions to add/remove headers and return the serverport now the structure is private.
    This commit will break the test application but I will fix that in due course
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2365 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index d844072..55d9101 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -49,6 +49,22 @@
 
 #include "rtsp.h"
 
+struct pa_rtsp_context {
+    pa_socket_client *sc;
+    pa_iochannel *io;
+    pa_rtsp_cb_t callback;
+    void* userdata;
+    const char* useragent;
+    pa_headerlist* headers;
+    char* localip;
+    char* url;
+    uint32_t port;
+    uint32_t cseq;
+    char* session;
+    char* transport;
+    pa_rtsp_state state;
+};
+
 /*
  * read one line from the file descriptor
  * timeout: msec unit, -1 for infinite
@@ -112,18 +128,10 @@ static int pa_read_line(pa_iochannel* io, char *line, int maxlen, int timeout)
 static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
                         const char* content_type, const char* content,
                         int expect_response,
-                        pa_headerlist* headers, pa_headerlist** response_headers) {
+                        pa_headerlist* headers) {
     pa_strbuf* buf;
     char* hdrs;
     ssize_t l;
-    char response[1024];
-    int timeout;
-    char* token;
-    const char* token_state;
-    char delimiters[2];
-    char* header;
-    char* delimpos;
-
 
     pa_assert(c);
     pa_assert(c->url);
@@ -167,91 +175,6 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
     l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
     pa_xfree(hdrs);
 
-    /* Do we expect a response? */
-    if (!expect_response)
-        return 0;
-
-    timeout = 5000;
-    if (pa_read_line(c->io, response, sizeof(response), timeout) <= 0) {
-        /*ERRMSG("%s: request failed\n",__func__);*/
-        return -1;
-    }
-
-    delimiters[0] = ' ';
-    delimiters[1] = '\0';
-    token_state = NULL;
-    pa_xfree(pa_split(response, delimiters, &token_state));
-    token = pa_split(response, delimiters, &token_state);
-    if (!token || strcmp(token, "200")) {
-        pa_xfree(token);
-        /*ERRMSG("%s: request failed, error %s\n",__func__,token);*/
-        return -1;
-    }
-    pa_xfree(token);
-
-    /* We want to return the headers? */
-    if (!response_headers)
-    {
-        /* We have no storage, so just clear out the response. */
-        while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
-            /* Reduce timeout for future requests */
-            timeout = 1000;
-        }
-        return 0;
-    }
-
-    /* TODO: Move header reading into the headerlist. */
-    header = NULL;
-    buf = pa_strbuf_new();
-    while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
-        /* Reduce timeout for future requests */
-        timeout = 1000;
-
-        /* If the first character is a space, it's a continuation header */
-        if (header && ' ' == response[0]) {
-            /* Add this line to the buffer (sans the space. */
-            pa_strbuf_puts(buf, &(response[1]));
-            continue;
-        }
-
-        if (header) {
-            /* This is not a continuation header so let's dump the full
-               header/value into our proplist */
-            pa_headerlist_puts(*response_headers, header, pa_strbuf_tostring_free(buf));
-            pa_xfree(header);
-            buf = pa_strbuf_new();
-        }
-
-        delimpos = strstr(response, ":");
-        if (!delimpos) {
-            /*ERRMSG("%s: Request failed, bad header\n",__func__);*/
-            return -1;
-        }
-
-        if (strlen(delimpos) > 1) {
-            /* Cut our line off so we can copy the header name out */
-            *delimpos++ = '\0';
-
-            /* Trim the front of any spaces */
-            while (' ' == *delimpos)
-                ++delimpos;
-
-            pa_strbuf_puts(buf, delimpos);
-        } else {
-            /* Cut our line off so we can copy the header name out */
-            *delimpos = '\0';
-        }
-
-        /* Save the header name */
-        header = pa_xstrdup(response);
-    }
-    /* We will have a header left from our looping itteration, so add it in :) */
-    if (header) {
-        /* This is not a continuation header so let's dump it into our proplist */
-        pa_headerlist_puts(*response_headers, header, pa_strbuf_tostring(buf));
-    }
-    pa_strbuf_free(buf);
-
     return 0;
 }
 
@@ -286,6 +209,146 @@ void pa_rtsp_context_free(pa_rtsp_context* c) {
 }
 
 
+static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
+    pa_strbuf* buf;
+    pa_headerlist* response_headers = NULL;
+    char response[1024];
+    int timeout;
+    char* token;
+    char* header;
+    char* delimpos;
+    char delimiters[] = " ";
+    pa_rtsp_context *c = userdata;
+    pa_assert(c);
+
+    /* TODO: convert this to a pa_ioline based reader */
+    if (STATE_CONNECT == c->state) {
+        response_headers = pa_headerlist_new();
+    }
+    timeout = 5000;
+    /* read in any response headers */
+    if (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
+        const char* token_state = NULL;
+
+        timeout = 1000;
+        pa_xfree(pa_split(response, delimiters, &token_state));
+        token = pa_split(response, delimiters, &token_state);
+        if (!token || strcmp(token, "200")) {
+            pa_xfree(token);
+            pa_log("Invalid Response");
+            /* TODO: Bail out completely */
+            return;
+        }
+        pa_xfree(token);
+
+        /* We want to return the headers? */
+        if (!response_headers) {
+            /* We have no storage, so just clear out the response. */
+            while (pa_read_line(c->io, response, sizeof(response), timeout) > 0);
+        } else {
+            /* TODO: Move header reading into the headerlist. */
+            header = NULL;
+            buf = pa_strbuf_new();
+            while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
+                /* If the first character is a space, it's a continuation header */
+                if (header && ' ' == response[0]) {
+                    /* Add this line to the buffer (sans the space. */
+                    pa_strbuf_puts(buf, &(response[1]));
+                    continue;
+                }
+
+                if (header) {
+                    /* This is not a continuation header so let's dump the full
+                      header/value into our proplist */
+                    pa_headerlist_puts(response_headers, header, pa_strbuf_tostring_free(buf));
+                    pa_xfree(header);
+                    buf = pa_strbuf_new();
+                }
+
+                delimpos = strstr(response, ":");
+                if (!delimpos) {
+                    pa_log("Invalid response header");
+                    return;
+                }
+
+                if (strlen(delimpos) > 1) {
+                    /* Cut our line off so we can copy the header name out */
+                    *delimpos++ = '\0';
+
+                    /* Trim the front of any spaces */
+                    while (' ' == *delimpos)
+                        ++delimpos;
+
+                    pa_strbuf_puts(buf, delimpos);
+                } else {
+                    /* Cut our line off so we can copy the header name out */
+                    *delimpos = '\0';
+                }
+
+                /* Save the header name */
+                header = pa_xstrdup(response);
+            }
+            /* We will have a header left from our looping itteration, so add it in :) */
+            if (header) {
+                /* This is not a continuation header so let's dump it into our proplist */
+                pa_headerlist_puts(response_headers, header, pa_strbuf_tostring(buf));
+            }
+            pa_strbuf_free(buf);
+        }
+    }
+
+    /* Deal with a CONNECT response */
+    if (STATE_CONNECT == c->state) {
+        const char* token_state = NULL;
+        const char* pc = NULL;
+        c->session = pa_xstrdup(pa_headerlist_gets(response_headers, "Session"));
+        c->transport = pa_xstrdup(pa_headerlist_gets(response_headers, "Transport"));
+
+        if (!c->session || !c->transport) {
+            pa_headerlist_free(response_headers);
+            return;
+        }
+
+        /* Now parse out the server port component of the response. */
+        c->port = 0;
+        delimiters[0] = ';';
+        while ((token = pa_split(c->transport, delimiters, &token_state))) {
+            if ((pc = strstr(token, "="))) {
+                if (0 == strncmp(token, "server_port", 11)) {
+                    pa_atou(pc+1, &c->port);
+                    pa_xfree(token);
+                    break;
+                }
+            }
+            pa_xfree(token);
+        }
+        if (0 == c->port) {
+            /* Error no server_port in response */
+            pa_headerlist_free(response_headers);
+            return;
+        }
+    }
+
+    /* Call our callback */
+    if (c->callback)
+        c->callback(c, c->state, response_headers, c->userdata);
+
+
+    if (response_headers)
+        pa_headerlist_free(response_headers);
+
+    /*
+    if (do_read(u) < 0 || do_write(u) < 0) {
+
+        if (u->io) {
+            pa_iochannel_free(u->io);
+            u->io = NULL;
+        }
+
+       pa_module_unload_request(u->module);
+    }
+    */
+}
 
 static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
     pa_rtsp_context *c = userdata;
@@ -309,6 +372,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
     }
     pa_assert(!c->io);
     c->io = io;
+    pa_iochannel_set_callback(c->io, io_callback, c);
 
     /* Get the local IP address for use externally */
     if (0 == getsockname(pa_iochannel_get_recv_fd(io), &sa.sa, &sa_len)) {
@@ -337,9 +401,16 @@ int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* h
     }
 
     pa_socket_client_set_callback(c->sc, on_connection, c);
+    c->state = STATE_CONNECT;
     return 0;
 }
 
+void pa_rtsp_set_callback(pa_rtsp_context *c, pa_rtsp_cb_t callback, void *userdata) {
+    pa_assert(c);
+
+    c->callback = callback;
+    c->userdata = userdata;
+}
 
 void pa_rtsp_disconnect(pa_rtsp_context *c) {
     pa_assert(c);
@@ -356,6 +427,11 @@ const char* pa_rtsp_localip(pa_rtsp_context* c) {
     return c->localip;
 }
 
+uint32_t pa_rtsp_serverport(pa_rtsp_context* c) {
+    pa_assert(c);
+
+    return c->port;
+}
 
 void pa_rtsp_set_url(pa_rtsp_context* c, const char* url) {
     pa_assert(c);
@@ -363,67 +439,46 @@ void pa_rtsp_set_url(pa_rtsp_context* c, const char* url) {
     c->url = pa_xstrdup(url);
 }
 
+void pa_rtsp_add_header(pa_rtsp_context *c, const char* key, const char* value)
+{
+    pa_assert(c);
+    pa_assert(key);
+    pa_assert(value);
+
+    pa_headerlist_puts(c->headers, key, value);
+}
+
+void pa_rtsp_remove_header(pa_rtsp_context *c, const char* key)
+{
+    pa_assert(c);
+    pa_assert(key);
+
+    pa_headerlist_remove(c->headers, key);
+}
+
 int pa_rtsp_announce(pa_rtsp_context *c, const char* sdp) {
     pa_assert(c);
     if (!sdp)
         return -1;
 
-    return pa_rtsp_exec(c, "ANNOUNCE", "application/sdp", sdp, 1, NULL, NULL);
+    c->state = STATE_ANNOUNCE;
+    return pa_rtsp_exec(c, "ANNOUNCE", "application/sdp", sdp, 1, NULL);
 }
 
 
-int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers) {
+int pa_rtsp_setup(pa_rtsp_context* c) {
     pa_headerlist* headers;
-    pa_headerlist* rheaders;
-    char delimiters[2];
-    char* token;
-    const char* token_state;
-    const char* pc;
+    int rv;
 
     pa_assert(c);
 
     headers = pa_headerlist_new();
-    rheaders = pa_headerlist_new();
     pa_headerlist_puts(headers, "Transport", "RTP/AVP/TCP;unicast;interleaved=0-1;mode=record");
 
-    if (pa_rtsp_exec(c, "SETUP", NULL, NULL, 1, headers, &rheaders)) {
-        pa_headerlist_free(headers);
-        pa_headerlist_free(rheaders);
-        return -1;
-    }
+    c->state = STATE_SETUP;
+    rv = pa_rtsp_exec(c, "SETUP", NULL, NULL, 1, headers);
     pa_headerlist_free(headers);
-
-    c->session = pa_xstrdup(pa_headerlist_gets(rheaders, "Session"));
-    c->transport = pa_xstrdup(pa_headerlist_gets(rheaders, "Transport"));
-
-    if (!c->session || !c->transport) {
-        pa_headerlist_free(rheaders);
-        return -1;
-    }
-
-    /* Now parse out the server port component of the response. */
-    c->port = 0;
-    delimiters[0] = ';';
-    delimiters[1] = '\0';
-    token_state = NULL;
-    while ((token = pa_split(c->transport, delimiters, &token_state))) {
-        if ((pc = strstr(token, "="))) {
-            if (0 == strncmp(token, "server_port", 11)) {
-                pa_atou(pc+1, &c->port);
-                pa_xfree(token);
-                break;
-            }
-        }
-        pa_xfree(token);
-    }
-    if (0 == c->port) {
-        /* Error no server_port in response */
-        pa_headerlist_free(rheaders);
-        return -1;
-    }
-
-    *response_headers = rheaders;
-    return 0;
+    return rv;
 }
 
 
@@ -441,7 +496,8 @@ int pa_rtsp_record(pa_rtsp_context* c) {
     pa_headerlist_puts(headers, "Range", "npt=0-");
     pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
 
-    rv = pa_rtsp_exec(c, "RECORD", NULL, NULL, 1, headers, NULL);
+    c->state = STATE_RECORD;
+    rv = pa_rtsp_exec(c, "RECORD", NULL, NULL, 1, headers);
     pa_headerlist_free(headers);
     return rv;
 }
@@ -450,7 +506,8 @@ int pa_rtsp_record(pa_rtsp_context* c) {
 int pa_rtsp_teardown(pa_rtsp_context *c) {
     pa_assert(c);
 
-    return pa_rtsp_exec(c, "TEARDOWN", NULL, NULL, 0, NULL, NULL);
+    c->state = STATE_TEARDOWN;
+    return pa_rtsp_exec(c, "TEARDOWN", NULL, NULL, 0, NULL);
 }
 
 
@@ -459,7 +516,8 @@ int pa_rtsp_setparameter(pa_rtsp_context *c, const char* param) {
     if (!param)
         return -1;
 
-    return pa_rtsp_exec(c, "SET_PARAMETER", "text/parameters", param, 1, NULL, NULL);
+    c->state = STATE_SET_PARAMETER;
+    return pa_rtsp_exec(c, "SET_PARAMETER", "text/parameters", param, 1, NULL);
 }
 
 
@@ -472,7 +530,8 @@ int pa_rtsp_flush(pa_rtsp_context *c) {
     headers = pa_headerlist_new();
     pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
 
-    rv = pa_rtsp_exec(c, "FLUSH", NULL, NULL, 1, headers, NULL);
+    c->state = STATE_FLUSH;
+    rv = pa_rtsp_exec(c, "FLUSH", NULL, NULL, 1, headers);
     pa_headerlist_free(headers);
     return rv;
 }
diff --git a/src/modules/rtp/rtsp.h b/src/modules/rtp/rtsp.h
index 181d085..6458f85 100644
--- a/src/modules/rtp/rtsp.h
+++ b/src/modules/rtp/rtsp.h
@@ -36,30 +36,35 @@
 
 #include "headerlist.h"
 
-typedef struct pa_rtsp_context {
-    pa_socket_client *sc;
-    pa_iochannel *io;
-    const char* useragent;
-    pa_headerlist* headers;
-    char* localip;
-    char* url;
-    uint32_t port;
-    uint32_t cseq;
-    char* session;
-    char* transport;
-} pa_rtsp_context;
+typedef struct pa_rtsp_context pa_rtsp_context;
+typedef enum {
+  STATE_CONNECT,
+  STATE_ANNOUNCE,
+  STATE_SETUP,
+  STATE_RECORD,
+  STATE_TEARDOWN,
+  STATE_SET_PARAMETER,
+  STATE_FLUSH
+} pa_rtsp_state;
+typedef void (*pa_rtsp_cb_t)(pa_rtsp_context *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);
 
 pa_rtsp_context* pa_rtsp_context_new(const char* useragent);
 void pa_rtsp_context_free(pa_rtsp_context* c);
 
 int pa_rtsp_connect(pa_rtsp_context* c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port);
+void pa_rtsp_set_callback(pa_rtsp_context *c, pa_rtsp_cb_t callback, void *userdata);
+
 void pa_rtsp_disconnect(pa_rtsp_context* c);
 
 const char* pa_rtsp_localip(pa_rtsp_context* c);
+uint32_t pa_rtsp_serverport(pa_rtsp_context* c);
 void pa_rtsp_set_url(pa_rtsp_context* c, const char* url);
+void pa_rtsp_add_header(pa_rtsp_context *c, const char* key, const char* value);
+void pa_rtsp_remove_header(pa_rtsp_context *c, const char* key);
+
 int pa_rtsp_announce(pa_rtsp_context* c, const char* sdp);
 
-int pa_rtsp_setup(pa_rtsp_context* c, pa_headerlist** response_headers);
+int pa_rtsp_setup(pa_rtsp_context* c);
 int pa_rtsp_record(pa_rtsp_context* c);
 int pa_rtsp_teardown(pa_rtsp_context* c);
 

commit 20478a4544e8ef622434c5af5dcb4c66269a7dd9
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue May 6 00:20:35 2008 +0000

    Add a skeleton raop client which builds on the rtsp client.
    
    It still requires a socket client and callback system to be added before it will be functional.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2366 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/Makefile.am b/src/Makefile.am
index 831e456..5bd6388 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1009,6 +1009,7 @@ librtp_la_SOURCES = \
 		modules/rtp/sdp.c modules/rtp/sdp.h \
 		modules/rtp/sap.c modules/rtp/sap.h \
 		modules/rtp/rtsp.c modules/rtp/rtsp.h \
+		modules/rtp/raop_client.c modules/rtp/raop_client.h \
 		modules/rtp/headerlist.c modules/rtp/headerlist.h \
 		modules/rtp/base64.c modules/rtp/base64.h
 librtp_la_LDFLAGS = -avoid-version
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
new file mode 100644
index 0000000..18e596b
--- /dev/null
+++ b/src/modules/rtp/raop_client.c
@@ -0,0 +1,308 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+
+/* TODO: Replace OpenSSL with NSS */
+#include <openssl/err.h>
+#include <openssl/rand.h>
+#include <openssl/aes.h>
+#include <openssl/rsa.h>
+#include <openssl/engine.h>
+
+#include <pulse/xmalloc.h>
+
+#include <pulsecore/core-error.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/socket-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/strbuf.h>
+#include <pulsecore/random.h>
+#include <pulsecore/poll.h>
+
+#include "raop_client.h"
+#include "rtsp.h"
+#include "base64.h"
+
+#define AES_CHUNKSIZE 16
+
+#define JACK_STATUS_DISCONNECTED 0
+#define JACK_STATUS_CONNECTED 1
+
+#define JACK_TYPE_ANALOG 0
+#define JACK_TYPE_DIGITAL 1
+
+#define VOLUME_DEF -30
+#define VOLUME_MIN -144
+#define VOLUME_MAX 0
+
+
+struct pa_raop_client {
+    pa_rtsp_context *rtsp;
+    pa_socket_client *sc;
+    const char *host;
+    char *sid;
+
+    uint8_t jack_type;
+    uint8_t jack_status;
+
+    /* Encryption Related bits */
+    AES_KEY aes;
+    uint8_t aes_iv[AES_CHUNKSIZE]; /* initialization vector for aes-cbc */
+    uint8_t aes_nv[AES_CHUNKSIZE]; /* next vector for aes-cbc */
+    uint8_t aes_key[AES_CHUNKSIZE]; /* key for aes-cbc */
+
+    pa_iochannel *io;
+    pa_iochannel_cb_t callback;
+    void* userdata;
+};
+
+static int rsa_encrypt(uint8_t *text, int len, uint8_t *res) {
+    char n[] =
+        "59dE8qLieItsH1WgjrcFRKj6eUWqi+bGLOX1HL3U3GhC/j0Qg90u3sG/1CUtwC"
+        "5vOYvfDmFI6oSFXi5ELabWJmT2dKHzBJKa3k9ok+8t9ucRqMd6DZHJ2YCCLlDR"
+        "KSKv6kDqnw4UwPdpOMXziC/AMj3Z/lUVX1G7WSHCAWKf1zNS1eLvqr+boEjXuB"
+        "OitnZ/bDzPHrTOZz0Dew0uowxf/+sG+NCK3eQJVxqcaJ/vEHKIVd2M+5qL71yJ"
+        "Q+87X6oV3eaYvt3zWZYD6z5vYTcrtij2VZ9Zmni/UAaHqn9JdsBWLUEpVviYnh"
+        "imNVvYFZeCXg/IdTQ+x4IRdiXNv5hEew==";
+    char e[] = "AQAB";
+    uint8_t modules[256];
+    uint8_t exponent[8];
+    int size;
+    RSA *rsa;
+
+    rsa = RSA_new();
+    size = pa_base64_decode(n, modules);
+    rsa->n = BN_bin2bn(modules, size, NULL);
+    size = pa_base64_decode(e, exponent);
+    rsa->e = BN_bin2bn(exponent, size, NULL);
+
+    size = RSA_public_encrypt(len, text, res, rsa, RSA_PKCS1_OAEP_PADDING);
+    RSA_free(rsa);
+    return size;
+}
+
+static int aes_encrypt(pa_raop_client* c, uint8_t *data, int size)
+{
+    uint8_t *buf;
+    int i=0, j;
+
+    pa_assert(c);
+
+    memcpy(c->aes_nv, c->aes_iv, AES_CHUNKSIZE);
+    while (i+AES_CHUNKSIZE <= size) {
+        buf = data + i;
+        for (j=0; j<AES_CHUNKSIZE; ++j)
+            buf[j] ^= c->aes_nv[j];
+
+        AES_encrypt(buf, buf, &c->aes);
+        memcpy(c->aes_nv, buf, AES_CHUNKSIZE);
+        i += AES_CHUNKSIZE;
+    }
+    return i;
+}
+
+pa_raop_client* pa_raop_client_new(void)
+{
+    pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
+    return c;
+}
+
+void pa_raop_client_free(pa_raop_client* c)
+{
+    pa_assert(c);
+    pa_xfree(c);
+}
+
+static int remove_char_from_string(char *str, char rc)
+{
+  int i=0, j=0, len;
+  int num = 0;
+  len = strlen(str);
+  while (i<len) {
+      if (str[i] == rc) {
+          for (j=i; j<len; j++)
+              str[j] = str[j+1];
+          len--;
+          num++;
+      } else {
+          i++;
+      }
+  }
+  return num;
+}
+
+static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* headers, void *userdata)
+{
+    pa_raop_client* c = userdata;
+    pa_assert(c);
+    pa_assert(rtsp);
+    pa_assert(rtsp == c->rtsp);
+
+    switch (state) {
+        case STATE_CONNECT: {
+            int i;
+            uint8_t rsakey[512];
+            char *key, *iv, *sac, *sdp;
+            uint16_t rand_data;
+            const char *ip;
+            char *url;
+
+            ip = pa_rtsp_localip(c->rtsp);
+            /* First of all set the url properly */
+            url = pa_sprintf_malloc("rtsp://%s/%s", ip, c->sid);
+            pa_rtsp_set_url(c->rtsp, url);
+            pa_xfree(url);
+
+            /* Now encrypt our aes_public key to send to the device */
+            i = rsa_encrypt(c->aes_key, AES_CHUNKSIZE, rsakey);
+            pa_base64_encode(rsakey, i, &key);
+            remove_char_from_string(key, '=');
+            pa_base64_encode(c->aes_iv, AES_CHUNKSIZE, &iv);
+            remove_char_from_string(iv, '=');
+
+            pa_random(&rand_data, sizeof(rand_data));
+            pa_base64_encode(&rand_data, AES_CHUNKSIZE, &sac);
+            remove_char_from_string(sac, '=');
+            pa_rtsp_add_header(c->rtsp, "Apple-Challenge", sac);
+            sdp = pa_sprintf_malloc(
+                "v=0\r\n"
+                "o=iTunes %s 0 IN IP4 %s\r\n"
+                "s=iTunes\r\n"
+                "c=IN IP4 %s\r\n"
+                "t=0 0\r\n"
+                "m=audio 0 RTP/AVP 96\r\n"
+                "a=rtpmap:96 AppleLossless\r\n"
+                "a=fmtp:96 4096 0 16 40 10 14 2 255 0 0 44100\r\n"
+                "a=rsaaeskey:%s\r\n"
+                "a=aesiv:%s\r\n",
+                c->sid, ip, c->host, key, iv);
+            pa_rtsp_announce(c->rtsp, sdp);
+            pa_xfree(key);
+            pa_xfree(iv);
+            pa_xfree(sac);
+            pa_xfree(sdp);
+            break;
+        }
+
+        case STATE_ANNOUNCE:
+            pa_rtsp_remove_header(c->rtsp, "Apple-Challenge");
+            pa_rtsp_setup(c->rtsp);
+            break;
+
+        case STATE_SETUP: {
+            char *aj = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Jack-Status"));
+            if (aj) {
+                char *token, *pc;
+                char delimiters[] = ";";
+                const char* token_state = NULL;
+                c->jack_type = JACK_TYPE_ANALOG;
+                c->jack_status = JACK_STATUS_DISCONNECTED;
+
+                while ((token = pa_split(aj, delimiters, &token_state))) {
+                    if ((pc = strstr(token, "="))) {
+                      *pc = 0;
+                      if (!strcmp(token, "type") && !strcmp(pc+1, "digital")) {
+                          c->jack_type = JACK_TYPE_DIGITAL;
+                      }
+                    } else {
+                        if (!strcmp(token,"connected"))
+                            c->jack_status = JACK_STATUS_CONNECTED;
+                    }
+                    pa_xfree(token);
+                }
+                pa_xfree(aj);
+                pa_rtsp_record(c->rtsp);
+            } else {
+                pa_log("Audio Jack Status missing");
+            }
+            break;
+        }
+
+        case STATE_RECORD:
+            /* Connect to the actual stream ;) */
+            /* if(raopcl_stream_connect(raopcld)) goto erexit; */
+            break;
+
+        case STATE_TEARDOWN:
+        case STATE_SET_PARAMETER:
+        case STATE_FLUSH:
+            break;
+    }
+}
+
+int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const char* host)
+{
+    char *sci;
+    struct {
+        uint32_t a;
+        uint32_t b;
+        uint32_t c;
+    } rand_data;
+
+    pa_assert(c);
+    pa_assert(host);
+
+    c->host = host;
+    c->rtsp = pa_rtsp_context_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
+
+    /* Initialise the AES encryption system */
+    pa_random_seed();
+    pa_random(c->aes_iv, sizeof(c->aes_iv));
+    pa_random(c->aes_key, sizeof(c->aes_key));
+    memcpy(c->aes_nv, c->aes_iv, sizeof(c->aes_nv));
+    AES_set_encrypt_key(c->aes_key, 128, &c->aes);
+
+    /* Generate random instance id */
+    pa_random(&rand_data, sizeof(rand_data));
+    c->sid = pa_sprintf_malloc("%u", rand_data.a);
+    sci = pa_sprintf_malloc("%08x%08x",rand_data.b, rand_data.c);
+    pa_rtsp_add_header(c->rtsp, "Client-Instance", sci);
+    pa_rtsp_set_callback(c->rtsp, rtsp_cb, c);
+    return pa_rtsp_connect(c->rtsp, mainloop, host, 5000);
+}
+
+void pa_raop_client_disconnect(pa_raop_client* c)
+{
+
+}
+
+void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsigned int count)
+{
+
+}
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
new file mode 100644
index 0000000..499b124
--- /dev/null
+++ b/src/modules/rtp/raop_client.h
@@ -0,0 +1,40 @@
+#ifndef fooraopclientfoo
+#define fooraopclientfoo
+
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as published
+  by the Free Software Foundation; either version 2 of the License,
+  or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public License
+  along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#include <pulse/mainloop-api.h>
+
+typedef struct pa_raop_client pa_raop_client;
+
+pa_raop_client* pa_raop_client_new(void);
+void pa_raop_client_free(pa_raop_client* c);
+
+int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const char* host);
+
+void pa_raop_client_disconnect(pa_raop_client* c);
+
+void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsigned int count);
+
+#endif

commit 66cf1d1f66c90b5f92d67a00ea2c1f6404453d97
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue May 6 00:25:37 2008 +0000

    Some minor tidyup to remove code now in raop client. Still nowhere near functional.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2367 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index ad10d78..f2ddf1c 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -36,11 +36,6 @@
 #include <limits.h>
 #include <sys/ioctl.h>
 #include <poll.h>
-#include <openssl/err.h>
-#include <openssl/rand.h>
-#include <openssl/aes.h>
-#include <openssl/rsa.h>
-#include <openssl/engine.h>
 
 #include <pulse/xmalloc.h>
 
@@ -58,8 +53,7 @@
 #include "rtp.h"
 #include "sdp.h"
 #include "sap.h"
-#include "rtsp.h"
-#include "base64.h"
+#include "raop_client.h"
 
 
 #include "module-raop-sink-symdef.h"
@@ -88,7 +82,6 @@ PA_MODULE_USAGE(
         "channel_map=<channel map>");
 
 #define DEFAULT_SINK_NAME "airtunes"
-#define AES_CHUNKSIZE 16
 
 struct userdata {
     pa_core *core;
@@ -101,13 +94,7 @@ struct userdata {
 
     char *server_name;
 
-    // Encryption Related bits
-    AES_KEY aes;
-    uint8_t aes_iv[AES_CHUNKSIZE]; // initialization vector for aes-cbc
-    uint8_t aes_nv[AES_CHUNKSIZE]; // next vector for aes-cbc
-    uint8_t aes_key[AES_CHUNKSIZE]; // key for aes-cbc
-
-    pa_rtsp_context *rtsp;
+    pa_raop_client *raop;
     //pa_socket_client *client;
     pa_memchunk memchunk;
 
@@ -124,51 +111,6 @@ static const char* const valid_modargs[] = {
     NULL
 };
 
-static int rsa_encrypt(uint8_t *text, int len, uint8_t *res) {
-    char n[] =
-        "59dE8qLieItsH1WgjrcFRKj6eUWqi+bGLOX1HL3U3GhC/j0Qg90u3sG/1CUtwC"
-        "5vOYvfDmFI6oSFXi5ELabWJmT2dKHzBJKa3k9ok+8t9ucRqMd6DZHJ2YCCLlDR"
-        "KSKv6kDqnw4UwPdpOMXziC/AMj3Z/lUVX1G7WSHCAWKf1zNS1eLvqr+boEjXuB"
-        "OitnZ/bDzPHrTOZz0Dew0uowxf/+sG+NCK3eQJVxqcaJ/vEHKIVd2M+5qL71yJ"
-        "Q+87X6oV3eaYvt3zWZYD6z5vYTcrtij2VZ9Zmni/UAaHqn9JdsBWLUEpVviYnh"
-        "imNVvYFZeCXg/IdTQ+x4IRdiXNv5hEew==";
-    char e[] = "AQAB";
-    uint8_t modules[256];
-    uint8_t exponent[8];
-    int size;
-    RSA *rsa;
-
-    rsa = RSA_new();
-    size = pa_base64_decode(n, modules);
-    rsa->n = BN_bin2bn(modules, size, NULL);
-    size = pa_base64_decode(e, exponent);
-    rsa->e = BN_bin2bn(exponent, size, NULL);
-
-    size = RSA_public_encrypt(len, text, res, rsa, RSA_PKCS1_OAEP_PADDING);
-    RSA_free(rsa);
-    return size;
-}
-
-static int aes_encrypt(struct userdata *u, uint8_t *data, int size)
-{
-    uint8_t *buf;
-    int i=0, j;
-
-    pa_assert(u);
-
-    memcpy(u->aes_nv, u->aes_iv, AES_CHUNKSIZE);
-    while (i+AES_CHUNKSIZE <= size) {
-        buf = data + i;
-        for (j=0; j<AES_CHUNKSIZE; ++j)
-            buf[j] ^= u->aes_nv[j];
-
-        AES_encrypt(buf, buf, &u->aes);
-        memcpy(u->aes_nv, buf, AES_CHUNKSIZE);
-        i += AES_CHUNKSIZE;
-    }
-    return i;
-}
-
 static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
     struct userdata *u = PA_SINK(o)->userdata;
 
@@ -307,13 +249,6 @@ int pa__init(pa_module*m) {
     u->module = m;
     m->userdata = u;
 
-    // Initialise the AES encryption system
-    pa_random_seed();
-    pa_random(u->aes_iv, sizeof(u->aes_iv));
-    pa_random(u->aes_key, sizeof(u->aes_key));
-    memcpy(u->aes_nv, u->aes_iv, sizeof(u->aes_nv));
-    AES_set_encrypt_key(u->aes_key, 128, &u->aes);
-
     pa_memchunk_reset(&u->memchunk);
     pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
     u->rtpoll = pa_rtpoll_new();

commit 8fb58e3a9082bafc3aa7b874d2bba9258b29cb38
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue May 6 00:28:04 2008 +0000

    Add a function for packing bits into a byte buffer. This will be needed when encoding the audio data in ALAC format.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2368 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 18e596b..fbcbe4b 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -92,6 +92,58 @@ struct pa_raop_client {
     void* userdata;
 };
 
+/**
+ * Function to write bits into a buffer.
+ * @param buffer Handle to the buffer. It will be incremented if new data requires it.
+ * @param bit_pos A pointer to a position buffer to keep track the current write location (0 for MSB, 7 for LSB)
+ * @param size A pointer to the byte size currently written. This allows the calling function to do simple buffer overflow checks
+ * @param data The data to write
+ * @param data_bit_len The number of bits from data to write
+ */
+static inline void bit_writer(uint8_t **buffer, uint8_t *bit_pos, int *size, uint8_t data, uint8_t data_bit_len) {
+    int bits_left, bit_overflow;
+    uint8_t bit_data;
+
+    if (!data_bit_len)
+        return;
+
+    /* If bit pos is zero, we will definatly use at least one bit from the current byte so size increments. */
+    if (!*bit_pos)
+        *size = 1;
+
+    /* Calc the number of bits left in the current byte of buffer */
+    bits_left = 7 - *bit_pos  + 1;
+    /* Calc the overflow of bits in relation to how much space we have left... */
+    bit_overflow = bits_left - data_bit_len;
+    if (bit_overflow >= 0) {
+        /* We can fit the new data in our current byte */
+        /* As we write from MSB->LSB we need to left shift by the overflow amount */
+        bit_data = data << bit_overflow;
+        if (*bit_pos)
+            **buffer |= bit_data;
+        else
+            **buffer = bit_data;
+        /* If our data fits exactly into the current byte, we need to increment our pointer */
+        if (0 == bit_overflow) {
+            /* Do not increment size as it will be incremeneted on next call as bit_pos is zero */
+            *buffer += 1;
+            *bit_pos = 0;
+        } else {
+            *bit_pos += data_bit_len;
+        }
+    } else {
+        /* bit_overflow is negative, there for we will need a new byte from our buffer */
+        /* Firstly fill up what's left in the current byte */
+        bit_data = data >> -bit_overflow;
+        **buffer |= bit_data;
+        /* Increment our buffer pointer and size counter*/
+        *buffer += 1;
+        *size += 1;
+        **buffer = data << (8 + bit_overflow);
+        *bit_pos = -bit_overflow;
+    }
+}
+
 static int rsa_encrypt(uint8_t *text, int len, uint8_t *res) {
     char n[] =
         "59dE8qLieItsH1WgjrcFRKj6eUWqi+bGLOX1HL3U3GhC/j0Qg90u3sG/1CUtwC"

commit 22e299ad3e16d1a2636653a7be9d625ecdc23802
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue May 6 18:39:09 2008 +0000

    Add a pa_iochannel callback for when the RAOP connection connects.
    
    Properly handle the sequence of events that establish a connection.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2369 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index fbcbe4b..8f6f259 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -73,10 +73,10 @@
 
 
 struct pa_raop_client {
-    pa_rtsp_context *rtsp;
-    pa_socket_client *sc;
+    pa_mainloop_api *mainloop;
     const char *host;
     char *sid;
+    pa_rtsp_context *rtsp;
 
     uint8_t jack_type;
     uint8_t jack_status;
@@ -87,9 +87,13 @@ struct pa_raop_client {
     uint8_t aes_nv[AES_CHUNKSIZE]; /* next vector for aes-cbc */
     uint8_t aes_key[AES_CHUNKSIZE]; /* key for aes-cbc */
 
+    pa_socket_client *sc;
     pa_iochannel *io;
     pa_iochannel_cb_t callback;
     void* userdata;
+
+    uint8_t *buffer;
+    /*pa_memchunk memchunk;*/
 };
 
 /**
@@ -219,6 +223,25 @@ static int remove_char_from_string(char *str, char rc)
   return num;
 }
 
+static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
+    pa_raop_client *c = userdata;
+
+    pa_assert(sc);
+    pa_assert(c);
+    pa_assert(c->sc == sc);
+
+    pa_socket_client_unref(c->sc);
+    c->sc = NULL;
+
+    if (!io) {
+        pa_log("Connection failed: %s", pa_cstrerror(errno));
+        return;
+    }
+    pa_assert(!c->io);
+    c->io = io;
+    pa_iochannel_set_callback(c->io, c->callback, c->userdata);
+}
+
 static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* headers, void *userdata)
 {
     pa_raop_client* c = userdata;
@@ -235,6 +258,7 @@ static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* h
             const char *ip;
             char *url;
 
+            pa_log_debug("RAOP: CONNECTED");
             ip = pa_rtsp_localip(c->rtsp);
             /* First of all set the url properly */
             url = pa_sprintf_malloc("rtsp://%s/%s", ip, c->sid);
@@ -273,12 +297,14 @@ static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* h
         }
 
         case STATE_ANNOUNCE:
+            pa_log_debug("RAOP: ANNOUNCED");
             pa_rtsp_remove_header(c->rtsp, "Apple-Challenge");
             pa_rtsp_setup(c->rtsp);
             break;
 
         case STATE_SETUP: {
             char *aj = pa_xstrdup(pa_headerlist_gets(headers, "Audio-Jack-Status"));
+            pa_log_debug("RAOP: SETUP");
             if (aj) {
                 char *token, *pc;
                 char delimiters[] = ";";
@@ -299,17 +325,24 @@ static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* h
                     pa_xfree(token);
                 }
                 pa_xfree(aj);
-                pa_rtsp_record(c->rtsp);
             } else {
-                pa_log("Audio Jack Status missing");
+                pa_log_warn("Audio Jack Status missing");
             }
+            pa_rtsp_record(c->rtsp);
             break;
         }
 
-        case STATE_RECORD:
-            /* Connect to the actual stream ;) */
-            /* if(raopcl_stream_connect(raopcld)) goto erexit; */
+        case STATE_RECORD: {
+            uint32_t port = pa_rtsp_serverport(c->rtsp);
+            pa_log_debug("RAOP: RECORDED");
+
+            if (!(c->sc = pa_socket_client_new_string(c->mainloop, c->host, port))) {
+                pa_log("failed to connect to server '%s:%d'", c->host, port);
+                return;
+            }
+            pa_socket_client_set_callback(c->sc, on_connection, c);
             break;
+        }
 
         case STATE_TEARDOWN:
         case STATE_SET_PARAMETER:
@@ -330,6 +363,7 @@ int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const c
     pa_assert(c);
     pa_assert(host);
 
+    c->mainloop = mainloop;
     c->host = host;
     c->rtsp = pa_rtsp_context_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
@@ -356,5 +390,40 @@ void pa_raop_client_disconnect(pa_raop_client* c)
 
 void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsigned int count)
 {
+    ssize_t l;
+    uint16_t len;
+    static uint8_t header[] = {
+        0x24, 0x00, 0x00, 0x00,
+        0xF0, 0xFF, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00,
+        0x00, 0x00, 0x00, 0x00,
+    };
+    const int header_size = sizeof(header);
+
+    pa_assert(c);
+    pa_assert(buffer);
+    pa_assert(count > 0);
+
+    c->buffer = pa_xrealloc(c->buffer, (count + header_size + 16));
+    memcpy(c->buffer, header, header_size);
+    len = count + header_size - 4;
+
+    /* store the lenght (endian swapped: make this better) */
+    *(c->buffer + 2) = len >> 8;
+    *(c->buffer + 3) = len & 0xff;
+
+    memcpy((c->buffer+header_size), buffer, count);
+    aes_encrypt(c, (c->buffer + header_size), count);
+    len = header_size + count;
+
+    /* TODO: move this into a memchunk/memblock and write only in callback */
+    l = pa_iochannel_write(c->io, c->buffer, len);
+}
+
+void pa_raop_client_set_callback(pa_raop_client* c, pa_iochannel_cb_t callback, void *userdata)
+{
+    pa_assert(c);
 
+    c->callback = callback;
+    c->userdata = userdata;
 }
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 499b124..99c75fd 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -25,6 +25,7 @@
 ***/
 
 #include <pulse/mainloop-api.h>
+#include <pulsecore/iochannel.h>
 
 typedef struct pa_raop_client pa_raop_client;
 
@@ -37,4 +38,6 @@ void pa_raop_client_disconnect(pa_raop_client* c);
 
 void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsigned int count);
 
+void pa_raop_client_set_callback(pa_raop_client* c, pa_iochannel_cb_t callback, void *userdata);
+
 #endif
diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index 55d9101..4f2411a 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -172,6 +172,8 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
 
     /* Our packet is created... now we can send it :) */
     hdrs = pa_strbuf_tostring_free(buf);
+    pa_log_debug("Submitting request:");
+    pa_log_debug(hdrs);
     l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
     pa_xfree(hdrs);
 
@@ -220,15 +222,22 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
     char delimiters[] = " ";
     pa_rtsp_context *c = userdata;
     pa_assert(c);
+    pa_assert(c->io == io);
+
+    if (!pa_iochannel_is_readable(c->io)) {
+        if (STATE_SETUP == c->state || STATE_ANNOUNCE == c->state) return;
+        goto do_callback;
+    }
 
     /* TODO: convert this to a pa_ioline based reader */
-    if (STATE_CONNECT == c->state) {
+    if (STATE_SETUP == c->state || STATE_ANNOUNCE == c->state) {
         response_headers = pa_headerlist_new();
     }
     timeout = 5000;
     /* read in any response headers */
     if (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
         const char* token_state = NULL;
+        pa_log_debug("Response Line: %s", response);
 
         timeout = 1000;
         pa_xfree(pa_split(response, delimiters, &token_state));
@@ -244,12 +253,15 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
         /* We want to return the headers? */
         if (!response_headers) {
             /* We have no storage, so just clear out the response. */
-            while (pa_read_line(c->io, response, sizeof(response), timeout) > 0);
+            while (pa_read_line(c->io, response, sizeof(response), timeout) > 0){
+                pa_log_debug("Response Line: %s", response);
+            }
         } else {
             /* TODO: Move header reading into the headerlist. */
             header = NULL;
             buf = pa_strbuf_new();
             while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
+                pa_log_debug("Response Line: %s", response);
                 /* If the first character is a space, it's a continuation header */
                 if (header && ' ' == response[0]) {
                     /* Add this line to the buffer (sans the space. */
@@ -297,8 +309,8 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
         }
     }
 
-    /* Deal with a CONNECT response */
-    if (STATE_CONNECT == c->state) {
+    /* Deal with a SETUP response */
+    if (STATE_SETUP == c->state) {
         const char* token_state = NULL;
         const char* pc = NULL;
         c->session = pa_xstrdup(pa_headerlist_gets(response_headers, "Session"));
@@ -330,6 +342,7 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
     }
 
     /* Call our callback */
+do_callback:
     if (c->callback)
         c->callback(c, c->state, response_headers, c->userdata);
 
@@ -387,6 +400,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
         if (res)
             c->localip = pa_xstrdup(res);
     }
+    pa_log_debug("Established RTSP connection from local ip %s", c->localip);
 }
 
 int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port) {

commit 6510d97315b9bdf7b1afc204c3dca0a2b0a3a528
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed May 7 00:35:10 2008 +0000

    Use a more stateful response parser.
    
    This makes things fully asyncronous.
    Some of the continuation headerlist stuff could be moved to headerlist for neatness, but this is OK for now.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2373 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp.c
index 4f2411a..44cd80b 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp.c
@@ -46,84 +46,35 @@
 #include <pulsecore/macro.h>
 #include <pulsecore/strbuf.h>
 #include <pulsecore/poll.h>
+#include <pulsecore/ioline.h>
 
 #include "rtsp.h"
 
 struct pa_rtsp_context {
     pa_socket_client *sc;
     pa_iochannel *io;
-    pa_rtsp_cb_t callback;
-    void* userdata;
-    const char* useragent;
-    pa_headerlist* headers;
-    char* localip;
-    char* url;
-    uint32_t port;
-    uint32_t cseq;
-    char* session;
-    char* transport;
-    pa_rtsp_state state;
-};
+    pa_ioline *ioline;
 
-/*
- * read one line from the file descriptor
- * timeout: msec unit, -1 for infinite
- * if CR comes then following LF is expected
- * returned string in line is always null terminated, maxlen-1 is maximum string length
- */
-static int pa_read_line(pa_iochannel* io, char *line, int maxlen, int timeout)
-{
-    int i, rval;
-    int count;
-    int fd;
-    char ch;
-    struct pollfd pfds;
-
-    pa_assert(io);
-    fd = pa_iochannel_get_recv_fd(io);
-
-    count = 0;
-    *line = 0;
-    pfds.events = POLLIN;
-    pfds.fd = fd;
-
-    for (i=0; i<maxlen; ++i) {
-        if (!poll(&pfds, 1, timeout))
-            return 0;
-
-        rval = read(fd, &ch, 1);
-
-        if (-1 == rval) {
-            if (EAGAIN == errno)
-                return 0;
-            /*ERRMSG("%s:read error: %s\n", __func__, strerror(errno));*/
-            return -1;
-        }
-
-        if (0 == rval) {
-            /*INFMSG("%s:disconnected on the other end\n", __func__);*/
-            return -1;
-        }
-
-        if ('\n' == ch) {
-            *line = 0;
-            return count;
-        }
-
-        if ('\r' == ch)
-            continue;
+    pa_rtsp_cb_t callback;
 
-        *line++ = ch;
-        count++;
+    void *userdata;
+    const char *useragent;
 
-        if (count >= maxlen-1)
-            break;
-    }
+    pa_rtsp_state state;
+    uint8_t waiting;
 
-    *line = 0;
-    return count;
-}
+    pa_headerlist* headers;
+    char *last_header;
+    pa_strbuf *header_buffer;
+    pa_headerlist* response_headers;
 
+    char *localip;
+    char *url;
+    uint32_t port;
+    uint32_t cseq;
+    char *session;
+    char *transport;
+};
 
 static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
                         const char* content_type, const char* content,
@@ -172,8 +123,8 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
 
     /* Our packet is created... now we can send it :) */
     hdrs = pa_strbuf_tostring_free(buf);
-    pa_log_debug("Submitting request:");
-    pa_log_debug(hdrs);
+    /*pa_log_debug("Submitting request:");
+    pa_log_debug(hdrs);*/
     l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
     pa_xfree(hdrs);
 
@@ -205,125 +156,39 @@ void pa_rtsp_context_free(pa_rtsp_context* c) {
         pa_xfree(c->localip);
         pa_xfree(c->session);
         pa_xfree(c->transport);
+        pa_xfree(c->last_header);
+        if (c->header_buffer)
+            pa_strbuf_free(c->header_buffer);
+        if (c->response_headers)
+            pa_headerlist_free(c->response_headers);
         pa_headerlist_free(c->headers);
     }
     pa_xfree(c);
 }
 
 
-static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
-    pa_strbuf* buf;
-    pa_headerlist* response_headers = NULL;
-    char response[1024];
-    int timeout;
+static void headers_read(pa_rtsp_context *c) {
     char* token;
-    char* header;
-    char* delimpos;
-    char delimiters[] = " ";
-    pa_rtsp_context *c = userdata;
-    pa_assert(c);
-    pa_assert(c->io == io);
-
-    if (!pa_iochannel_is_readable(c->io)) {
-        if (STATE_SETUP == c->state || STATE_ANNOUNCE == c->state) return;
-        goto do_callback;
-    }
-
-    /* TODO: convert this to a pa_ioline based reader */
-    if (STATE_SETUP == c->state || STATE_ANNOUNCE == c->state) {
-        response_headers = pa_headerlist_new();
-    }
-    timeout = 5000;
-    /* read in any response headers */
-    if (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
-        const char* token_state = NULL;
-        pa_log_debug("Response Line: %s", response);
-
-        timeout = 1000;
-        pa_xfree(pa_split(response, delimiters, &token_state));
-        token = pa_split(response, delimiters, &token_state);
-        if (!token || strcmp(token, "200")) {
-            pa_xfree(token);
-            pa_log("Invalid Response");
-            /* TODO: Bail out completely */
-            return;
-        }
-        pa_xfree(token);
-
-        /* We want to return the headers? */
-        if (!response_headers) {
-            /* We have no storage, so just clear out the response. */
-            while (pa_read_line(c->io, response, sizeof(response), timeout) > 0){
-                pa_log_debug("Response Line: %s", response);
-            }
-        } else {
-            /* TODO: Move header reading into the headerlist. */
-            header = NULL;
-            buf = pa_strbuf_new();
-            while (pa_read_line(c->io, response, sizeof(response), timeout) > 0) {
-                pa_log_debug("Response Line: %s", response);
-                /* If the first character is a space, it's a continuation header */
-                if (header && ' ' == response[0]) {
-                    /* Add this line to the buffer (sans the space. */
-                    pa_strbuf_puts(buf, &(response[1]));
-                    continue;
-                }
-
-                if (header) {
-                    /* This is not a continuation header so let's dump the full
-                      header/value into our proplist */
-                    pa_headerlist_puts(response_headers, header, pa_strbuf_tostring_free(buf));
-                    pa_xfree(header);
-                    buf = pa_strbuf_new();
-                }
-
-                delimpos = strstr(response, ":");
-                if (!delimpos) {
-                    pa_log("Invalid response header");
-                    return;
-                }
-
-                if (strlen(delimpos) > 1) {
-                    /* Cut our line off so we can copy the header name out */
-                    *delimpos++ = '\0';
-
-                    /* Trim the front of any spaces */
-                    while (' ' == *delimpos)
-                        ++delimpos;
+    char delimiters[] = ";";
 
-                    pa_strbuf_puts(buf, delimpos);
-                } else {
-                    /* Cut our line off so we can copy the header name out */
-                    *delimpos = '\0';
-                }
-
-                /* Save the header name */
-                header = pa_xstrdup(response);
-            }
-            /* We will have a header left from our looping itteration, so add it in :) */
-            if (header) {
-                /* This is not a continuation header so let's dump it into our proplist */
-                pa_headerlist_puts(response_headers, header, pa_strbuf_tostring(buf));
-            }
-            pa_strbuf_free(buf);
-        }
-    }
+    pa_assert(c);
+    pa_assert(c->response_headers);
 
     /* Deal with a SETUP response */
     if (STATE_SETUP == c->state) {
         const char* token_state = NULL;
         const char* pc = NULL;
-        c->session = pa_xstrdup(pa_headerlist_gets(response_headers, "Session"));
-        c->transport = pa_xstrdup(pa_headerlist_gets(response_headers, "Transport"));
+        c->session = pa_xstrdup(pa_headerlist_gets(c->response_headers, "Session"));
+        c->transport = pa_xstrdup(pa_headerlist_gets(c->response_headers, "Transport"));
 
         if (!c->session || !c->transport) {
-            pa_headerlist_free(response_headers);
+            pa_headerlist_free(c->response_headers);
+            c->response_headers = NULL;
+            pa_log("Invalid SETUP response.");
             return;
         }
 
         /* Now parse out the server port component of the response. */
-        c->port = 0;
-        delimiters[0] = ';';
         while ((token = pa_split(c->transport, delimiters, &token_state))) {
             if ((pc = strstr(token, "="))) {
                 if (0 == strncmp(token, "server_port", 11)) {
@@ -336,33 +201,117 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata) {
         }
         if (0 == c->port) {
             /* Error no server_port in response */
-            pa_headerlist_free(response_headers);
+            pa_headerlist_free(c->response_headers);
+            c->response_headers = NULL;
+            pa_log("Invalid SETUP response (no port number).");
             return;
         }
     }
 
     /* Call our callback */
-do_callback:
     if (c->callback)
-        c->callback(c, c->state, response_headers, c->userdata);
+        c->callback(c, c->state, c->response_headers, c->userdata);
 
+    pa_headerlist_free(c->response_headers);
+    c->response_headers = NULL;
+}
 
-    if (response_headers)
-        pa_headerlist_free(response_headers);
 
-    /*
-    if (do_read(u) < 0 || do_write(u) < 0) {
+static void line_callback(pa_ioline *line, const char *s, void *userdata) {
+    char *delimpos;
+    char *s2, *s2p;
 
-        if (u->io) {
-            pa_iochannel_free(u->io);
-            u->io = NULL;
+    pa_rtsp_context *c = userdata;
+    pa_assert(line);
+    pa_assert(c);
+    pa_assert(s);
+
+    s2 = pa_xstrdup(s);
+    /* Trim trailing carriage returns */
+    s2p = s2 + strlen(s2) - 1;
+    while (s2p >= s2 && '\r' == *s2p) {
+        *s2p = '\0';
+        s2p -= 1;
+    }
+    if (c->waiting && 0 == strcmp("RTSP/1.0 200 OK", s2)) {
+        c->waiting = 0;
+        pa_assert(!c->response_headers);
+        c->response_headers = pa_headerlist_new();
+        goto exit;
+    }
+    if (c->waiting) {
+        pa_log_warn("Unexpected response: %s", s2);
+        goto exit;;
+    }
+    if (!strlen(s2)) {
+        /* End of headers */
+        /* We will have a header left from our looping itteration, so add it in :) */
+        if (c->last_header) {
+            /* This is not a continuation header so let's dump it into our proplist */
+            pa_headerlist_puts(c->response_headers, c->last_header, pa_strbuf_tostring_free(c->header_buffer));
+            pa_xfree(c->last_header);
+            c->last_header = NULL;
+            c->header_buffer= NULL;
         }
 
-       pa_module_unload_request(u->module);
+        pa_log_debug("Full response received. Dispatching");
+        headers_read(c);
+        c->waiting = 1;
+        goto exit;
     }
-    */
+
+    /* Read and parse a header (we know it's not empty) */
+    /* TODO: Move header reading into the headerlist. */
+
+    /* If the first character is a space, it's a continuation header */
+    if (c->last_header && ' ' == s2[0]) {
+        pa_assert(c->header_buffer);
+
+        /* Add this line to the buffer (sans the space. */
+        pa_strbuf_puts(c->header_buffer, &(s2[1]));
+        goto exit;
+    }
+
+    if (c->last_header) {
+        /* This is not a continuation header so let's dump the full
+          header/value into our proplist */
+        pa_headerlist_puts(c->response_headers, c->last_header, pa_strbuf_tostring_free(c->header_buffer));
+        pa_xfree(c->last_header);
+        c->last_header = NULL;
+        c->header_buffer = NULL;
+    }
+
+    delimpos = strstr(s2, ":");
+    if (!delimpos) {
+        pa_log_warn("Unexpected response when expecting header: %s", s);
+        goto exit;
+    }
+
+    pa_assert(!c->header_buffer);
+    pa_assert(!c->last_header);
+
+    c->header_buffer = pa_strbuf_new();
+    if (strlen(delimpos) > 1) {
+        /* Cut our line off so we can copy the header name out */
+        *delimpos++ = '\0';
+
+        /* Trim the front of any spaces */
+        while (' ' == *delimpos)
+            ++delimpos;
+
+        pa_strbuf_puts(c->header_buffer, delimpos);
+    } else {
+        /* Cut our line off so we can copy the header name out */
+        *delimpos = '\0';
+    }
+
+    /* Save the header name */
+    c->last_header = pa_xstrdup(s2);
+  exit:
+    pa_xfree(s2);
 }
 
+
 static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
     pa_rtsp_context *c = userdata;
     union {
@@ -385,7 +334,9 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
     }
     pa_assert(!c->io);
     c->io = io;
-    pa_iochannel_set_callback(c->io, io_callback, c);
+
+    c->ioline = pa_ioline_new(io);
+    pa_ioline_set_callback(c->ioline, line_callback, c);
 
     /* Get the local IP address for use externally */
     if (0 == getsockname(pa_iochannel_get_recv_fd(io), &sa.sa, &sa_len)) {
@@ -401,6 +352,11 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
             c->localip = pa_xstrdup(res);
     }
     pa_log_debug("Established RTSP connection from local ip %s", c->localip);
+
+    c->waiting = 1;
+    c->state = STATE_CONNECT;
+    if (c->callback)
+        c->callback(c, c->state, NULL, c->userdata);
 }
 
 int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port) {

commit e596f42f39232e4e0d36c3764474f73a7ff48fbb
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed May 7 01:10:31 2008 +0000

    Wrap the io_callback to ensure that all data is written before asking for more.
    
    Fix the length type for send_sample (restrict to 16bit value)
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2374 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 8f6f259..2dd2de9 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -93,6 +93,8 @@ struct pa_raop_client {
     void* userdata;
 
     uint8_t *buffer;
+    uint8_t *buffer_index;
+    uint16_t buffer_count;
     /*pa_memchunk memchunk;*/
 };
 
@@ -205,22 +207,51 @@ void pa_raop_client_free(pa_raop_client* c)
     pa_xfree(c);
 }
 
-static int remove_char_from_string(char *str, char rc)
+static inline void rtrimchar(char *str, char rc)
 {
-  int i=0, j=0, len;
-  int num = 0;
-  len = strlen(str);
-  while (i<len) {
-      if (str[i] == rc) {
-          for (j=i; j<len; j++)
-              str[j] = str[j+1];
-          len--;
-          num++;
-      } else {
-          i++;
-      }
-  }
-  return num;
+    char *sp = str + strlen(str) - 1;
+    while (sp >= str && *sp == rc) {
+        *sp = '\0';
+        sp -= 1;
+    }
+}
+
+static int pa_raop_client_process(pa_raop_client* c)
+{
+    ssize_t l;
+
+    pa_assert(c);
+
+    if (!c->buffer_index || !c->buffer_count)
+        return 1;
+
+    if (!pa_iochannel_is_writable(c->io))
+        return 0;
+    l = pa_iochannel_write(c->io, c->buffer_index, c->buffer_count);
+    /*pa_log_debug("Wrote %d bytes (from buffer)", (int)l);*/
+    if (l == c->buffer_count) {
+        c->buffer_index = NULL;
+        c->buffer_count = 0;
+        return 1;
+    }
+    c->buffer_index += l;
+    c->buffer_count -= l;
+    /*pa_log_debug("Sill have %d bytes (in buffer)", c->buffer_count);*/
+
+    return 0;
+}
+
+static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata)
+{
+    pa_raop_client *c = userdata;
+
+    pa_assert(c);
+    pa_assert(c->io == io);
+    pa_assert(c->callback);
+
+    if (pa_raop_client_process(c)) {
+        c->callback(c->io, c->userdata);
+    }
 }
 
 static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
@@ -239,7 +270,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
     }
     pa_assert(!c->io);
     c->io = io;
-    pa_iochannel_set_callback(c->io, c->callback, c->userdata);
+    pa_iochannel_set_callback(c->io, io_callback, c);
 }
 
 static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* headers, void *userdata)
@@ -268,13 +299,13 @@ static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* h
             /* Now encrypt our aes_public key to send to the device */
             i = rsa_encrypt(c->aes_key, AES_CHUNKSIZE, rsakey);
             pa_base64_encode(rsakey, i, &key);
-            remove_char_from_string(key, '=');
+            rtrimchar(key, '=');
             pa_base64_encode(c->aes_iv, AES_CHUNKSIZE, &iv);
-            remove_char_from_string(iv, '=');
+            rtrimchar(iv, '=');
 
             pa_random(&rand_data, sizeof(rand_data));
             pa_base64_encode(&rand_data, AES_CHUNKSIZE, &sac);
-            remove_char_from_string(sac, '=');
+            rtrimchar(sac, '=');
             pa_rtsp_add_header(c->rtsp, "Apple-Challenge", sac);
             sdp = pa_sprintf_malloc(
                 "v=0\r\n"
@@ -388,7 +419,7 @@ void pa_raop_client_disconnect(pa_raop_client* c)
 
 }
 
-void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsigned int count)
+void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, uint16_t count)
 {
     ssize_t l;
     uint16_t len;
@@ -406,7 +437,7 @@ void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsign
 
     c->buffer = pa_xrealloc(c->buffer, (count + header_size + 16));
     memcpy(c->buffer, header, header_size);
-    len = count + header_size - 4;
+    len = header_size + count - 4;
 
     /* store the lenght (endian swapped: make this better) */
     *(c->buffer + 2) = len >> 8;
@@ -417,9 +448,18 @@ void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsign
     len = header_size + count;
 
     /* TODO: move this into a memchunk/memblock and write only in callback */
+    /*pa_log_debug("Channel status: %d", pa_iochannel_is_writable(c->io));
+    pa_log_debug("Writing %d bytes", len);*/
     l = pa_iochannel_write(c->io, c->buffer, len);
+    /*pa_log_debug("Wrote %d bytes", (int)l);*/
+    if (l != len) {
+        c->buffer_index = c->buffer + l;
+        c->buffer_count = len - l;
+    }
+    /*pa_log_debug("Sill have %d bytes (in buffer)", c->buffer_count);*/
 }
 
+
 void pa_raop_client_set_callback(pa_raop_client* c, pa_iochannel_cb_t callback, void *userdata)
 {
     pa_assert(c);
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 99c75fd..1dcf779 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -36,7 +36,7 @@ int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const c
 
 void pa_raop_client_disconnect(pa_raop_client* c);
 
-void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, unsigned int count);
+void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, uint16_t count);
 
 void pa_raop_client_set_callback(pa_raop_client* c, pa_iochannel_cb_t callback, void *userdata);
 

commit 41e31ab204ca48ea749c416eb270ebfa2f74b086
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed May 7 01:23:16 2008 +0000

    Rename rtsp.{c,h} to rtsp_client.{c,h}.
    
    Renate pa_rtsp_context to pa_rtsp_client.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2376 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/Makefile.am b/src/Makefile.am
index 5bd6388..9197920 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1008,7 +1008,7 @@ librtp_la_SOURCES = \
 		modules/rtp/rtp.c modules/rtp/rtp.h \
 		modules/rtp/sdp.c modules/rtp/sdp.h \
 		modules/rtp/sap.c modules/rtp/sap.h \
-		modules/rtp/rtsp.c modules/rtp/rtsp.h \
+		modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
 		modules/rtp/raop_client.c modules/rtp/raop_client.h \
 		modules/rtp/headerlist.c modules/rtp/headerlist.h \
 		modules/rtp/base64.c modules/rtp/base64.h
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 2dd2de9..7bfce93 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -56,7 +56,7 @@
 #include <pulsecore/poll.h>
 
 #include "raop_client.h"
-#include "rtsp.h"
+#include "rtsp_client.h"
 #include "base64.h"
 
 #define AES_CHUNKSIZE 16
@@ -76,7 +76,7 @@ struct pa_raop_client {
     pa_mainloop_api *mainloop;
     const char *host;
     char *sid;
-    pa_rtsp_context *rtsp;
+    pa_rtsp_client *rtsp;
 
     uint8_t jack_type;
     uint8_t jack_status;
@@ -273,7 +273,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
     pa_iochannel_set_callback(c->io, io_callback, c);
 }
 
-static void rtsp_cb(pa_rtsp_context *rtsp, pa_rtsp_state state, pa_headerlist* headers, void *userdata)
+static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* headers, void *userdata)
 {
     pa_raop_client* c = userdata;
     pa_assert(c);
@@ -396,7 +396,7 @@ int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const c
 
     c->mainloop = mainloop;
     c->host = host;
-    c->rtsp = pa_rtsp_context_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
+    c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
     pa_random_seed();
diff --git a/src/modules/rtp/rtsp.c b/src/modules/rtp/rtsp_client.c
similarity index 90%
rename from src/modules/rtp/rtsp.c
rename to src/modules/rtp/rtsp_client.c
index 44cd80b..c22f801 100644
--- a/src/modules/rtp/rtsp.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -48,9 +48,9 @@
 #include <pulsecore/poll.h>
 #include <pulsecore/ioline.h>
 
-#include "rtsp.h"
+#include "rtsp_client.h"
 
-struct pa_rtsp_context {
+struct pa_rtsp_client {
     pa_socket_client *sc;
     pa_iochannel *io;
     pa_ioline *ioline;
@@ -76,7 +76,7 @@ struct pa_rtsp_context {
     char *transport;
 };
 
-static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
+static int pa_rtsp_exec(pa_rtsp_client* c, const char* cmd,
                         const char* content_type, const char* content,
                         int expect_response,
                         pa_headerlist* headers) {
@@ -132,10 +132,10 @@ static int pa_rtsp_exec(pa_rtsp_context* c, const char* cmd,
 }
 
 
-pa_rtsp_context* pa_rtsp_context_new(const char* useragent) {
-    pa_rtsp_context *c;
+pa_rtsp_client* pa_rtsp_client_new(const char* useragent) {
+    pa_rtsp_client *c;
 
-    c = pa_xnew0(pa_rtsp_context, 1);
+    c = pa_xnew0(pa_rtsp_client, 1);
     c->headers = pa_headerlist_new();
 
     if (useragent)
@@ -147,7 +147,7 @@ pa_rtsp_context* pa_rtsp_context_new(const char* useragent) {
 }
 
 
-void pa_rtsp_context_free(pa_rtsp_context* c) {
+void pa_rtsp_client_free(pa_rtsp_client* c) {
     if (c) {
         if (c->sc)
             pa_socket_client_unref(c->sc);
@@ -167,7 +167,7 @@ void pa_rtsp_context_free(pa_rtsp_context* c) {
 }
 
 
-static void headers_read(pa_rtsp_context *c) {
+static void headers_read(pa_rtsp_client *c) {
     char* token;
     char delimiters[] = ";";
 
@@ -221,7 +221,7 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
     char *delimpos;
     char *s2, *s2p;
 
-    pa_rtsp_context *c = userdata;
+    pa_rtsp_client *c = userdata;
     pa_assert(line);
     pa_assert(c);
     pa_assert(s);
@@ -313,7 +313,7 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
 
 
 static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
-    pa_rtsp_context *c = userdata;
+    pa_rtsp_client *c = userdata;
     union {
         struct sockaddr sa;
         struct sockaddr_in in;
@@ -359,7 +359,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
         c->callback(c, c->state, NULL, c->userdata);
 }
 
-int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port) {
+int pa_rtsp_connect(pa_rtsp_client *c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port) {
     pa_assert(c);
     pa_assert(mainloop);
     pa_assert(hostname);
@@ -375,14 +375,14 @@ int pa_rtsp_connect(pa_rtsp_context *c, pa_mainloop_api *mainloop, const char* h
     return 0;
 }
 
-void pa_rtsp_set_callback(pa_rtsp_context *c, pa_rtsp_cb_t callback, void *userdata) {
+void pa_rtsp_set_callback(pa_rtsp_client *c, pa_rtsp_cb_t callback, void *userdata) {
     pa_assert(c);
 
     c->callback = callback;
     c->userdata = userdata;
 }
 
-void pa_rtsp_disconnect(pa_rtsp_context *c) {
+void pa_rtsp_disconnect(pa_rtsp_client *c) {
     pa_assert(c);
 
     if (c->io)
@@ -391,25 +391,25 @@ void pa_rtsp_disconnect(pa_rtsp_context *c) {
 }
 
 
-const char* pa_rtsp_localip(pa_rtsp_context* c) {
+const char* pa_rtsp_localip(pa_rtsp_client* c) {
     pa_assert(c);
 
     return c->localip;
 }
 
-uint32_t pa_rtsp_serverport(pa_rtsp_context* c) {
+uint32_t pa_rtsp_serverport(pa_rtsp_client* c) {
     pa_assert(c);
 
     return c->port;
 }
 
-void pa_rtsp_set_url(pa_rtsp_context* c, const char* url) {
+void pa_rtsp_set_url(pa_rtsp_client* c, const char* url) {
     pa_assert(c);
 
     c->url = pa_xstrdup(url);
 }
 
-void pa_rtsp_add_header(pa_rtsp_context *c, const char* key, const char* value)
+void pa_rtsp_add_header(pa_rtsp_client *c, const char* key, const char* value)
 {
     pa_assert(c);
     pa_assert(key);
@@ -418,7 +418,7 @@ void pa_rtsp_add_header(pa_rtsp_context *c, const char* key, const char* value)
     pa_headerlist_puts(c->headers, key, value);
 }
 
-void pa_rtsp_remove_header(pa_rtsp_context *c, const char* key)
+void pa_rtsp_remove_header(pa_rtsp_client *c, const char* key)
 {
     pa_assert(c);
     pa_assert(key);
@@ -426,7 +426,7 @@ void pa_rtsp_remove_header(pa_rtsp_context *c, const char* key)
     pa_headerlist_remove(c->headers, key);
 }
 
-int pa_rtsp_announce(pa_rtsp_context *c, const char* sdp) {
+int pa_rtsp_announce(pa_rtsp_client *c, const char* sdp) {
     pa_assert(c);
     if (!sdp)
         return -1;
@@ -436,7 +436,7 @@ int pa_rtsp_announce(pa_rtsp_context *c, const char* sdp) {
 }
 
 
-int pa_rtsp_setup(pa_rtsp_context* c) {
+int pa_rtsp_setup(pa_rtsp_client* c) {
     pa_headerlist* headers;
     int rv;
 
@@ -452,7 +452,7 @@ int pa_rtsp_setup(pa_rtsp_context* c) {
 }
 
 
-int pa_rtsp_record(pa_rtsp_context* c) {
+int pa_rtsp_record(pa_rtsp_client* c) {
     pa_headerlist* headers;
     int rv;
 
@@ -473,7 +473,7 @@ int pa_rtsp_record(pa_rtsp_context* c) {
 }
 
 
-int pa_rtsp_teardown(pa_rtsp_context *c) {
+int pa_rtsp_teardown(pa_rtsp_client *c) {
     pa_assert(c);
 
     c->state = STATE_TEARDOWN;
@@ -481,7 +481,7 @@ int pa_rtsp_teardown(pa_rtsp_context *c) {
 }
 
 
-int pa_rtsp_setparameter(pa_rtsp_context *c, const char* param) {
+int pa_rtsp_setparameter(pa_rtsp_client *c, const char* param) {
     pa_assert(c);
     if (!param)
         return -1;
@@ -491,7 +491,7 @@ int pa_rtsp_setparameter(pa_rtsp_context *c, const char* param) {
 }
 
 
-int pa_rtsp_flush(pa_rtsp_context *c) {
+int pa_rtsp_flush(pa_rtsp_client *c) {
     pa_headerlist* headers;
     int rv;
 
diff --git a/src/modules/rtp/rtsp.h b/src/modules/rtp/rtsp_client.h
similarity index 51%
rename from src/modules/rtp/rtsp.h
rename to src/modules/rtp/rtsp_client.h
index 6458f85..0f1daab 100644
--- a/src/modules/rtp/rtsp.h
+++ b/src/modules/rtp/rtsp_client.h
@@ -1,5 +1,5 @@
-#ifndef foortsphfoo
-#define foortsphfoo
+#ifndef foortspclienthfoo
+#define foortspclienthfoo
 
 /* $Id$ */
 
@@ -36,7 +36,7 @@
 
 #include "headerlist.h"
 
-typedef struct pa_rtsp_context pa_rtsp_context;
+typedef struct pa_rtsp_client pa_rtsp_client;
 typedef enum {
   STATE_CONNECT,
   STATE_ANNOUNCE,
@@ -46,29 +46,29 @@ typedef enum {
   STATE_SET_PARAMETER,
   STATE_FLUSH
 } pa_rtsp_state;
-typedef void (*pa_rtsp_cb_t)(pa_rtsp_context *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);
+typedef void (*pa_rtsp_cb_t)(pa_rtsp_client *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);
 
-pa_rtsp_context* pa_rtsp_context_new(const char* useragent);
-void pa_rtsp_context_free(pa_rtsp_context* c);
+pa_rtsp_client* pa_rtsp_client_new(const char* useragent);
+void pa_rtsp_client_free(pa_rtsp_client* c);
 
-int pa_rtsp_connect(pa_rtsp_context* c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port);
-void pa_rtsp_set_callback(pa_rtsp_context *c, pa_rtsp_cb_t callback, void *userdata);
+int pa_rtsp_connect(pa_rtsp_client* c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port);
+void pa_rtsp_set_callback(pa_rtsp_client *c, pa_rtsp_cb_t callback, void *userdata);
 
-void pa_rtsp_disconnect(pa_rtsp_context* c);
+void pa_rtsp_disconnect(pa_rtsp_client* c);
 
-const char* pa_rtsp_localip(pa_rtsp_context* c);
-uint32_t pa_rtsp_serverport(pa_rtsp_context* c);
-void pa_rtsp_set_url(pa_rtsp_context* c, const char* url);
-void pa_rtsp_add_header(pa_rtsp_context *c, const char* key, const char* value);
-void pa_rtsp_remove_header(pa_rtsp_context *c, const char* key);
+const char* pa_rtsp_localip(pa_rtsp_client* c);
+uint32_t pa_rtsp_serverport(pa_rtsp_client* c);
+void pa_rtsp_set_url(pa_rtsp_client* c, const char* url);
+void pa_rtsp_add_header(pa_rtsp_client *c, const char* key, const char* value);
+void pa_rtsp_remove_header(pa_rtsp_client *c, const char* key);
 
-int pa_rtsp_announce(pa_rtsp_context* c, const char* sdp);
+int pa_rtsp_announce(pa_rtsp_client* c, const char* sdp);
 
-int pa_rtsp_setup(pa_rtsp_context* c);
-int pa_rtsp_record(pa_rtsp_context* c);
-int pa_rtsp_teardown(pa_rtsp_context* c);
+int pa_rtsp_setup(pa_rtsp_client* c);
+int pa_rtsp_record(pa_rtsp_client* c);
+int pa_rtsp_teardown(pa_rtsp_client* c);
 
-int pa_rtsp_setparameter(pa_rtsp_context* c, const char* param);
-int pa_rtsp_flush(pa_rtsp_context* c);
+int pa_rtsp_setparameter(pa_rtsp_client* c, const char* param);
+int pa_rtsp_flush(pa_rtsp_client* c);
 
 #endif

commit 1fb046536a687e7c5eef9a440f66d111cd0e8cb4
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sat May 10 23:01:37 2008 +0000

    Combine pa_raop_client_new and pa_raop_client_connect (no point in having them separate)
    
    Convert the iochannel to an fd and do not call a pa_iochannel_cb_t callback but rather trigger the callback on connection and pass the fd.
    Change pa_raop_client_send_sample to pa_raop_client_encode_sample and work with memchunks.
    Fix a subtle size bug in the bit writer that techincally isn't triggered in normal operation.
    Clean up the _free function to actually free stuff.
    Do the actual ALAC encoding.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2394 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 7bfce93..0df80e1 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -88,8 +88,8 @@ struct pa_raop_client {
     uint8_t aes_key[AES_CHUNKSIZE]; /* key for aes-cbc */
 
     pa_socket_client *sc;
-    pa_iochannel *io;
-    pa_iochannel_cb_t callback;
+    int fd;
+    pa_raop_client_cb_t callback;
     void* userdata;
 
     uint8_t *buffer;
@@ -115,7 +115,7 @@ static inline void bit_writer(uint8_t **buffer, uint8_t *bit_pos, int *size, uin
 
     /* If bit pos is zero, we will definatly use at least one bit from the current byte so size increments. */
     if (!*bit_pos)
-        *size = 1;
+        *size += 1;
 
     /* Calc the number of bits left in the current byte of buffer */
     bits_left = 7 - *bit_pos  + 1;
@@ -195,18 +195,6 @@ static int aes_encrypt(pa_raop_client* c, uint8_t *data, int size)
     return i;
 }
 
-pa_raop_client* pa_raop_client_new(void)
-{
-    pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
-    return c;
-}
-
-void pa_raop_client_free(pa_raop_client* c)
-{
-    pa_assert(c);
-    pa_xfree(c);
-}
-
 static inline void rtrimchar(char *str, char rc)
 {
     char *sp = str + strlen(str) - 1;
@@ -216,50 +204,14 @@ static inline void rtrimchar(char *str, char rc)
     }
 }
 
-static int pa_raop_client_process(pa_raop_client* c)
-{
-    ssize_t l;
-
-    pa_assert(c);
-
-    if (!c->buffer_index || !c->buffer_count)
-        return 1;
-
-    if (!pa_iochannel_is_writable(c->io))
-        return 0;
-    l = pa_iochannel_write(c->io, c->buffer_index, c->buffer_count);
-    /*pa_log_debug("Wrote %d bytes (from buffer)", (int)l);*/
-    if (l == c->buffer_count) {
-        c->buffer_index = NULL;
-        c->buffer_count = 0;
-        return 1;
-    }
-    c->buffer_index += l;
-    c->buffer_count -= l;
-    /*pa_log_debug("Sill have %d bytes (in buffer)", c->buffer_count);*/
-
-    return 0;
-}
-
-static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void *userdata)
-{
-    pa_raop_client *c = userdata;
-
-    pa_assert(c);
-    pa_assert(c->io == io);
-    pa_assert(c->callback);
-
-    if (pa_raop_client_process(c)) {
-        c->callback(c->io, c->userdata);
-    }
-}
-
 static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata) {
     pa_raop_client *c = userdata;
 
     pa_assert(sc);
     pa_assert(c);
     pa_assert(c->sc == sc);
+    pa_assert(c->fd < 0);
+    pa_assert(c->callback);
 
     pa_socket_client_unref(c->sc);
     c->sc = NULL;
@@ -268,9 +220,16 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
         pa_log("Connection failed: %s", pa_cstrerror(errno));
         return;
     }
-    pa_assert(!c->io);
-    c->io = io;
-    pa_iochannel_set_callback(c->io, io_callback, c);
+
+    c->fd = pa_iochannel_get_send_fd(io);
+
+    pa_iochannel_set_noclose(io, TRUE);
+    pa_iochannel_free(io);
+
+    pa_make_tcp_socket_low_delay(c->fd);
+
+    pa_log_debug("Connection established");
+    c->callback(c->fd, c->userdata);
 }
 
 static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* headers, void *userdata)
@@ -382,7 +341,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
     }
 }
 
-int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const char* host)
+pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host)
 {
     char *sci;
     struct {
@@ -390,11 +349,12 @@ int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const c
         uint32_t b;
         uint32_t c;
     } rand_data;
+    pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
 
-    pa_assert(c);
     pa_assert(host);
 
     c->mainloop = mainloop;
+    c->fd = -1;
     c->host = host;
     c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
@@ -411,18 +371,41 @@ int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const c
     sci = pa_sprintf_malloc("%08x%08x",rand_data.b, rand_data.c);
     pa_rtsp_add_header(c->rtsp, "Client-Instance", sci);
     pa_rtsp_set_callback(c->rtsp, rtsp_cb, c);
-    return pa_rtsp_connect(c->rtsp, mainloop, host, 5000);
+    if (pa_rtsp_connect(c->rtsp, mainloop, host, 5000)) {
+        pa_rtsp_client_free(c->rtsp);
+        pa_xfree(c->aes_iv);
+        pa_xfree(c->aes_nv);
+        pa_xfree(c->aes_key);
+        return NULL;
+    }
+    return c;
 }
 
-void pa_raop_client_disconnect(pa_raop_client* c)
+
+void pa_raop_client_free(pa_raop_client* c)
 {
+    pa_assert(c);
 
+    pa_rtsp_client_free(c->rtsp);
+    pa_xfree(c->aes_iv);
+    pa_xfree(c->aes_nv);
+    pa_xfree(c->aes_key);
+    pa_xfree(c);
 }
 
-void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, uint16_t count)
+
+static void noop(PA_GCC_UNUSED void* p) {}
+
+pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool, pa_memchunk* raw)
 {
-    ssize_t l;
-    uint16_t len;
+    uint16_t len, bufmax;
+    uint8_t *bp, bpos;
+    uint8_t *ibp, *maxibp;
+    int size;
+    uint8_t *p;
+    uint16_t bsize;
+    pa_memchunk rv;
+    size_t length;
     static uint8_t header[] = {
         0x24, 0x00, 0x00, 0x00,
         0xF0, 0xFF, 0x00, 0x00,
@@ -432,35 +415,66 @@ void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, uint16
     const int header_size = sizeof(header);
 
     pa_assert(c);
-    pa_assert(buffer);
-    pa_assert(count > 0);
-
-    c->buffer = pa_xrealloc(c->buffer, (count + header_size + 16));
+    pa_assert(c->fd > 0);
+    pa_assert(raw);
+    pa_assert(raw->memblock);
+    pa_assert(raw->length > 0);
+
+    /* We have to send 4 byte chunks */
+    bsize = (int)(raw->length / 4);
+    length = bsize * 4;
+
+    /* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
+    bufmax = length + header_size + 16;
+    c->buffer = pa_xrealloc(c->buffer, bufmax);
     memcpy(c->buffer, header, header_size);
-    len = header_size + count - 4;
+    pa_memchunk_reset(&rv);
+    rv.memblock = pa_memblock_new_user(mempool, c->buffer, (header_size + length), noop, 1);
+
+    /* Now write the actual samples */
+    bp = c->buffer + header_size;
+    size = bpos = 0;
+    bit_writer(&bp,&bpos,&size,1,3); // channel=1, stereo
+    bit_writer(&bp,&bpos,&size,0,4); // unknown
+    bit_writer(&bp,&bpos,&size,0,8); // unknown
+    bit_writer(&bp,&bpos,&size,0,4); // unknown
+    bit_writer(&bp,&bpos,&size,1,1); // hassize
+    bit_writer(&bp,&bpos,&size,0,2); // unused
+    bit_writer(&bp,&bpos,&size,1,1); // is-not-compressed
+
+    /* size of data, integer, big endian */
+    bit_writer(&bp,&bpos,&size,(bsize>>24)&0xff,8);
+    bit_writer(&bp,&bpos,&size,(bsize>>16)&0xff,8);
+    bit_writer(&bp,&bpos,&size,(bsize>>8)&0xff,8);
+    bit_writer(&bp,&bpos,&size,(bsize)&0xff,8);
+
+    ibp = p = pa_memblock_acquire(raw->memblock);
+    maxibp = p + raw->length - 4;
+    while (ibp <= maxibp) {
+        /* Byte swap stereo data */
+        bit_writer(&bp,&bpos,&size,*(ibp+1),8);
+        bit_writer(&bp,&bpos,&size,*(ibp+0),8);
+        bit_writer(&bp,&bpos,&size,*(ibp+3),8);
+        bit_writer(&bp,&bpos,&size,*(ibp+2),8);
+        ibp += 4;
+        raw->index += 4;
+        raw->length -= 4;
+    }
+    pa_memblock_release(raw->memblock);
+    rv.length = header_size + size;
 
     /* store the lenght (endian swapped: make this better) */
+    len = size + header_size - 4;
     *(c->buffer + 2) = len >> 8;
     *(c->buffer + 3) = len & 0xff;
 
-    memcpy((c->buffer+header_size), buffer, count);
-    aes_encrypt(c, (c->buffer + header_size), count);
-    len = header_size + count;
-
-    /* TODO: move this into a memchunk/memblock and write only in callback */
-    /*pa_log_debug("Channel status: %d", pa_iochannel_is_writable(c->io));
-    pa_log_debug("Writing %d bytes", len);*/
-    l = pa_iochannel_write(c->io, c->buffer, len);
-    /*pa_log_debug("Wrote %d bytes", (int)l);*/
-    if (l != len) {
-        c->buffer_index = c->buffer + l;
-        c->buffer_count = len - l;
-    }
-    /*pa_log_debug("Sill have %d bytes (in buffer)", c->buffer_count);*/
+    /* encrypt our data */
+    aes_encrypt(c, (c->buffer + header_size), size);
+    return rv;
 }
 
 
-void pa_raop_client_set_callback(pa_raop_client* c, pa_iochannel_cb_t callback, void *userdata)
+void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata)
 {
     pa_assert(c);
 
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 1dcf779..68a1cdb 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -26,18 +26,16 @@
 
 #include <pulse/mainloop-api.h>
 #include <pulsecore/iochannel.h>
+#include <pulsecore/memchunk.h>
 
 typedef struct pa_raop_client pa_raop_client;
 
-pa_raop_client* pa_raop_client_new(void);
+pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host);
 void pa_raop_client_free(pa_raop_client* c);
 
-int pa_raop_client_connect(pa_raop_client* c, pa_mainloop_api *mainloop, const char* host);
+pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool, pa_memchunk* raw);
 
-void pa_raop_client_disconnect(pa_raop_client* c);
-
-void pa_raop_client_send_sample(pa_raop_client* c, const uint8_t* buffer, uint16_t count);
-
-void pa_raop_client_set_callback(pa_raop_client* c, pa_iochannel_cb_t callback, void *userdata);
+typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
+void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);
 
 #endif

commit f97c5debcc9564d368e6d79606df7b3ce6269d58
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 12:18:36 2008 +0000

    Properly duplicate the hostname passed in on connect.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2396 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 0df80e1..bad747b 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -355,7 +355,7 @@ pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host)
 
     c->mainloop = mainloop;
     c->fd = -1;
-    c->host = host;
+    c->host = pa_xstrdup(host);
     c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
@@ -390,6 +390,7 @@ void pa_raop_client_free(pa_raop_client* c)
     pa_xfree(c->aes_iv);
     pa_xfree(c->aes_nv);
     pa_xfree(c->aes_key);
+    pa_xfree(c->host);
     pa_xfree(c);
 }
 

commit 264a1c2ffc3b38fd88421c7d7ad9ebbab6b7e1bb
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 12:20:14 2008 +0000

    Add more libraries to librtp now that it's doing a lot more.
    
    This currently hacks in -lssl rather than writing a configure hook to detect it as I want to replace this with nss before official release.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2397 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/Makefile.am b/src/Makefile.am
index 9197920..5a9b902 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1013,7 +1013,7 @@ librtp_la_SOURCES = \
 		modules/rtp/headerlist.c modules/rtp/headerlist.h \
 		modules/rtp/base64.c modules/rtp/base64.h
 librtp_la_LDFLAGS = -avoid-version
-librtp_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+librtp_la_LIBADD = $(AM_LIBADD) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore.la -lssl
 
 # X11
 

commit d51f5944b7248ec759ab71b0e811ec0f7c655e22
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 12:21:32 2008 +0000

    A very rough first version of the sink.
    
    I can actually play music to my airport now (woot).
    Still very rough round the edges and I need to handle disconnects etc. but it's all good progress :)
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2398 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index f2ddf1c..3d08cb8 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -3,8 +3,7 @@
 /***
   This file is part of PulseAudio.
 
-  Copyright 2004-2006 Lennart Poettering
-  Copyright 2008      Colin Guthrie
+  Copyright 2008 Colin Guthrie
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
@@ -34,52 +33,50 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <limits.h>
-#include <sys/ioctl.h>
 #include <poll.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <sys/ioctl.h>
+
+#ifdef HAVE_LINUX_SOCKIOS_H
+#include <linux/sockios.h>
+#endif
 
 #include <pulse/xmalloc.h>
+#include <pulse/timeval.h>
 
 #include <pulsecore/core-error.h>
+#include <pulsecore/iochannel.h>
 #include <pulsecore/sink.h>
 #include <pulsecore/module.h>
 #include <pulsecore/core-util.h>
 #include <pulsecore/modargs.h>
 #include <pulsecore/log.h>
-#include <pulsecore/thread.h>
+#include <pulsecore/socket-client.h>
+#include <pulsecore/authkey.h>
 #include <pulsecore/thread-mq.h>
-#include <pulsecore/random.h>
-#include <pulsecore/rtpoll.h>
+#include <pulsecore/thread.h>
+#include <pulsecore/time-smoother.h>
+#include <pulsecore/rtclock.h>
+#include <pulsecore/socket-util.h>
 
+#include "module-raop-sink-symdef.h"
 #include "rtp.h"
 #include "sdp.h"
 #include "sap.h"
 #include "raop_client.h"
 
-
-#include "module-raop-sink-symdef.h"
-
-#define JACK_STATUS_DISCONNECTED 0
-#define JACK_STATUS_CONNECTED 1
-
-#define JACK_TYPE_ANALOG 0
-#define JACK_TYPE_DIGITAL 1
-
-#define VOLUME_DEF -30
-#define VOLUME_MIN -144
-#define VOLUME_MAX 0
-
-
 PA_MODULE_AUTHOR("Colin Guthrie");
-PA_MODULE_DESCRIPTION("RAOP Sink (Apple Airport)");
+PA_MODULE_DESCRIPTION("RAOP Sink (Apple Airtunes)");
 PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(FALSE);
 PA_MODULE_USAGE(
-        "server=<address> "
         "sink_name=<name for the sink> "
+        "server=<address> cookie=<filename>  "
         "format=<sample format> "
         "channels=<number of channels> "
-        "rate=<sample rate>"
-        "channel_map=<channel map>");
+        "rate=<sample rate>");
 
 #define DEFAULT_SINK_NAME "airtunes"
 
@@ -88,17 +85,35 @@ struct userdata {
     pa_module *module;
     pa_sink *sink;
 
-    pa_thread *thread;
     pa_thread_mq thread_mq;
     pa_rtpoll *rtpoll;
+    pa_rtpoll_item *rtpoll_item;
+    pa_thread *thread;
+
+    pa_memchunk raw_memchunk;
+    pa_memchunk encoded_memchunk;
+
+    void *write_data;
+    size_t write_length, write_index;
+
+    void *read_data;
+    size_t read_length, read_index;
+
+    pa_usec_t latency;
+
+    /*esd_format_t format;*/
+    int32_t rate;
+
+    pa_smoother *smoother;
+    int fd;
 
-    char *server_name;
+    int64_t offset;
+    int64_t encoding_overhead;
+    double encoding_ratio;
 
     pa_raop_client *raop;
-    //pa_socket_client *client;
-    pa_memchunk memchunk;
 
-    pa_rtpoll_item *rtpoll_item;
+    size_t block_size;
 };
 
 static const char* const valid_modargs[] = {
@@ -107,31 +122,65 @@ static const char* const valid_modargs[] = {
     "format",
     "channels",
     "sink_name",
-    "channel_map",
     NULL
 };
 
+enum {
+    SINK_MESSAGE_PASS_SOCKET = PA_SINK_MESSAGE_MAX
+};
+
 static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
     struct userdata *u = PA_SINK(o)->userdata;
 
     switch (code) {
 
+        case PA_SINK_MESSAGE_SET_STATE:
+
+            switch ((pa_sink_state_t) PA_PTR_TO_UINT(data)) {
+
+                case PA_SINK_SUSPENDED:
+                    pa_assert(PA_SINK_OPENED(u->sink->thread_info.state));
+
+                    pa_smoother_pause(u->smoother, pa_rtclock_usec());
+                    break;
+
+                case PA_SINK_IDLE:
+                case PA_SINK_RUNNING:
+
+                    if (u->sink->thread_info.state == PA_SINK_SUSPENDED)
+                        pa_smoother_resume(u->smoother, pa_rtclock_usec());
+
+                    break;
+
+                case PA_SINK_UNLINKED:
+                case PA_SINK_INIT:
+                    ;
+            }
+
+            break;
+
         case PA_SINK_MESSAGE_GET_LATENCY: {
-            size_t n = 0;
-            //int l;
-
-#ifdef TIOCINQ
-            /*
-            if (ioctl(u->fd, TIOCINQ, &l) >= 0 && l > 0)
-                n = (size_t) l;
-            */
-#endif
+            pa_usec_t w, r;
 
-            n += u->memchunk.length;
+            r = pa_smoother_get(u->smoother, pa_rtclock_usec());
+            w = pa_bytes_to_usec((u->offset - u->encoding_overhead + (u->encoded_memchunk.length / u->encoding_ratio)), &u->sink->sample_spec);
 
-            *((pa_usec_t*) data) = pa_bytes_to_usec(n, &u->sink->sample_spec);
+            *((pa_usec_t*) data) = w > r ? w - r : 0;
             break;
         }
+
+        case SINK_MESSAGE_PASS_SOCKET: {
+            struct pollfd *pollfd;
+
+            pa_assert(!u->rtpoll_item);
+
+            u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
+            pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+            pollfd->fd = u->fd;
+            pollfd->events = pollfd->revents = 0;
+
+            return 0;
+        }
     }
 
     return pa_sink_process_msg(o, code, data, offset, chunk);
@@ -139,7 +188,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
 
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
-    //int write_type = 0;
+    int write_type = 0;
 
     pa_assert(u);
 
@@ -148,55 +197,113 @@ static void thread_func(void *userdata) {
     pa_thread_mq_install(&u->thread_mq);
     pa_rtpoll_install(u->rtpoll);
 
+    pa_smoother_set_time_offset(u->smoother, pa_rtclock_usec());
+
     for (;;) {
-        struct pollfd *pollfd;
         int ret;
 
-        pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
-
-        /* Render some data and write it to the fifo */
-        if (u->sink->thread_info.state == PA_SINK_RUNNING && pollfd->revents) {
-            ssize_t l;
-            void *p;
-
-            if (u->memchunk.length <= 0)
-                pa_sink_render(u->sink, PIPE_BUF, &u->memchunk);
-
-            pa_assert(u->memchunk.length > 0);
+        if (u->rtpoll_item) {
+            struct pollfd *pollfd;
+            pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+
+            /* Render some data and write it to the fifo */
+            if (PA_SINK_OPENED(u->sink->thread_info.state) && pollfd->revents) {
+                pa_usec_t usec;
+                int64_t n;
+
+                for (;;) {
+                    ssize_t l;
+                    void *p;
+
+                    if (u->raw_memchunk.length <= 0) {
+                        /* Grab unencoded data */
+                        pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
+                    }
+                    pa_assert(u->raw_memchunk.length > 0);
+
+                    if (u->encoded_memchunk.length <= 0) {
+                        /* Encode it */
+                        size_t rl = u->raw_memchunk.length;
+                        if (u->encoded_memchunk.memblock)
+                            pa_memblock_unref(u->encoded_memchunk.memblock);
+                        u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, u->core->mempool, &u->raw_memchunk);
+                        u->encoding_overhead += (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
+                        u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
+                    }
+                    pa_assert(u->encoded_memchunk.length > 0);
+
+                    p = pa_memblock_acquire(u->encoded_memchunk.memblock);
+                    l = pa_write(u->fd, (uint8_t*) p + u->encoded_memchunk.index, u->encoded_memchunk.length, &write_type);
+                    pa_memblock_release(u->encoded_memchunk.memblock);
+
+                    pa_assert(l != 0);
+
+                    if (l < 0) {
+
+                        if (errno == EINTR)
+                            continue;
+                        else if (errno == EAGAIN) {
+
+                            /* OK, we filled all socket buffers up
+                             * now. */
+                            goto filled_up;
+
+                        } else {
+                            pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
+                            goto fail;
+                        }
+
+                    } else {
+                        u->offset += l;
+
+                        u->encoded_memchunk.index += l;
+                        u->encoded_memchunk.length -= l;
+
+                        if (u->encoded_memchunk.length <= 0) {
+                            pa_memblock_unref(u->encoded_memchunk.memblock);
+                            pa_memchunk_reset(&u->encoded_memchunk);
+                        }
+
+                        pollfd->revents = 0;
+
+                        if (u->encoded_memchunk.length > 0)
+
+                            /* OK, we wrote less that we asked for,
+                             * hence we can assume that the socket
+                             * buffers are full now */
+                            goto filled_up;
+                    }
+                }
 
-            p = pa_memblock_acquire(u->memchunk.memblock);
-            //l = pa_write(u->fd, (uint8_t*) p + u->memchunk.index, u->memchunk.length, &write_type);
-            // Fake the length of the "write".
-            l = u->memchunk.length;
-            pa_memblock_release(u->memchunk.memblock);
+            filled_up:
 
-            pa_assert(l != 0);
+                /* At this spot we know that the socket buffers are
+                 * fully filled up. This is the best time to estimate
+                 * the playback position of the server */
 
-            if (l < 0) {
+                n = u->offset;
 
-                if (errno == EINTR)
-                    continue;
-                else if (errno != EAGAIN) {
-                    pa_log("Failed to write data to FIFO: %s", pa_cstrerror(errno));
-                    goto fail;
+#ifdef SIOCOUTQ
+                {
+                    int l;
+                    if (ioctl(u->fd, SIOCOUTQ, &l) >= 0 && l > 0)
+                        n -= l;
                 }
+#endif
 
-            } else {
-
-                u->memchunk.index += l;
-                u->memchunk.length -= l;
+                usec = pa_bytes_to_usec(n, &u->sink->sample_spec);
 
-                if (u->memchunk.length <= 0) {
-                    pa_memblock_unref(u->memchunk.memblock);
-                    pa_memchunk_reset(&u->memchunk);
-                }
+                if (usec > u->latency)
+                    usec -= u->latency;
+                else
+                    usec = 0;
 
-                pollfd->revents = 0;
+                pa_smoother_put(u->smoother, pa_rtclock_usec(), usec);
             }
-        }
 
-        /* Hmm, nothing to do. Let's sleep */
-        pollfd->events = u->sink->thread_info.state == PA_SINK_RUNNING ? POLLOUT : 0;
+            /* Hmm, nothing to do. Let's sleep */
+            pollfd->events = PA_SINK_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0;
+        }
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
             goto fail;
@@ -204,11 +311,15 @@ static void thread_func(void *userdata) {
         if (ret == 0)
             goto finish;
 
-        pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+        if (u->rtpoll_item) {
+            struct pollfd* pollfd;
 
-        if (pollfd->revents & ~POLLOUT) {
-            pa_log("FIFO shutdown.");
-            goto fail;
+            pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
+
+            if (pollfd->revents & ~POLLOUT) {
+                pa_log("FIFO shutdown.");
+                goto fail;
+            }
         }
     }
 
@@ -222,25 +333,41 @@ finish:
     pa_log_debug("Thread shutting down");
 }
 
+static void on_connection(PA_GCC_UNUSED int fd, void*userdata) {
+    struct userdata *u = userdata;
+    pa_assert(u);
+
+    pa_assert(u->fd < 0);
+    u->fd = fd;
+
+    pa_log_debug("Connection authenticated, handing fd to IO thread...");
+
+    pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_PASS_SOCKET, NULL, 0, NULL, NULL);
+}
+
 int pa__init(pa_module*m) {
-    struct userdata *u;
-    //struct stat st;
+    struct userdata *u = NULL;
+    const char *p;
     pa_sample_spec ss;
-    pa_channel_map map;
-    pa_modargs *ma;
+    pa_modargs *ma = NULL;
     char *t;
-    struct pollfd *pollfd;
 
     pa_assert(m);
 
     if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
-        pa_log("Failed to parse module arguments.");
+        pa_log("failed to parse module arguments");
         goto fail;
     }
 
     ss = m->core->default_sample_spec;
-    if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
-        pa_log("Invalid sample format specification or channel map");
+    if (pa_modargs_get_sample_spec(ma, &ss) < 0) {
+        pa_log("invalid sample format specification");
+        goto fail;
+    }
+
+    if ((/*ss.format != PA_SAMPLE_U8 &&*/ ss.format != PA_SAMPLE_S16NE) ||
+        (ss.channels > 2)) {
+        pa_log("sample type support is limited to mono/stereo and U8 or S16NE sample data");
         goto fail;
     }
 
@@ -248,54 +375,58 @@ int pa__init(pa_module*m) {
     u->core = m->core;
     u->module = m;
     m->userdata = u;
+    u->fd = -1;
+    u->smoother = pa_smoother_new(PA_USEC_PER_SEC, PA_USEC_PER_SEC*2, TRUE);
+    pa_memchunk_reset(&u->raw_memchunk);
+    pa_memchunk_reset(&u->encoded_memchunk);
+    u->offset = 0;
+    u->encoding_overhead = 0;
+    u->encoding_ratio = 1.0;
 
-    pa_memchunk_reset(&u->memchunk);
     pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
     u->rtpoll = pa_rtpoll_new();
     pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY, u->thread_mq.inq);
+    u->rtpoll_item = NULL;
 
-    u->server_name = pa_xstrdup(pa_modargs_get_value(ma, "server", NULL));
+    /*u->format =
+        (ss.format == PA_SAMPLE_U8 ? ESD_BITS8 : ESD_BITS16) |
+        (ss.channels == 2 ? ESD_STEREO : ESD_MONO);*/
+    u->rate = ss.rate;
+    u->block_size = pa_usec_to_bytes(PA_USEC_PER_SEC/20, &ss);
 
-    // Open a connection to the server... this is just to connect and test....
-    /*
-    mkfifo(u->filename, 0666);
-    if ((u->fd = open(u->filename, O_RDWR|O_NOCTTY)) < 0) {
-        pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno));
-        goto fail;
-    }
-
-    pa_make_fd_cloexec(u->fd);
-    pa_make_fd_nonblock(u->fd);
+    u->read_data = u->write_data = NULL;
+    u->read_index = u->write_index = u->read_length = u->write_length = 0;
 
-    if (fstat(u->fd, &st) < 0) {
-        pa_log("fstat('%s'): %s", u->filename, pa_cstrerror(errno));
-        goto fail;
-    }
+    /*u->state = STATE_AUTH;*/
+    u->latency = 0;
 
-    if (!S_ISFIFO(st.st_mode)) {
-        pa_log("'%s' is not a FIFO.", u->filename);
-        goto fail;
-    }
-    */
-    if (!(u->sink = pa_sink_new(m->core, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
+    if (!(u->sink = pa_sink_new(m->core, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, NULL))) {
         pa_log("Failed to create sink.");
         goto fail;
     }
 
     u->sink->parent.process_msg = sink_process_msg;
     u->sink->userdata = u;
-    u->sink->flags = PA_SINK_LATENCY;
+    u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK;
 
     pa_sink_set_module(u->sink, m);
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
     pa_sink_set_rtpoll(u->sink, u->rtpoll);
-    pa_sink_set_description(u->sink, t = pa_sprintf_malloc("Airtunes sink '%s'", u->server_name));
+
+    if (!(p = pa_modargs_get_value(ma, "server", NULL))) {
+        pa_log("No server argument given.");
+        goto fail;
+    }
+
+    if (!(u->raop = pa_raop_client_new(u->core->mainloop, p))) {
+        pa_log("Failed to connect to server.");
+        goto fail;
+    }
+
+    pa_raop_client_set_callback(u->raop, on_connection, u);
+    pa_sink_set_description(u->sink, t = pa_sprintf_malloc("Airtunes sink '%s'", p));
     pa_xfree(t);
 
-    u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
-    pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
-    //pollfd->fd = u->fd;
-    pollfd->events = pollfd->revents = 0;
 
     if (!(u->thread = pa_thread_new(thread_func, u))) {
         pa_log("Failed to create thread.");
@@ -319,7 +450,6 @@ fail:
 
 void pa__done(pa_module*m) {
     struct userdata *u;
-
     pa_assert(m);
 
     if (!(u = m->userdata))
@@ -338,15 +468,29 @@ void pa__done(pa_module*m) {
     if (u->sink)
         pa_sink_unref(u->sink);
 
-    if (u->memchunk.memblock)
-       pa_memblock_unref(u->memchunk.memblock);
-
     if (u->rtpoll_item)
         pa_rtpoll_item_free(u->rtpoll_item);
 
     if (u->rtpoll)
         pa_rtpoll_free(u->rtpoll);
 
-    pa_xfree(u->server_name);
+    if (u->raw_memchunk.memblock)
+        pa_memblock_unref(u->raw_memchunk.memblock);
+
+    if (u->encoded_memchunk.memblock)
+        pa_memblock_unref(u->encoded_memchunk.memblock);
+
+    if (u->raop)
+        pa_raop_client_free(u->raop);
+
+    pa_xfree(u->read_data);
+    pa_xfree(u->write_data);
+
+    if (u->smoother)
+        pa_smoother_free(u->smoother);
+
+    if (u->fd >= 0)
+        pa_close(u->fd);
+
     pa_xfree(u);
 }

commit 4dd318519fbec1811a16dca05aca859da74b60c2
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 13:32:09 2008 +0000

    Do not assert on NULL values of s. This means the connection was closed. This change somehow kills the mainloop with an assert, so I need to sort that out.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2399 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index c22f801..5665c9f 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -224,7 +224,14 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
     pa_rtsp_client *c = userdata;
     pa_assert(line);
     pa_assert(c);
-    pa_assert(s);
+
+    if (!s) {
+        pa_log_warn("Connection closed");
+        pa_ioline_unref(c->ioline);
+        c->ioline = NULL;
+        pa_rtsp_disconnect(c);
+        return;
+    }
 
     s2 = pa_xstrdup(s);
     /* Trim trailing carriage returns */

commit 5eecfa2e3f3abcacc9df2776cba798598e5fb6ee
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 13:35:01 2008 +0000

    Move the ownership of the encoded data memchunk into the raop_client.
    
    This does not seem to fix the pool full messages so I'll have to try and suss that out.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2400 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 3d08cb8..f6f93a4 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -1,4 +1,4 @@
-/* $Id$ */
+/* $Id: module-esound-sink.c 2043 2007-11-09 18:25:40Z lennart $ */
 
 /***
   This file is part of PulseAudio.
@@ -109,6 +109,7 @@ struct userdata {
 
     int64_t offset;
     int64_t encoding_overhead;
+    int32_t next_encoding_overhead;
     double encoding_ratio;
 
     pa_raop_client *raop;
@@ -224,10 +225,9 @@ static void thread_func(void *userdata) {
                     if (u->encoded_memchunk.length <= 0) {
                         /* Encode it */
                         size_t rl = u->raw_memchunk.length;
-                        if (u->encoded_memchunk.memblock)
-                            pa_memblock_unref(u->encoded_memchunk.memblock);
+                        u->encoding_overhead += u->next_encoding_overhead;
                         u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, u->core->mempool, &u->raw_memchunk);
-                        u->encoding_overhead += (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
+                        u->next_encoding_overhead = (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
                         u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
                     }
                     pa_assert(u->encoded_memchunk.length > 0);
@@ -259,11 +259,6 @@ static void thread_func(void *userdata) {
                         u->encoded_memchunk.index += l;
                         u->encoded_memchunk.length -= l;
 
-                        if (u->encoded_memchunk.length <= 0) {
-                            pa_memblock_unref(u->encoded_memchunk.memblock);
-                            pa_memchunk_reset(&u->encoded_memchunk);
-                        }
-
                         pollfd->revents = 0;
 
                         if (u->encoded_memchunk.length > 0)
@@ -381,6 +376,7 @@ int pa__init(pa_module*m) {
     pa_memchunk_reset(&u->encoded_memchunk);
     u->offset = 0;
     u->encoding_overhead = 0;
+    u->next_encoding_overhead = 0;
     u->encoding_ratio = 1.0;
 
     pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
@@ -477,9 +473,6 @@ void pa__done(pa_module*m) {
     if (u->raw_memchunk.memblock)
         pa_memblock_unref(u->raw_memchunk.memblock);
 
-    if (u->encoded_memchunk.memblock)
-        pa_memblock_unref(u->encoded_memchunk.memblock);
-
     if (u->raop)
         pa_raop_client_free(u->raop);
 
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index bad747b..b4cbd2b 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -74,7 +74,7 @@
 
 struct pa_raop_client {
     pa_mainloop_api *mainloop;
-    const char *host;
+    char *host;
     char *sid;
     pa_rtsp_client *rtsp;
 
@@ -93,9 +93,10 @@ struct pa_raop_client {
     void* userdata;
 
     uint8_t *buffer;
+    uint32_t buffer_length;
     uint8_t *buffer_index;
     uint16_t buffer_count;
-    /*pa_memchunk memchunk;*/
+    pa_memchunk memchunk;
 };
 
 /**
@@ -356,6 +357,7 @@ pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host)
     c->mainloop = mainloop;
     c->fd = -1;
     c->host = pa_xstrdup(host);
+    pa_memchunk_reset(&c->memchunk);
     c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
@@ -386,6 +388,9 @@ void pa_raop_client_free(pa_raop_client* c)
 {
     pa_assert(c);
 
+    if (c->memchunk.memblock)
+        pa_memblock_unref(c->memchunk.memblock);
+    pa_xfree(c->buffer);
     pa_rtsp_client_free(c->rtsp);
     pa_xfree(c->aes_iv);
     pa_xfree(c->aes_nv);
@@ -403,9 +408,8 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
     uint8_t *bp, bpos;
     uint8_t *ibp, *maxibp;
     int size;
-    uint8_t *p;
+    uint8_t *b, *p;
     uint16_t bsize;
-    pa_memchunk rv;
     size_t length;
     static uint8_t header[] = {
         0x24, 0x00, 0x00, 0x00,
@@ -427,13 +431,22 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
 
     /* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
     bufmax = length + header_size + 16;
-    c->buffer = pa_xrealloc(c->buffer, bufmax);
-    memcpy(c->buffer, header, header_size);
-    pa_memchunk_reset(&rv);
-    rv.memblock = pa_memblock_new_user(mempool, c->buffer, (header_size + length), noop, 1);
+    if (bufmax > c->buffer_length) {
+        if (c->memchunk.memblock)
+            pa_memblock_unref(c->memchunk.memblock);
+
+        c->buffer = pa_xrealloc(c->buffer, bufmax);
+        c->buffer_length = bufmax;
+        pa_log_debug("Creating new memblock");
+        c->memchunk.memblock = pa_memblock_new_user(mempool, c->buffer, bufmax, noop, 0);
+    }
+    c->memchunk.index = 0;
+    c->memchunk.length = 0;
+    b = pa_memblock_acquire(c->memchunk.memblock);
+    memcpy(b, header, header_size);
 
     /* Now write the actual samples */
-    bp = c->buffer + header_size;
+    bp = b + header_size;
     size = bpos = 0;
     bit_writer(&bp,&bpos,&size,1,3); // channel=1, stereo
     bit_writer(&bp,&bpos,&size,0,4); // unknown
@@ -462,16 +475,20 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
         raw->length -= 4;
     }
     pa_memblock_release(raw->memblock);
-    rv.length = header_size + size;
+    c->memchunk.length = header_size + size;
 
     /* store the lenght (endian swapped: make this better) */
     len = size + header_size - 4;
-    *(c->buffer + 2) = len >> 8;
-    *(c->buffer + 3) = len & 0xff;
+    *(b + 2) = len >> 8;
+    *(b + 3) = len & 0xff;
 
     /* encrypt our data */
-    aes_encrypt(c, (c->buffer + header_size), size);
-    return rv;
+    aes_encrypt(c, (b + header_size), size);
+
+    /* We're done with the chunk */
+    pa_memblock_release(c->memchunk.memblock);
+
+    return c->memchunk;
 }
 
 

commit 899492c31581f5591cd9437052dda15ad02ec0ac
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 14:18:48 2008 +0000

    Add a new callback structure to propigate when the RTSP connection dies
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2402 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index b4cbd2b..75881c6 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -89,8 +89,11 @@ struct pa_raop_client {
 
     pa_socket_client *sc;
     int fd;
+
     pa_raop_client_cb_t callback;
     void* userdata;
+    pa_raop_client_closed_cb_t closed_callback;
+    void* closed_userdata;
 
     uint8_t *buffer;
     uint32_t buffer_length;
@@ -339,6 +342,19 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
         case STATE_SET_PARAMETER:
         case STATE_FLUSH:
             break;
+        case STATE_DISCONNECTED:
+            pa_assert(c->closed_callback);
+            pa_log_debug("RTSP channel closed");
+            if (c->fd > 0) {
+                pa_close(c->fd);
+                c->fd = -1;
+            }
+            if (c->sc) {
+                pa_socket_client_unref(c->sc);
+                c->sc = NULL;
+            }
+            c->closed_callback(c->closed_userdata);
+            break;
     }
 }
 
@@ -437,7 +453,6 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
 
         c->buffer = pa_xrealloc(c->buffer, bufmax);
         c->buffer_length = bufmax;
-        pa_log_debug("Creating new memblock");
         c->memchunk.memblock = pa_memblock_new_user(mempool, c->buffer, bufmax, noop, 0);
     }
     c->memchunk.index = 0;
@@ -499,3 +514,11 @@ void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback
     c->callback = callback;
     c->userdata = userdata;
 }
+
+void pa_raop_client_set_closed_callback(pa_raop_client* c, pa_raop_client_closed_cb_t callback, void *userdata)
+{
+    pa_assert(c);
+
+    c->closed_callback = callback;
+    c->closed_userdata = userdata;
+}
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 68a1cdb..1ec56ca 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -38,4 +38,7 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
 typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
 void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);
 
+typedef void (*pa_raop_client_closed_cb_t)(void *userdata);
+void pa_raop_client_set_closed_callback(pa_raop_client* c, pa_raop_client_closed_cb_t callback, void *userdata);
+
 #endif
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 5665c9f..22f0f0c 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -173,6 +173,7 @@ static void headers_read(pa_rtsp_client *c) {
 
     pa_assert(c);
     pa_assert(c->response_headers);
+    pa_assert(c->callback);
 
     /* Deal with a SETUP response */
     if (STATE_SETUP == c->state) {
@@ -209,8 +210,7 @@ static void headers_read(pa_rtsp_client *c) {
     }
 
     /* Call our callback */
-    if (c->callback)
-        c->callback(c, c->state, c->response_headers, c->userdata);
+    c->callback(c, c->state, c->response_headers, c->userdata);
 
     pa_headerlist_free(c->response_headers);
     c->response_headers = NULL;
@@ -224,12 +224,13 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
     pa_rtsp_client *c = userdata;
     pa_assert(line);
     pa_assert(c);
+    pa_assert(c->callback);
 
     if (!s) {
-        pa_log_warn("Connection closed");
         pa_ioline_unref(c->ioline);
         c->ioline = NULL;
         pa_rtsp_disconnect(c);
+        c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
         return;
     }
 
diff --git a/src/modules/rtp/rtsp_client.h b/src/modules/rtp/rtsp_client.h
index 0f1daab..3c5280c 100644
--- a/src/modules/rtp/rtsp_client.h
+++ b/src/modules/rtp/rtsp_client.h
@@ -44,7 +44,8 @@ typedef enum {
   STATE_RECORD,
   STATE_TEARDOWN,
   STATE_SET_PARAMETER,
-  STATE_FLUSH
+  STATE_FLUSH,
+  STATE_DISCONNECTED
 } pa_rtsp_state;
 typedef void (*pa_rtsp_cb_t)(pa_rtsp_client *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);
 

commit ec9a618768790055fef00a46866b4e0e1fa33048
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 14:19:41 2008 +0000

    Listen to the on_close callback. This still causes asserts in the mainloop, so this is not a complete solution
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2403 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index f6f93a4..090f04f 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -340,6 +340,14 @@ static void on_connection(PA_GCC_UNUSED int fd, void*userdata) {
     pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_PASS_SOCKET, NULL, 0, NULL, NULL);
 }
 
+static void on_close(void*userdata) {
+    struct userdata *u = userdata;
+    pa_assert(u);
+
+    pa_log_debug("Control connection closed.");
+    pa_module_unload_request(u->module);
+}
+
 int pa__init(pa_module*m) {
     struct userdata *u = NULL;
     const char *p;
@@ -420,6 +428,7 @@ int pa__init(pa_module*m) {
     }
 
     pa_raop_client_set_callback(u->raop, on_connection, u);
+    pa_raop_client_set_closed_callback(u->raop, on_close, u);
     pa_sink_set_description(u->sink, t = pa_sprintf_malloc("Airtunes sink '%s'", p));
     pa_xfree(t);
 

commit e00127fe245cc2065f74617dada3b474b88907af
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 14:57:30 2008 +0000

    Various changes suggested by Lennart.
    
    Store the core* rather than just the mainloop as we can reuse the mempool without passing it in as an argument.
    const'ify and deconst'ify some vars
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2404 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 090f04f..0a7ce17 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -226,7 +226,7 @@ static void thread_func(void *userdata) {
                         /* Encode it */
                         size_t rl = u->raw_memchunk.length;
                         u->encoding_overhead += u->next_encoding_overhead;
-                        u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, u->core->mempool, &u->raw_memchunk);
+                        u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, &u->raw_memchunk);
                         u->next_encoding_overhead = (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
                         u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
                     }
@@ -422,7 +422,7 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
-    if (!(u->raop = pa_raop_client_new(u->core->mainloop, p))) {
+    if (!(u->raop = pa_raop_client_new(u->core, p))) {
         pa_log("Failed to connect to server.");
         goto fail;
     }
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 75881c6..92be6cd 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -73,7 +73,7 @@
 
 
 struct pa_raop_client {
-    pa_mainloop_api *mainloop;
+    pa_core *core;
     char *host;
     char *sid;
     pa_rtsp_client *rtsp;
@@ -155,14 +155,14 @@ static inline void bit_writer(uint8_t **buffer, uint8_t *bit_pos, int *size, uin
 }
 
 static int rsa_encrypt(uint8_t *text, int len, uint8_t *res) {
-    char n[] =
+    const char n[] =
         "59dE8qLieItsH1WgjrcFRKj6eUWqi+bGLOX1HL3U3GhC/j0Qg90u3sG/1CUtwC"
         "5vOYvfDmFI6oSFXi5ELabWJmT2dKHzBJKa3k9ok+8t9ucRqMd6DZHJ2YCCLlDR"
         "KSKv6kDqnw4UwPdpOMXziC/AMj3Z/lUVX1G7WSHCAWKf1zNS1eLvqr+boEjXuB"
         "OitnZ/bDzPHrTOZz0Dew0uowxf/+sG+NCK3eQJVxqcaJ/vEHKIVd2M+5qL71yJ"
         "Q+87X6oV3eaYvt3zWZYD6z5vYTcrtij2VZ9Zmni/UAaHqn9JdsBWLUEpVviYnh"
         "imNVvYFZeCXg/IdTQ+x4IRdiXNv5hEew==";
-    char e[] = "AQAB";
+    const char e[] = "AQAB";
     uint8_t modules[256];
     uint8_t exponent[8];
     int size;
@@ -330,7 +330,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
             uint32_t port = pa_rtsp_serverport(c->rtsp);
             pa_log_debug("RAOP: RECORDED");
 
-            if (!(c->sc = pa_socket_client_new_string(c->mainloop, c->host, port))) {
+            if (!(c->sc = pa_socket_client_new_string(c->core->mainloop, c->host, port))) {
                 pa_log("failed to connect to server '%s:%d'", c->host, port);
                 return;
             }
@@ -358,7 +358,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
     }
 }
 
-pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host)
+pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
 {
     char *sci;
     struct {
@@ -368,16 +368,16 @@ pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host)
     } rand_data;
     pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
 
+    pa_assert(core);
     pa_assert(host);
 
-    c->mainloop = mainloop;
+    c->core = core;
     c->fd = -1;
     c->host = pa_xstrdup(host);
     pa_memchunk_reset(&c->memchunk);
     c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
-    pa_random_seed();
     pa_random(c->aes_iv, sizeof(c->aes_iv));
     pa_random(c->aes_key, sizeof(c->aes_key));
     memcpy(c->aes_nv, c->aes_iv, sizeof(c->aes_nv));
@@ -389,7 +389,7 @@ pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host)
     sci = pa_sprintf_malloc("%08x%08x",rand_data.b, rand_data.c);
     pa_rtsp_add_header(c->rtsp, "Client-Instance", sci);
     pa_rtsp_set_callback(c->rtsp, rtsp_cb, c);
-    if (pa_rtsp_connect(c->rtsp, mainloop, host, 5000)) {
+    if (pa_rtsp_connect(c->rtsp, c->core->mainloop, host, 5000)) {
         pa_rtsp_client_free(c->rtsp);
         pa_xfree(c->aes_iv);
         pa_xfree(c->aes_nv);
@@ -418,14 +418,14 @@ void pa_raop_client_free(pa_raop_client* c)
 
 static void noop(PA_GCC_UNUSED void* p) {}
 
-pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool, pa_memchunk* raw)
+pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
 {
     uint16_t len, bufmax;
     uint8_t *bp, bpos;
     uint8_t *ibp, *maxibp;
     int size;
     uint8_t *b, *p;
-    uint16_t bsize;
+    uint32_t bsize;
     size_t length;
     static uint8_t header[] = {
         0x24, 0x00, 0x00, 0x00,
@@ -433,7 +433,7 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
         0x00, 0x00, 0x00, 0x00,
         0x00, 0x00, 0x00, 0x00,
     };
-    const int header_size = sizeof(header);
+    int header_size = sizeof(header);
 
     pa_assert(c);
     pa_assert(c->fd > 0);
@@ -453,7 +453,7 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
 
         c->buffer = pa_xrealloc(c->buffer, bufmax);
         c->buffer_length = bufmax;
-        c->memchunk.memblock = pa_memblock_new_user(mempool, c->buffer, bufmax, noop, 0);
+        c->memchunk.memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
     }
     c->memchunk.index = 0;
     c->memchunk.length = 0;
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 1ec56ca..b2817e5 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -26,14 +26,14 @@
 
 #include <pulse/mainloop-api.h>
 #include <pulsecore/iochannel.h>
-#include <pulsecore/memchunk.h>
+#include <pulsecore/core.h>
 
 typedef struct pa_raop_client pa_raop_client;
 
-pa_raop_client* pa_raop_client_new(pa_mainloop_api *mainloop, const char* host);
+pa_raop_client* pa_raop_client_new(pa_core *core, const char* host);
 void pa_raop_client_free(pa_raop_client* c);
 
-pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool, pa_memchunk* raw);
+pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw);
 
 typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
 void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);

commit d195d06da7009db985c0a5827b096bc39dd994bf
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 15:06:14 2008 +0000

    Change suggested by Lennart. Do not return a memchunk, instead pass in the pointer.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2405 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 0a7ce17..3d0eaef 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -226,7 +226,7 @@ static void thread_func(void *userdata) {
                         /* Encode it */
                         size_t rl = u->raw_memchunk.length;
                         u->encoding_overhead += u->next_encoding_overhead;
-                        u->encoded_memchunk = pa_raop_client_encode_sample(u->raop, &u->raw_memchunk);
+                        pa_raop_client_encode_sample(u->raop, &u->raw_memchunk, &u->encoded_memchunk);
                         u->next_encoding_overhead = (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
                         u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
                     }
@@ -482,6 +482,9 @@ void pa__done(pa_module*m) {
     if (u->raw_memchunk.memblock)
         pa_memblock_unref(u->raw_memchunk.memblock);
 
+    if (u->encoded_memchunk.memblock)
+        pa_memblock_unref(u->encoded_memchunk.memblock);
+
     if (u->raop)
         pa_raop_client_free(u->raop);
 
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 92be6cd..1581017 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -96,10 +96,9 @@ struct pa_raop_client {
     void* closed_userdata;
 
     uint8_t *buffer;
-    uint32_t buffer_length;
+    size_t buffer_length;
     uint8_t *buffer_index;
     uint16_t buffer_count;
-    pa_memchunk memchunk;
 };
 
 /**
@@ -374,7 +373,6 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
     c->core = core;
     c->fd = -1;
     c->host = pa_xstrdup(host);
-    pa_memchunk_reset(&c->memchunk);
     c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
@@ -404,8 +402,6 @@ void pa_raop_client_free(pa_raop_client* c)
 {
     pa_assert(c);
 
-    if (c->memchunk.memblock)
-        pa_memblock_unref(c->memchunk.memblock);
     pa_xfree(c->buffer);
     pa_rtsp_client_free(c->rtsp);
     pa_xfree(c->aes_iv);
@@ -418,9 +414,10 @@ void pa_raop_client_free(pa_raop_client* c)
 
 static void noop(PA_GCC_UNUSED void* p) {}
 
-pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
+int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded)
 {
-    uint16_t len, bufmax;
+    uint16_t len;
+    size_t bufmax;
     uint8_t *bp, bpos;
     uint8_t *ibp, *maxibp;
     int size;
@@ -440,6 +437,7 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
     pa_assert(raw);
     pa_assert(raw->memblock);
     pa_assert(raw->length > 0);
+    pa_assert(encoded);
 
     /* We have to send 4 byte chunks */
     bsize = (int)(raw->length / 4);
@@ -448,16 +446,16 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
     /* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
     bufmax = length + header_size + 16;
     if (bufmax > c->buffer_length) {
-        if (c->memchunk.memblock)
-            pa_memblock_unref(c->memchunk.memblock);
+        if (encoded->memblock)
+            pa_memblock_unref(encoded->memblock);
 
         c->buffer = pa_xrealloc(c->buffer, bufmax);
         c->buffer_length = bufmax;
-        c->memchunk.memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
+        encoded->memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
     }
-    c->memchunk.index = 0;
-    c->memchunk.length = 0;
-    b = pa_memblock_acquire(c->memchunk.memblock);
+    encoded->index = 0;
+    encoded->length = 0;
+    b = pa_memblock_acquire(encoded->memblock);
     memcpy(b, header, header_size);
 
     /* Now write the actual samples */
@@ -490,7 +488,7 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
         raw->length -= 4;
     }
     pa_memblock_release(raw->memblock);
-    c->memchunk.length = header_size + size;
+    encoded->length = header_size + size;
 
     /* store the lenght (endian swapped: make this better) */
     len = size + header_size - 4;
@@ -501,9 +499,9 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw)
     aes_encrypt(c, (b + header_size), size);
 
     /* We're done with the chunk */
-    pa_memblock_release(c->memchunk.memblock);
+    pa_memblock_release(encoded->memblock);
 
-    return c->memchunk;
+    return 0;
 }
 
 
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index b2817e5..303fdaa 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -33,7 +33,7 @@ typedef struct pa_raop_client pa_raop_client;
 pa_raop_client* pa_raop_client_new(pa_core *core, const char* host);
 void pa_raop_client_free(pa_raop_client* c);
 
-pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw);
+int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded);
 
 typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
 void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);

commit 4b7b7b15d73a5f2a98229b12406b4397563d2983
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 15:12:20 2008 +0000

    Fix up IPv6 address format to enclose it in []
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2406 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 22f0f0c..193248e 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -352,12 +352,14 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
         const char *res = NULL;
 
         if (AF_INET == sa.sa.sa_family) {
-            res = inet_ntop(sa.sa.sa_family, &sa.in.sin_addr, buf, sizeof(buf));
+            if ((res = inet_ntop(sa.sa.sa_family, &sa.in.sin_addr, buf, sizeof(buf)))) {
+                c->localip = pa_xstrdup(res);
+            }
         } else if (AF_INET6 == sa.sa.sa_family) {
-            res = inet_ntop(AF_INET6, &sa.in6.sin6_addr, buf, sizeof(buf));
+            if ((res = inet_ntop(AF_INET6, &sa.in6.sin6_addr, buf, sizeof(buf)))) {
+                c->localip = pa_sprintf_malloc("[%s]", res);
+            }
         }
-        if (res)
-            c->localip = pa_xstrdup(res);
     }
     pa_log_debug("Established RTSP connection from local ip %s", c->localip);
 

commit cb8c5a925fc22819626cbe4525b1d334db75d071
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 15:34:37 2008 +0000

    Some misc fixes. consts, base64 optimisation (not that it will be with us long anyway), and c comments
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2407 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/base64.c b/src/modules/rtp/base64.c
index 043ef5a..980b018 100644
--- a/src/modules/rtp/base64.c
+++ b/src/modules/rtp/base64.c
@@ -37,16 +37,16 @@
 
 #include "base64.h"
 
-static char base64_chars[] =
+static const char base64_chars[] =
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 static int pos(char c)
 {
-    char *p;
-    for (p = base64_chars; *p; p++)
-        if (*p == c)
-            return p - base64_chars;
-    return -1;
+    if (c >= 'A' && c <= 'Z') return c - 'A' + 0;
+    if (c >= 'a' && c <= 'z') return c - 'a' + 26;
+    if (c >= '0' && c <= '9') return c - '0' + 52;
+    if (c == '+') return 62;
+    if (c == '/') return 63;
 }
 
 int pa_base64_encode(const void *data, int size, char **str)
diff --git a/src/modules/rtp/headerlist.c b/src/modules/rtp/headerlist.c
index 8bdc725..de8710b 100644
--- a/src/modules/rtp/headerlist.c
+++ b/src/modules/rtp/headerlist.c
@@ -102,7 +102,7 @@ int pa_headerlist_putsappend(pa_headerlist *p, const char *key, const char *valu
         hdr->value = pa_xstrdup(value);
         add = TRUE;
     } else {
-        void *newval = (void*)pa_sprintf_malloc("%s%s", (char*)hdr->value, value);
+        void *newval = pa_sprintf_malloc("%s%s", (char*)hdr->value, value);
         pa_xfree(hdr->value);
         hdr->value = newval;
     }
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 1581017..fc42340 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -461,13 +461,13 @@ int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchun
     /* Now write the actual samples */
     bp = b + header_size;
     size = bpos = 0;
-    bit_writer(&bp,&bpos,&size,1,3); // channel=1, stereo
-    bit_writer(&bp,&bpos,&size,0,4); // unknown
-    bit_writer(&bp,&bpos,&size,0,8); // unknown
-    bit_writer(&bp,&bpos,&size,0,4); // unknown
-    bit_writer(&bp,&bpos,&size,1,1); // hassize
-    bit_writer(&bp,&bpos,&size,0,2); // unused
-    bit_writer(&bp,&bpos,&size,1,1); // is-not-compressed
+    bit_writer(&bp,&bpos,&size,1,3); /* channel=1, stereo */
+    bit_writer(&bp,&bpos,&size,0,4); /* unknown */
+    bit_writer(&bp,&bpos,&size,0,8); /* unknown */
+    bit_writer(&bp,&bpos,&size,0,4); /* unknown */
+    bit_writer(&bp,&bpos,&size,1,1); /* hassize */
+    bit_writer(&bp,&bpos,&size,0,2); /* unused */
+    bit_writer(&bp,&bpos,&size,1,1); /* is-not-compressed */
 
     /* size of data, integer, big endian */
     bit_writer(&bp,&bpos,&size,(bsize>>24)&0xff,8);

commit be73d378f5fd5ea1aedcc75b0c7c1e1a82a27047
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 15:43:56 2008 +0000

    unref the raw data memblock before requesting more data.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2408 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 3d0eaef..79c517a 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -217,6 +217,10 @@ static void thread_func(void *userdata) {
                     void *p;
 
                     if (u->raw_memchunk.length <= 0) {
+                        if (u->raw_memchunk.memblock)
+                            pa_memblock_unref(u->raw_memchunk.memblock);
+                        pa_memchunk_reset(&u->raw_memchunk);
+
                         /* Grab unencoded data */
                         pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
                     }

commit eca94fee59ba68603f1c34f5a4abe55dd7d9d638
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 16:38:33 2008 +0000

    Don't try to free stack variables.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2409 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index fc42340..a9b9ab1 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -389,9 +389,6 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
     pa_rtsp_set_callback(c->rtsp, rtsp_cb, c);
     if (pa_rtsp_connect(c->rtsp, c->core->mainloop, host, 5000)) {
         pa_rtsp_client_free(c->rtsp);
-        pa_xfree(c->aes_iv);
-        pa_xfree(c->aes_nv);
-        pa_xfree(c->aes_key);
         return NULL;
     }
     return c;
@@ -404,9 +401,6 @@ void pa_raop_client_free(pa_raop_client* c)
 
     pa_xfree(c->buffer);
     pa_rtsp_client_free(c->rtsp);
-    pa_xfree(c->aes_iv);
-    pa_xfree(c->aes_nv);
-    pa_xfree(c->aes_key);
     pa_xfree(c->host);
     pa_xfree(c);
 }

commit 92166846913ebb5e86f36352e20c9ca4f4bf23ae
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 16:40:26 2008 +0000

    Do not prefix internal function rtsp_exec.
    
    Change port to be 16 bits
    Do not free stuff on closure as this happens further up the stack.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2410 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 193248e..2483972 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -70,13 +70,13 @@ struct pa_rtsp_client {
 
     char *localip;
     char *url;
-    uint32_t port;
+    uint16_t port;
     uint32_t cseq;
     char *session;
     char *transport;
 };
 
-static int pa_rtsp_exec(pa_rtsp_client* c, const char* cmd,
+static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
                         const char* content_type, const char* content,
                         int expect_response,
                         pa_headerlist* headers) {
@@ -193,7 +193,7 @@ static void headers_read(pa_rtsp_client *c) {
         while ((token = pa_split(c->transport, delimiters, &token_state))) {
             if ((pc = strstr(token, "="))) {
                 if (0 == strncmp(token, "server_port", 11)) {
-                    pa_atou(pc+1, &c->port);
+                    pa_atou(pc+1, (uint32_t*)(&c->port));
                     pa_xfree(token);
                     break;
                 }
@@ -227,9 +227,6 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
     pa_assert(c->callback);
 
     if (!s) {
-        pa_ioline_unref(c->ioline);
-        c->ioline = NULL;
-        pa_rtsp_disconnect(c);
         c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
         return;
     }
@@ -442,7 +439,7 @@ int pa_rtsp_announce(pa_rtsp_client *c, const char* sdp) {
         return -1;
 
     c->state = STATE_ANNOUNCE;
-    return pa_rtsp_exec(c, "ANNOUNCE", "application/sdp", sdp, 1, NULL);
+    return rtsp_exec(c, "ANNOUNCE", "application/sdp", sdp, 1, NULL);
 }
 
 
@@ -456,7 +453,7 @@ int pa_rtsp_setup(pa_rtsp_client* c) {
     pa_headerlist_puts(headers, "Transport", "RTP/AVP/TCP;unicast;interleaved=0-1;mode=record");
 
     c->state = STATE_SETUP;
-    rv = pa_rtsp_exec(c, "SETUP", NULL, NULL, 1, headers);
+    rv = rtsp_exec(c, "SETUP", NULL, NULL, 1, headers);
     pa_headerlist_free(headers);
     return rv;
 }
@@ -477,7 +474,7 @@ int pa_rtsp_record(pa_rtsp_client* c) {
     pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
 
     c->state = STATE_RECORD;
-    rv = pa_rtsp_exec(c, "RECORD", NULL, NULL, 1, headers);
+    rv = rtsp_exec(c, "RECORD", NULL, NULL, 1, headers);
     pa_headerlist_free(headers);
     return rv;
 }
@@ -487,7 +484,7 @@ int pa_rtsp_teardown(pa_rtsp_client *c) {
     pa_assert(c);
 
     c->state = STATE_TEARDOWN;
-    return pa_rtsp_exec(c, "TEARDOWN", NULL, NULL, 0, NULL);
+    return rtsp_exec(c, "TEARDOWN", NULL, NULL, 0, NULL);
 }
 
 
@@ -497,7 +494,7 @@ int pa_rtsp_setparameter(pa_rtsp_client *c, const char* param) {
         return -1;
 
     c->state = STATE_SET_PARAMETER;
-    return pa_rtsp_exec(c, "SET_PARAMETER", "text/parameters", param, 1, NULL);
+    return rtsp_exec(c, "SET_PARAMETER", "text/parameters", param, 1, NULL);
 }
 
 
@@ -511,7 +508,7 @@ int pa_rtsp_flush(pa_rtsp_client *c) {
     pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
 
     c->state = STATE_FLUSH;
-    rv = pa_rtsp_exec(c, "FLUSH", NULL, NULL, 1, headers);
+    rv = rtsp_exec(c, "FLUSH", NULL, NULL, 1, headers);
     pa_headerlist_free(headers);
     return rv;
 }

commit 3767cdb6d16c5817eb489129585fb353e3ad6afa
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun May 11 17:02:19 2008 +0000

    Do tidy up on disconnection.
    
    Only clear IO related stuff if this free() was triggered deliberatly (i.e. not by server side disconnect)
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2411 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index a9b9ab1..e5a373d 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -344,6 +344,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
         case STATE_DISCONNECTED:
             pa_assert(c->closed_callback);
             pa_log_debug("RTSP channel closed");
+            c->rtsp = NULL;
             if (c->fd > 0) {
                 pa_close(c->fd);
                 c->fd = -1;
@@ -400,7 +401,8 @@ void pa_raop_client_free(pa_raop_client* c)
     pa_assert(c);
 
     pa_xfree(c->buffer);
-    pa_rtsp_client_free(c->rtsp);
+    if (c->rtsp)
+        pa_rtsp_client_free(c->rtsp);
     pa_xfree(c->host);
     pa_xfree(c);
 }
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 2483972..f9fe9bf 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -151,6 +151,10 @@ void pa_rtsp_client_free(pa_rtsp_client* c) {
     if (c) {
         if (c->sc)
             pa_socket_client_unref(c->sc);
+        if (c->ioline)
+            pa_ioline_close(c->ioline);
+        else if (c->io)
+            pa_iochannel_free(c->io);
 
         pa_xfree(c->url);
         pa_xfree(c->localip);
@@ -227,6 +231,10 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
     pa_assert(c->callback);
 
     if (!s) {
+        /* Keep the ioline/iochannel open as they will be freed automatically */
+        c->ioline = NULL;
+        c->io = NULL;
+        pa_rtsp_client_free(c);
         c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
         return;
     }

commit 6c1dd6e54b4b5b4213467d156abc9f260c63aaa3
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon May 26 21:04:45 2008 +0000

    Move the encoding loop around a bit such that it does not grab the data and keep it for the next loop iteration.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2481 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 79c517a..e17198c 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -216,17 +216,19 @@ static void thread_func(void *userdata) {
                     ssize_t l;
                     void *p;
 
-                    if (u->raw_memchunk.length <= 0) {
-                        if (u->raw_memchunk.memblock)
-                            pa_memblock_unref(u->raw_memchunk.memblock);
-                        pa_memchunk_reset(&u->raw_memchunk);
-
-                        /* Grab unencoded data */
-                        pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
-                    }
-                    pa_assert(u->raw_memchunk.length > 0);
-
                     if (u->encoded_memchunk.length <= 0) {
+                        if (u->raw_memchunk.length <= 0) {
+                            if (u->raw_memchunk.memblock)
+                                pa_memblock_unref(u->raw_memchunk.memblock);
+                            pa_memchunk_reset(&u->raw_memchunk);
+
+                            /* Grab unencoded data */
+                            pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
+                            p = pa_memblock_acquire(u->raw_memchunk.memblock);
+                            pa_memblock_release(u->raw_memchunk.memblock);
+                        }
+                        pa_assert(u->raw_memchunk.length > 0);
+
                         /* Encode it */
                         size_t rl = u->raw_memchunk.length;
                         u->encoding_overhead += u->next_encoding_overhead;

commit 6dc5e0797738d6afe2c3c99750abd2fb26fed9a9
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon May 26 21:05:53 2008 +0000

    Set the send buffer size to prevent rendering silence in amongst our good data (this should be more sophisticated but that can wait for a glitch-free port)
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2482 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index e5a373d..cdf9150 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -227,6 +227,7 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
     c->fd = pa_iochannel_get_send_fd(io);
 
     pa_iochannel_set_noclose(io, TRUE);
+    pa_iochannel_socket_set_sndbuf(io, 1024);
     pa_iochannel_free(io);
 
     pa_make_tcp_socket_low_delay(c->fd);

commit 8108121fa76e51c36772a592f74b075dcaf7c4cb
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon May 26 21:10:08 2008 +0000

    Set forgotten keyword property
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2483 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index e17198c..42092e0 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -1,4 +1,4 @@
-/* $Id: module-esound-sink.c 2043 2007-11-09 18:25:40Z lennart $ */
+/* $Id$ */
 
 /***
   This file is part of PulseAudio.

commit b93e9e80ecbdc90c0bf6f90c5bd4aafcdb4d2488
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon May 26 23:02:30 2008 +0000

    Keep track of the memblock pointer internally and do not rely on subsequent calls to pass it back in for unref'ing
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2484 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index cdf9150..7ba1be7 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -96,6 +96,7 @@ struct pa_raop_client {
     void* closed_userdata;
 
     uint8_t *buffer;
+    pa_memblock *memblock;
     size_t buffer_length;
     uint8_t *buffer_index;
     uint16_t buffer_count;
@@ -443,15 +444,14 @@ int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchun
     /* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
     bufmax = length + header_size + 16;
     if (bufmax > c->buffer_length) {
-        if (encoded->memblock)
-            pa_memblock_unref(encoded->memblock);
-
         c->buffer = pa_xrealloc(c->buffer, bufmax);
         c->buffer_length = bufmax;
-        encoded->memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
+        if (c->memblock)
+            pa_memblock_unref(c->memblock);
+        c->memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
     }
-    encoded->index = 0;
-    encoded->length = 0;
+    pa_memchunk_reset(encoded);
+    encoded->memblock = c->memblock;
     b = pa_memblock_acquire(encoded->memblock);
     memcpy(b, header, header_size);
 

commit 13bc07587564977a64222f5a4075b7fa63ac5548
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon May 26 23:43:51 2008 +0000

    A few related changes:
    
    * Change the encode_sample routine to simply return normal memchunks allocated from the mempool.
    * unref the memchunks returned from encode_sample when we are done with them.
    * Create an encoded 'silence' sample and play this at all times to prevent hangup and to 'hog' the airtunes device
    
    This now works and can be used as a regular sink albeit with a constant latency of about 8 seconds :s
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2485 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 42092e0..f78abba 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -178,7 +178,8 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             u->rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
             pollfd->fd = u->fd;
-            pollfd->events = pollfd->revents = 0;
+            pollfd->events = POLLOUT;
+            pollfd->revents = 0;
 
             return 0;
         }
@@ -190,6 +191,9 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
     int write_type = 0;
+    pa_memchunk silence;
+    uint32_t silence_overhead;
+    double silence_ratio;
 
     pa_assert(u);
 
@@ -200,6 +204,9 @@ static void thread_func(void *userdata) {
 
     pa_smoother_set_time_offset(u->smoother, pa_rtclock_usec());
 
+    /* Create a chunk of memory that is our encoded silence sample. */
+    pa_memchunk_reset(&silence);
+
     for (;;) {
         int ret;
 
@@ -208,33 +215,61 @@ static void thread_func(void *userdata) {
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
             /* Render some data and write it to the fifo */
-            if (PA_SINK_OPENED(u->sink->thread_info.state) && pollfd->revents) {
+            if (pollfd->revents) {
                 pa_usec_t usec;
                 int64_t n;
+                void *p;
+
+                if (!silence.memblock) {
+                    pa_memchunk silence_tmp;
+
+                    pa_memchunk_reset(&silence_tmp);
+                    silence_tmp.memblock = pa_memblock_new(u->core->mempool, 4096);
+                    silence_tmp.length = 4096;
+                    p = pa_memblock_acquire(silence_tmp.memblock);
+                      memset(p, 0, 4096);
+                    pa_memblock_release(silence_tmp.memblock);
+                    pa_raop_client_encode_sample(u->raop, &silence_tmp, &silence);
+                    pa_assert(0 == silence_tmp.length);
+                    silence_overhead = silence_tmp.length - 4096;
+                    silence_ratio = silence_tmp.length / 4096;
+                    pa_memblock_unref(silence_tmp.memblock);
+                }
 
                 for (;;) {
                     ssize_t l;
-                    void *p;
 
                     if (u->encoded_memchunk.length <= 0) {
-                        if (u->raw_memchunk.length <= 0) {
-                            if (u->raw_memchunk.memblock)
-                                pa_memblock_unref(u->raw_memchunk.memblock);
-                            pa_memchunk_reset(&u->raw_memchunk);
-
-                            /* Grab unencoded data */
-                            pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
-                            p = pa_memblock_acquire(u->raw_memchunk.memblock);
-                            pa_memblock_release(u->raw_memchunk.memblock);
+                        if (u->encoded_memchunk.memblock)
+                            pa_memblock_unref(u->encoded_memchunk.memblock);
+                        if (PA_SINK_OPENED(u->sink->thread_info.state)) {
+                            size_t rl;
+
+                            /* We render real data */
+                            if (u->raw_memchunk.length <= 0) {
+                                if (u->raw_memchunk.memblock)
+                                    pa_memblock_unref(u->raw_memchunk.memblock);
+                                pa_memchunk_reset(&u->raw_memchunk);
+
+                                /* Grab unencoded data */
+                                pa_sink_render(u->sink, u->block_size, &u->raw_memchunk);
+                            }
+                            pa_assert(u->raw_memchunk.length > 0);
+
+                            /* Encode it */
+                            rl = u->raw_memchunk.length;
+                            u->encoding_overhead += u->next_encoding_overhead;
+                            pa_raop_client_encode_sample(u->raop, &u->raw_memchunk, &u->encoded_memchunk);
+                            u->next_encoding_overhead = (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
+                            u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
+                        } else {
+                            /* We render some silence into our memchunk */
+                            u->encoding_overhead += u->next_encoding_overhead;
+                            memcpy(&u->encoded_memchunk, &silence, sizeof(pa_memchunk));
+                            pa_memblock_ref(silence.memblock);
+                            u->next_encoding_overhead = silence_overhead;
+                            u->encoding_ratio = silence_ratio;
                         }
-                        pa_assert(u->raw_memchunk.length > 0);
-
-                        /* Encode it */
-                        size_t rl = u->raw_memchunk.length;
-                        u->encoding_overhead += u->next_encoding_overhead;
-                        pa_raop_client_encode_sample(u->raop, &u->raw_memchunk, &u->encoded_memchunk);
-                        u->next_encoding_overhead = (u->encoded_memchunk.length - (rl - u->raw_memchunk.length));
-                        u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
                     }
                     pa_assert(u->encoded_memchunk.length > 0);
 
@@ -303,7 +338,7 @@ static void thread_func(void *userdata) {
             }
 
             /* Hmm, nothing to do. Let's sleep */
-            pollfd->events = PA_SINK_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0;
+            /* pollfd->events = PA_SINK_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0; */
         }
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
@@ -331,6 +366,8 @@ fail:
     pa_asyncmsgq_wait_for(u->thread_mq.inq, PA_MESSAGE_SHUTDOWN);
 
 finish:
+    if (silence.memblock)
+        pa_memblock_unref(silence.memblock);
     pa_log_debug("Thread shutting down");
 }
 
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 7ba1be7..4085a49 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -94,12 +94,6 @@ struct pa_raop_client {
     void* userdata;
     pa_raop_client_closed_cb_t closed_callback;
     void* closed_userdata;
-
-    uint8_t *buffer;
-    pa_memblock *memblock;
-    size_t buffer_length;
-    uint8_t *buffer_index;
-    uint16_t buffer_count;
 };
 
 /**
@@ -402,7 +396,6 @@ void pa_raop_client_free(pa_raop_client* c)
 {
     pa_assert(c);
 
-    pa_xfree(c->buffer);
     if (c->rtsp)
         pa_rtsp_client_free(c->rtsp);
     pa_xfree(c->host);
@@ -443,15 +436,8 @@ int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchun
 
     /* Leave 16 bytes extra to allow for the ALAC header which is about 55 bits */
     bufmax = length + header_size + 16;
-    if (bufmax > c->buffer_length) {
-        c->buffer = pa_xrealloc(c->buffer, bufmax);
-        c->buffer_length = bufmax;
-        if (c->memblock)
-            pa_memblock_unref(c->memblock);
-        c->memblock = pa_memblock_new_user(c->core->mempool, c->buffer, bufmax, noop, 0);
-    }
     pa_memchunk_reset(encoded);
-    encoded->memblock = c->memblock;
+    encoded->memblock = pa_memblock_new(c->core->mempool, bufmax);
     b = pa_memblock_acquire(encoded->memblock);
     memcpy(b, header, header_size);
 

commit 7f0cf0c9adc5176ba41d549754ea25ed6f12bdce
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue Jun 3 23:07:48 2008 +0000

    Fix up a couple of values related to encoding overhead.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2497 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index f78abba..96c98a6 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -317,13 +317,13 @@ static void thread_func(void *userdata) {
                  * fully filled up. This is the best time to estimate
                  * the playback position of the server */
 
-                n = u->offset;
+                n = u->offset - u->encoding_overhead;
 
 #ifdef SIOCOUTQ
                 {
                     int l;
                     if (ioctl(u->fd, SIOCOUTQ, &l) >= 0 && l > 0)
-                        n -= l;
+                        n -= (l / u->encoding_ratio);
                 }
 #endif
 

commit 651da7d095f78e930fb758442905d5769cfda1c5
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon Jun 9 21:59:00 2008 +0000

    Minor update to copywrite (I still plan to replace this completely but in the mean time....)
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2499 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/base64.h b/src/modules/rtp/base64.h
index 199c635..347a997 100644
--- a/src/modules/rtp/base64.h
+++ b/src/modules/rtp/base64.h
@@ -7,6 +7,7 @@
   This file is part of PulseAudio.
 
   Copyright 2008 Colin Guthrie
+  Copyright Kungliga Tekniska Høgskolan
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
@@ -26,7 +27,7 @@
 
 /*
   This file was originally inspired by a file developed by
-    Kungliga Tekniska Högskolan
+    Kungliga Tekniska Høgskolan
 */
 
 int pa_base64_encode(const void *data, int size, char **str);

commit 5f527dc47944bbd97a49e8d89427d09850b28e5d
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon Jun 9 21:59:41 2008 +0000

    Add seq and rtptime params to record/flush with a view to using these for timing and device suspension
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2500 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 4085a49..4714d27 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -90,6 +90,9 @@ struct pa_raop_client {
     pa_socket_client *sc;
     int fd;
 
+    uint16_t seq;
+    uint32_t rtptime;
+
     pa_raop_client_cb_t callback;
     void* userdata;
     pa_raop_client_closed_cb_t closed_callback;
@@ -317,7 +320,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
             } else {
                 pa_log_warn("Audio Jack Status missing");
             }
-            pa_rtsp_record(c->rtsp);
+            pa_rtsp_record(c->rtsp, &c->seq, &c->rtptime);
             break;
         }
 
@@ -403,8 +406,6 @@ void pa_raop_client_free(pa_raop_client* c)
 }
 
 
-static void noop(PA_GCC_UNUSED void* p) {}
-
 int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded)
 {
     uint16_t len;
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index f9fe9bf..7004042 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -47,6 +47,8 @@
 #include <pulsecore/strbuf.h>
 #include <pulsecore/poll.h>
 #include <pulsecore/ioline.h>
+#include <pulsecore/time-smoother.h>
+#include <pulsecore/rtclock.h>
 
 #include "rtsp_client.h"
 
@@ -467,9 +469,10 @@ int pa_rtsp_setup(pa_rtsp_client* c) {
 }
 
 
-int pa_rtsp_record(pa_rtsp_client* c) {
+int pa_rtsp_record(pa_rtsp_client* c, uint16_t* seq, uint32_t* rtptime) {
     pa_headerlist* headers;
     int rv;
+    char *info;
 
     pa_assert(c);
     if (!c->session) {
@@ -477,9 +480,14 @@ int pa_rtsp_record(pa_rtsp_client* c) {
         return -1;
     }
 
+    /* Todo: Generate these values randomly as per spec */
+    *seq = *rtptime = 0;
+
     headers = pa_headerlist_new();
     pa_headerlist_puts(headers, "Range", "npt=0-");
-    pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
+    info = pa_sprintf_malloc("seq=%u;rtptime=%u", *seq, *rtptime);
+    pa_headerlist_puts(headers, "RTP-Info", info);
+    pa_xfree(info);
 
     c->state = STATE_RECORD;
     rv = rtsp_exec(c, "RECORD", NULL, NULL, 1, headers);
@@ -506,14 +514,17 @@ int pa_rtsp_setparameter(pa_rtsp_client *c, const char* param) {
 }
 
 
-int pa_rtsp_flush(pa_rtsp_client *c) {
+int pa_rtsp_flush(pa_rtsp_client *c, uint16_t seq, uint32_t rtptime) {
     pa_headerlist* headers;
     int rv;
+    char *info;
 
     pa_assert(c);
 
     headers = pa_headerlist_new();
-    pa_headerlist_puts(headers, "RTP-Info", "seq=0;rtptime=0");
+    info = pa_sprintf_malloc("seq=%u;rtptime=%u", seq, rtptime);
+    pa_headerlist_puts(headers, "RTP-Info", info);
+    pa_xfree(info);
 
     c->state = STATE_FLUSH;
     rv = rtsp_exec(c, "FLUSH", NULL, NULL, 1, headers);
diff --git a/src/modules/rtp/rtsp_client.h b/src/modules/rtp/rtsp_client.h
index 3c5280c..5554018 100644
--- a/src/modules/rtp/rtsp_client.h
+++ b/src/modules/rtp/rtsp_client.h
@@ -66,10 +66,10 @@ void pa_rtsp_remove_header(pa_rtsp_client *c, const char* key);
 int pa_rtsp_announce(pa_rtsp_client* c, const char* sdp);
 
 int pa_rtsp_setup(pa_rtsp_client* c);
-int pa_rtsp_record(pa_rtsp_client* c);
+int pa_rtsp_record(pa_rtsp_client* c, uint16_t* seq, uint32_t* rtptime);
 int pa_rtsp_teardown(pa_rtsp_client* c);
 
 int pa_rtsp_setparameter(pa_rtsp_client* c, const char* param);
-int pa_rtsp_flush(pa_rtsp_client* c);
+int pa_rtsp_flush(pa_rtsp_client* c, uint16_t seq, uint32_t rtptime);
 
 #endif

commit 19dcb529ad3baa8e8e506ddfa703e952044e0f60
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Mon Jun 9 22:01:23 2008 +0000

    Remove unneeded headers accidentially added in r2500.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2501 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 7004042..c0ca49f 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -47,8 +47,6 @@
 #include <pulsecore/strbuf.h>
 #include <pulsecore/poll.h>
 #include <pulsecore/ioline.h>
-#include <pulsecore/time-smoother.h>
-#include <pulsecore/rtclock.h>
 
 #include "rtsp_client.h"
 

commit d86fc75e0cbc9d102dc000d2781f9dfddc89fbbf
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue Jun 10 23:49:35 2008 +0000

    Change the API of the RTSP client a bit.
    
    * Store the mainloop, hostname and port internally on construction
    * This should allow use to easily reconnect if disconnected although this has thus far proved unreliable.
    The changes look like more than they are due to moving a function around.
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2502 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index c0ca49f..88f7781 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -51,6 +51,10 @@
 #include "rtsp_client.h"
 
 struct pa_rtsp_client {
+    pa_mainloop_api *mainloop;
+    char *hostname;
+    uint16_t port;
+
     pa_socket_client *sc;
     pa_iochannel *io;
     pa_ioline *ioline;
@@ -70,72 +74,23 @@ struct pa_rtsp_client {
 
     char *localip;
     char *url;
-    uint16_t port;
+    uint16_t rtp_port;
     uint32_t cseq;
     char *session;
     char *transport;
 };
 
-static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
-                        const char* content_type, const char* content,
-                        int expect_response,
-                        pa_headerlist* headers) {
-    pa_strbuf* buf;
-    char* hdrs;
-    ssize_t l;
-
-    pa_assert(c);
-    pa_assert(c->url);
-
-    if (!cmd)
-        return -1;
-
-    buf = pa_strbuf_new();
-    pa_strbuf_printf(buf, "%s %s RTSP/1.0\r\nCSeq: %d\r\n", cmd, c->url, ++c->cseq);
-    if (c->session)
-        pa_strbuf_printf(buf, "Session: %s\r\n", c->session);
-
-    /* Add the headers */
-    if (headers) {
-        hdrs = pa_headerlist_to_string(headers);
-        pa_strbuf_puts(buf, hdrs);
-        pa_xfree(hdrs);
-    }
-
-    if (content_type && content) {
-        pa_strbuf_printf(buf, "Content-Type: %s\r\nContent-Length: %d\r\n",
-          content_type, (int)strlen(content));
-    }
-
-    pa_strbuf_printf(buf, "User-Agent: %s\r\n", c->useragent);
-
-    if (c->headers) {
-        hdrs = pa_headerlist_to_string(c->headers);
-        pa_strbuf_puts(buf, hdrs);
-        pa_xfree(hdrs);
-    }
-
-    pa_strbuf_puts(buf, "\r\n");
-
-    if (content_type && content) {
-        pa_strbuf_puts(buf, content);
-    }
-
-    /* Our packet is created... now we can send it :) */
-    hdrs = pa_strbuf_tostring_free(buf);
-    /*pa_log_debug("Submitting request:");
-    pa_log_debug(hdrs);*/
-    l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
-    pa_xfree(hdrs);
-
-    return 0;
-}
-
-
-pa_rtsp_client* pa_rtsp_client_new(const char* useragent) {
+pa_rtsp_client* pa_rtsp_client_new(pa_mainloop_api *mainloop, const char* hostname, uint16_t port, const char* useragent) {
     pa_rtsp_client *c;
 
+    pa_assert(mainloop);
+    pa_assert(hostname);
+    pa_assert(port > 0);
+
     c = pa_xnew0(pa_rtsp_client, 1);
+    c->mainloop = mainloop;
+    c->hostname = pa_xstrdup(hostname);
+    c->port = port;
     c->headers = pa_headerlist_new();
 
     if (useragent)
@@ -156,6 +111,7 @@ void pa_rtsp_client_free(pa_rtsp_client* c) {
         else if (c->io)
             pa_iochannel_free(c->io);
 
+        pa_xfree(c->hostname);
         pa_xfree(c->url);
         pa_xfree(c->localip);
         pa_xfree(c->session);
@@ -197,14 +153,14 @@ static void headers_read(pa_rtsp_client *c) {
         while ((token = pa_split(c->transport, delimiters, &token_state))) {
             if ((pc = strstr(token, "="))) {
                 if (0 == strncmp(token, "server_port", 11)) {
-                    pa_atou(pc+1, (uint32_t*)(&c->port));
+                    pa_atou(pc+1, (uint32_t*)(&c->rtp_port));
                     pa_xfree(token);
                     break;
                 }
             }
             pa_xfree(token);
         }
-        if (0 == c->port) {
+        if (0 == c->rtp_port) {
             /* Error no server_port in response */
             pa_headerlist_free(c->response_headers);
             c->response_headers = NULL;
@@ -234,7 +190,6 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
         /* Keep the ioline/iochannel open as they will be freed automatically */
         c->ioline = NULL;
         c->io = NULL;
-        pa_rtsp_client_free(c);
         c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
         return;
     }
@@ -336,8 +291,8 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
 
     pa_assert(sc);
     pa_assert(c);
+    pa_assert(STATE_CONNECT == c->state);
     pa_assert(c->sc == sc);
-
     pa_socket_client_unref(c->sc);
     c->sc = NULL;
 
@@ -368,24 +323,24 @@ static void on_connection(pa_socket_client *sc, pa_iochannel *io, void *userdata
     }
     pa_log_debug("Established RTSP connection from local ip %s", c->localip);
 
-    c->waiting = 1;
-    c->state = STATE_CONNECT;
     if (c->callback)
         c->callback(c, c->state, NULL, c->userdata);
 }
 
-int pa_rtsp_connect(pa_rtsp_client *c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port) {
+int pa_rtsp_connect(pa_rtsp_client *c) {
     pa_assert(c);
-    pa_assert(mainloop);
-    pa_assert(hostname);
-    pa_assert(port > 0);
+    pa_assert(!c->sc);
+
+    pa_xfree(c->session);
+    c->session = NULL;
 
-    if (!(c->sc = pa_socket_client_new_string(mainloop, hostname, port))) {
-        pa_log("failed to connect to server '%s:%d'", hostname, port);
+    if (!(c->sc = pa_socket_client_new_string(c->mainloop, c->hostname, c->port))) {
+        pa_log("failed to connect to server '%s:%d'", c->hostname, c->port);
         return -1;
     }
 
     pa_socket_client_set_callback(c->sc, on_connection, c);
+    c->waiting = 1;
     c->state = STATE_CONNECT;
     return 0;
 }
@@ -415,7 +370,7 @@ const char* pa_rtsp_localip(pa_rtsp_client* c) {
 uint32_t pa_rtsp_serverport(pa_rtsp_client* c) {
     pa_assert(c);
 
-    return c->port;
+    return c->rtp_port;
 }
 
 void pa_rtsp_set_url(pa_rtsp_client* c, const char* url) {
@@ -441,6 +396,64 @@ void pa_rtsp_remove_header(pa_rtsp_client *c, const char* key)
     pa_headerlist_remove(c->headers, key);
 }
 
+static int rtsp_exec(pa_rtsp_client* c, const char* cmd,
+                        const char* content_type, const char* content,
+                        int expect_response,
+                        pa_headerlist* headers) {
+    pa_strbuf* buf;
+    char* hdrs;
+    ssize_t l;
+
+    pa_assert(c);
+    pa_assert(c->url);
+
+    if (!cmd)
+        return -1;
+
+    pa_log_debug("Sending command: %s", cmd);
+
+    buf = pa_strbuf_new();
+    pa_strbuf_printf(buf, "%s %s RTSP/1.0\r\nCSeq: %d\r\n", cmd, c->url, ++c->cseq);
+    if (c->session)
+        pa_strbuf_printf(buf, "Session: %s\r\n", c->session);
+
+    /* Add the headers */
+    if (headers) {
+        hdrs = pa_headerlist_to_string(headers);
+        pa_strbuf_puts(buf, hdrs);
+        pa_xfree(hdrs);
+    }
+
+    if (content_type && content) {
+        pa_strbuf_printf(buf, "Content-Type: %s\r\nContent-Length: %d\r\n",
+          content_type, (int)strlen(content));
+    }
+
+    pa_strbuf_printf(buf, "User-Agent: %s\r\n", c->useragent);
+
+    if (c->headers) {
+        hdrs = pa_headerlist_to_string(c->headers);
+        pa_strbuf_puts(buf, hdrs);
+        pa_xfree(hdrs);
+    }
+
+    pa_strbuf_puts(buf, "\r\n");
+
+    if (content_type && content) {
+        pa_strbuf_puts(buf, content);
+    }
+
+    /* Our packet is created... now we can send it :) */
+    hdrs = pa_strbuf_tostring_free(buf);
+    /*pa_log_debug("Submitting request:");
+    pa_log_debug(hdrs);*/
+    l = pa_iochannel_write(c->io, hdrs, strlen(hdrs));
+    pa_xfree(hdrs);
+
+    return 0;
+}
+
+
 int pa_rtsp_announce(pa_rtsp_client *c, const char* sdp) {
     pa_assert(c);
     if (!sdp)
diff --git a/src/modules/rtp/rtsp_client.h b/src/modules/rtp/rtsp_client.h
index 5554018..dcc9209 100644
--- a/src/modules/rtp/rtsp_client.h
+++ b/src/modules/rtp/rtsp_client.h
@@ -42,17 +42,17 @@ typedef enum {
   STATE_ANNOUNCE,
   STATE_SETUP,
   STATE_RECORD,
+  STATE_FLUSH,
   STATE_TEARDOWN,
   STATE_SET_PARAMETER,
-  STATE_FLUSH,
   STATE_DISCONNECTED
 } pa_rtsp_state;
 typedef void (*pa_rtsp_cb_t)(pa_rtsp_client *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);
 
-pa_rtsp_client* pa_rtsp_client_new(const char* useragent);
+pa_rtsp_client* pa_rtsp_client_new(pa_mainloop_api *mainloop, const char* hostname, uint16_t port, const char* useragent);
 void pa_rtsp_client_free(pa_rtsp_client* c);
 
-int pa_rtsp_connect(pa_rtsp_client* c, pa_mainloop_api *mainloop, const char* hostname, uint16_t port);
+int pa_rtsp_connect(pa_rtsp_client* c);
 void pa_rtsp_set_callback(pa_rtsp_client *c, pa_rtsp_cb_t callback, void *userdata);
 
 void pa_rtsp_disconnect(pa_rtsp_client* c);

commit c49be7891fac98056010cf553042946740061590
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue Jun 10 23:55:58 2008 +0000

    Add some new public API functions to connect and flush.
    
    This allows us to reconnect upon disconnection but this has thus far proved unreliable.
    We no longer close the socket. We leave this to the module thread to do the closing.
    We can also flush the remote buffer now.
    Refs #69
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2503 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 4714d27..48deff0 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -336,22 +336,30 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
             break;
         }
 
+        case STATE_FLUSH:
+            pa_log_debug("RAOP: FLUSHED");
+            break;
+
         case STATE_TEARDOWN:
         case STATE_SET_PARAMETER:
-        case STATE_FLUSH:
             break;
         case STATE_DISCONNECTED:
             pa_assert(c->closed_callback);
-            pa_log_debug("RTSP channel closed");
+            pa_assert(c->rtsp);
+
+            pa_log_debug("RTSP control channel closed");
+            pa_rtsp_client_free(c->rtsp);
             c->rtsp = NULL;
             if (c->fd > 0) {
-                pa_close(c->fd);
+                /* We do not close the fd, we leave it to the closed callback to do that */
                 c->fd = -1;
             }
             if (c->sc) {
                 pa_socket_client_unref(c->sc);
                 c->sc = NULL;
             }
+            pa_xfree(c->sid);
+            c->sid = NULL;
             c->closed_callback(c->closed_userdata);
             break;
     }
@@ -359,12 +367,6 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
 
 pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
 {
-    char *sci;
-    struct {
-        uint32_t a;
-        uint32_t b;
-        uint32_t c;
-    } rand_data;
     pa_raop_client* c = pa_xnew0(pa_raop_client, 1);
 
     pa_assert(core);
@@ -373,7 +375,43 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
     c->core = core;
     c->fd = -1;
     c->host = pa_xstrdup(host);
-    c->rtsp = pa_rtsp_client_new("iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
+
+    if (pa_raop_connect(c)) {
+        pa_raop_client_free(c);
+        return NULL;
+    }
+    return c;
+}
+
+
+void pa_raop_client_free(pa_raop_client* c)
+{
+    pa_assert(c);
+
+    if (c->rtsp)
+        pa_rtsp_client_free(c->rtsp);
+    pa_xfree(c->host);
+    pa_xfree(c);
+}
+
+
+int pa_raop_connect(pa_raop_client* c)
+{
+    char *sci;
+    struct {
+        uint32_t a;
+        uint32_t b;
+        uint32_t c;
+    } rand_data;
+
+    pa_assert(c);
+
+    if (c->rtsp) {
+        pa_log_debug("Connection already in progress");
+        return 0;
+    }
+
+    c->rtsp = pa_rtsp_client_new(c->core->mainloop, c->host, 5000, "iTunes/4.6 (Macintosh; U; PPC Mac OS X 10.3)");
 
     /* Initialise the AES encryption system */
     pa_random(c->aes_iv, sizeof(c->aes_iv));
@@ -386,23 +424,18 @@ pa_raop_client* pa_raop_client_new(pa_core *core, const char* host)
     c->sid = pa_sprintf_malloc("%u", rand_data.a);
     sci = pa_sprintf_malloc("%08x%08x",rand_data.b, rand_data.c);
     pa_rtsp_add_header(c->rtsp, "Client-Instance", sci);
+    pa_xfree(sci);
     pa_rtsp_set_callback(c->rtsp, rtsp_cb, c);
-    if (pa_rtsp_connect(c->rtsp, c->core->mainloop, host, 5000)) {
-        pa_rtsp_client_free(c->rtsp);
-        return NULL;
-    }
-    return c;
+    return pa_rtsp_connect(c->rtsp);
 }
 
 
-void pa_raop_client_free(pa_raop_client* c)
+int pa_raop_flush(pa_raop_client* c)
 {
     pa_assert(c);
 
-    if (c->rtsp)
-        pa_rtsp_client_free(c->rtsp);
-    pa_xfree(c->host);
-    pa_xfree(c);
+    pa_rtsp_flush(c->rtsp, c->seq, c->rtptime);
+    return 0;
 }
 
 
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 303fdaa..882dae1 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -33,6 +33,9 @@ typedef struct pa_raop_client pa_raop_client;
 pa_raop_client* pa_raop_client_new(pa_core *core, const char* host);
 void pa_raop_client_free(pa_raop_client* c);
 
+int pa_raop_connect(pa_raop_client* c);
+int pa_raop_flush(pa_raop_client* c);
+
 int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded);
 
 typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);

commit 15e8420a251ec4912d2df9d29dfb728bdc97f33c
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed Jun 11 00:02:10 2008 +0000

    Still send silence when we are not doing anything else, but also flush the buffers correctly upon recovery from suspension.
    
    Close the RTP socket correctly after passing messages about.
    When not sending silence, the RTSP socket will be closed after some period of inactivity. I'm not sure why this is.
    Sending silence keeps things working and with the flushes after suspension we now get a better latency. As this relies on the auto-suspend feature, it's not exactly ideal.
    Typical latencies are currently about 3s which makes it more or less usuable for listening to music.
    If the connection is disconnected, it will reconnect but I've found that the second connection is silent. Hopefully the silence will prevent the first connection dropping.
    Refs #69
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2504 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 96c98a6..51c2368 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -127,9 +127,31 @@ static const char* const valid_modargs[] = {
 };
 
 enum {
-    SINK_MESSAGE_PASS_SOCKET = PA_SINK_MESSAGE_MAX
+    SINK_MESSAGE_PASS_SOCKET = PA_SINK_MESSAGE_MAX,
+    SINK_MESSAGE_RIP_SOCKET
 };
 
+static void on_connection(PA_GCC_UNUSED int fd, void*userdata) {
+    struct userdata *u = userdata;
+    pa_assert(u);
+
+    pa_assert(u->fd < 0);
+    u->fd = fd;
+
+    pa_log_debug("Connection authenticated, handing fd to IO thread...");
+
+    pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_PASS_SOCKET, NULL, 0, NULL, NULL);
+}
+
+static void on_close(void*userdata) {
+    struct userdata *u = userdata;
+    pa_assert(u);
+
+    pa_log_debug("Connection closed, informing IO thread...");
+
+    pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_RIP_SOCKET, NULL, 0, NULL, NULL);
+}
+
 static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) {
     struct userdata *u = PA_SINK(o)->userdata;
 
@@ -143,14 +165,27 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                     pa_assert(PA_SINK_OPENED(u->sink->thread_info.state));
 
                     pa_smoother_pause(u->smoother, pa_rtclock_usec());
+
+                    /* Issue a FLUSH if we are connected */
+                    if (u->fd >= 0) {
+                        pa_raop_flush(u->raop);
+                    }
                     break;
 
                 case PA_SINK_IDLE:
                 case PA_SINK_RUNNING:
 
-                    if (u->sink->thread_info.state == PA_SINK_SUSPENDED)
+                    if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
                         pa_smoother_resume(u->smoother, pa_rtclock_usec());
 
+                        /* The connection can be closed when idle, so check to
+                           see if we need to reestablish it */
+                        if (u->fd < 0)
+                            pa_raop_connect(u->raop);
+                        else
+                            pa_raop_flush(u->raop);
+                    }
+
                     break;
 
                 case PA_SINK_UNLINKED:
@@ -179,8 +214,34 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
             pollfd->fd = u->fd;
             pollfd->events = POLLOUT;
-            pollfd->revents = 0;
+            /*pollfd->events = */pollfd->revents = 0;
+
+            if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
+                /* Our stream has been suspended so we just flush it.... */
+                pa_raop_flush(u->raop);
+            }
+            return 0;
+        }
+
+        case SINK_MESSAGE_RIP_SOCKET: {
+            pa_assert(u->fd >= 0);
 
+            pa_close(u->fd);
+            u->fd = -1;
+
+            if (u->sink->thread_info.state == PA_SINK_SUSPENDED) {
+
+                pa_log_debug("RTSP control connection closed, but we're suspended so let's not worry about it... we'll open it again later");
+
+                if (u->rtpoll_item)
+                    pa_rtpoll_item_free(u->rtpoll_item);
+                u->rtpoll_item = NULL;
+            } else {
+                /* Quesiton: is this valid here: or should we do some sort of:
+                   return pa_sink_process_msg(PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL);
+                   ?? */
+                pa_module_unload_request(u->module);
+            }
             return 0;
         }
     }
@@ -215,7 +276,7 @@ static void thread_func(void *userdata) {
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
             /* Render some data and write it to the fifo */
-            if (pollfd->revents) {
+            if (/*PA_SINK_OPENED(u->sink->thread_info.state) && */pollfd->revents) {
                 pa_usec_t usec;
                 int64_t n;
                 void *p;
@@ -264,9 +325,10 @@ static void thread_func(void *userdata) {
                             u->encoding_ratio = u->encoded_memchunk.length / (rl - u->raw_memchunk.length);
                         } else {
                             /* We render some silence into our memchunk */
-                            u->encoding_overhead += u->next_encoding_overhead;
                             memcpy(&u->encoded_memchunk, &silence, sizeof(pa_memchunk));
                             pa_memblock_ref(silence.memblock);
+
+                            /* Calculate/store some values to be used with the smoother */
                             u->next_encoding_overhead = silence_overhead;
                             u->encoding_ratio = silence_ratio;
                         }
@@ -302,12 +364,15 @@ static void thread_func(void *userdata) {
 
                         pollfd->revents = 0;
 
-                        if (u->encoded_memchunk.length > 0)
+                        if (u->encoded_memchunk.length > 0) {
+                            /* we've completely written the encoded data, so update our overhead */
+                            u->encoding_overhead += u->next_encoding_overhead;
 
                             /* OK, we wrote less that we asked for,
                              * hence we can assume that the socket
                              * buffers are full now */
                             goto filled_up;
+                        }
                     }
                 }
 
@@ -338,7 +403,7 @@ static void thread_func(void *userdata) {
             }
 
             /* Hmm, nothing to do. Let's sleep */
-            /* pollfd->events = PA_SINK_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0; */
+            pollfd->events = POLLOUT; /*PA_SINK_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0;*/
         }
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
@@ -353,8 +418,16 @@ static void thread_func(void *userdata) {
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
             if (pollfd->revents & ~POLLOUT) {
-                pa_log("FIFO shutdown.");
-                goto fail;
+                if (u->sink->thread_info.state != PA_SINK_SUSPENDED) {
+                    pa_log("FIFO shutdown.");
+                    goto fail;
+                }
+
+                /* We expect this to happen on occasion if we are not sending data.
+                   It's perfectly natural and normal and natural */
+                if (u->rtpoll_item)
+                    pa_rtpoll_item_free(u->rtpoll_item);
+                u->rtpoll_item = NULL;
             }
         }
     }
@@ -371,26 +444,6 @@ finish:
     pa_log_debug("Thread shutting down");
 }
 
-static void on_connection(PA_GCC_UNUSED int fd, void*userdata) {
-    struct userdata *u = userdata;
-    pa_assert(u);
-
-    pa_assert(u->fd < 0);
-    u->fd = fd;
-
-    pa_log_debug("Connection authenticated, handing fd to IO thread...");
-
-    pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_PASS_SOCKET, NULL, 0, NULL, NULL);
-}
-
-static void on_close(void*userdata) {
-    struct userdata *u = userdata;
-    pa_assert(u);
-
-    pa_log_debug("Control connection closed.");
-    pa_module_unload_request(u->module);
-}
-
 int pa__init(pa_module*m) {
     struct userdata *u = NULL;
     const char *p;

commit d997420791cb8defbda65acdf08fe18072d01d7b
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed Jun 11 22:43:27 2008 +0000

    Minor correction of help text
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2518 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 51c2368..545266d 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -73,7 +73,7 @@ PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(FALSE);
 PA_MODULE_USAGE(
         "sink_name=<name for the sink> "
-        "server=<address> cookie=<filename>  "
+        "server=<address>  "
         "format=<sample format> "
         "channels=<number of channels> "
         "rate=<sample rate>");

commit 729bbaf88485207c8637f3c30fffed60a1f73ca1
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed Jun 11 22:44:09 2008 +0000

    Automatic discovery of airtunes devices via Bonjour/Avahi.
    
    This also does some minor reordering in the Makefile.am
    Refs #69
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2519 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/Makefile.am b/src/Makefile.am
index 5a9b902..4ffdfd9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1127,7 +1127,8 @@ endif
 if HAVE_AVAHI
 modlibexec_LTLIBRARIES += \
 		module-zeroconf-publish.la \
-		module-zeroconf-discover.la
+		module-zeroconf-discover.la \
+		module-raop-discover.la
 endif
 
 if HAVE_LIRC
@@ -1207,7 +1208,6 @@ SYMDEF_FILES = \
 		modules/module-esound-compat-spawnfd-symdef.h \
 		modules/module-esound-compat-spawnpid-symdef.h \
 		modules/module-match-symdef.h \
-		modules/module-raop-sink-symdef.h \
 		modules/module-tunnel-sink-symdef.h \
 		modules/module-tunnel-source-symdef.h \
 		modules/module-null-sink-symdef.h \
@@ -1242,6 +1242,8 @@ SYMDEF_FILES = \
 		modules/bluetooth/module-bluetooth-proximity-symdef.h \
 		modules/bluetooth/module-bluetooth-discover-symdef.h \
 		modules/bluetooth/module-bluetooth-device-symdef.h \
+		modules/module-raop-sink-symdef.h \
+		modules/module-raop-discover-symdef.h \
 		modules/gconf/module-gconf-symdef.h \
 		modules/module-position-event-sounds-symdef.h \
 		modules/module-console-kit-symdef.h
@@ -1376,10 +1378,6 @@ module_match_la_SOURCES = modules/module-match.c
 module_match_la_LDFLAGS = -module -avoid-version
 module_match_la_LIBADD = $(AM_LIBADD) libpulsecore.la
 
-module_raop_sink_la_SOURCES = modules/module-raop-sink.c
-module_raop_sink_la_LDFLAGS = -module -avoid-version
-module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la
-
 module_tunnel_sink_la_SOURCES = modules/module-tunnel.c
 module_tunnel_sink_la_CFLAGS = -DTUNNEL_SINK=1 $(AM_CFLAGS)
 module_tunnel_sink_la_LDFLAGS = -module -avoid-version
@@ -1608,6 +1606,17 @@ module_bluetooth_device_la_LDFLAGS = -module -avoid-version
 module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libsocket-util.la
 module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
+# Apple Airtunes/RAOP
+module_raop_sink_la_SOURCES = modules/module-raop-sink.c
+module_raop_sink_la_LDFLAGS = -module -avoid-version
+module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la
+
+module_raop_discover_la_SOURCES = modules/module-raop-discover.c
+module_raop_discover_la_LDFLAGS = -module -avoid-version
+module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore.la
+module_raop_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
+
+
 ###################################
 #        Some minor stuff         #
 ###################################
diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c
new file mode 100644
index 0000000..7f62361
--- /dev/null
+++ b/src/modules/module-raop-discover.c
@@ -0,0 +1,380 @@
+/* $Id$ */
+
+/***
+  This file is part of PulseAudio.
+
+  Copyright 2008 Colin Guthrie
+
+  PulseAudio is free software; you can redistribute it and/or modify
+  it under the terms of the GNU Lesser General Public License as
+  published by the Free Software Foundation; either version 2 of the
+  License, or (at your option) any later version.
+
+  PulseAudio is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU Lesser General Public
+  License along with PulseAudio; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+  USA.
+***/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <avahi-client/client.h>
+#include <avahi-client/lookup.h>
+#include <avahi-common/alternative.h>
+#include <avahi-common/error.h>
+#include <avahi-common/domain.h>
+#include <avahi-common/malloc.h>
+
+#include <pulse/xmalloc.h>
+#include <pulse/util.h>
+
+#include <pulsecore/sink.h>
+#include <pulsecore/source.h>
+#include <pulsecore/native-common.h>
+#include <pulsecore/core-util.h>
+#include <pulsecore/log.h>
+#include <pulsecore/core-subscribe.h>
+#include <pulsecore/hashmap.h>
+#include <pulsecore/modargs.h>
+#include <pulsecore/namereg.h>
+#include <pulsecore/avahi-wrap.h>
+
+#include "module-raop-discover-symdef.h"
+
+PA_MODULE_AUTHOR("Colin Guthrie");
+PA_MODULE_DESCRIPTION("mDNS/DNS-SD Service Discovery of Airtunes");
+PA_MODULE_VERSION(PACKAGE_VERSION);
+PA_MODULE_LOAD_ONCE(TRUE);
+
+#define SERVICE_TYPE_SINK "_raop._tcp"
+
+static const char* const valid_modargs[] = {
+    NULL
+};
+
+struct tunnel {
+    AvahiIfIndex interface;
+    AvahiProtocol protocol;
+    char *name, *type, *domain;
+    uint32_t module_index;
+};
+
+struct userdata {
+    pa_core *core;
+    pa_module *module;
+    AvahiPoll *avahi_poll;
+    AvahiClient *client;
+    AvahiServiceBrowser *sink_browser;
+
+    pa_hashmap *tunnels;
+};
+
+static unsigned tunnel_hash(const void *p) {
+    const struct tunnel *t = p;
+
+    return
+        (unsigned) t->interface +
+        (unsigned) t->protocol +
+        pa_idxset_string_hash_func(t->name) +
+        pa_idxset_string_hash_func(t->type) +
+        pa_idxset_string_hash_func(t->domain);
+}
+
+static int tunnel_compare(const void *a, const void *b) {
+    const struct tunnel *ta = a, *tb = b;
+    int r;
+
+    if (ta->interface != tb->interface)
+        return 1;
+    if (ta->protocol != tb->protocol)
+        return 1;
+    if ((r = strcmp(ta->name, tb->name)))
+        return r;
+    if ((r = strcmp(ta->type, tb->type)))
+        return r;
+    if ((r = strcmp(ta->domain, tb->domain)))
+        return r;
+
+    return 0;
+}
+
+static struct tunnel *tunnel_new(
+        AvahiIfIndex interface, AvahiProtocol protocol,
+        const char *name, const char *type, const char *domain) {
+
+    struct tunnel *t;
+    t = pa_xnew(struct tunnel, 1);
+    t->interface = interface;
+    t->protocol = protocol;
+    t->name = pa_xstrdup(name);
+    t->type = pa_xstrdup(type);
+    t->domain = pa_xstrdup(domain);
+    t->module_index = PA_IDXSET_INVALID;
+    return t;
+}
+
+static void tunnel_free(struct tunnel *t) {
+    pa_assert(t);
+    pa_xfree(t->name);
+    pa_xfree(t->type);
+    pa_xfree(t->domain);
+    pa_xfree(t);
+}
+
+static void resolver_cb(
+        AvahiServiceResolver *r,
+        AvahiIfIndex interface, AvahiProtocol protocol,
+        AvahiResolverEvent event,
+        const char *name, const char *type, const char *domain,
+        const char *host_name, const AvahiAddress *a, uint16_t port,
+        AvahiStringList *txt,
+        AvahiLookupResultFlags flags,
+        void *userdata) {
+
+    struct userdata *u = userdata;
+    struct tunnel *tnl;
+
+    pa_assert(u);
+
+    tnl = tunnel_new(interface, protocol, name, type, domain);
+
+    if (event != AVAHI_RESOLVER_FOUND)
+        pa_log("Resolving of '%s' failed: %s", name, avahi_strerror(avahi_client_errno(u->client)));
+    else {
+        char *device = NULL, *dname, *args;
+        char at[AVAHI_ADDRESS_STR_MAX];
+        AvahiStringList *l;
+        pa_module *m;
+
+        for (l = txt; l; l = l->next) {
+            char *key, *value;
+            pa_assert_se(avahi_string_list_get_pair(l, &key, &value, NULL) == 0);
+
+            pa_log_debug("Found key: '%s' with value: '%s'", key, value);
+            if (strcmp(key, "device") == 0) {
+                pa_xfree(device);
+                device = value;
+                value = NULL;
+            }
+            avahi_free(key);
+            avahi_free(value);
+        }
+
+        if (device)
+            dname = pa_sprintf_malloc("airtunes.%s.%s", host_name, device);
+        else
+            dname = pa_sprintf_malloc("airtunes.%s", host_name);
+
+        if (!pa_namereg_is_valid_name(dname)) {
+            pa_log("Cannot construct valid device name from credentials of service '%s'.", dname);
+            avahi_free(device);
+            pa_xfree(dname);
+            goto finish;
+        }
+
+        /*
+         TODO: allow this syntax of server name in things....
+        args = pa_sprintf_malloc("server=[%s]:%u "
+                                 "sink_name=%s",
+                                 avahi_address_snprint(at, sizeof(at), a), port,
+                                 dname);*/
+        args = pa_sprintf_malloc("server=%s "
+                                 "sink_name=%s",
+                                 avahi_address_snprint(at, sizeof(at), a),
+                                 dname);
+
+        pa_log_debug("Loading module-raop-sink with arguments '%s'", args);
+
+        if ((m = pa_module_load(u->core, "module-raop-sink", args))) {
+            tnl->module_index = m->index;
+            pa_hashmap_put(u->tunnels, tnl, tnl);
+            tnl = NULL;
+        }
+
+        pa_xfree(dname);
+        pa_xfree(args);
+        avahi_free(device);
+    }
+
+finish:
+
+    avahi_service_resolver_free(r);
+
+    if (tnl)
+        tunnel_free(tnl);
+}
+
+static void browser_cb(
+        AvahiServiceBrowser *b,
+        AvahiIfIndex interface, AvahiProtocol protocol,
+        AvahiBrowserEvent event,
+        const char *name, const char *type, const char *domain,
+        AvahiLookupResultFlags flags,
+        void *userdata) {
+
+    struct userdata *u = userdata;
+    struct tunnel *t;
+
+    pa_assert(u);
+
+    if (flags & AVAHI_LOOKUP_RESULT_LOCAL)
+        return;
+
+    t = tunnel_new(interface, protocol, name, type, domain);
+
+    if (event == AVAHI_BROWSER_NEW) {
+
+        if (!pa_hashmap_get(u->tunnels, t))
+            if (!(avahi_service_resolver_new(u->client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, resolver_cb, u)))
+                pa_log("avahi_service_resolver_new() failed: %s", avahi_strerror(avahi_client_errno(u->client)));
+
+        /* We ignore the returned resolver object here, since the we don't
+         * need to attach any special data to it, and we can still destory
+         * it from the callback */
+
+    } else if (event == AVAHI_BROWSER_REMOVE) {
+        struct tunnel *t2;
+
+        if ((t2 = pa_hashmap_get(u->tunnels, t))) {
+            pa_module_unload_by_index(u->core, t2->module_index);
+            pa_hashmap_remove(u->tunnels, t2);
+            tunnel_free(t2);
+        }
+    }
+
+    tunnel_free(t);
+}
+
+static void client_callback(AvahiClient *c, AvahiClientState state, void *userdata) {
+    struct userdata *u = userdata;
+
+    pa_assert(c);
+    pa_assert(u);
+
+    u->client = c;
+
+    switch (state) {
+        case AVAHI_CLIENT_S_REGISTERING:
+        case AVAHI_CLIENT_S_RUNNING:
+        case AVAHI_CLIENT_S_COLLISION:
+
+            if (!u->sink_browser) {
+
+                if (!(u->sink_browser = avahi_service_browser_new(
+                              c,
+                              AVAHI_IF_UNSPEC, AVAHI_PROTO_UNSPEC,
+                              SERVICE_TYPE_SINK,
+                              NULL,
+                              0,
+                              browser_cb, u))) {
+
+                    pa_log("avahi_service_browser_new() failed: %s", avahi_strerror(avahi_client_errno(c)));
+                    pa_module_unload_request(u->module);
+                }
+            }
+
+            break;
+
+        case AVAHI_CLIENT_FAILURE:
+            if (avahi_client_errno(c) == AVAHI_ERR_DISCONNECTED) {
+                int error;
+
+                pa_log_debug("Avahi daemon disconnected.");
+
+                if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
+                    pa_log("avahi_client_new() failed: %s", avahi_strerror(error));
+                    pa_module_unload_request(u->module);
+                }
+            }
+
+            /* Fall through */
+
+        case AVAHI_CLIENT_CONNECTING:
+
+            if (u->sink_browser) {
+                avahi_service_browser_free(u->sink_browser);
+                u->sink_browser = NULL;
+            }
+
+            break;
+
+        default: ;
+    }
+}
+
+int pa__init(pa_module*m) {
+
+    struct userdata *u;
+    pa_modargs *ma = NULL;
+    int error;
+
+    if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
+        pa_log("Failed to parse module arguments.");
+        goto fail;
+    }
+
+    m->userdata = u = pa_xnew(struct userdata, 1);
+    u->core = m->core;
+    u->module = m;
+    u->sink_browser = NULL;
+
+    u->tunnels = pa_hashmap_new(tunnel_hash, tunnel_compare);
+
+    u->avahi_poll = pa_avahi_poll_new(m->core->mainloop);
+
+    if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
+        pa_log("pa_avahi_client_new() failed: %s", avahi_strerror(error));
+        goto fail;
+    }
+
+    pa_modargs_free(ma);
+
+    return 0;
+
+fail:
+    pa__done(m);
+
+    if (ma)
+        pa_modargs_free(ma);
+
+    return -1;
+}
+
+void pa__done(pa_module*m) {
+    struct userdata*u;
+    pa_assert(m);
+
+    if (!(u = m->userdata))
+        return;
+
+    if (u->client)
+        avahi_client_free(u->client);
+
+    if (u->avahi_poll)
+        pa_avahi_poll_free(u->avahi_poll);
+
+    if (u->tunnels) {
+        struct tunnel *t;
+
+        while ((t = pa_hashmap_steal_first(u->tunnels))) {
+            pa_module_unload_by_index(u->core, t->module_index);
+            tunnel_free(t);
+        }
+
+        pa_hashmap_free(u->tunnels, NULL, NULL);
+    }
+
+    pa_xfree(u);
+}

commit 0ff75aea053cb8a7af958aa72d99b27cc90becf6
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed Jun 11 23:01:07 2008 +0000

    Add Lennart back in to Copyright as I copied these files from his originals and was a bit overzealous in changing things ;)
    
    git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2520 fefdeb5f-60dc-0310-8127-8f9354f1896f

diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c
index 7f62361..7f89bb5 100644
--- a/src/modules/module-raop-discover.c
+++ b/src/modules/module-raop-discover.c
@@ -3,6 +3,7 @@
 /***
   This file is part of PulseAudio.
 
+  Copyright 2004-2006 Lennart Poettering
   Copyright 2008 Colin Guthrie
 
   PulseAudio is free software; you can redistribute it and/or modify
diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 545266d..39374a3 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -3,6 +3,7 @@
 /***
   This file is part of PulseAudio.
 
+  Copyright 2004-2006 Lennart Poettering
   Copyright 2008 Colin Guthrie
 
   PulseAudio is free software; you can redistribute it and/or modify

commit 36f2aad5f0892e6738a8d59111c3c9017152db7e
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Tue Jun 24 23:57:37 2008 +0100

    Use the new pa_namereg_make_valid_name() function.

diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c
index 7f89bb5..baa64ee 100644
--- a/src/modules/module-raop-discover.c
+++ b/src/modules/module-raop-discover.c
@@ -154,7 +154,7 @@ static void resolver_cb(
     if (event != AVAHI_RESOLVER_FOUND)
         pa_log("Resolving of '%s' failed: %s", name, avahi_strerror(avahi_client_errno(u->client)));
     else {
-        char *device = NULL, *dname, *args;
+        char *device = NULL, *dname, *vname, *args;
         char at[AVAHI_ADDRESS_STR_MAX];
         AvahiStringList *l;
         pa_module *m;
@@ -178,23 +178,24 @@ static void resolver_cb(
         else
             dname = pa_sprintf_malloc("airtunes.%s", host_name);
 
-        if (!pa_namereg_is_valid_name(dname)) {
-            pa_log("Cannot construct valid device name from credentials of service '%s'.", dname);
+        if (!(vname = pa_namereg_make_valid_name(dname))) {
+            pa_log("Cannot construct valid device name from '%s'.", dname);
             avahi_free(device);
             pa_xfree(dname);
             goto finish;
         }
+        pa_xfree(dname);
 
         /*
          TODO: allow this syntax of server name in things....
         args = pa_sprintf_malloc("server=[%s]:%u "
                                  "sink_name=%s",
                                  avahi_address_snprint(at, sizeof(at), a), port,
-                                 dname);*/
+                                 vname);*/
         args = pa_sprintf_malloc("server=%s "
                                  "sink_name=%s",
                                  avahi_address_snprint(at, sizeof(at), a),
-                                 dname);
+                                 vname);
 
         pa_log_debug("Loading module-raop-sink with arguments '%s'", args);
 
@@ -204,7 +205,7 @@ static void resolver_cb(
             tnl = NULL;
         }
 
-        pa_xfree(dname);
+        pa_xfree(vname);
         pa_xfree(args);
         avahi_free(device);
     }

commit e543e04ca725ef1c240762529e7dafec31749683
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Thu Jul 3 23:47:34 2008 +0100

    Implement a set volume function to expose this capability to higher layers

diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 48deff0..792ecee 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -342,6 +342,7 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
 
         case STATE_TEARDOWN:
         case STATE_SET_PARAMETER:
+            pa_log_debug("RAOP: SET_PARAMETER");
             break;
         case STATE_DISCONNECTED:
             pa_assert(c->closed_callback);
@@ -439,6 +440,29 @@ int pa_raop_flush(pa_raop_client* c)
 }
 
 
+int pa_raop_client_set_volume(pa_raop_client* c, pa_volume_t volume)
+{
+    int rv;
+    double db;
+    char *param;
+
+    pa_assert(c);
+
+    db = pa_sw_volume_to_dB(volume);
+    if (db < VOLUME_MIN)
+        db = VOLUME_MIN;
+    else if (db > VOLUME_MAX)
+        db = VOLUME_MAX;
+
+    param = pa_sprintf_malloc("volume: %0.6f\r\n",  db);
+
+    /* We just hit and hope, cannot wait for the callback */
+    rv = pa_rtsp_setparameter(c->rtsp, param);
+    pa_xfree(param);
+    return rv;
+}
+
+
 int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded)
 {
     uint16_t len;
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 882dae1..3d5ef16 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -36,6 +36,7 @@ void pa_raop_client_free(pa_raop_client* c);
 int pa_raop_connect(pa_raop_client* c);
 int pa_raop_flush(pa_raop_client* c);
 
+int pa_raop_client_set_volume(pa_raop_client* c, pa_volume_t volume);
 int pa_raop_client_encode_sample(pa_raop_client* c, pa_memchunk* raw, pa_memchunk* encoded);
 
 typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);

commit ded09d1f9b00ac793ccc26caea0f8706e88bd521
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Thu Jul 3 23:49:01 2008 +0100

    Implement hardware volume control.
    This allows near instant change of volume when controlling the hardware but the stream volume still suffers from a sizable delay.

diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 39374a3..50ef985 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -102,6 +102,9 @@ struct userdata {
 
     pa_usec_t latency;
 
+    pa_volume_t volume;
+    pa_bool_t muted;
+
     /*esd_format_t format;*/
     int32_t rate;
 
@@ -139,6 +142,9 @@ static void on_connection(PA_GCC_UNUSED int fd, void*userdata) {
     pa_assert(u->fd < 0);
     u->fd = fd;
 
+    /* Set the initial volume */
+    pa_raop_client_set_volume(u->raop, u->volume);
+
     pa_log_debug("Connection authenticated, handing fd to IO thread...");
 
     pa_asyncmsgq_post(u->thread_mq.inq, PA_MSGOBJECT(u->sink), SINK_MESSAGE_PASS_SOCKET, NULL, 0, NULL, NULL);
@@ -250,12 +256,68 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
     return pa_sink_process_msg(o, code, data, offset, chunk);
 }
 
+static int sink_get_volume_cb(pa_sink *s) {
+    struct userdata *u = s->userdata;
+    int i;
+
+    pa_assert(u);
+
+    for (i = 0; i < s->sample_spec.channels; i++) {
+        s->volume.values[i] = u->volume;
+    }
+
+    return 0;
+}
+
+static int sink_set_volume_cb(pa_sink *s) {
+    struct userdata *u = s->userdata;
+    int rv;
+
+    pa_assert(u);
+
+    /* If we're muted, we fake it */
+    if (u->muted)
+        return 0;
+
+    pa_assert(s->sample_spec.channels > 0);
+
+    /* Avoid pointless volume sets */
+    if (u->volume == s->volume.values[0])
+        return 0;
+
+    rv = pa_raop_client_set_volume(u->raop, s->volume.values[0]);
+    if (0 == rv)
+        u->volume = s->volume.values[0];
+
+    return rv;
+}
+
+static int sink_get_mute_cb(pa_sink *s) {
+    struct userdata *u = s->userdata;
+
+    pa_assert(u);
+
+    s->muted = u->muted;
+    return 0;
+}
+
+static int sink_set_mute_cb(pa_sink *s) {
+    struct userdata *u = s->userdata;
+    int rv;
+
+    pa_assert(u);
+
+    rv = pa_raop_client_set_volume(u->raop, (s->muted ? PA_VOLUME_MUTED : u->volume));
+    u->muted = s->muted;
+    return rv;
+}
+
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
     int write_type = 0;
     pa_memchunk silence;
-    uint32_t silence_overhead;
-    double silence_ratio;
+    uint32_t silence_overhead = 0;
+    double silence_ratio = 0;
 
     pa_assert(u);
 
@@ -484,6 +546,9 @@ int pa__init(pa_module*m) {
     u->next_encoding_overhead = 0;
     u->encoding_ratio = 1.0;
 
+    u->volume = roundf(0.7 * PA_VOLUME_NORM);
+    u->muted = FALSE;
+
     pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
     u->rtpoll = pa_rtpoll_new();
     pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY, u->thread_mq.inq);
@@ -508,7 +573,11 @@ int pa__init(pa_module*m) {
 
     u->sink->parent.process_msg = sink_process_msg;
     u->sink->userdata = u;
-    u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK;
+    u->sink->get_volume = sink_get_volume_cb;
+    u->sink->set_volume = sink_set_volume_cb;
+    u->sink->get_mute = sink_get_mute_cb;
+    u->sink->set_mute = sink_set_mute_cb;
+    u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK|PA_SINK_HW_VOLUME_CTRL;
 
     pa_sink_set_module(u->sink, m);
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);

commit 19d28319733f92cc518d0d45a15f15b704f603d8
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun Aug 3 20:52:35 2008 +0100

    Make module-raop-sink/discover work with 0.9.11 API

diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c
index baa64ee..38436a3 100644
--- a/src/modules/module-raop-discover.c
+++ b/src/modules/module-raop-discover.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index 50ef985..b90d4e2 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
@@ -169,7 +167,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             switch ((pa_sink_state_t) PA_PTR_TO_UINT(data)) {
 
                 case PA_SINK_SUSPENDED:
-                    pa_assert(PA_SINK_OPENED(u->sink->thread_info.state));
+                    pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
 
                     pa_smoother_pause(u->smoother, pa_rtclock_usec());
 
@@ -334,12 +332,16 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
+        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
+            if (u->sink->thread_info.rewind_requested)
+                pa_sink_process_rewind(u->sink, 0);
+
         if (u->rtpoll_item) {
             struct pollfd *pollfd;
             pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
             /* Render some data and write it to the fifo */
-            if (/*PA_SINK_OPENED(u->sink->thread_info.state) && */pollfd->revents) {
+            if (/*PA_SINK_IS_OPENED(u->sink->thread_info.state) && */pollfd->revents) {
                 pa_usec_t usec;
                 int64_t n;
                 void *p;
@@ -366,7 +368,7 @@ static void thread_func(void *userdata) {
                     if (u->encoded_memchunk.length <= 0) {
                         if (u->encoded_memchunk.memblock)
                             pa_memblock_unref(u->encoded_memchunk.memblock);
-                        if (PA_SINK_OPENED(u->sink->thread_info.state)) {
+                        if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
                             size_t rl;
 
                             /* We render real data */
@@ -466,7 +468,7 @@ static void thread_func(void *userdata) {
             }
 
             /* Hmm, nothing to do. Let's sleep */
-            pollfd->events = POLLOUT; /*PA_SINK_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0;*/
+            pollfd->events = POLLOUT; /*PA_SINK_IS_OPENED(u->sink->thread_info.state)  ? POLLOUT : 0;*/
         }
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
@@ -509,10 +511,10 @@ finish:
 
 int pa__init(pa_module*m) {
     struct userdata *u = NULL;
-    const char *p;
     pa_sample_spec ss;
     pa_modargs *ma = NULL;
-    char *t;
+    const char *server;
+    pa_sink_new_data data;
 
     pa_assert(m);
 
@@ -538,7 +540,7 @@ int pa__init(pa_module*m) {
     u->module = m;
     m->userdata = u;
     u->fd = -1;
-    u->smoother = pa_smoother_new(PA_USEC_PER_SEC, PA_USEC_PER_SEC*2, TRUE);
+    u->smoother = pa_smoother_new(PA_USEC_PER_SEC, PA_USEC_PER_SEC*2, TRUE, 10);
     pa_memchunk_reset(&u->raw_memchunk);
     pa_memchunk_reset(&u->encoded_memchunk);
     u->offset = 0;
@@ -549,9 +551,8 @@ int pa__init(pa_module*m) {
     u->volume = roundf(0.7 * PA_VOLUME_NORM);
     u->muted = FALSE;
 
-    pa_thread_mq_init(&u->thread_mq, m->core->mainloop);
     u->rtpoll = pa_rtpoll_new();
-    pa_rtpoll_item_new_asyncmsgq(u->rtpoll, PA_RTPOLL_EARLY, u->thread_mq.inq);
+    pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
     u->rtpoll_item = NULL;
 
     /*u->format =
@@ -566,7 +567,23 @@ int pa__init(pa_module*m) {
     /*u->state = STATE_AUTH;*/
     u->latency = 0;
 
-    if (!(u->sink = pa_sink_new(m->core, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, NULL))) {
+    if (!(server = pa_modargs_get_value(ma, "server", NULL))) {
+        pa_log("No server argument given.");
+        goto fail;
+    }
+
+    pa_sink_new_data_init(&data);
+    data.driver = __FILE__;
+    data.module = m;
+    pa_sink_new_data_set_name(&data, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
+    pa_sink_new_data_set_sample_spec(&data, &ss);
+    pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, server);
+    pa_proplist_setf(data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Airtunes sink '%s'", server);
+
+    u->sink = pa_sink_new(m->core, &data, PA_SINK_LATENCY|PA_SINK_NETWORK);
+    pa_sink_new_data_done(&data);
+
+    if (!u->sink) {
         pa_log("Failed to create sink.");
         goto fail;
     }
@@ -579,25 +596,16 @@ int pa__init(pa_module*m) {
     u->sink->set_mute = sink_set_mute_cb;
     u->sink->flags = PA_SINK_LATENCY|PA_SINK_NETWORK|PA_SINK_HW_VOLUME_CTRL;
 
-    pa_sink_set_module(u->sink, m);
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
     pa_sink_set_rtpoll(u->sink, u->rtpoll);
 
-    if (!(p = pa_modargs_get_value(ma, "server", NULL))) {
-        pa_log("No server argument given.");
-        goto fail;
-    }
-
-    if (!(u->raop = pa_raop_client_new(u->core, p))) {
+    if (!(u->raop = pa_raop_client_new(u->core, server))) {
         pa_log("Failed to connect to server.");
         goto fail;
     }
 
     pa_raop_client_set_callback(u->raop, on_connection, u);
     pa_raop_client_set_closed_callback(u->raop, on_close, u);
-    pa_sink_set_description(u->sink, t = pa_sprintf_malloc("Airtunes sink '%s'", p));
-    pa_xfree(t);
-
 
     if (!(u->thread = pa_thread_new(thread_func, u))) {
         pa_log("Failed to create thread.");

commit c3d8bb5b34c45f4dda594cc1d8107cac468fa232
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun Aug 3 20:56:21 2008 +0100

    Remove $Id$ lines left over from SVN

diff --git a/src/modules/rtp/base64.c b/src/modules/rtp/base64.c
index 980b018..8918def 100644
--- a/src/modules/rtp/base64.c
+++ b/src/modules/rtp/base64.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/base64.h b/src/modules/rtp/base64.h
index 347a997..dac0e70 100644
--- a/src/modules/rtp/base64.h
+++ b/src/modules/rtp/base64.h
@@ -1,8 +1,6 @@
 #ifndef foobase64hfoo
 #define foobase64hfoo
 
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/headerlist.c b/src/modules/rtp/headerlist.c
index de8710b..0fef835 100644
--- a/src/modules/rtp/headerlist.c
+++ b/src/modules/rtp/headerlist.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/headerlist.h b/src/modules/rtp/headerlist.h
index 276d0e3..4b9c643 100644
--- a/src/modules/rtp/headerlist.h
+++ b/src/modules/rtp/headerlist.h
@@ -1,8 +1,6 @@
 #ifndef foopulseheaderlisthfoo
 #define foopulseheaderlisthfoo
 
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/raop_client.c b/src/modules/rtp/raop_client.c
index 792ecee..4627545 100644
--- a/src/modules/rtp/raop_client.c
+++ b/src/modules/rtp/raop_client.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/raop_client.h b/src/modules/rtp/raop_client.h
index 3d5ef16..ec3136a 100644
--- a/src/modules/rtp/raop_client.h
+++ b/src/modules/rtp/raop_client.h
@@ -1,8 +1,6 @@
 #ifndef fooraopclientfoo
 #define fooraopclientfoo
 
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/rtsp_client.c b/src/modules/rtp/rtsp_client.c
index 88f7781..9eb3d96 100644
--- a/src/modules/rtp/rtsp_client.c
+++ b/src/modules/rtp/rtsp_client.c
@@ -1,5 +1,3 @@
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 
diff --git a/src/modules/rtp/rtsp_client.h b/src/modules/rtp/rtsp_client.h
index dcc9209..88fb383 100644
--- a/src/modules/rtp/rtsp_client.h
+++ b/src/modules/rtp/rtsp_client.h
@@ -1,8 +1,6 @@
 #ifndef foortspclienthfoo
 #define foortspclienthfoo
 
-/* $Id$ */
-
 /***
   This file is part of PulseAudio.
 

commit 8715121755ad1aa9c083dd70781a63ced13359c2
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sun Aug 3 22:46:21 2008 +0100

    Modularise the RAOP stuff that requires OpenSSL and make it optional at compile time

diff --git a/configure.ac b/configure.ac
index 2b91a00..2a04076 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1000,6 +1000,41 @@ AC_SUBST(POLKIT_LIBS)
 AC_SUBST(HAVE_POLKIT)
 AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
 
+#### OpenSSL support (optional) ####
+
+AC_ARG_ENABLE([openssl],
+    AC_HELP_STRING([--disable-openssl], [Disable OpenSSL support (used for Airtunes/RAOP)]),
+        [
+            case "${enableval}" in
+                yes) openssl=yes ;;
+                no) openssl=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --disable-openssl) ;;
+            esac
+        ],
+        [openssl=auto])
+
+if test "x${openssl}" != xno ; then
+
+    PKG_CHECK_MODULES(OPENSSL, [ openssl > 0.9 ],
+        [
+            HAVE_OPENSSL=1
+            AC_DEFINE([HAVE_OPENSSL], 1, [Have OpenSSL])
+        ],
+        [
+            HAVE_OPENSSL=0
+            if test "x$openssl" = xyes ; then
+                AC_MSG_ERROR([*** OpenSSL support not found])
+            fi
+        ])
+else
+    HAVE_OPENSSL=0
+fi
+
+AC_SUBST(OPENSSL_CFLAGS)
+AC_SUBST(OPENSSL_LIBS)
+AC_SUBST(HAVE_OPENSSL)
+AM_CONDITIONAL([HAVE_OPENSSL], [test "x$HAVE_OPENSSL" = x1])
+
 ### Build and Install man pages ###
 AC_ARG_ENABLE(manpages,
         AS_HELP_STRING([--disable-manpages],[Disable building and installation of man pages]),
@@ -1201,6 +1236,11 @@ if test "x${HAVE_POLKIT}" = "x1" ; then
    ENABLE_POLKIT=yes
 fi
 
+ENABLE_OPENSSL=no
+if test "x${HAVE_OPENSSL}" = "x1" ; then
+   ENABLE_OPENSSL=yes
+fi
+
 ENABLE_PER_USER_ESOUND_SOCKET=no
 if test "x$per_user_esound_socket" = "x1" ; then
    ENABLE_PER_USER_ESOUND_SOCKET=yes
@@ -1232,6 +1272,7 @@ echo "
     Enable TCP Wrappers:           ${ENABLE_TCPWRAP}
     Enable libsamplerate:          ${ENABLE_LIBSAMPLERATE}
     Enable PolicyKit:              ${ENABLE_POLKIT}
+    Enable OpenSSL (for Airtunes): ${ENABLE_OPENSSL}
     System User:                   ${PA_SYSTEM_USER}
     System Group:                  ${PA_SYSTEM_GROUP}
     Realtime Group:                ${PA_REALTIME_GROUP}
diff --git a/src/Makefile.am b/src/Makefile.am
index 4ffdfd9..f216b71 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -62,6 +62,10 @@ AM_CFLAGS += -DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\"
 # This cool debug trap works on i386/gcc only
 AM_CFLAGS += '-DDEBUG_TRAP=__asm__("int $$3")'
 
+if HAVE_OPENSSL
+AM_CFLAGS += -I$(top_builddir)/src/modules/raop
+endif
+
 AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
 AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)
 
@@ -89,6 +93,7 @@ PA_THREAD_OBJS = \
 		pulsecore/semaphore-posix.c pulsecore/semaphore.h
 endif
 
+
 ###################################
 #          Extra files            #
 ###################################
@@ -1009,11 +1014,16 @@ librtp_la_SOURCES = \
 		modules/rtp/sdp.c modules/rtp/sdp.h \
 		modules/rtp/sap.c modules/rtp/sap.h \
 		modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
-		modules/rtp/raop_client.c modules/rtp/raop_client.h \
-		modules/rtp/headerlist.c modules/rtp/headerlist.h \
-		modules/rtp/base64.c modules/rtp/base64.h
+		modules/rtp/headerlist.c modules/rtp/headerlist.h
 librtp_la_LDFLAGS = -avoid-version
-librtp_la_LIBADD = $(AM_LIBADD) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore.la -lssl
+librtp_la_LIBADD = $(AM_LIBADD) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore.la
+
+libraop_la_SOURCES = \
+        modules/raop/raop_client.c modules/raop/raop_client.h \
+        modules/raop/base64.c modules/raop/base64.h
+libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS)
+libraop_la_LDFLAGS = -avoid-version
+libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore.la librtp.la
 
 # X11
 
@@ -1060,7 +1070,6 @@ modlibexec_LTLIBRARIES += \
 		module-remap-sink.la \
 		module-ladspa-sink.la \
 		module-esound-sink.la \
-		module-raop-sink.la \
 		module-tunnel-sink.la \
 		module-tunnel-source.la \
 		module-position-event-sounds.la
@@ -1127,8 +1136,7 @@ endif
 if HAVE_AVAHI
 modlibexec_LTLIBRARIES += \
 		module-zeroconf-publish.la \
-		module-zeroconf-discover.la \
-		module-raop-discover.la
+		module-zeroconf-discover.la
 endif
 
 if HAVE_LIRC
@@ -1186,6 +1194,17 @@ pulselibexec_PROGRAMS += \
 		proximity-helper
 endif
 
+if HAVE_OPENSSL
+modlibexec_LTLIBRARIES += \
+		libraop.la \
+		module-raop-sink.la
+if HAVE_AVAHI
+modlibexec_LTLIBRARIES += \
+		module-raop-discover.la
+endif
+endif
+
+
 # These are generated by a M4 script
 
 SYMDEF_FILES = \
@@ -1609,7 +1628,7 @@ module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 # Apple Airtunes/RAOP
 module_raop_sink_la_SOURCES = modules/module-raop-sink.c
 module_raop_sink_la_LDFLAGS = -module -avoid-version
-module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la
+module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la libraop.la
 
 module_raop_discover_la_SOURCES = modules/module-raop-discover.c
 module_raop_discover_la_LDFLAGS = -module -avoid-version
diff --git a/src/modules/rtp/base64.c b/src/modules/raop/base64.c
similarity index 100%
rename from src/modules/rtp/base64.c
rename to src/modules/raop/base64.c
diff --git a/src/modules/rtp/base64.h b/src/modules/raop/base64.h
similarity index 100%
rename from src/modules/rtp/base64.h
rename to src/modules/raop/base64.h
diff --git a/src/modules/rtp/raop_client.c b/src/modules/raop/raop_client.c
similarity index 100%
rename from src/modules/rtp/raop_client.c
rename to src/modules/raop/raop_client.c
diff --git a/src/modules/rtp/raop_client.h b/src/modules/raop/raop_client.h
similarity index 100%
rename from src/modules/rtp/raop_client.h
rename to src/modules/raop/raop_client.h

commit 59eb64987fdf5dde71638f5f77e705e490ec7133
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Fri Aug 22 09:51:41 2008 +0100

    Follow master change r34dd4a and fix shutdown when --disallow-module-loading=1 is passed

diff --git a/src/modules/module-raop-discover.c b/src/modules/module-raop-discover.c
index 38436a3..3706d92 100644
--- a/src/modules/module-raop-discover.c
+++ b/src/modules/module-raop-discover.c
@@ -248,7 +248,7 @@ static void browser_cb(
         struct tunnel *t2;
 
         if ((t2 = pa_hashmap_get(u->tunnels, t))) {
-            pa_module_unload_by_index(u->core, t2->module_index);
+            pa_module_unload_by_index(u->core, t2->module_index, TRUE);
             pa_hashmap_remove(u->tunnels, t2);
             tunnel_free(t2);
         }
@@ -281,7 +281,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
                               browser_cb, u))) {
 
                     pa_log("avahi_service_browser_new() failed: %s", avahi_strerror(avahi_client_errno(c)));
-                    pa_module_unload_request(u->module);
+                    pa_module_unload_request(u->module, TRUE);
                 }
             }
 
@@ -295,7 +295,7 @@ static void client_callback(AvahiClient *c, AvahiClientState state, void *userda
 
                 if (!(u->client = avahi_client_new(u->avahi_poll, AVAHI_CLIENT_NO_FAIL, client_callback, u, &error))) {
                     pa_log("avahi_client_new() failed: %s", avahi_strerror(error));
-                    pa_module_unload_request(u->module);
+                    pa_module_unload_request(u->module, TRUE);
                 }
             }
 
@@ -369,7 +369,7 @@ void pa__done(pa_module*m) {
         struct tunnel *t;
 
         while ((t = pa_hashmap_steal_first(u->tunnels))) {
-            pa_module_unload_by_index(u->core, t->module_index);
+            pa_module_unload_by_index(u->core, t->module_index, TRUE);
             tunnel_free(t);
         }
 
diff --git a/src/modules/module-raop-sink.c b/src/modules/module-raop-sink.c
index b90d4e2..62f0a73 100644
--- a/src/modules/module-raop-sink.c
+++ b/src/modules/module-raop-sink.c
@@ -245,7 +245,7 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                 /* Quesiton: is this valid here: or should we do some sort of:
                    return pa_sink_process_msg(PA_MSGOBJECT(u->core), PA_CORE_MESSAGE_UNLOAD_MODULE, u->module, 0, NULL);
                    ?? */
-                pa_module_unload_request(u->module);
+                pa_module_unload_request(u->module, TRUE);
             }
             return 0;
         }

commit 91b64bc96b941692f7fd507e4afbe3bd1b9f9001
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Wed Oct 8 22:56:12 2008 +0200

    Fix a potential C++/C99 ism, add a log message on error condition
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index ce8ef19..99ba3e1 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -211,6 +211,7 @@ int pa_pid_file_create(const char *procname) {
     if ((pid = read_pid(fn, fd)) == (pid_t) -1)
         pa_log_warn("Corrupt PID file, overwriting.");
     else if (pid > 0) {
+        int ours = 1;
 
 #ifdef OS_IS_WIN32
         if ((process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid)) != NULL) {
@@ -218,11 +219,13 @@ int pa_pid_file_create(const char *procname) {
 #else
         if (kill(pid, 0) >= 0 || errno != ESRCH) {
 #endif
-            int ours = 1;
 
             if (procname)
-                if ((ours = proc_name_ours(pid, procname)) < 0)
+                if ((ours = proc_name_ours(pid, procname)) < 0) {
+                    pa_log_warn("Could not check to see if pid %lu is a pulseaudio process. "
+                                "Asssuming it is and the daemon is already running.", (unsigned long) pid);
                     goto fail;
+                }
 
             if (ours) {
                 pa_log("Daemon already running.");

commit 8e3e88df8b4f9eb82d305e04b23b22574fb7847d
Merge: 91b64bc... 59eb649...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 8 23:03:16 2008 +0200

    Merge commit 'coling/airtunes-0.9.13'

diff --cc src/Makefile.am
index 7487839,f216b71..4d1812e
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@@ -1234,10 -1261,11 +1262,12 @@@ SYMDEF_FILES = 
  		modules/bluetooth/module-bluetooth-proximity-symdef.h \
  		modules/bluetooth/module-bluetooth-discover-symdef.h \
  		modules/bluetooth/module-bluetooth-device-symdef.h \
+ 		modules/module-raop-sink-symdef.h \
+ 		modules/module-raop-discover-symdef.h \
  		modules/gconf/module-gconf-symdef.h \
  		modules/module-position-event-sounds-symdef.h \
 -		modules/module-console-kit-symdef.h
 +		modules/module-console-kit-symdef.h \
 +		modules/module-flat-volume-symdef.h
  
  EXTRA_DIST += $(SYMDEF_FILES)
  BUILT_SOURCES += $(SYMDEF_FILES)

commit 931cbd19f269a64dd4d8edfa592ac21500cbd380
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Thu Oct 9 19:31:43 2008 -0300

    Fix possible invalid read while attempting to load module-bluetooth-device.

diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
index ae54c0a..a831876 100755
--- a/src/daemon/default.pa.in
+++ b/src/daemon/default.pa.in
@@ -73,7 +73,7 @@ load-module module-native-protocol-unix
 #load-module module-rtp-send source=rtp.monitor
 
 ### Enable flat volumes where possible
-load-module module-flat-volumes
+load-module module-flat-volume
 
 ### Automatically restore the volume of streams and devices
 load-module module-device-restore
diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index a33ca64..79fb7a8 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -346,7 +346,7 @@ static void load_module_for_device(struct userdata *u, struct device *d, const c
     pa_m = pa_module_load(u->module->core, "module-bluetooth-device", args);
     pa_xfree(args);
 
-    if (!m) {
+    if (!pa_m) {
         pa_log_debug("Failed to load module for device %s", d->object_path);
         return;
     }

commit 65ea1a282b88ab263efdf940a10ca20c405d37a1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Oct 13 19:28:14 2008 +0200

    correctly load module-flat-volume instead of module-flat-volumes

diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
index ae54c0a..a831876 100755
--- a/src/daemon/default.pa.in
+++ b/src/daemon/default.pa.in
@@ -73,7 +73,7 @@ load-module module-native-protocol-unix
 #load-module module-rtp-send source=rtp.monitor
 
 ### Enable flat volumes where possible
-load-module module-flat-volumes
+load-module module-flat-volume
 
 ### Automatically restore the volume of streams and devices
 load-module module-device-restore

commit 5a5d2884e08e964a8d94302bd065b2187732cb94
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Oct 13 19:52:02 2008 +0200

    properly remove dbus matches an filters when unloading m-b-d

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index a33ca64..ad436f3 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -485,8 +485,23 @@ void pa__done(pa_module* m) {
         device_free(i);
     }
 
-    if (u->conn)
+    if (u->conn) {
+        DBusError error;
+        dbus_error_init(&error);
+
+        dbus_bus_remove_match(pa_dbus_connection_get(u->conn), "type='signal',sender='org.bluez',interface='org.bluez.Adapter',member='DeviceRemoved'", &error);
+        dbus_error_free(&error);
+
+        dbus_bus_remove_match(pa_dbus_connection_get(u->conn), "type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'", &error);
+        dbus_error_free(&error);
+
+        dbus_bus_remove_match(pa_dbus_connection_get(u->conn), "type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'", &error);
+        dbus_error_free(&error);
+
+        dbus_connection_remove_filter(pa_dbus_connection_get(u->conn), filter_cb, u);
+
         pa_dbus_connection_unref(u->conn);
+    }
 
     pa_xfree(u);
 }

commit d8465f2c4f22629f84c1b70f5b867ae00fd2760c
Author: Colin Guthrie <pulse at colin.guthr.ie>
Date:   Sat Oct 11 18:20:06 2008 +0100

    Fix two typos that broke tunnels
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index 4bbb11a..a46d6e5 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -508,7 +508,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
 
     switch (code) {
 
-        case PA_SINK_MESSAGE_SET_STATE: {
+        case PA_SOURCE_MESSAGE_SET_STATE: {
             int r;
 
             if ((r = pa_source_process_msg(o, code, data, offset, chunk)) >= 0)
@@ -520,7 +520,7 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
         case PA_SOURCE_MESSAGE_GET_LATENCY: {
             pa_usec_t yr, yl, *usec = data;
 
-            yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SINK(o)->sample_spec);
+            yl = pa_bytes_to_usec((uint64_t) u->counter, &PA_SOURCE(o)->sample_spec);
             yr = pa_smoother_get(u->smoother, pa_rtclock_usec());
 
             *usec = yr > yl ? yr - yl : 0;

commit 60c2a82462df9429930894c220f168ef1a3fef38
Merge: d8465f2... 931cbd1...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Oct 13 19:55:11 2008 +0200

    Merge commit 'vudentz/master'


commit d395792788f8e3b81a03a2b508d55f53b8f44cdb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Oct 19 22:24:18 2008 +0200

    always check for libtool prefix binary name to avoid confusion when using both installed and run-from-build-tree versions of PA in parallel

diff --git a/src/pulsecore/pid.c b/src/pulsecore/pid.c
index 99ba3e1..bf9ba98 100644
--- a/src/pulsecore/pid.c
+++ b/src/pulsecore/pid.c
@@ -171,14 +171,14 @@ static int proc_name_ours(pid_t pid, const char *procname) {
         good = pa_startswith(stored, expected);
         pa_xfree(expected);
 
-#if !defined(__OPTIMIZE__)
+/*#if !defined(__OPTIMIZE__)*/
         if (!good) {
             /* libtool likes to rename our binary names ... */
             expected = pa_sprintf_malloc("%lu (lt-%s)", (unsigned long) pid, procname);
             good = pa_startswith(stored, expected);
             pa_xfree(expected);
         }
-#endif
+/*#endif*/
 
         return !!good;
     }

commit d6750583588539d3065daf062c2f13f0e9198eda
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Oct 19 22:25:58 2008 +0200

    Fix spelling of privilige

diff --git a/src/daemon/caps.c b/src/daemon/caps.c
index 707b532..b5cbbc6 100644
--- a/src/daemon/caps.c
+++ b/src/daemon/caps.c
@@ -60,7 +60,7 @@ void pa_drop_root(void) {
     if (uid == 0 || geteuid() != 0)
         return;
 
-    pa_log_info(_("Dropping root priviliges."));
+    pa_log_info(_("Dropping root privileges."));
 
 #if defined(HAVE_SETRESUID)
     pa_assert_se(setresuid(uid, uid, uid) >= 0);
diff --git a/src/daemon/main.c b/src/daemon/main.c
index bc8bc63..2306483 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -222,7 +222,7 @@ static int change_user(void) {
 #elif defined(HAVE_SETREGID)
     r = setregid(gr->gr_gid, gr->gr_gid);
 #else
-#error "No API to drop priviliges"
+#error "No API to drop privileges"
 #endif
 
     if (r < 0) {
@@ -238,7 +238,7 @@ static int change_user(void) {
 #elif defined(HAVE_SETREUID)
     r = setreuid(pw->pw_uid, pw->pw_uid);
 #else
-#error "No API to drop priviliges"
+#error "No API to drop privileges"
 #endif
 
     if (r < 0) {
@@ -382,7 +382,7 @@ int main(int argc, char *argv[]) {
         /* Drop all capabilities except CAP_SYS_NICE  */
         pa_limit_caps();
 
-        /* Drop priviliges, but keep CAP_SYS_NICE */
+        /* Drop privileges, but keep CAP_SYS_NICE */
         pa_drop_root();
 
         /* After dropping root, the effective set is reset, hence,
@@ -476,9 +476,9 @@ int main(int argc, char *argv[]) {
             pa_drop_caps();
 
             if (conf->high_priority || conf->realtime_scheduling)
-                pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
-                                "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-                                "For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
+                pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
+                                "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us privileges. Dropping SUID again.\n"
+                                "For enabling real-time scheduling please acquire the appropriate PolicyKit privileges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
         }
     }
 
@@ -626,7 +626,7 @@ int main(int argc, char *argv[]) {
     if (real_root && !conf->system_instance)
         pa_log_warn(_("This program is not intended to be run as root (unless --system is specified)."));
     else if (!real_root && conf->system_instance) {
-        pa_log(_("Root priviliges required."));
+        pa_log(_("Root privileges required."));
         goto finish;
     }
 

commit b709e1d7b40ddd5b92298fe8061604bf9037bbcf
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Oct 20 20:33:28 2008 +0200

    Make missing git-changelog.perl non-fatal

diff --git a/Makefile.am b/Makefile.am
index facce0d..ebc5e69 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,7 +58,7 @@ dist-hook:
 	if test -d .git ; then \
 		git pull ; \
 		chmod u+w ${distdir}/ChangeLog || true ; \
-		git-changelog.perl > ${distdir}/ChangeLog ; \
+		( git-changelog.perl || echo "git-changelog.perl failed." ) > ${distdir}/ChangeLog 2>&1 ; \
 	fi
 
 .PHONY: homepage distcleancheck doxygen

commit 309bc71f07bdb00ecf050d7a4b1734accafcb95f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:22:28 2008 +0200

    fix invalid validity check

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 8505c63..1384116 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -157,10 +157,10 @@ pa_sink_input* pa_sink_input_new(
     }
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->volume));
-    pa_return_null_if_fail(pa_cvolume_compatible(&data->volume.channels, &data->sample_spec));
+    pa_return_null_if_fail(pa_cvolume_compatible(&data->volume, &data->sample_spec));
 
     pa_return_null_if_fail(pa_cvolume_valid(&data->virtual_volume));
-    pa_return_null_if_fail(pa_cvolume_compatible(&data->virtual_volume.channels, &data->sample_spec));
+    pa_return_null_if_fail(pa_cvolume_compatible(&data->virtual_volume, &data->sample_spec));
 
     if (!data->muted_is_set)
         data->muted = FALSE;

commit 358824b330e20b9e6472fdefc4613e03b20c9abb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:24:45 2008 +0200

    add new virtual function may_move_to to sink inputs/source outputs to allow modules to forbid certain connections

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 1384116..0e1224f 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -108,6 +108,7 @@ static void reset_callbacks(pa_sink_input *i) {
     i->kill = NULL;
     i->get_latency = NULL;
     i->state_change = NULL;
+    i->may_move_to = NULL;
 }
 
 /* Called from main context */
@@ -911,6 +912,35 @@ pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i) {
 }
 
 /* Called from main context */
+pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest) {
+    pa_sink_input_assert_ref(i);
+    pa_assert(PA_SINK_INPUT_IS_LINKED(i->state));
+    pa_sink_assert_ref(dest);
+
+    if (dest == i->sink)
+        return TRUE;
+
+    if (i->flags & PA_SINK_INPUT_DONT_MOVE)
+        return FALSE;
+
+    if (i->sync_next || i->sync_prev) {
+        pa_log_warn("Moving synchronised streams not supported.");
+        return FALSE;
+    }
+
+    if (pa_idxset_size(dest->inputs) >= PA_MAX_INPUTS_PER_SINK) {
+        pa_log_warn("Failed to move sink input: too many inputs per sink.");
+        return FALSE;
+    }
+
+    if (i->may_move_to)
+        if (!i->may_move_to(i, dest))
+            return FALSE;
+
+    return TRUE;
+}
+
+/* Called from main context */
 int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest) {
     pa_resampler *new_resampler;
     pa_sink *origin;
@@ -926,19 +956,9 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest) {
     if (dest == origin)
         return 0;
 
-    if (i->flags & PA_SINK_INPUT_DONT_MOVE)
+    if (!pa_sink_input_may_move_to(i, dest))
         return -1;
 
-    if (i->sync_next || i->sync_prev) {
-        pa_log_warn("Moving synchronised streams not supported.");
-        return -1;
-    }
-
-    if (pa_idxset_size(dest->inputs) >= PA_MAX_INPUTS_PER_SINK) {
-        pa_log_warn("Failed to move sink input: too many inputs per sink.");
-        return -1;
-    }
-
     /* Kill directly connected outputs */
     while ((o = pa_idxset_first(i->direct_outputs, NULL))) {
         pa_assert(o != p);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index ed95fe4..97668c5 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -156,10 +156,15 @@ struct pa_sink_input {
     returns */
     pa_usec_t (*get_latency) (pa_sink_input *i); /* may be NULL */
 
-    /* If non_NULL this function is called from thread context if the
+    /* If non-NULL this function is called from thread context if the
      * state changes. The old state is found in thread_info.state.  */
     void (*state_change) (pa_sink_input *i, pa_sink_input_state_t state); /* may be NULL */
 
+    /* If non-NULL this function is called before this sink input is
+     * move to a sink and if it returns FALSE the move will not
+     * be allowed */
+    pa_bool_t (*may_move_to) (pa_sink_input *i, pa_sink *s); /* may be NULL */
+
     struct {
         pa_sink_input_state_t state;
         pa_atomic_t drained;
@@ -292,6 +297,7 @@ pa_bool_t pa_sink_input_get_mute(pa_sink_input *i);
 pa_resample_method_t pa_sink_input_get_resample_method(pa_sink_input *i);
 
 int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest);
+pa_bool_t pa_sink_input_may_move_to(pa_sink_input *i, pa_sink *dest);
 
 pa_sink_input_state_t pa_sink_input_get_state(pa_sink_input *i);
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 7adc757..376402f 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -90,6 +90,7 @@ static void reset_callbacks(pa_source_output *o) {
     o->kill = NULL;
     o->get_latency = NULL;
     o->state_change = NULL;
+    o->may_move_to = NULL;
 }
 
 /* Called from main context */
@@ -593,6 +594,32 @@ pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o) {
     return o->resample_method;
 }
 
+pa_bool_t pa_source_output_may_move_to(pa_source_output *o, pa_source *dest) {
+    pa_source_output_assert_ref(o);
+    pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(o->state));
+    pa_source_assert_ref(dest);
+
+    if (dest == o->source)
+        return TRUE;
+
+    if (o->flags & PA_SOURCE_OUTPUT_DONT_MOVE)
+        return FALSE;
+
+    if (o->direct_on_input)
+        return FALSE;
+
+    if (pa_idxset_size(dest->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
+        pa_log_warn("Failed to move source output: too many outputs per source.");
+        return FALSE;
+    }
+
+    if (o->may_move_to)
+        if (!o->may_move_to(o, dest))
+            return FALSE;
+
+    return TRUE;
+}
+
 /* Called from main context */
 int pa_source_output_move_to(pa_source_output *o, pa_source *dest) {
     pa_source *origin;
@@ -608,16 +635,8 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest) {
     if (dest == origin)
         return 0;
 
-    if (o->flags & PA_SOURCE_OUTPUT_DONT_MOVE)
-        return -1;
-
-    if (o->direct_on_input)
-        return -1;
-
-    if (pa_idxset_size(dest->outputs) >= PA_MAX_OUTPUTS_PER_SOURCE) {
-        pa_log_warn("Failed to move source output: too many outputs per source.");
+    if (!pa_source_output_may_move_to(o, dest))
         return -1;
-    }
 
     if (o->thread_info.resampler &&
         pa_sample_spec_equal(&origin->sample_spec, &dest->sample_spec) &&
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index a7aac81..6ae10c6 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -126,10 +126,15 @@ struct pa_source_output {
     returns */
     pa_usec_t (*get_latency) (pa_source_output *o); /* may be NULL */
 
-    /* If non_NULL this function is called from thread context if the
+    /* If non-NULL this function is called from thread context if the
      * state changes. The old state is found in thread_info.state.  */
     void (*state_change) (pa_source_output *o, pa_source_output_state_t state); /* may be NULL */
 
+    /* If non-NULL this function is called before this source output
+     * is moved to a source and if it returns FALSE the move
+     * will not be allowed */
+    pa_bool_t (*may_move_to) (pa_source_output *o, pa_source *s); /* may be NULL */
+
     struct {
         pa_source_output_state_t state;
 
@@ -220,6 +225,7 @@ pa_usec_t pa_source_output_get_latency(pa_source_output *i, pa_usec_t *source_la
 
 pa_resample_method_t pa_source_output_get_resample_method(pa_source_output *o);
 
+pa_bool_t pa_source_output_may_move_to(pa_source_output *o, pa_source *dest);
 int pa_source_output_move_to(pa_source_output *o, pa_source *dest);
 
 #define pa_source_output_get_state(o) ((o)->state)

commit 4ee5e06f386c91d436f1702c51484130c1e2f413
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:25:26 2008 +0200

    implement may_move_to for ladspa/remap sinks

diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 9127af0..a27ed71 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -359,6 +359,16 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
     }
 }
 
+/* Called from main context */
+static pa_bool_t sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
+    struct userdata *u;
+
+    pa_sink_input_assert_ref(i);
+    pa_assert_se(u = i->userdata);
+
+    return u->sink != dest;
+}
+
 int pa__init(pa_module*m) {
     struct userdata *u;
     pa_sample_spec ss;
@@ -737,6 +747,7 @@ int pa__init(pa_module*m) {
     u->sink_input->attach = sink_input_attach_cb;
     u->sink_input->detach = sink_input_detach_cb;
     u->sink_input->state_change = sink_input_state_change_cb;
+    u->sink_input->may_move_to = sink_input_may_move_to_cb;
     u->sink_input->userdata = u;
 
     pa_sink_put(u->sink);
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 5b2be11..976a8ce 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -274,6 +274,16 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
     }
 }
 
+/* Called from main context */
+static pa_bool_t sink_input_may_move_to_cb(pa_sink_input *i, pa_sink *dest) {
+    struct userdata *u;
+
+    pa_sink_input_assert_ref(i);
+    pa_assert_se(u = i->userdata);
+
+    return u->sink != dest;
+}
+
 int pa__init(pa_module*m) {
     struct userdata *u;
     pa_sample_spec ss;
@@ -386,6 +396,7 @@ int pa__init(pa_module*m) {
     u->sink_input->detach = sink_input_detach_cb;
     u->sink_input->kill = sink_input_kill_cb;
     u->sink_input->state_change = sink_input_state_change_cb;
+    u->sink_input->may_move_to = sink_input_may_move_to_cb;
     u->sink_input->userdata = u;
 
     pa_sink_put(u->sink);

commit 519bb556cd2ca47e62247a87d5d76cde1ca2c18b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:26:24 2008 +0200

    fix return value of pa_frame_aligned()

diff --git a/src/pulsecore/sample-util.c b/src/pulsecore/sample-util.c
index 7b9ac7b..9f0f795 100644
--- a/src/pulsecore/sample-util.c
+++ b/src/pulsecore/sample-util.c
@@ -777,7 +777,7 @@ size_t pa_frame_align(size_t l, const pa_sample_spec *ss) {
     return (l/fs) * fs;
 }
 
-int pa_frame_aligned(size_t l, const pa_sample_spec *ss) {
+pa_bool_t pa_frame_aligned(size_t l, const pa_sample_spec *ss) {
     size_t fs;
 
     pa_assert(ss);
diff --git a/src/pulsecore/sample-util.h b/src/pulsecore/sample-util.h
index 06ecb72..2fe2c81 100644
--- a/src/pulsecore/sample-util.h
+++ b/src/pulsecore/sample-util.h
@@ -71,7 +71,7 @@ void pa_volume_memchunk(
 
 size_t pa_frame_align(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
 
-int pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
+pa_bool_t pa_frame_aligned(size_t l, const pa_sample_spec *ss) PA_GCC_PURE;
 
 void pa_interleave(const void *src[], unsigned channels, void *dst, size_t ss, unsigned n);
 void pa_deinterleave(const void *src, void *dst[], unsigned channels, size_t ss, unsigned n);

commit 7fecb2340e0ffa3f7ec2c9542cbcdefa70786120
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:27:25 2008 +0200

    convert argument to boolean int in PA_UNLIKELY, too

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 39e9b58..2d031da 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -40,7 +40,7 @@
 #ifndef PA_LIKELY
 #ifdef __GNUC__
 #define PA_LIKELY(x) (__builtin_expect(!!(x),1))
-#define PA_UNLIKELY(x) (__builtin_expect((x),0))
+#define PA_UNLIKELY(x) (__builtin_expect(!!(x),0))
 #else
 #define PA_LIKELY(x) (x)
 #define PA_UNLIKELY(x) (x)

commit c7ed771a98dab63bb954942d20297bb93aed76af
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:28:19 2008 +0200

    fix arguments to format string

diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index e1381a5..5589700 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -134,7 +134,7 @@ static char *get_name(pa_proplist *p, const char *prefix) {
     else if ((r = pa_proplist_gets(p, PA_PROP_MEDIA_NAME)))
         return pa_sprintf_malloc("%s-by-media-name:%s", prefix, r);
 
-    return pa_sprintf_malloc("%s-fallback:%s", prefix);
+    return pa_sprintf_malloc("%s-fallback:%s", prefix, r);
 }
 
 static struct entry* read_entry(struct userdata *u, char *name) {

commit d4c63420320da18a6223554976dec1b02ee9ac90
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:38:55 2008 +0200

    add pa_config_parse_unsigned()

diff --git a/src/pulsecore/conf-parser.c b/src/pulsecore/conf-parser.c
index 58ceab9..ef6d6bb 100644
--- a/src/pulsecore/conf-parser.c
+++ b/src/pulsecore/conf-parser.c
@@ -166,6 +166,24 @@ int pa_config_parse_int(const char *filename, unsigned line, const char *lvalue,
     return 0;
 }
 
+int pa_config_parse_unsigned(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
+    unsigned *u = data;
+    uint32_t k;
+
+    pa_assert(filename);
+    pa_assert(lvalue);
+    pa_assert(rvalue);
+    pa_assert(data);
+
+    if (pa_atou(rvalue, &k) < 0) {
+        pa_log("[%s:%u] Failed to parse numeric value: %s", filename, line, rvalue);
+        return -1;
+    }
+
+    *u = (unsigned) k;
+    return 0;
+}
+
 int pa_config_parse_size(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata) {
     size_t *i = data;
     uint32_t k;
diff --git a/src/pulsecore/conf-parser.h b/src/pulsecore/conf-parser.h
index a5174fc..48a0fd2 100644
--- a/src/pulsecore/conf-parser.h
+++ b/src/pulsecore/conf-parser.h
@@ -41,6 +41,7 @@ int pa_config_parse(const char *filename, FILE *f, const pa_config_item *t, void
 
 /* Generic parsers for integers, size_t, booleans and strings */
 int pa_config_parse_int(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata);
+int pa_config_parse_unsigned(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_size(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_bool(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata);
 int pa_config_parse_string(const char *filename, unsigned line, const char *lvalue, const char *rvalue, void *data, void *userdata);

commit f92a8141188236f07c95a5912e905acab0f75e7d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 18:40:01 2008 +0200

    include log.h near the end so that macro.h can be included in log.h and defines pa_bool_t properly

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index 2d031da..cf02696 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -30,7 +30,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 
-#include <pulsecore/log.h>
 #include <pulse/gccmacro.h>
 
 #ifndef PACKAGE
@@ -221,4 +220,7 @@ typedef int pa_bool_t;
 
 #endif
 
+/* We include this at the very last place */
+#include <pulsecore/log.h>
+
 #endif

commit f4320d83a2f801af34e577585c1abba3a14b9e4c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 19:13:15 2008 +0200

    Support showing a backtrace on log messages

diff --git a/configure.ac b/configure.ac
index 2a04076..f93903d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -297,6 +297,7 @@ AC_CHECK_HEADERS([sys/ioctl.h])
 AC_CHECK_HEADERS([byteswap.h])
 AC_CHECK_HEADERS([sys/syscall.h])
 AC_CHECK_HEADERS([sys/eventfd.h])
+AC_CHECK_HEADERS([execinfo.h])
 
 #### Typdefs, structures, etc. ####
 
diff --git a/src/pulsecore/log.c b/src/pulsecore/log.c
index b1de696..adf2f11 100644
--- a/src/pulsecore/log.c
+++ b/src/pulsecore/log.c
@@ -30,6 +30,10 @@
 #include <string.h>
 #include <errno.h>
 
+#ifdef HAVE_EXECINFO_H
+#include <execinfo.h>
+#endif
+
 #ifdef HAVE_SYSLOG_H
 #include <syslog.h>
 #endif
@@ -49,11 +53,15 @@
 #define ENV_LOGLEVEL "PULSE_LOG"
 #define ENV_LOGMETA "PULSE_LOG_META"
 #define ENV_LOGTIME "PULSE_LOG_TIME"
+#define ENV_LOGBACKTRACE "PULSE_LOG_BACKTRACE"
 
 static char *log_ident = NULL, *log_ident_local = NULL;
 static pa_log_target_t log_target = PA_LOG_STDERR;
 static pa_log_func_t user_log_func = NULL;
 static pa_log_level_t maximal_level = PA_LOG_ERROR;
+static unsigned show_backtrace = 0;
+static pa_bool_t show_meta = FALSE;
+static pa_bool_t show_time = FALSE;
 
 #ifdef HAVE_SYSLOG_H
 static const int level_to_syslog[] = {
@@ -105,6 +113,74 @@ void pa_log_set_target(pa_log_target_t t, pa_log_func_t func) {
     user_log_func = func;
 }
 
+void pa_log_set_show_meta(pa_bool_t b) {
+    show_meta = b;
+}
+
+void pa_log_set_show_time(pa_bool_t b) {
+    show_time = b;
+}
+
+void pa_log_set_show_backtrace(unsigned nlevels) {
+    show_backtrace = nlevels;
+}
+
+#ifdef HAVE_EXECINFO_H
+
+static char* get_backtrace(unsigned show_nframes) {
+    void* trace[32];
+    int n_frames;
+    char **symbols, *e, *r;
+    unsigned j, n;
+    size_t a;
+
+    if (show_nframes <= 0)
+        return NULL;
+
+    n_frames = backtrace(trace, PA_ELEMENTSOF(trace));
+
+    if (n_frames <= 0)
+        return NULL;
+
+    symbols = backtrace_symbols(trace, n_frames);
+
+    if (!symbols)
+        return NULL;
+
+    n = PA_MIN((unsigned) n_frames, show_nframes);
+
+    a = 4;
+
+    for (j = 0; j < n; j++) {
+        if (j > 0)
+            a += 2;
+        a += strlen(symbols[j]);
+    }
+
+    r = pa_xnew(char, a);
+
+    strcpy(r, " (");
+    e = r + 2;
+
+    for (j = 0; j < n; j++) {
+        if (j > 0) {
+            strcpy(e, "<<");
+            e += 2;
+        }
+
+        strcpy(e, symbols[j]);
+        e += strlen(symbols[j]);
+    }
+
+    strcpy(e, ")");
+
+    free(symbols);
+
+    return r;
+}
+
+#endif
+
 void pa_log_levelv_meta(
         pa_log_level_t level,
         const char*file,
@@ -116,32 +192,43 @@ void pa_log_levelv_meta(
     const char *e;
     char *t, *n;
     int saved_errno = errno;
+    char *bt = NULL;
+    pa_log_level_t ml;
+#ifdef HAVE_EXECINFO_H
+    unsigned show_bt;
+#endif
 
     /* We don't use dynamic memory allocation here to minimize the hit
      * in RT threads */
-    char text[1024], location[128], timestamp[32];
+    char text[4096], location[128], timestamp[32];
 
     pa_assert(level < PA_LOG_LEVEL_MAX);
     pa_assert(format);
 
-    if ((e = getenv(ENV_LOGLEVEL)))
-        maximal_level = atoi(e);
+    ml = maximal_level;
+
+    if (PA_UNLIKELY((e = getenv(ENV_LOGLEVEL)))) {
+        pa_log_level_t eml = (pa_log_level_t) atoi(e);
 
-    if (level > maximal_level) {
+        if (eml > ml)
+            ml = eml;
+    }
+
+    if (PA_LIKELY(level > ml)) {
         errno = saved_errno;
         return;
     }
 
     pa_vsnprintf(text, sizeof(text), format, ap);
 
-    if (getenv(ENV_LOGMETA) && file && line > 0 && func)
+    if ((show_meta || getenv(ENV_LOGMETA)) && file && line > 0 && func)
         pa_snprintf(location, sizeof(location), "[%s:%i %s()] ", file, line, func);
     else if (file)
         pa_snprintf(location, sizeof(location), "%s: ", pa_path_get_filename(file));
     else
         location[0] = 0;
 
-    if (getenv(ENV_LOGTIME)) {
+    if (show_time || getenv(ENV_LOGTIME)) {
         static pa_usec_t start, last;
         pa_usec_t u, a, r;
 
@@ -168,6 +255,19 @@ void pa_log_levelv_meta(
     } else
         timestamp[0] = 0;
 
+#ifdef HAVE_EXECINFO_H
+    show_bt = show_backtrace;
+
+    if ((e = getenv(ENV_LOGBACKTRACE))) {
+        unsigned ebt = (unsigned) atoi(e);
+
+        if (ebt > show_bt)
+            show_bt = ebt;
+    }
+
+    bt = get_backtrace(show_bt);
+#endif
+
     if (!pa_utf8_valid(text))
         pa_log_level(level, __FILE__": invalid UTF-8 string following below:");
 
@@ -182,19 +282,22 @@ void pa_log_levelv_meta(
 
         switch (log_target) {
             case PA_LOG_STDERR: {
-                const char *prefix = "", *suffix = "";
+                const char *prefix = "", *suffix = "", *grey = "";
                 char *local_t;
 
 #ifndef OS_IS_WIN32
                 /* Yes indeed. Useless, but fun! */
                 if (isatty(STDERR_FILENO)) {
-                    if (level <= PA_LOG_ERROR) {
+                    if (level <= PA_LOG_ERROR)
                         prefix = "\x1B[1;31m";
-                        suffix = "\x1B[0m";
-                    } else if (level <= PA_LOG_WARN) {
+                    else if (level <= PA_LOG_WARN)
                         prefix = "\x1B[1m";
+
+                    if (bt)
+                        grey = "\x1B[2m";
+
+                    if (grey[0] || prefix[0])
                         suffix = "\x1B[0m";
-                    }
                 }
 #endif
 
@@ -202,9 +305,9 @@ void pa_log_levelv_meta(
                  * minimize the hit in RT threads */
                 local_t = pa_utf8_to_locale(t);
                 if (!local_t)
-                    fprintf(stderr, "%s%c: %s%s%s%s\n", timestamp, level_to_char[level], location, prefix, t, suffix);
+                    fprintf(stderr, "%s%c: %s%s%s%s%s%s\n", timestamp, level_to_char[level], location, prefix, t, grey, pa_strempty(bt), suffix);
                 else {
-                    fprintf(stderr, "%s%c: %s%s%s%s\n", timestamp, level_to_char[level], location, prefix, local_t, suffix);
+                    fprintf(stderr, "%s%c: %s%s%s%s%s%s\n", timestamp, level_to_char[level], location, prefix, local_t, grey, pa_strempty(bt), suffix);
                     pa_xfree(local_t);
                 }
 
@@ -219,9 +322,9 @@ void pa_log_levelv_meta(
 
                 local_t = pa_utf8_to_locale(t);
                 if (!local_t)
-                    syslog(level_to_syslog[level], "%s%s%s", timestamp, location, t);
+                    syslog(level_to_syslog[level], "%s%s%s%s", timestamp, location, t, pa_strempty(bt));
                 else {
-                    syslog(level_to_syslog[level], "%s%s%s", timestamp, location, local_t);
+                    syslog(level_to_syslog[level], "%s%s%s%s", timestamp, location, local_t, pa_strempty(bt));
                     pa_xfree(local_t);
                 }
 
diff --git a/src/pulsecore/log.h b/src/pulsecore/log.h
index 633227f..3d66e90 100644
--- a/src/pulsecore/log.h
+++ b/src/pulsecore/log.h
@@ -25,6 +25,8 @@
 
 #include <stdarg.h>
 #include <stdlib.h>
+
+#include <pulsecore/macro.h>
 #include <pulse/gccmacro.h>
 
 /* A simple logging subsystem */
@@ -54,8 +56,11 @@ typedef void (*pa_log_func_t)(pa_log_level_t t, const char*s);
 /* Set another log target. If t is PA_LOG_USER you may specify a function that is called every log string */
 void pa_log_set_target(pa_log_target_t t, pa_log_func_t func);
 
-/* Minimal log level */
+/* Maximal log level */
 void pa_log_set_maximal_level(pa_log_level_t l);
+void pa_log_set_show_meta(pa_bool_t b);
+void pa_log_set_show_time(pa_bool_t b);
+void pa_log_set_show_backtrace(unsigned nlevels);
 
 void pa_log_level_meta(
         pa_log_level_t level,

commit 651a451c54011d6730f6cc834ed84d9aaf209ba6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 19:14:07 2008 +0200

    support changing logging parameters during runtime using the CLI

diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index 1624165..b5ff98d 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -117,6 +117,10 @@ static int pa_cli_command_vacuum(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa
 static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_log_level(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
+static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail);
 
 /* A method table for all available commands */
 
@@ -167,6 +171,10 @@ static const struct command commands[] = {
     { "suspend-sink",            pa_cli_command_suspend_sink,       "Suspend sink (args: index|name, bool)", 3},
     { "suspend-source",          pa_cli_command_suspend_source,     "Suspend source (args: index|name, bool)", 3},
     { "suspend",                 pa_cli_command_suspend,            "Suspend all sinks and all sources (args: bool)", 2},
+    { "set-log-level",           pa_cli_command_log_level,          "Change the log level (args: numeric level)", 2},
+    { "set-log-meta",            pa_cli_command_log_meta,           "Show source code location in log messages (args: bool)", 2},
+    { "set-log-time",            pa_cli_command_log_time,           "Show timestamps in log messages (args: bool)", 2},
+    { "set-log-backtrace",       pa_cli_command_log_backtrace,      "Show bakctrace in log messages (args: frames)", 2},
     { NULL, NULL, NULL, 0 }
 };
 
@@ -1203,6 +1211,102 @@ static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, p
     return 0;
 }
 
+static int pa_cli_command_log_level(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+    const char *m;
+    uint32_t level;
+
+    pa_core_assert_ref(c);
+    pa_assert(t);
+    pa_assert(buf);
+    pa_assert(fail);
+
+    if (!(m = pa_tokenizer_get(t, 1))) {
+        pa_strbuf_puts(buf, "You need to specify a log level (0..4).\n");
+        return -1;
+    }
+
+    if (pa_atou(m, &level) < 0 || level >= PA_LOG_LEVEL_MAX) {
+        pa_strbuf_puts(buf, "Failed to parse log level.\n");
+        return -1;
+    }
+
+    pa_log_set_maximal_level(level);
+
+    return 0;
+}
+
+static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+    const char *m;
+    pa_bool_t b;
+
+    pa_core_assert_ref(c);
+    pa_assert(t);
+    pa_assert(buf);
+    pa_assert(fail);
+
+    if (!(m = pa_tokenizer_get(t, 1))) {
+        pa_strbuf_puts(buf, "You need to specify a boolean.\n");
+        return -1;
+    }
+
+    if ((b = pa_parse_boolean(m)) < 0) {
+        pa_strbuf_puts(buf, "Failed to parse log meta switch.\n");
+        return -1;
+    }
+
+    pa_log_set_show_meta(b);
+
+    return 0;
+}
+
+static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+    const char *m;
+    pa_bool_t b;
+
+    pa_core_assert_ref(c);
+    pa_assert(t);
+    pa_assert(buf);
+    pa_assert(fail);
+
+    if (!(m = pa_tokenizer_get(t, 1))) {
+        pa_strbuf_puts(buf, "You need to specify a boolean.\n");
+        return -1;
+    }
+
+    if ((b = pa_parse_boolean(m)) < 0) {
+        pa_strbuf_puts(buf, "Failed to parse log meta switch.\n");
+        return -1;
+    }
+
+    pa_log_set_show_time(b);
+
+    return 0;
+}
+
+static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
+    const char *m;
+    uint32_t nframes;
+
+    pa_core_assert_ref(c);
+    pa_assert(t);
+    pa_assert(buf);
+    pa_assert(fail);
+
+    if (!(m = pa_tokenizer_get(t, 1))) {
+        pa_strbuf_puts(buf, "You need to specify a backtrace level.\n");
+        return -1;
+    }
+
+    if (pa_atou(m, &nframes) < 0 || nframes >= 1000) {
+        pa_strbuf_puts(buf, "Failed to parse backtrace level.\n");
+        return -1;
+    }
+
+    pa_log_set_show_backtrace(nframes);
+
+    return 0;
+}
+
 static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
     pa_module *m;
     pa_sink *sink;

commit 496499c0df237dea16344cc7bc4d30efa0868317
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 19:15:41 2008 +0200

    Make log meta, time, backtrace configurable using config file

diff --git a/src/daemon/daemon-conf.c b/src/daemon/daemon-conf.c
index 939b25d..d7ffc10 100644
--- a/src/daemon/daemon-conf.c
+++ b/src/daemon/daemon-conf.c
@@ -74,6 +74,9 @@ static const pa_daemon_conf default_conf = {
     .default_script_file = NULL,
     .log_target = PA_LOG_SYSLOG,
     .log_level = PA_LOG_NOTICE,
+    .log_backtrace = 0,
+    .log_meta = FALSE,
+    .log_time = FALSE,
     .resample_method = PA_RESAMPLER_AUTO,
     .disable_remixing = FALSE,
     .disable_lfe_remixing = TRUE,
@@ -399,6 +402,7 @@ static int parse_rtprio(const char *filename, unsigned line, const char *lvalue,
 int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
     int r = -1;
     FILE *f = NULL;
+    unsigned i = 0;
 
     pa_config_item table[] = {
         { "daemonize",                  pa_config_parse_bool,     NULL },
@@ -431,6 +435,9 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
         { "disable-lfe-remixing",       pa_config_parse_bool,     NULL },
         { "load-default-script-file",   pa_config_parse_bool,     NULL },
         { "shm-size-bytes",             pa_config_parse_size,     NULL },
+        { "log-meta",                   pa_config_parse_bool,     NULL },
+        { "log-time",                   pa_config_parse_bool,     NULL },
+        { "log-backtrace",              pa_config_parse_unsigned, NULL },
 #ifdef HAVE_SYS_RESOURCE_H
         { "rlimit-fsize",               parse_rlimit,             NULL },
         { "rlimit-data",                parse_rlimit,             NULL },
@@ -467,98 +474,75 @@ int pa_daemon_conf_load(pa_daemon_conf *c, const char *filename) {
         { NULL,                         NULL,                     NULL },
     };
 
-    table[0].data = &c->daemonize;
-    table[1].data = &c->fail;
-    table[2].data = &c->high_priority;
-    table[3].data = &c->realtime_scheduling;
-    table[4].data = &c->disallow_module_loading;
-    table[5].data = &c->disallow_exit;
-    table[6].data = &c->use_pid_file;
-    table[7].data = &c->system_instance;
-    table[8].data = &c->no_cpu_limit;
-    table[9].data = &c->disable_shm;
-    table[10].data = &c->exit_idle_time;
-    table[11].data = &c->module_idle_time;
-    table[12].data = &c->scache_idle_time;
-    table[13].data = c;
-    table[14].data = &c->dl_search_path;
-    table[15].data = &c->default_script_file;
-    table[16].data = c;
-    table[17].data = c;
-    table[18].data = c;
-    table[19].data = c;
-    table[20].data = c;
-    table[21].data = c;
-    table[22].data = c;
-    table[23].data = c;
-    table[24].data = c;
-    table[25].data = c;
-    table[26].data = &c->disable_remixing;
-    table[27].data = &c->disable_lfe_remixing;
-    table[28].data = &c->load_default_script_file;
-    table[29].data = &c->shm_size;
+    table[i++].data = &c->daemonize;
+    table[i++].data = &c->fail;
+    table[i++].data = &c->high_priority;
+    table[i++].data = &c->realtime_scheduling;
+    table[i++].data = &c->disallow_module_loading;
+    table[i++].data = &c->disallow_exit;
+    table[i++].data = &c->use_pid_file;
+    table[i++].data = &c->system_instance;
+    table[i++].data = &c->no_cpu_limit;
+    table[i++].data = &c->disable_shm;
+    table[i++].data = &c->exit_idle_time;
+    table[i++].data = &c->module_idle_time;
+    table[i++].data = &c->scache_idle_time;
+    table[i++].data = c;
+    table[i++].data = &c->dl_search_path;
+    table[i++].data = &c->default_script_file;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = c;
+    table[i++].data = &c->disable_remixing;
+    table[i++].data = &c->disable_lfe_remixing;
+    table[i++].data = &c->load_default_script_file;
+    table[i++].data = &c->shm_size;
+    table[i++].data = &c->log_meta;
+    table[i++].data = &c->log_time;
+    table[i++].data = &c->log_backtrace;
 #ifdef HAVE_SYS_RESOURCE_H
-    table[30].data = &c->rlimit_fsize;
-    table[31].data = &c->rlimit_data;
-    table[32].data = &c->rlimit_stack;
-    table[33].data = &c->rlimit_as;
-    table[34].data = &c->rlimit_core;
-    table[35].data = &c->rlimit_nofile;
-    table[36].data = &c->rlimit_as;
+    table[i++].data = &c->rlimit_fsize;
+    table[i++].data = &c->rlimit_data;
+    table[i++].data = &c->rlimit_stack;
+    table[i++].data = &c->rlimit_as;
+    table[i++].data = &c->rlimit_core;
+    table[i++].data = &c->rlimit_nofile;
+    table[i++].data = &c->rlimit_as;
 #ifdef RLIMIT_NPROC
-    table[37].data = &c->rlimit_nproc;
+    table[i++].data = &c->rlimit_nproc;
 #endif
-
 #ifdef RLIMIT_MEMLOCK
-#ifndef RLIMIT_NPROC
-#error "Houston, we have a numbering problem!"
-#endif
-    table[38].data = &c->rlimit_memlock;
+    table[i++].data = &c->rlimit_memlock;
 #endif
-
 #ifdef RLIMIT_LOCKS
-#ifndef RLIMIT_MEMLOCK
-#error "Houston, we have a numbering problem!"
-#endif
-    table[39].data = &c->rlimit_locks;
+    table[i++].data = &c->rlimit_locks;
 #endif
-
 #ifdef RLIMIT_SIGPENDING
-#ifndef RLIMIT_LOCKS
-#error "Houston, we have a numbering problem!"
-#endif
-    table[40].data = &c->rlimit_sigpending;
+    table[i++].data = &c->rlimit_sigpending;
 #endif
-
 #ifdef RLIMIT_MSGQUEUE
-#ifndef RLIMIT_SIGPENDING
-#error "Houston, we have a numbering problem!"
-#endif
-    table[41].data = &c->rlimit_msgqueue;
+    table[i++].data = &c->rlimit_msgqueue;
 #endif
-
 #ifdef RLIMIT_NICE
-#ifndef RLIMIT_MSGQUEUE
-#error "Houston, we have a numbering problem!"
-#endif
-    table[42].data = &c->rlimit_nice;
+    table[i++].data = &c->rlimit_nice;
 #endif
-
 #ifdef RLIMIT_RTPRIO
-#ifndef RLIMIT_NICE
-#error "Houston, we have a numbering problem!"
-#endif
-    table[43].data = &c->rlimit_rtprio;
+    table[i++].data = &c->rlimit_rtprio;
 #endif
-
 #ifdef RLIMIT_RTTIME
-#ifndef RLIMIT_RTTIME
-#error "Houston, we have a numbering problem!"
-#endif
-    table[44].data = &c->rlimit_rttime;
+    table[i++].data = &c->rlimit_rttime;
 #endif
 #endif
 
+    pa_assert(i == PA_ELEMENTSOF(table)-1);
+
     pa_xfree(c->config_file);
     c->config_file = NULL;
 
@@ -674,6 +658,9 @@ char *pa_daemon_conf_dump(pa_daemon_conf *c) {
     pa_strbuf_printf(s, "default-fragments = %u\n", c->default_n_fragments);
     pa_strbuf_printf(s, "default-fragment-size-msec = %u\n", c->default_fragment_size_msec);
     pa_strbuf_printf(s, "shm-size-bytes = %lu\n", (unsigned long) c->shm_size);
+    pa_strbuf_printf(s, "log-meta = %s\n", pa_yes_no(c->log_meta));
+    pa_strbuf_printf(s, "log-time = %s\n", pa_yes_no(c->log_time));
+    pa_strbuf_printf(s, "log-backtrace = %u\n", c->log_backtrace);
 #ifdef HAVE_SYS_RESOURCE_H
     pa_strbuf_printf(s, "rlimit-fsize = %li\n", c->rlimit_fsize.is_set ? (long int) c->rlimit_fsize.value : -1);
     pa_strbuf_printf(s, "rlimit-data = %li\n", c->rlimit_data.is_set ? (long int) c->rlimit_data.value : -1);
diff --git a/src/daemon/daemon-conf.h b/src/daemon/daemon-conf.h
index 9032926..04a4ebe 100644
--- a/src/daemon/daemon-conf.h
+++ b/src/daemon/daemon-conf.h
@@ -68,7 +68,9 @@ typedef struct pa_daemon_conf {
         disable_remixing,
         disable_lfe_remixing,
         load_default_script_file,
-        disallow_exit;
+        disallow_exit,
+        log_meta,
+        log_time;
     int exit_idle_time,
         module_idle_time,
         scache_idle_time,
@@ -79,6 +81,7 @@ typedef struct pa_daemon_conf {
     char *script_commands, *dl_search_path, *default_script_file;
     pa_log_target_t log_target;
     pa_log_level_t log_level;
+    unsigned log_backtrace;
     char *config_file;
 
 #ifdef HAVE_SYS_RESOURCE_H
diff --git a/src/daemon/daemon.conf.in b/src/daemon/daemon.conf.in
index c672d42..00a9593 100644
--- a/src/daemon/daemon.conf.in
+++ b/src/daemon/daemon.conf.in
@@ -45,6 +45,9 @@
 
 ; log-target = auto
 ; log-level = notice
+; log-meta = no
+; log-time = no
+; log-backtrace = 0
 
 ; resample-method = speex-float-3
 ; disable-remixing = no
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 2306483..f6d2512 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -428,6 +428,9 @@ int main(int argc, char *argv[]) {
 
     pa_log_set_maximal_level(conf->log_level);
     pa_log_set_target(conf->auto_log_target ? PA_LOG_STDERR : conf->log_target, NULL);
+    pa_log_set_show_meta(conf->log_meta);
+    pa_log_set_show_backtrace(conf->log_backtrace);
+    pa_log_set_show_time(conf->log_time);
 
     pa_log_debug("Started as real root: %s, suid root: %s", pa_yes_no(real_root), pa_yes_no(suid_root));
 

commit 16471915af1d95f4e4953df7c0f0c5e491d57d30
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 19:16:49 2008 +0200

    make log meta, time, backtrace configurable using command line

diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
index fbd6dc3..0bfc8a9 100644
--- a/src/daemon/cmdline.c
+++ b/src/daemon/cmdline.c
@@ -55,6 +55,9 @@ enum {
     ARG_MODULE_IDLE_TIME,
     ARG_SCACHE_IDLE_TIME,
     ARG_LOG_TARGET,
+    ARG_LOG_META,
+    ARG_LOG_TIME,
+    ARG_LOG_BACKTRACE,
     ARG_LOAD,
     ARG_FILE,
     ARG_DL_SEARCH_PATH,
@@ -88,6 +91,9 @@ static const struct option long_options[] = {
     {"module-idle-time",            2, 0, ARG_MODULE_IDLE_TIME},
     {"scache-idle-time",            2, 0, ARG_SCACHE_IDLE_TIME},
     {"log-target",                  1, 0, ARG_LOG_TARGET},
+    {"log-meta",                    2, 0, ARG_LOG_META},
+    {"log-time",                    2, 0, ARG_LOG_TIME},
+    {"log-backtrace",               1, 0, ARG_LOG_BACKTRACE},
     {"load",                        1, 0, ARG_LOAD},
     {"file",                        1, 0, ARG_FILE},
     {"dl-search-path",              1, 0, ARG_DL_SEARCH_PATH},
@@ -148,6 +154,9 @@ void pa_cmdline_help(const char *argv0) {
            "      --log-level[=LEVEL]               Increase or set verbosity level\n"
            "  -v                                    Increase the verbosity level\n"
            "      --log-target={auto,syslog,stderr} Specify the log target\n"
+           "      --log-meta[=BOOL]                 Include code location in log messages\n"
+           "      --log-time[=BOOL]                 Include timestamps in log messages\n"
+           "      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
            "  -p, --dl-search-path=PATH             Set the search path for dynamic shared\n"
            "                                        objects (plugins)\n"
            "      --resample-method=METHOD          Use the specified resampling method\n"
@@ -321,6 +330,24 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
                 }
                 break;
 
+            case ARG_LOG_TIME:
+                if ((conf->log_time = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--log-time boolean argument"));
+                    goto fail;
+                }
+                break;
+
+            case ARG_LOG_META:
+                if ((conf->log_meta = optarg ? pa_parse_boolean(optarg) : TRUE) < 0) {
+                    pa_log(_("--log-meta boolean argument"));
+                    goto fail;
+                }
+                break;
+
+            case ARG_LOG_BACKTRACE:
+                conf->log_backtrace = (unsigned) atoi(optarg);
+                break;
+
             case ARG_EXIT_IDLE_TIME:
                 conf->exit_idle_time = atoi(optarg);
                 break;

commit ef9f3f6ec4d73b9a1cdac648bcf3c4ad1a051393
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 20:00:36 2008 +0200

    Try to catch certain driver errors
    
    ... by verifying return values of snd_pcm_avail_update() and
    snd_pcm_begin_mmap() for their sanenness.

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index ffe7795..39cea49 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -30,6 +30,7 @@
 
 #include <pulse/sample.h>
 #include <pulse/xmalloc.h>
+#include <pulse/timeval.h>
 
 #include <pulsecore/log.h>
 #include <pulsecore/macro.h>
@@ -1109,3 +1110,62 @@ pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) {
 
     return item;
 }
+
+snd_pcm_sframes_t pa_alsa_safe_avail_update(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss) {
+    snd_pcm_sframes_t n;
+    size_t k;
+
+    pa_assert(pcm);
+    pa_assert(hwbuf_size > 0);
+    pa_assert(ss);
+
+    /* Some ALSA driver expose weird bugs, let's inform the user about
+     * what is going on */
+
+    n = snd_pcm_avail_update(pcm);
+
+    if (n <= 0)
+        return n;
+
+    k = (size_t) n * pa_frame_size(ss);
+
+    if (k >= hwbuf_size * 3 ||
+        k >= pa_bytes_per_second(ss)*10)
+        pa_log("snd_pcm_avail_update() returned a value that is exceptionally large: %lu bytes (%lu ms) "
+               "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
+               (unsigned long) k, (unsigned long) pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC);
+
+    return n;
+}
+
+int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss) {
+    int r;
+    snd_pcm_uframes_t before;
+    size_t k;
+
+    pa_assert(pcm);
+    pa_assert(areas);
+    pa_assert(offset);
+    pa_assert(frames);
+    pa_assert(hwbuf_size > 0);
+    pa_assert(ss);
+
+    before = *frames;
+
+    r = snd_pcm_mmap_begin(pcm, areas, offset, frames);
+
+    if (r < 0)
+        return r;
+
+    k = (size_t) *frames * pa_frame_size(ss);
+
+    if (*frames > before ||
+        k >= hwbuf_size * 3 ||
+        k >= pa_bytes_per_second(ss)*10)
+
+        pa_log("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms) "
+               "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
+               (unsigned long) k, (unsigned long) pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC);
+
+    return r;
+}
diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h
index b66adc1..aaa01c7 100644
--- a/src/modules/alsa-util.h
+++ b/src/modules/alsa-util.h
@@ -92,4 +92,7 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
 
 pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll);
 
+snd_pcm_sframes_t pa_alsa_safe_avail_update(snd_pcm_t *pcm, size_t hwbuf_size, const pa_sample_spec *ss);
+int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas, snd_pcm_uframes_t *offset, snd_pcm_uframes_t *frames, size_t hwbuf_size, const pa_sample_spec *ss);
+
 #endif
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index 4044de1..af83103 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -261,7 +261,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
         /* First we determine how many samples are missing to fill the
          * buffer up to 100% */
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
@@ -299,7 +299,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
 
 /*             pa_log_debug("%lu frames to write", (unsigned long) frames); */
 
-            if (PA_UNLIKELY((err = snd_pcm_mmap_begin(u->pcm_handle, &areas, &offset, &frames)) < 0)) {
+            if (PA_UNLIKELY((err = pa_alsa_safe_mmap_begin(u->pcm_handle, &areas, &offset, &frames, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
 
                 if ((r = try_recover(u, "snd_pcm_mmap_begin", err)) == 0)
                     continue;
@@ -374,7 +374,7 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
 
         snd_pcm_hwsync(u->pcm_handle);
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->sink->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index a743776..dd6ca97 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -255,7 +255,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
 
         snd_pcm_hwsync(u->pcm_handle);
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;
@@ -282,7 +282,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
 
 /*             pa_log_debug("%lu frames to read", (unsigned long) frames); */
 
-            if (PA_UNLIKELY((err = snd_pcm_mmap_begin(u->pcm_handle, &areas, &offset, &frames)) < 0)) {
+            if (PA_UNLIKELY((err = pa_alsa_safe_mmap_begin(u->pcm_handle, &areas, &offset, &frames, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
 
                 if ((r = try_recover(u, "snd_pcm_mmap_begin", err)) == 0)
                     continue;
@@ -353,7 +353,7 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
 
         snd_pcm_hwsync(u->pcm_handle);
 
-        if (PA_UNLIKELY((n = snd_pcm_avail_update(u->pcm_handle)) < 0)) {
+        if (PA_UNLIKELY((n = pa_alsa_safe_avail_update(u->pcm_handle, u->hwbuf_size, &u->source->sample_spec)) < 0)) {
 
             if ((r = try_recover(u, "snd_pcm_avail_update", (int) n)) == 0)
                 continue;

commit c4b346259fa59dfad040c51ab064ed44395d0911
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 22:04:22 2008 +0200

    make the debug trap macro a proper macro in macro.h

diff --git a/src/pulsecore/macro.h b/src/pulsecore/macro.h
index cf02696..f9ce949 100644
--- a/src/pulsecore/macro.h
+++ b/src/pulsecore/macro.h
@@ -220,6 +220,12 @@ typedef int pa_bool_t;
 
 #endif
 
+#if defined(__i386__) || defined(__x86_64__)
+#define PA_DEBUG_TRAP __asm__("int $3")
+#else
+#define PA_DEBUG_TRAP raise(SIGTRAP)
+#endif
+
 /* We include this at the very last place */
 #include <pulsecore/log.h>
 

commit 260fc50b36dc3c0a1ae5376de238779d442936a2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 22:05:13 2008 +0200

    reorder setting of AM_CFLAGS a bit

diff --git a/src/Makefile.am b/src/Makefile.am
index 4d1812e..b911c43 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,26 +45,27 @@ endif
 #     Compiler/linker flags       #
 ###################################
 
-AM_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src/modules -I$(top_builddir)/src/modules/rtp -I$(top_builddir)/src/modules/gconf -I$(top_builddir)/src/modules/bluetooth
-AM_CFLAGS += $(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS
-AM_CFLAGS += $(LTDLINCL)
-AM_CFLAGS += $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS) $(LIBSPEEX_CFLAGS)
-AM_CFLAGS += -DPA_DLSEARCHPATH=\"$(modlibexecdir)\"
-AM_CFLAGS += -DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\"
-AM_CFLAGS += -DPA_BINARY=\"$(PA_BINARY)\"
-AM_CFLAGS += -DPA_SYSTEM_RUNTIME_PATH=\"$(PA_SYSTEM_RUNTIME_PATH)\"
-AM_CFLAGS += -DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\"
-AM_CFLAGS += -DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\"
-AM_CFLAGS += -DAO_REQUIRE_CAS
-AM_CFLAGS += -DPULSE_LOCALEDIR=\"$(pulselocaledir)\"
-AM_CFLAGS += -DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\"
-
-# This cool debug trap works on i386/gcc only
-AM_CFLAGS += '-DDEBUG_TRAP=__asm__("int $$3")'
-
-if HAVE_OPENSSL
-AM_CFLAGS += -I$(top_builddir)/src/modules/raop
-endif
+AM_CFLAGS = \
+	-I$(top_srcdir)/src \
+	-I$(top_builddir)/src/modules \
+	-I$(top_builddir)/src/modules/rtp \
+	-I$(top_builddir)/src/modules/gconf \
+	-I$(top_builddir)/src/modules/bluetooth \
+	-I$(top_builddir)/src/modules/raop \
+	$(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS \
+	$(LTDLINCL) \
+	$(LIBSAMPLERATE_CFLAGS) \
+	$(LIBSNDFILE_CFLAGS) \
+	$(LIBSPEEX_CFLAGS) \
+	-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
+	-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
+	-DPA_BINARY=\"$(PA_BINARY)\" \
+	-DPA_SYSTEM_RUNTIME_PATH=\"$(PA_SYSTEM_RUNTIME_PATH)\" \
+	-DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\" \
+	-DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\" \
+	-DAO_REQUIRE_CAS \
+	-DPULSE_LOCALEDIR=\"$(pulselocaledir)\" \
+	-DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\"
 
 AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
 AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)

commit df6e38bfd226db442783e8a1cb6af0f656139765
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 23:55:33 2008 +0200

    temporary commit to allow flameeyes a look

diff --git a/configure.ac b/configure.ac
index f93903d..6c21ca5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,7 +32,9 @@ AC_CONFIG_MACRO_DIR([m4])
 AC_CONFIG_HEADERS([config.h])
 AM_INIT_AUTOMAKE([foreign 1.10 -Wall])
 
-AC_SUBST(PA_MAJORMINOR, "PA_MAJOR.PA_MINOR")
+AC_SUBST(PA_MAJORMINOR, PA_MAJOR.PA_MINOR)
+AC_SUBST(PA_MAJORMINORMICRO, PA_MAJOR.PA_MINOR.PA_MICRO)
+AC_SUBST(PA_MMM_USCORE, AS_TR_SH(PA_MAJOR.PA_MINOR.PA_MICRO))
 AC_SUBST(PACKAGE_URL, [http://pulseaudio.org/])
 
 AC_SUBST(PA_API_VERSION, 12)
@@ -54,11 +56,6 @@ AC_SUBST(LIBPULSE_BROWSE_VERSION_INFO, [1:1:1])
 # info x:y:z always will hold y=z
 AC_SUBST(LIBPULSE_MAINLOOP_GLIB_VERSION_INFO, [0:4:0])
 
-# An internally used, ABI-unstable library that contains the
-# PulseAudio core, SONAMEs are bumped on every release, version info
-# suffix will always be 0:0
-AC_SUBST(LIBPULSECORE_VERSION_INFO, [8:0:0])
-
 AC_CANONICAL_HOST
 AC_DEFINE_UNQUOTED([CANONICAL_HOST], "$host", [Canonical host string.])
 
@@ -1135,8 +1132,8 @@ fi
 
 AC_ARG_WITH(
         [module-dir],
-        AS_HELP_STRING([--with-module-dir],[Directory where to install the modules to (defaults to ${libdir}/pulse-${PA_MAJORMINOR}/modules/]),
-        [modlibexecdir=$withval], [modlibexecdir="${libdir}/pulse-${PA_MAJORMINOR}/modules/"])
+        AS_HELP_STRING([--with-module-dir],[Directory where to install the modules to (defaults to ${libdir}/pulse-${PA_MAJORMINORMICRO}/modules/]),
+        [modlibexecdir=$withval], [modlibexecdir="${libdir}/pulse-${PA_MAJORMINORMICRO}/modules/"])
 
 AC_SUBST(modlibexecdir)
 
diff --git a/src/Makefile.am b/src/Makefile.am
index b911c43..32ffbc5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -54,9 +54,6 @@ AM_CFLAGS = \
 	-I$(top_builddir)/src/modules/raop \
 	$(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS \
 	$(LTDLINCL) \
-	$(LIBSAMPLERATE_CFLAGS) \
-	$(LIBSNDFILE_CFLAGS) \
-	$(LIBSPEEX_CFLAGS) \
 	-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
 	-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
 	-DPA_BINARY=\"$(PA_BINARY)\" \
@@ -71,7 +68,8 @@ AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
 AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)
 
 # Only required on some platforms but defined for all to avoid errors
-AM_LDFLAGS = -Wl,-no-undefined -Wl,--gc-sections
+AM_LDFLAGS =
+#-Wl,-no-undefined -Wl,--gc-sections
 
 if STATIC_BINS
 BINLDFLAGS = -static
@@ -146,9 +144,9 @@ pulseaudio_SOURCES = \
 
 pulseaudio_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSPEEX_CFLAGS) $(LIBSNDFILE_CFLAGS) $(CAP_CFLAGS) $(LIBOIL_CFLAGS) $(DBUS_CFLAGS)
 pulseaudio_CPPFLAGS = $(AM_CPPFLAGS)
-pulseaudio_LDADD = $(AM_LDADD) libpulsecore.la $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(CAP_LIBS) $(LIBOIL_LIBS) $(DBUS_LIBS)
+pulseaudio_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la libpulse.la $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(CAP_LIBS) $(LIBOIL_LIBS) $(DBUS_LIBS)
 # This is needed because automake doesn't properly expand the foreach below
-pulseaudio_DEPENDENCIES = libpulsecore.la $(PREOPEN_LIBS)
+pulseaudio_DEPENDENCIES = libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la libpulse.la $(PREOPEN_LIBS)
 
 if PREOPEN_MODS
 PREOPEN_LIBS = $(PREOPEN_MODS)
@@ -163,14 +161,11 @@ pulseaudio_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) -dlopen force $(foreach f,$(PRE
 endif
 
 if HAVE_POLKIT
-
 policy_DATA = daemon/org.pulseaudio.policy
 
 pulseaudio_SOURCES += daemon/polkit.c daemon/polkit.h
 pulseaudio_CFLAGS += $(POLKIT_CFLAGS)
 pulseaudio_LDADD += $(POLKIT_LIBS)
-
-
 endif
 
 ###################################
@@ -207,24 +202,24 @@ paplay_LDADD = $(AM_LDADD) libpulse.la $(LIBSNDFILE_LIBS)
 paplay_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 paplay_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-pactl_SOURCES = utils/pactl.c pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h pulsecore/log.c pulsecore/log.h pulsecore/rtclock.c pulsecore/rtclock.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
-pactl_LDADD = $(AM_LDADD) libpulse.la $(LIBSNDFILE_LIBS)
+pactl_SOURCES = utils/pactl.c
+pactl_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la $(LIBSNDFILE_LIBS)
 pactl_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 pactl_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-pasuspender_SOURCES = utils/pasuspender.c pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h pulsecore/log.c pulsecore/log.h pulsecore/rtclock.c pulsecore/rtclock.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
-pasuspender_LDADD = $(AM_LDADD) libpulse.la $(LIBSNDFILE_LIBS)
+pasuspender_SOURCES = utils/pasuspender.c
+pasuspender_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la $(LIBSNDFILE_LIBS)
 pasuspender_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 pasuspender_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-pacmd_SOURCES = utils/pacmd.c pulsecore/pid.c pulsecore/pid.h pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h pulsecore/log.c pulsecore/log.h pulsecore/rtclock.c pulsecore/rtclock.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
+pacmd_SOURCES = utils/pacmd.c
 pacmd_CFLAGS = $(AM_CFLAGS)
-pacmd_LDADD = $(AM_LDADD) libpulse.la
+pacmd_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 pacmd_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-pax11publish_SOURCES = utils/pax11publish.c pulsecore/x11prop.c pulsecore/x11prop.h pulse/client-conf.c pulse/client-conf.h pulsecore/authkey.h pulsecore/authkey.c pulsecore/random.h pulsecore/random.c pulsecore/conf-parser.c pulsecore/rtclock.c pulsecore/rtclock.h pulsecore/conf-parser.h pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h  pulsecore/log.c pulsecore/log.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
+pax11publish_SOURCES = utils/pax11publish.c
 pax11publish_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
-pax11publish_LDADD = $(AM_LDADD) libpulse.la $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
 pax11publish_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pabrowse_SOURCES = utils/pabrowse.c
@@ -290,12 +285,12 @@ mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 thread_mainloop_test_SOURCES = tests/thread-mainloop-test.c
 thread_mainloop_test_CFLAGS = $(AM_CFLAGS)
-thread_mainloop_test_LDADD = $(AM_LDADD) libpulsecore.la libpulse.la
+thread_mainloop_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 utf8_test_SOURCES = tests/utf8-test.c
 utf8_test_CFLAGS = $(AM_CFLAGS)
-utf8_test_LDADD = $(AM_LDADD) libpulsecore.la
+utf8_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 utf8_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 get_binary_name_test_SOURCES = tests/get-binary-name-test.c
@@ -303,56 +298,54 @@ get_binary_name_test_CFLAGS = $(AM_CFLAGS)
 get_binary_name_test_LDADD = $(AM_LDADD) libpulse.la
 get_binary_name_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-ipacl_test_SOURCES = tests/ipacl-test.c \
-		pulsecore/ipacl.c pulsecore/ipacl.h \
-		pulsecore/inet_pton.c pulsecore/inet_pton.h
+ipacl_test_SOURCES = tests/ipacl-test.c
 ipacl_test_CFLAGS = $(AM_CFLAGS)
-ipacl_test_LDADD = $(AM_LDADD) libpulsecore.la
+ipacl_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 ipacl_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 hook_list_test_SOURCES = tests/hook-list-test.c
 hook_list_test_CFLAGS = $(AM_CFLAGS)
-hook_list_test_LDADD = $(AM_LDADD) libpulsecore.la
+hook_list_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 hook_list_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 memblock_test_SOURCES = tests/memblock-test.c
 memblock_test_CFLAGS = $(AM_CFLAGS)
-memblock_test_LDADD = $(AM_LDADD) libpulsecore.la
+memblock_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 memblock_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 thread_test_SOURCES = tests/thread-test.c
 thread_test_CFLAGS = $(AM_CFLAGS)
-thread_test_LDADD = $(AM_LDADD) libpulsecore.la
+thread_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 thread_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 flist_test_SOURCES = tests/flist-test.c
 flist_test_CFLAGS = $(AM_CFLAGS)
-flist_test_LDADD = $(AM_LDADD) libpulsecore.la
+flist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 flist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 asyncq_test_SOURCES = tests/asyncq-test.c
 asyncq_test_CFLAGS = $(AM_CFLAGS)
-asyncq_test_LDADD = $(AM_LDADD) libpulsecore.la
+asyncq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 asyncq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 asyncmsgq_test_SOURCES = tests/asyncmsgq-test.c
 asyncmsgq_test_CFLAGS = $(AM_CFLAGS)
-asyncmsgq_test_LDADD = $(AM_LDADD) libpulsecore.la
+asyncmsgq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 asyncmsgq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 queue_test_SOURCES = tests/queue-test.c
 queue_test_CFLAGS = $(AM_CFLAGS)
-queue_test_LDADD = $(AM_LDADD) libpulsecore.la
+queue_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 queue_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 rtpoll_test_SOURCES = tests/rtpoll-test.c
 rtpoll_test_CFLAGS = $(AM_CFLAGS)
-rtpoll_test_LDADD = $(AM_LDADD) libpulsecore.la
+rtpoll_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 rtpoll_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 mcalign_test_SOURCES = tests/mcalign-test.c
 mcalign_test_CFLAGS = $(AM_CFLAGS)
-mcalign_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore.la
+mcalign_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 mcalign_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pacat_simple_SOURCES = tests/pacat-simple.c
@@ -367,12 +360,12 @@ parec_simple_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 strlist_test_SOURCES = tests/strlist-test.c
 strlist_test_CFLAGS = $(AM_CFLAGS)
-strlist_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore.la libstrlist.la
+strlist_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
 strlist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 close_test_SOURCES = tests/close-test.c
 close_test_CFLAGS = $(AM_CFLAGS)
-close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore.la libstrlist.la
+close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libstrlist.la
 close_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 voltest_SOURCES = tests/voltest.c
@@ -387,12 +380,12 @@ channelmap_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 cpulimit_test_SOURCES = tests/cpulimit-test.c daemon/cpulimit.c daemon/cpulimit.h
 cpulimit_test_CFLAGS = $(AM_CFLAGS)
-cpulimit_test_LDADD = $(AM_LDADD) libpulsecore.la
+cpulimit_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 cpulimit_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 cpulimit_test2_SOURCES = tests/cpulimit-test.c daemon/cpulimit.c daemon/cpulimit.h
 cpulimit_test2_CFLAGS = $(AM_CFLAGS) -DTEST2
-cpulimit_test2_LDADD = $(AM_LDADD) libpulsecore.la
+cpulimit_test2_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 cpulimit_test2_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 mainloop_test_glib_SOURCES = $(mainloop_test_SOURCES)
@@ -402,7 +395,7 @@ mainloop_test_glib_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 memblockq_test_SOURCES = tests/memblockq-test.c
 memblockq_test_CFLAGS = $(AM_CFLAGS)
-memblockq_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore.la
+memblockq_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 memblockq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 sync_playback_SOURCES = tests/sync-playback.c
@@ -411,66 +404,147 @@ sync_playback_CFLAGS = $(AM_CFLAGS)
 sync_playback_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 interpol_test_SOURCES = tests/interpol-test.c
-interpol_test_LDADD = $(AM_LDADD) libpulse.la libpulsecore.la
+interpol_test_LDADD = $(AM_LDADD) libpulse.la libpulsecore- at PA_MAJORMINORMICRO@.la
 interpol_test_CFLAGS = $(AM_CFLAGS)
 interpol_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 sig2str_test_SOURCES = tests/sig2str-test.c
-sig2str_test_LDADD = $(AM_LDADD) libpulsecore.la
+sig2str_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 sig2str_test_CFLAGS = $(AM_CFLAGS)
 sig2str_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 resampler_test_SOURCES = tests/resampler-test.c
-resampler_test_LDADD = $(AM_LDADD) libpulsecore.la
+resampler_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 resampler_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 resampler_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 mix_test_SOURCES = tests/mix-test.c
-mix_test_LDADD = $(AM_LDADD) libpulsecore.la
+mix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 mix_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 mix_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 remix_test_SOURCES = tests/remix-test.c
-remix_test_LDADD = $(AM_LDADD) libpulsecore.la
+remix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 remix_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 remix_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 smoother_test_SOURCES = tests/smoother-test.c
-smoother_test_LDADD = $(AM_LDADD) libpulsecore.la
+smoother_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 smoother_test_CFLAGS = $(AM_CFLAGS)
 smoother_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 envelope_test_SOURCES = tests/envelope-test.c
-envelope_test_LDADD = $(AM_LDADD) libpulsecore.la
+envelope_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 envelope_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 envelope_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 proplist_test_SOURCES = tests/proplist-test.c
-proplist_test_LDADD = $(AM_LDADD) libpulsecore.la
+proplist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 proplist_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 proplist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 rtstutter_SOURCES = tests/rtstutter.c
-rtstutter_LDADD = $(AM_LDADD) libpulsecore.la
+rtstutter_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 rtstutter_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 rtstutter_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 stripnul_SOURCES = tests/stripnul.c
-stripnul_LDADD = $(AM_LDADD) libpulsecore.la
+stripnul_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 stripnul_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 stripnul_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 lock_autospawn_test_SOURCES = tests/lock-autospawn-test.c
-lock_autospawn_test_LDADD = $(AM_LDADD) libpulsecore.la
+lock_autospawn_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 lock_autospawn_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 lock_autospawn_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 prioq_test_SOURCES = tests/prioq-test.c
-prioq_test_LDADD = $(AM_LDADD) libpulsecore.la
+prioq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 prioq_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 prioq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 ###################################
+#         Common library          #
+###################################
+
+lib_LTLIBRARIES = \
+		libpulsecommon-$(PA_MAJORMINORMICRO).la
+
+libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES = \
+		pulsecore/auth-cookie.c pulsecore/auth-cookie.h \
+		pulsecore/authkey.c pulsecore/authkey.h \
+		pulsecore/conf-parser.c pulsecore/conf-parser.h \
+		pulsecore/core-error.c pulsecore/core-error.h \
+		pulsecore/core-util.c pulsecore/core-util.h \
+		pulsecore/dynarray.c pulsecore/dynarray.h \
+		pulsecore/endianmacros.h \
+		pulsecore/flist.c pulsecore/flist.h \
+		pulsecore/hashmap.c pulsecore/hashmap.h \
+		pulsecore/idxset.c pulsecore/idxset.h \
+		pulsecore/inet_ntop.c pulsecore/inet_ntop.h \
+		pulsecore/inet_pton.c pulsecore/inet_pton.h \
+		pulsecore/iochannel.c pulsecore/iochannel.h \
+		pulsecore/ioline.c pulsecore/ioline.h \
+		pulsecore/ipacl.h pulsecore/ipacl.c \
+		pulsecore/llist.h \
+		pulsecore/lock-autospawn.c pulsecore/lock-autospawn.h \
+		pulsecore/log.c pulsecore/log.h \
+		pulsecore/macro.h \
+		pulsecore/mcalign.c pulsecore/mcalign.h \
+		pulsecore/memblock.c pulsecore/memblock.h \
+		pulsecore/memblockq.c pulsecore/memblockq.h \
+		pulsecore/memchunk.c pulsecore/memchunk.h \
+		pulsecore/native-common.h \
+		pulsecore/once.c pulsecore/once.h \
+		pulsecore/packet.c pulsecore/packet.h \
+		pulsecore/parseaddr.c pulsecore/parseaddr.h \
+		pulsecore/pdispatch.c pulsecore/pdispatch.h \
+		pulsecore/pid.c pulsecore/pid.h \
+		pulsecore/pipe.c pulsecore/pipe.h \
+		pulsecore/poll.c pulsecore/poll.h \
+		pulsecore/prioq.c pulsecore/prioq.h \
+		pulsecore/proplist-util.c pulsecore/proplist-util.h \
+		pulsecore/pstream-util.c pulsecore/pstream-util.h \
+		pulsecore/pstream.c pulsecore/pstream.h \
+		pulsecore/queue.c pulsecore/queue.h \
+		pulsecore/random.c pulsecore/random.h \
+		pulsecore/rtclock.c pulsecore/rtclock.h \
+		pulsecore/shm.c pulsecore/shm.h \
+		pulsecore/socket-client.c pulsecore/socket-client.h \
+		pulsecore/socket-server.c pulsecore/socket-server.h \
+		pulsecore/socket-util.c pulsecore/socket-util.h \
+		pulsecore/strbuf.c pulsecore/strbuf.h \
+		pulsecore/strlist.c pulsecore/strlist.h \
+		pulsecore/tagstruct.c pulsecore/tagstruct.h \
+		pulsecore/time-smoother.c pulsecore/time-smoother.h \
+		pulsecore/tokenizer.c pulsecore/tokenizer.h \
+		pulsecore/winsock.h \
+		pulsecore/creds.h \
+		$(PA_THREAD_OBJS)
+
+libpulsecommon_ at PA_MMM_USCORE@_la_CFLAGS = $(AM_CFLAGS)
+libpulsecommon_ at PA_MMM_USCORE@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+libpulsecommon_ at PA_MMM_USCORE@_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) $(LTLIBICONV)
+
+if HAVE_X11
+libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES += \
+		pulsecore/x11wrap.c pulsecore/x11wrap.h \
+		pulsecore/x11prop.c pulsecore/x11prop.h
+
+libpulsecommon_ at PA_MMM_USCORE@_la_CFLAGS += $(X_CFLAGS)
+libpulsecommon_ at PA_MMM_USCORE@_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+endif
+
+if HAVE_LIBASYNCNS
+libpulsecommon_ at PA_MMM_USCORE@_la_CFLAGS += $(LIBASYNCNS_CFLAGS)
+libpulsecommon_ at PA_MMM_USCORE@_la_LIBADD += $(LIBASYNCNS_LIBS)
+endif
+
+if OS_IS_WIN32
+libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES += pulsecore/dllmain.c
+endif
+
+###################################
 #         Client library          #
 ###################################
 
@@ -480,11 +554,14 @@ pulseinclude_HEADERS = \
 		pulse/context.h \
 		pulse/def.h \
 		pulse/error.h \
+		pulse/ext-stream-restore.h \
+		pulse/gccmacro.h \
 		pulse/introspect.h \
-		pulse/mainloop.h \
 		pulse/mainloop-api.h \
 		pulse/mainloop-signal.h \
+		pulse/mainloop.h \
 		pulse/operation.h \
+		pulse/proplist.h \
 		pulse/pulseaudio.h \
 		pulse/sample.h \
 		pulse/scache.h \
@@ -497,31 +574,24 @@ pulseinclude_HEADERS = \
 		pulse/util.h \
 		pulse/version.h \
 		pulse/volume.h \
-		pulse/xmalloc.h \
-		pulse/proplist.h \
-		pulse/gccmacro.h \
-		pulse/ext-stream-restore.h
-
-if HAVE_AVAHI
-pulseinclude_HEADERS += \
-		pulse/browser.h
-endif
-
-if HAVE_GLIB20
-pulseinclude_HEADERS += \
-		pulse/glib-mainloop.h
-endif
+		pulse/xmalloc.h
 
-lib_LTLIBRARIES = \
+lib_LTLIBRARIES += \
 		libpulse.la \
 		libpulse-simple.la
 
 if HAVE_AVAHI
+pulseinclude_HEADERS += \
+		pulse/browser.h
+
 lib_LTLIBRARIES += \
 		libpulse-browse.la
 endif
 
 if HAVE_GLIB20
+pulseinclude_HEADERS += \
+		pulse/glib-mainloop.h
+
 lib_LTLIBRARIES += \
 		libpulse-mainloop-glib.la
 endif
@@ -534,12 +604,16 @@ libpulse_la_SOURCES = \
 		pulse/context.c pulse/context.h \
 		pulse/def.h \
 		pulse/error.c pulse/error.h \
+		pulse/ext-stream-restore.c pulse/ext-stream-restore.h \
+		pulse/gccmacro.h \
+		pulse/i18n.c pulse/i18n.h \
 		pulse/internal.h \
 		pulse/introspect.c pulse/introspect.h \
-		pulse/mainloop.c pulse/mainloop.h \
 		pulse/mainloop-api.c pulse/mainloop-api.h \
 		pulse/mainloop-signal.c pulse/mainloop-signal.h \
+		pulse/mainloop.c pulse/mainloop.h \
 		pulse/operation.c pulse/operation.h \
+		pulse/proplist.c pulse/proplist.h \
 		pulse/pulseaudio.h \
 		pulse/sample.c pulse/sample.h \
 		pulse/scache.c pulse/scache.h \
@@ -550,343 +624,115 @@ libpulse_la_SOURCES = \
 		pulse/utf8.c pulse/utf8.h \
 		pulse/util.c pulse/util.h \
 		pulse/volume.c pulse/volume.h \
-		pulse/xmalloc.c pulse/xmalloc.h \
-		pulse/proplist.c pulse/proplist.h \
-		pulse/ext-stream-restore.c pulse/ext-stream-restore.h \
-		pulse/i18n.c pulse/i18n.h
-
-# Internal stuff that is shared with libpulsecore
-libpulse_la_SOURCES += \
-		pulsecore/authkey.c pulsecore/authkey.h \
-		pulsecore/conf-parser.c pulsecore/conf-parser.h \
-		pulsecore/core-util.c pulsecore/core-util.h \
-		pulsecore/dynarray.c pulsecore/dynarray.h \
-		pulsecore/hashmap.c pulsecore/hashmap.h \
-		pulsecore/idxset.c pulsecore/idxset.h \
-		pulsecore/inet_ntop.c pulsecore/inet_ntop.h \
-		pulsecore/iochannel.c pulsecore/iochannel.h \
-		pulsecore/llist.h \
-		pulsecore/log.c pulsecore/log.h \
-		pulsecore/mcalign.c pulsecore/mcalign.h \
-		pulsecore/memblock.c pulsecore/memblock.h \
-		pulsecore/memblockq.c pulsecore/memblockq.h \
-		pulsecore/memchunk.c pulsecore/memchunk.h \
-		pulsecore/native-common.h \
-		pulsecore/packet.c pulsecore/packet.h \
-		pulsecore/parseaddr.c pulsecore/parseaddr.h \
-		pulsecore/pdispatch.c pulsecore/pdispatch.h \
-		pulsecore/pipe.c pulsecore/pipe.h \
-		pulsecore/poll.c pulsecore/poll.h \
-		pulsecore/pstream.c pulsecore/pstream.h \
-		pulsecore/pstream-util.c pulsecore/pstream-util.h \
-		pulsecore/queue.c pulsecore/queue.h \
-		pulsecore/random.c pulsecore/random.h \
-		pulsecore/socket-client.c pulsecore/socket-client.h \
-		pulsecore/socket-util.c pulsecore/socket-util.h \
-		pulsecore/strbuf.c pulsecore/strbuf.h \
-		pulsecore/strlist.c pulsecore/strlist.h \
-		pulsecore/tagstruct.c pulsecore/tagstruct.h \
-		pulsecore/core-error.c pulsecore/core-error.h \
-		pulsecore/winsock.h pulsecore/creds.h \
-		pulsecore/shm.c pulsecore/shm.h \
-		pulsecore/flist.c pulsecore/flist.h \
-		pulsecore/object.c pulsecore/object.h \
-		pulsecore/msgobject.c pulsecore/msgobject.h \
-		pulsecore/once.c pulsecore/once.h \
-		pulsecore/rtclock.c pulsecore/rtclock.h \
-		pulsecore/time-smoother.c pulsecore/time-smoother.h \
-		pulsecore/proplist-util.c pulsecore/proplist-util.h \
-		$(PA_THREAD_OBJS)
-
-if OS_IS_WIN32
-libpulse_la_SOURCES += \
-		pulsecore/dllmain.c
-endif
-
-if HAVE_X11
-libpulse_la_SOURCES += \
-		pulse/client-conf-x11.c pulse/client-conf-x11.h \
-		pulsecore/x11prop.c pulsecore/x11prop.h
-endif
+		pulse/xmalloc.c pulse/xmalloc.h
 
 libpulse_la_CFLAGS = $(AM_CFLAGS)
-libpulse_la_LDFLAGS = -version-info $(LIBPULSE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
-libpulse_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) $(LTLIBICONV)
+libpulse_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBPULSE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
+libpulse_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) $(LTLIBICONV) libpulsecommon- at PA_MAJORMINORMICRO@.la
 
 if HAVE_X11
+libpulse_la_SOURCES += pulse/client-conf-x11.c pulse/client-conf-x11.h
 libpulse_la_CFLAGS += $(X_CFLAGS)
 libpulse_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
 endif
 
-if HAVE_LIBASYNCNS
-libpulse_la_CFLAGS += $(LIBASYNCNS_CFLAGS)
-libpulse_la_LIBADD += $(LIBASYNCNS_LIBS)
-endif
-
-libpulse_simple_la_SOURCES = \
-		pulse/simple.c pulse/simple.h	\
-		pulsecore/log.c pulsecore/log.h \
-		pulsecore/core-util.c pulsecore/core-util.h  \
-		pulsecore/core-error.c pulsecore/core-error.h \
-		pulsecore/once.c pulsecore/once.h \
-		pulsecore/rtclock.c pulsecore/rtclock.h \
-		$(PA_THREAD_OBJS)
-
+libpulse_simple_la_SOURCES = pulse/simple.c pulse/simple.h
 libpulse_simple_la_CFLAGS = $(AM_CFLAGS)
-libpulse_simple_la_LIBADD = $(AM_LIBADD) libpulse.la
-libpulse_simple_la_LDFLAGS = -version-info $(LIBPULSE_SIMPLE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
+libpulse_simple_la_LIBADD = $(AM_LIBADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
+libpulse_simple_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBPULSE_SIMPLE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
 
-libpulse_browse_la_SOURCES = pulse/browser.c pulse/browser.h pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h  pulsecore/log.c pulsecore/log.h pulsecore/rtclock.c pulsecore/rtclock.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
+libpulse_browse_la_SOURCES = pulse/browser.c pulse/browser.h pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h
 libpulse_browse_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
-libpulse_browse_la_LIBADD = $(AM_LIBADD) libpulse.la $(AVAHI_LIBS)
-libpulse_browse_la_LDFLAGS = -version-info $(LIBPULSE_BROWSE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
+libpulse_browse_la_LIBADD = $(AM_LIBADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(AVAHI_LIBS)
+libpulse_browse_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBPULSE_BROWSE_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
 
-libpulse_mainloop_glib_la_SOURCES = \
-		pulse/glib-mainloop.h pulse/glib-mainloop.c \
-		pulsecore/log.c pulsecore/log.h \
-		pulsecore/rtclock.c pulsecore/rtclock.h \
-		pulsecore/core-util.c pulsecore/core-util.h  \
-		pulsecore/core-error.c pulsecore/core-error.h \
-		pulsecore/once.c pulsecore/once.h \
-		$(PA_THREAD_OBJS)
+libpulse_mainloop_glib_la_SOURCES = pulse/glib-mainloop.h pulse/glib-mainloop.c
 libpulse_mainloop_glib_la_CFLAGS = $(AM_CFLAGS) $(GLIB20_CFLAGS)
-libpulse_mainloop_glib_la_LIBADD = $(AM_LIBADD) libpulse.la $(GLIB20_LIBS)
-libpulse_mainloop_glib_la_LDFLAGS = -version-info $(LIBPULSE_MAINLOOP_GLIB_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
+libpulse_mainloop_glib_la_LIBADD = $(AM_LIBADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(GLIB20_LIBS)
+libpulse_mainloop_glib_la_LDFLAGS = $(AM_LDFLAGS) -version-info $(LIBPULSE_MAINLOOP_GLIB_VERSION_INFO) -Wl,-version-script=$(srcdir)/map-file
 
 ###################################
 #         OSS emulation           #
 ###################################
 
 if HAVE_OSS
-
 lib_LTLIBRARIES += libpulsedsp.la
-
 bin_SCRIPTS += utils/padsp
-
 endif
 
-libpulsedsp_la_SOURCES = utils/padsp.c pulsecore/core-util.c pulsecore/core-util.h pulsecore/core-error.c pulsecore/core-error.h  pulsecore/log.c pulsecore/log.h pulsecore/rtclock.c pulsecore/rtclock.h pulsecore/once.c pulsecore/once.h $(PA_THREAD_OBJS)
+libpulsedsp_la_SOURCES = utils/padsp.c
 libpulsedsp_la_CFLAGS = $(AM_CFLAGS)
-libpulsedsp_la_LIBADD = $(AM_LIBADD) libpulse.la
-libpulsedsp_la_LDFLAGS = -avoid-version
-
-###################################
-#      ffmpeg resampler           #
-###################################
-
-noinst_LTLIBRARIES = libffmpeg-resampler.la
-
-libffmpeg_resampler_la_CPPFLAGS = $(AM_CPPFLAGS)
-libffmpeg_resampler_la_SOURCES = pulsecore/ffmpeg/resample2.c pulsecore/ffmpeg/avcodec.h pulsecore/ffmpeg/dsputil.h
+libpulsedsp_la_LIBADD = $(AM_LIBADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
+libpulsedsp_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
 
 ###################################
 #      Daemon core library        #
 ###################################
 
-#pulsecoreinclude_HEADERS =
-noinst_HEADERS = \
-		pulsecore/autoload.h \
-		pulsecore/atomic.h \
-		pulsecore/cli-command.h \
-		pulsecore/cli-text.h \
-		pulsecore/client.h \
-		pulsecore/core.h \
-		pulsecore/core-scache.h \
-		pulsecore/core-subscribe.h \
-		pulsecore/conf-parser.h \
-		pulsecore/core-util.h \
-		pulsecore/dynarray.h \
-		pulsecore/g711.h \
-		pulsecore/hashmap.h \
-		pulsecore/idxset.h \
-		pulsecore/log.h \
-		pulsecore/mcalign.h \
-		pulsecore/memblock.h \
-		pulsecore/memblockq.h \
-		pulsecore/memchunk.h \
-		pulsecore/modargs.h \
-		pulsecore/modinfo.h \
-		pulsecore/module.h \
-		pulsecore/namereg.h \
-		pulsecore/pid.h \
-		pulsecore/play-memchunk.h \
-		pulsecore/play-memblockq.h \
-		pulsecore/shared.h \
-		pulsecore/queue.h \
-		pulsecore/random.h \
-		pulsecore/resampler.h \
-		pulsecore/sample-util.h \
-		pulsecore/sconv.h \
-		pulsecore/sink.h \
-		pulsecore/sink-input.h \
-		pulsecore/sioman.h \
-		pulsecore/sound-file.h \
-		pulsecore/sound-file-stream.h \
-		pulsecore/source.h \
-		pulsecore/source-output.h \
-		pulsecore/strbuf.h \
-		pulsecore/tokenizer.h \
-		pulsecore/creds.h \
-		pulsecore/shm.h \
-		pulsecore/llist.h \
-		pulsecore/refcnt.h \
-		pulsecore/mutex.h \
-		pulsecore/thread.h \
-		pulsecore/semaphore.h \
-		pulsecore/once.h
-
-lib_LTLIBRARIES += libpulsecore.la
-
-# Some public stuff is used even in the core
-libpulsecore_la_SOURCES = \
-		pulse/channelmap.c pulse/channelmap.h \
-		pulse/error.c pulse/error.h \
-		pulse/mainloop.c pulse/mainloop.h \
-		pulse/mainloop-api.c pulse/mainloop-api.h \
-		pulse/mainloop-signal.c pulse/mainloop-signal.h \
-		pulse/sample.c pulse/sample.h \
-		pulse/timeval.c pulse/timeval.h \
-		pulse/utf8.c pulse/utf8.h \
-		pulse/util.c pulse/util.h \
-		pulse/volume.c pulse/volume.h \
-		pulse/xmalloc.c pulse/xmalloc.h \
-		pulse/proplist.c pulse/proplist.h \
-		pulse/i18n.c pulse/i18n.h
+lib_LTLIBRARIES += libpulsecore-$(PA_MAJORMINORMICRO).la
 
-# Pure core stuff (some are shared in libpulse though).
-libpulsecore_la_SOURCES += \
+# Pure core stuff
+libpulsecore_ at PA_MMM_USCORE@_la_SOURCES = \
+		pulsecore/asyncmsgq.c pulsecore/asyncmsgq.h \
+		pulsecore/asyncq.c pulsecore/asyncq.h \
 		pulsecore/autoload.c pulsecore/autoload.h \
 		pulsecore/cli-command.c pulsecore/cli-command.h \
 		pulsecore/cli-text.c pulsecore/cli-text.h \
 		pulsecore/client.c pulsecore/client.h \
-		pulsecore/conf-parser.c pulsecore/conf-parser.h \
-		pulsecore/core.c pulsecore/core.h \
 		pulsecore/core-scache.c pulsecore/core-scache.h \
 		pulsecore/core-subscribe.c pulsecore/core-subscribe.h \
-		pulsecore/core-util.c pulsecore/core-util.h \
-		pulsecore/dynarray.c pulsecore/dynarray.h \
-		pulsecore/endianmacros.h \
+		pulsecore/core.c pulsecore/core.h \
+		pulsecore/envelope.c pulsecore/envelope.h \
+		pulsecore/fdsem.c pulsecore/fdsem.h \
 		pulsecore/g711.c pulsecore/g711.h \
-		pulsecore/hashmap.c pulsecore/hashmap.h \
-		pulsecore/idxset.c pulsecore/idxset.h \
-		pulsecore/prioq.c pulsecore/prioq.h \
-		pulsecore/log.c pulsecore/log.h \
-		pulsecore/mcalign.c pulsecore/mcalign.h \
-		pulsecore/memblock.c pulsecore/memblock.h \
-		pulsecore/memblockq.c pulsecore/memblockq.h \
-		pulsecore/memchunk.c pulsecore/memchunk.h \
+		pulsecore/hook-list.c pulsecore/hook-list.h \
+		pulsecore/ltdl-helper.c pulsecore/ltdl-helper.h \
 		pulsecore/modargs.c pulsecore/modargs.h \
 		pulsecore/modinfo.c pulsecore/modinfo.h \
-		pulsecore/ltdl-helper.c pulsecore/ltdl-helper.h \
 		pulsecore/module.c pulsecore/module.h \
+		pulsecore/msgobject.c pulsecore/msgobject.h \
 		pulsecore/namereg.c pulsecore/namereg.h \
-		pulsecore/pid.c pulsecore/pid.h \
-		pulsecore/pipe.c pulsecore/pipe.h \
-		pulsecore/play-memchunk.c pulsecore/play-memchunk.h \
+		pulsecore/object.c pulsecore/object.h \
 		pulsecore/play-memblockq.c pulsecore/play-memblockq.h \
-		pulsecore/poll.c pulsecore/poll.h \
-		pulsecore/shared.c pulsecore/shared.h \
-		pulsecore/queue.c pulsecore/queue.h \
-		pulsecore/random.c pulsecore/random.h \
+		pulsecore/play-memchunk.c pulsecore/play-memchunk.h \
 		pulsecore/resampler.c pulsecore/resampler.h \
+		pulsecore/rtpoll.c pulsecore/rtpoll.h \
+		pulsecore/rtsig.c pulsecore/rtsig.h \
 		pulsecore/sample-util.c pulsecore/sample-util.h \
-		pulsecore/sconv.c pulsecore/sconv.h \
 		pulsecore/sconv-s16be.c pulsecore/sconv-s16be.h \
 		pulsecore/sconv-s16le.c pulsecore/sconv-s16le.h \
-		pulsecore/sink.c pulsecore/sink.h \
+		pulsecore/sconv.c pulsecore/sconv.h \
+		pulsecore/shared.c pulsecore/shared.h \
+		pulsecore/shm.c pulsecore/shm.h \
 		pulsecore/sink-input.c pulsecore/sink-input.h \
+		pulsecore/sink.c pulsecore/sink.h \
 		pulsecore/sioman.c pulsecore/sioman.h \
-		pulsecore/sound-file.c pulsecore/sound-file.h \
 		pulsecore/sound-file-stream.c pulsecore/sound-file-stream.h \
-		pulsecore/source.c pulsecore/source.h \
+		pulsecore/sound-file.c pulsecore/sound-file.h \
 		pulsecore/source-output.c pulsecore/source-output.h \
-		pulsecore/strbuf.c pulsecore/strbuf.h \
-		pulsecore/tokenizer.c pulsecore/tokenizer.h \
-		pulsecore/winsock.h \
-		pulsecore/core-error.c pulsecore/core-error.h \
-		pulsecore/hook-list.c pulsecore/hook-list.h \
-		pulsecore/shm.c pulsecore/shm.h \
-		pulsecore/flist.c pulsecore/flist.h \
-		pulsecore/asyncmsgq.c pulsecore/asyncmsgq.h \
-		pulsecore/asyncq.c pulsecore/asyncq.h \
+		pulsecore/source.c pulsecore/source.h \
+		pulsecore/start-child.c pulsecore/start-child.h \
 		pulsecore/thread-mq.c pulsecore/thread-mq.h \
-		pulsecore/fdsem.c pulsecore/fdsem.h \
-		pulsecore/object.c pulsecore/object.h \
-		pulsecore/msgobject.c pulsecore/msgobject.h \
-		pulsecore/rtsig.c pulsecore/rtsig.h \
-		pulsecore/rtpoll.c pulsecore/rtpoll.h \
-		pulsecore/rtclock.c pulsecore/rtclock.h \
-		pulsecore/macro.h \
-		pulsecore/once.c pulsecore/once.h \
 		pulsecore/time-smoother.c pulsecore/time-smoother.h \
-		pulsecore/start-child.c pulsecore/start-child.h \
-		pulsecore/envelope.c pulsecore/envelope.h \
-		pulsecore/proplist-util.c pulsecore/proplist-util.h \
-		pulsecore/lock-autospawn.c pulsecore/lock-autospawn.h \
+		pulsecore/ffmpeg/resample2.c pulsecore/ffmpeg/avcodec.h pulsecore/ffmpeg/dsputil.h
 		$(PA_THREAD_OBJS)
 
-if OS_IS_WIN32
-libpulsecore_la_SOURCES += \
-		pulsecore/dllmain.c
-endif
-
-libpulsecore_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBOIL_CFLAGS)
-libpulsecore_la_LDFLAGS = -version-info $(LIBPULSECORE_VERSION_INFO)
-libpulsecore_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(LIBSPEEX_LIBS) $(WINSOCK_LIBS) $(LIBOIL_LIBS) $(LTLIBICONV) libffmpeg-resampler.la
+libpulsecore_ at PA_MMM_USCORE@_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBOIL_CFLAGS)
+libpulsecore_ at PA_MMM_USCORE@_la_LDFLAGS = -avoid-version
+libpulsecore_ at PA_MMM_USCORE@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(LIBSPEEX_LIBS) $(WINSOCK_LIBS) $(LIBOIL_LIBS) $(LTLIBICONV)
 
 ###################################
 #   Plug-in support libraries     #
 ###################################
 
-#pulsecoreinclude_HEADERS +=
-noinst_HEADERS += \
-		pulsecore/socket-util.h \
-		pulsecore/iochannel.h \
-		pulsecore/socket-server.h \
-		pulsecore/ipacl.h \
-		pulsecore/socket-client.h \
-		pulsecore/parseaddr.h \
-		pulsecore/packet.h \
-		pulsecore/pstream.h \
-		pulsecore/ioline.h \
-		pulsecore/cli.h \
-		pulsecore/protocol-cli.h \
-		pulsecore/tagstruct.h \
-		pulsecore/pstream-util.h \
-		pulsecore/pdispatch.h \
-		pulsecore/authkey.h \
-		pulsecore/auth-cookie.h \
-		pulsecore/strlist.h \
-		pulsecore/protocol-simple.h \
-		pulsecore/esound.h \
-		pulsecore/protocol-esound.h \
-		pulsecore/native-common.h \
-		pulsecore/protocol-native.h \
-		pulsecore/protocol-http.h
-
 ### Warning! Due to an obscure bug in libtool/automake it is required
 ### that the libraries in modlibexec_LTLIBRARIES are specified in-order,
 ### i.e. libraries near the end of the list depend on libraries near
 ### the head, and not the other way!
 
 modlibexec_LTLIBRARIES = \
-		libsocket-util.la \
-		libiochannel.la \
-		libsocket-server.la \
-		libipacl.la \
-		libparseaddr.la \
-		libsocket-client.la \
-		libpacket.la \
-		libpstream.la \
-		libioline.la \
 		libcli.la \
 		libprotocol-cli.la \
-		libtagstruct.la \
-		libpstream-util.la \
-		libpdispatch.la \
-		libauthkey.la \
-		libauth-cookie.la \
-		libstrlist.la \
 		libprotocol-simple.la \
 		libprotocol-http.la \
 		libprotocol-native.la \
@@ -898,117 +744,35 @@ modlibexec_LTLIBRARIES += \
 		librtp.la
 endif
 
-if HAVE_X11
-#pulsecoreinclude_HEADERS +=
-noinst_HEADERS += \
-		pulsecore/x11wrap.h \
-		pulsecore/x11prop.h
-
-modlibexec_LTLIBRARIES += \
-		libx11wrap.la \
-		libx11prop.la
-endif
-
 if HAVE_AVAHI
-#pulsecoreinclude_HEADERS +=
-noinst_HEADERS += \
-		pulsecore/avahi-wrap.h
-
 modlibexec_LTLIBRARIES += \
 		libavahi-wrap.la
 endif
 
 libprotocol_simple_la_SOURCES = pulsecore/protocol-simple.c pulsecore/protocol-simple.h
 libprotocol_simple_la_LDFLAGS = -avoid-version
-libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore.la libsocket-server.la libiochannel.la
-
-libsocket_server_la_SOURCES = \
-		pulsecore/inet_ntop.c pulsecore/inet_ntop.h \
-		pulsecore/inet_pton.c pulsecore/inet_pton.h \
-		pulsecore/socket-server.c pulsecore/socket-server.h
-libsocket_server_la_LDFLAGS = -avoid-version
-libsocket_server_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la libsocket-util.la $(LIBWRAP_LIBS) $(WINSOCK_LIBS)
-
-libipacl_la_SOURCES = pulsecore/ipacl.h pulsecore/ipacl.c \
-		pulsecore/inet_pton.c pulsecore/inet_pton.h
-libipacl_la_LDFLAGS = -avoid-version
-libipacl_la_LIBADD = $(AM_LIBADD) libpulsecore.la $(WINSOCK_LIBS)
-
-libsocket_client_la_SOURCES = pulsecore/socket-client.c pulsecore/socket-client.h
-libsocket_client_la_LDFLAGS = -avoid-version
-libsocket_client_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la libsocket-util.la libparseaddr.la $(LIBASYNCNS_LIBS) $(WINSOCK_LIBS)
-libsocket_client_la_CFLAGS = $(AM_CFLAGS) $(LIBASYNCNS_CFLAGS)
-
-libparseaddr_la_SOURCES = pulsecore/parseaddr.c pulsecore/parseaddr.h
-libparseaddr_la_LDFLAGS = -avoid-version
-libparseaddr_la_LIBADD = $(AM_LIBADD) libpulsecore.la
-
-libpstream_la_SOURCES = pulsecore/pstream.c pulsecore/pstream.h
-libpstream_la_LDFLAGS = -avoid-version
-libpstream_la_LIBADD = $(AM_LIBADD) libpulsecore.la libpacket.la libiochannel.la $(WINSOCK_LIBS)
-
-libpstream_util_la_SOURCES = pulsecore/pstream-util.c pulsecore/pstream-util.h
-libpstream_util_la_LDFLAGS = -avoid-version
-libpstream_util_la_LIBADD = $(AM_LIBADD) libpacket.la libpstream.la libtagstruct.la libpulsecore.la
-
-libpdispatch_la_SOURCES = pulsecore/pdispatch.c pulsecore/pdispatch.h
-libpdispatch_la_LDFLAGS = -avoid-version
-libpdispatch_la_LIBADD = $(AM_LIBADD) libtagstruct.la libpulsecore.la
-
-libiochannel_la_SOURCES = pulsecore/iochannel.c pulsecore/iochannel.h
-libiochannel_la_LDFLAGS = -avoid-version
-libiochannel_la_LIBADD = $(AM_LIBADD) libsocket-util.la libpulsecore.la $(WINSOCK_LIBS)
-
-libpacket_la_SOURCES = pulsecore/packet.c pulsecore/packet.h
-libpacket_la_LDFLAGS = -avoid-version
-libpacket_la_LIBADD = $(AM_LIBADD) libpulsecore.la
-
-libioline_la_SOURCES = pulsecore/ioline.c pulsecore/ioline.h
-libioline_la_LDFLAGS = -avoid-version
-libioline_la_LIBADD = $(AM_LIBADD) libiochannel.la libpulsecore.la
+libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libsocket-server.la libiochannel.la
 
 libcli_la_SOURCES = pulsecore/cli.c pulsecore/cli.h
 libcli_la_CPPFLAGS = $(AM_CPPFLAGS)
 libcli_la_LDFLAGS = -avoid-version
-libcli_la_LIBADD = $(AM_LIBADD) libiochannel.la libioline.la libpulsecore.la
-
-libstrlist_la_SOURCES = pulsecore/strlist.c pulsecore/strlist.h
-libstrlist_la_LDFLAGS = -avoid-version
-libstrlist_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+libcli_la_LIBADD = $(AM_LIBADD) libiochannel.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libprotocol_cli_la_SOURCES = pulsecore/protocol-cli.c pulsecore/protocol-cli.h
 libprotocol_cli_la_LDFLAGS = -avoid-version
-libprotocol_cli_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la libcli.la libpulsecore.la
+libprotocol_cli_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la libcli.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libprotocol_http_la_SOURCES = pulsecore/protocol-http.c pulsecore/protocol-http.h
 libprotocol_http_la_LDFLAGS = -avoid-version
-libprotocol_http_la_LIBADD = $(AM_LIBADD) libsocket-server.la libioline.la libpulsecore.la libiochannel.la
+libprotocol_http_la_LIBADD = $(AM_LIBADD) libsocket-server.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la libiochannel.la
 
 libprotocol_native_la_SOURCES = pulsecore/protocol-native.c pulsecore/protocol-native.h pulsecore/native-common.h
 libprotocol_native_la_LDFLAGS = -avoid-version
-libprotocol_native_la_LIBADD = $(AM_LIBADD) libsocket-server.la libpstream.la libpstream-util.la libpdispatch.la libtagstruct.la libauthkey.la libauth-cookie.la libstrlist.la libpulsecore.la libiochannel.la libipacl.la
-
-libtagstruct_la_SOURCES = pulsecore/tagstruct.c pulsecore/tagstruct.h
-libtagstruct_la_LDFLAGS = -avoid-version
-libtagstruct_la_LIBADD = $(AM_LIBADD) libpulsecore.la $(WINSOCK_LIBS)
+libprotocol_native_la_LIBADD = $(AM_LIBADD) libsocket-server.la libpstream.la libpstream-util.la libpdispatch.la libtagstruct.la libauthkey.la libauth-cookie.la libstrlist.la libpulsecore- at PA_MAJORMINORMICRO@.la libiochannel.la libipacl.la
 
 libprotocol_esound_la_SOURCES = pulsecore/protocol-esound.c pulsecore/protocol-esound.h pulsecore/esound.h
 libprotocol_esound_la_LDFLAGS = -avoid-version
-libprotocol_esound_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la libauthkey.la libauth-cookie.la libpulsecore.la libipacl.la
-
-libauthkey_la_SOURCES = pulsecore/authkey.c pulsecore/authkey.h
-libauthkey_la_LDFLAGS = -avoid-version
-libauthkey_la_LIBADD = $(AM_LIBADD) libpulsecore.la
-
-libauth_cookie_la_SOURCES = pulsecore/auth-cookie.c pulsecore/auth-cookie.h
-libauth_cookie_la_LDFLAGS = -avoid-version
-libauth_cookie_la_LIBADD = $(AM_LIBADD) libauthkey.la libpulsecore.la
-
-libsocket_util_la_SOURCES = \
-		pulsecore/inet_ntop.c pulsecore/inet_ntop.h \
-		pulsecore/socket-util.c pulsecore/socket-util.h
-libsocket_util_la_LDFLAGS = -avoid-version
-libsocket_util_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) libpulsecore.la
+libprotocol_esound_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la libauthkey.la libauth-cookie.la libpulsecore- at PA_MAJORMINORMICRO@.la libipacl.la
 
 librtp_la_SOURCES = \
 		modules/rtp/rtp.c modules/rtp/rtp.h \
@@ -1017,33 +781,20 @@ librtp_la_SOURCES = \
 		modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
 		modules/rtp/headerlist.c modules/rtp/headerlist.h
 librtp_la_LDFLAGS = -avoid-version
-librtp_la_LIBADD = $(AM_LIBADD) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore.la
+librtp_la_LIBADD = $(AM_LIBADD) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libraop_la_SOURCES = \
         modules/raop/raop_client.c modules/raop/raop_client.h \
         modules/raop/base64.c modules/raop/base64.h
 libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS)
 libraop_la_LDFLAGS = -avoid-version
-libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore.la librtp.la
-
-# X11
-
-libx11wrap_la_SOURCES = pulsecore/x11wrap.c pulsecore/x11wrap.h
-libx11wrap_la_LDFLAGS = -avoid-version
-libx11wrap_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
-libx11wrap_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore.la
-
-libx11prop_la_SOURCES = pulsecore/x11prop.c pulsecore/x11prop.h
-libx11prop_la_LDFLAGS = -avoid-version
-libx11prop_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
-libx11prop_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
 
 # Avahi
-
 libavahi_wrap_la_SOURCES = pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h
 libavahi_wrap_la_LDFLAGS = -avoid-version
 libavahi_wrap_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
-libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore.la
+libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 ###################################
 #        Plug-in libraries        #
@@ -1284,328 +1035,328 @@ $(SYMDEF_FILES): modules/module-defs.h.m4
 
 module_flat_volume_la_SOURCES = modules/module-flat-volume.c
 module_flat_volume_la_LDFLAGS = -module -avoid-version
-module_flat_volume_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_flat_volume_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # Simple protocol
 
 module_simple_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_simple_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_SIMPLE $(AM_CFLAGS)
 module_simple_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_simple_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-simple.la libsocket-server.la
+module_simple_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la
 
 module_simple_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_simple_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_SIMPLE $(AM_CFLAGS)
 module_simple_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-simple.la libsocket-server.la libsocket-util.la
+module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la
 
 # CLI protocol
 
 module_cli_la_SOURCES = modules/module-cli.c
 module_cli_la_LDFLAGS = -module -avoid-version
-module_cli_la_LIBADD = $(AM_LIBADD) libcli.la libiochannel.la libpulsecore.la
+module_cli_la_LIBADD = $(AM_LIBADD) libcli.la libiochannel.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_cli_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
 module_cli_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_cli_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-cli.la libsocket-server.la
+module_cli_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la
 
 module_cli_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
 module_cli_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_cli_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-cli.la libsocket-server.la libsocket-util.la
+module_cli_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la
 
 # HTTP protocol
 
 module_http_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_http_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
 module_http_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_http_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-http.la libsocket-server.la
+module_http_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la
 
 module_http_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_http_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
 module_http_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_http_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-http.la libsocket-server.la libsocket-util.la
+module_http_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la
 
 # Native protocol
 
 module_native_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_native_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_NATIVE $(AM_CFLAGS)
 module_native_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_native_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-native.la libsocket-server.la
+module_native_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la
 
 module_native_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_native_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_NATIVE $(AM_CFLAGS)
 module_native_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_native_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-native.la libsocket-server.la libsocket-util.la
+module_native_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la
 
 module_native_protocol_fd_la_SOURCES = modules/module-native-protocol-fd.c
 module_native_protocol_fd_la_CFLAGS = $(AM_CFLAGS)
 module_native_protocol_fd_la_LDFLAGS = -module -avoid-version
-module_native_protocol_fd_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-native.la libsocket-server.la libsocket-util.la libiochannel.la
+module_native_protocol_fd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la
 
 # EsounD protocol
 
 module_esound_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_esound_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_ESOUND $(AM_CFLAGS)
 module_esound_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_esound_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-esound.la libsocket-server.la
+module_esound_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la
 
 module_esound_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_esound_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_ESOUND $(AM_CFLAGS)
 module_esound_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_esound_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore.la libprotocol-esound.la libsocket-server.la libsocket-util.la
+module_esound_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la
 
 module_esound_compat_spawnfd_la_SOURCES = modules/module-esound-compat-spawnfd.c
 module_esound_compat_spawnfd_la_LDFLAGS = -module -avoid-version
-module_esound_compat_spawnfd_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_esound_compat_spawnfd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_esound_compat_spawnpid_la_SOURCES = modules/module-esound-compat-spawnpid.c
 module_esound_compat_spawnpid_la_LDFLAGS = -module -avoid-version
-module_esound_compat_spawnpid_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_esound_compat_spawnpid_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_esound_sink_la_SOURCES = modules/module-esound-sink.c
 module_esound_sink_la_LDFLAGS = -module -avoid-version
-module_esound_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la libsocket-client.la libauthkey.la libsocket-util.la
+module_esound_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # Pipes
 
 module_pipe_sink_la_SOURCES = modules/module-pipe-sink.c
 module_pipe_sink_la_LDFLAGS = -module -avoid-version
-module_pipe_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la
+module_pipe_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_pipe_source_la_SOURCES = modules/module-pipe-source.c
 module_pipe_source_la_LDFLAGS = -module -avoid-version
-module_pipe_source_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la
+module_pipe_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # Fake sources/sinks
 
 module_sine_la_SOURCES = modules/module-sine.c
 module_sine_la_LDFLAGS = -module -avoid-version
-module_sine_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_sine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_null_sink_la_SOURCES = modules/module-null-sink.c
 module_null_sink_la_LDFLAGS = -module -avoid-version
-module_null_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_null_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # Couplings
 
 module_combine_la_SOURCES = modules/module-combine.c
 module_combine_la_LDFLAGS = -module -avoid-version
-module_combine_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_combine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_remap_sink_la_SOURCES = modules/module-remap-sink.c
 module_remap_sink_la_LDFLAGS = -module -avoid-version
-module_remap_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_remap_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_ladspa_sink_la_SOURCES = modules/module-ladspa-sink.c modules/ladspa.h
 module_ladspa_sink_la_CFLAGS = -DLADSPA_PATH=\"$(libdir)/ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa:/usr/local/lib64/ladspa:/usr/lib64/ladspa\" $(AM_CFLAGS)
 module_ladspa_sink_la_LDFLAGS = -module -avoid-version
-module_ladspa_sink_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) libpulsecore.la
+module_ladspa_sink_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_match_la_SOURCES = modules/module-match.c
 module_match_la_LDFLAGS = -module -avoid-version
-module_match_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_match_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_tunnel_sink_la_SOURCES = modules/module-tunnel.c
 module_tunnel_sink_la_CFLAGS = -DTUNNEL_SINK=1 $(AM_CFLAGS)
 module_tunnel_sink_la_LDFLAGS = -module -avoid-version
-module_tunnel_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libsocket-client.la libpstream.la libpstream-util.la libpdispatch.la libtagstruct.la libauthkey.la libauth-cookie.la libsocket-util.la libiochannel.la
+module_tunnel_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_tunnel_source_la_SOURCES = modules/module-tunnel.c
 module_tunnel_source_la_LDFLAGS = -module -avoid-version
-module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore.la libsocket-client.la libpstream.la libpstream-util.la libpdispatch.la libtagstruct.la libauthkey.la libauth-cookie.la libsocket-util.la libiochannel.la
+module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # X11
 
 module_x11_bell_la_SOURCES = modules/module-x11-bell.c
 module_x11_bell_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_bell_la_LDFLAGS = -module -avoid-version
-module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libpulsecore.la
+module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_x11_publish_la_SOURCES = modules/module-x11-publish.c
 module_x11_publish_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_publish_la_LDFLAGS = -module -avoid-version
-module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libauthkey.la libauth-cookie.la libx11prop.la libstrlist.la libprotocol-native.la libpulsecore.la
+module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_x11_xsmp_la_SOURCES = modules/module-x11-xsmp.c
 module_x11_xsmp_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_xsmp_la_LDFLAGS = -module -avoid-version
-module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libpulsecore.la
+module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # OSS
 
 liboss_util_la_SOURCES = modules/oss-util.c modules/oss-util.h
 liboss_util_la_LDFLAGS = -avoid-version
-liboss_util_la_LIBADD = libpulsecore.la
+liboss_util_la_LIBADD = libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_oss_la_SOURCES = modules/module-oss.c
 module_oss_la_LDFLAGS = -module -avoid-version
-module_oss_la_LIBADD = $(AM_LIBADD) libiochannel.la liboss-util.la libpulsecore.la
+module_oss_la_LIBADD = $(AM_LIBADD) liboss-util.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # ALSA
 
 libalsa_util_la_SOURCES = modules/alsa-util.c modules/alsa-util.h
 libalsa_util_la_LDFLAGS = -avoid-version
-libalsa_util_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libpulsecore.la
+libalsa_util_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 libalsa_util_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 module_alsa_sink_la_SOURCES = modules/module-alsa-sink.c
 module_alsa_sink_la_LDFLAGS = -module -avoid-version
-module_alsa_sink_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore.la
+module_alsa_sink_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la
 module_alsa_sink_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 module_alsa_source_la_SOURCES = modules/module-alsa-source.c
 module_alsa_source_la_LDFLAGS = -module -avoid-version
-module_alsa_source_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore.la
+module_alsa_source_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la
 module_alsa_source_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 # Solaris
 
 module_solaris_la_SOURCES = modules/module-solaris.c
 module_solaris_la_LDFLAGS = -module -avoid-version
-module_solaris_la_LIBADD = $(AM_LIBADD) libiochannel.la libpulsecore.la
+module_solaris_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # Avahi
 
 module_zeroconf_publish_la_SOURCES = modules/module-zeroconf-publish.c
 module_zeroconf_publish_la_LDFLAGS = -module -avoid-version
-module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore.la
+module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
 module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 module_zeroconf_discover_la_SOURCES = modules/module-zeroconf-discover.c
 module_zeroconf_discover_la_LDFLAGS = -module -avoid-version
-module_zeroconf_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore.la
+module_zeroconf_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
 module_zeroconf_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 # LIRC
 
 module_lirc_la_SOURCES = modules/module-lirc.c
 module_lirc_la_LDFLAGS = -module -avoid-version
-module_lirc_la_LIBADD = $(AM_LIBADD) $(LIRC_LIBS) libpulsecore.la
+module_lirc_la_LIBADD = $(AM_LIBADD) $(LIRC_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_lirc_la_CFLAGS = $(AM_CFLAGS) $(LIRC_CFLAGS)
 
 # Linux evdev
 
 module_mmkbd_evdev_la_SOURCES = modules/module-mmkbd-evdev.c
 module_mmkbd_evdev_la_LDFLAGS = -module -avoid-version
-module_mmkbd_evdev_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_mmkbd_evdev_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_mmkbd_evdev_la_CFLAGS = $(AM_CFLAGS)
 
 # Windows waveout
 
 #module_waveout_la_SOURCES = modules/module-waveout.c
 #module_waveout_la_LDFLAGS = -module -avoid-version
-#module_waveout_la_LIBADD = $(AM_LIBADD) libpulsecore.la -lwinmm
+#module_waveout_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lwinmm
 #module_waveout_la_CFLAGS = $(AM_CFLAGS)
 
 # Hardware autodetection module
 module_detect_la_SOURCES = modules/module-detect.c
 module_detect_la_LDFLAGS = -module -avoid-version
-module_detect_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_detect_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_detect_la_CFLAGS = $(AM_CFLAGS)
 
 # Volume restore module
 module_volume_restore_la_SOURCES = modules/module-volume-restore.c
 module_volume_restore_la_LDFLAGS = -module -avoid-version
-module_volume_restore_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_volume_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_volume_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Position event sounds in space
 module_position_event_sounds_la_SOURCES = modules/module-position-event-sounds.c
 module_position_event_sounds_la_LDFLAGS = -module -avoid-version
-module_position_event_sounds_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_position_event_sounds_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_position_event_sounds_CFLAGS = $(AM_CFLAGS)
 
 # Device volume/muted restore module
 module_device_restore_la_SOURCES = modules/module-device-restore.c
 module_device_restore_la_LDFLAGS = -module -avoid-version
-module_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore.la -lgdbm
+module_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm
 module_device_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Stream volume/muted/device restore module
 module_stream_restore_la_SOURCES = modules/module-stream-restore.c
 module_stream_restore_la_LDFLAGS = -module -avoid-version
-module_stream_restore_la_LIBADD = $(AM_LIBADD) libtagstruct.la libprotocol-native.la libpulsecore.la -lgdbm
+module_stream_restore_la_LIBADD = $(AM_LIBADD) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm
 module_stream_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Default sink/source restore module
 module_default_device_restore_la_SOURCES = modules/module-default-device-restore.c
 module_default_device_restore_la_LDFLAGS = -module -avoid-version
-module_default_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_default_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_default_device_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Always Sink module
 module_always_sink_la_SOURCES = modules/module-always-sink.c
 module_always_sink_la_LDFLAGS = -module -avoid-version
-module_always_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_always_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_always_sink_la_CFLAGS = $(AM_CFLAGS)
 
 # Rescue streams module
 module_rescue_streams_la_SOURCES = modules/module-rescue-streams.c
 module_rescue_streams_la_LDFLAGS = -module -avoid-version
-module_rescue_streams_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_rescue_streams_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_rescue_streams_la_CFLAGS = $(AM_CFLAGS)
 
 # Suspend-on-idle module
 module_suspend_on_idle_la_SOURCES = modules/module-suspend-on-idle.c
 module_suspend_on_idle_la_LDFLAGS = -module -avoid-version
-module_suspend_on_idle_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_suspend_on_idle_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_suspend_on_idle_la_CFLAGS = $(AM_CFLAGS)
 
 # RTP modules
 module_rtp_send_la_SOURCES = modules/rtp/module-rtp-send.c
 module_rtp_send_la_LDFLAGS = -module -avoid-version
-module_rtp_send_la_LIBADD = $(AM_LIBADD) libpulsecore.la librtp.la libsocket-util.la
+module_rtp_send_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
 module_rtp_send_la_CFLAGS = $(AM_CFLAGS)
 
 module_rtp_recv_la_SOURCES = modules/rtp/module-rtp-recv.c
 module_rtp_recv_la_LDFLAGS = -module -avoid-version
-module_rtp_recv_la_LIBADD = $(AM_LIBADD) libpulsecore.la librtp.la
+module_rtp_recv_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
 module_rtp_recv_la_CFLAGS = $(AM_CFLAGS)
 
 # JACK
 
 module_jack_sink_la_SOURCES = modules/module-jack-sink.c
 module_jack_sink_la_LDFLAGS = -module -avoid-version
-module_jack_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la $(JACK_LIBS)
+module_jack_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS)
 module_jack_sink_la_CFLAGS = $(AM_CFLAGS) $(JACK_CFLAGS)
 
 module_jack_source_la_SOURCES = modules/module-jack-source.c
 module_jack_source_la_LDFLAGS = -module -avoid-version
-module_jack_source_la_LIBADD = $(AM_LIBADD) libpulsecore.la $(JACK_LIBS)
+module_jack_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS)
 module_jack_source_la_CFLAGS = $(AM_CFLAGS) $(JACK_CFLAGS)
 
 # HAL/D-Bus
 libdbus_util_la_SOURCES = modules/dbus-util.c modules/dbus-util.h
 libdbus_util_la_LDFLAGS = -avoid-version
-libdbus_util_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore.la
+libdbus_util_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 libdbus_util_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 module_hal_detect_la_SOURCES = modules/module-hal-detect.c
 module_hal_detect_la_LDFLAGS = -module -avoid-version
-module_hal_detect_la_LIBADD = $(AM_LIBADD) $(HAL_LIBS) libpulsecore.la libdbus-util.la
+module_hal_detect_la_LIBADD = $(AM_LIBADD) $(HAL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
 module_hal_detect_la_CFLAGS = $(AM_CFLAGS) $(HAL_CFLAGS)
 
 module_console_kit_la_SOURCES = modules/module-console-kit.c
 module_console_kit_la_LDFLAGS = -module -avoid-version
-module_console_kit_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore.la libdbus-util.la
+module_console_kit_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
 module_console_kit_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 # GConf support
 module_gconf_la_SOURCES = modules/gconf/module-gconf.c
 module_gconf_la_LDFLAGS = -module -avoid-version
-module_gconf_la_LIBADD = $(AM_LIBADD) libpulsecore.la
+module_gconf_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 module_gconf_la_CFLAGS = $(AM_CFLAGS) -DPA_GCONF_HELPER=\"$(pulselibexecdir)/gconf-helper\"
 
 gconf_helper_SOURCES = modules/gconf/gconf-helper.c
-gconf_helper_LDADD = $(AM_LDADD) $(GCONF_LIBS) libpulsecore.la
+gconf_helper_LDADD = $(AM_LDADD) $(GCONF_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 gconf_helper_CFLAGS = $(AM_CFLAGS) $(GCONF_CFLAGS)
 gconf_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 # Bluetooth proximity
 module_bluetooth_proximity_la_SOURCES = modules/bluetooth/module-bluetooth-proximity.c
 module_bluetooth_proximity_la_LDFLAGS = -module -avoid-version
-module_bluetooth_proximity_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore.la libdbus-util.la
+module_bluetooth_proximity_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
 module_bluetooth_proximity_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -DPA_BT_PROXIMITY_HELPER=\"$(pulselibexecdir)/proximity-helper\"
 
 proximity_helper_SOURCES = modules/bluetooth/proximity-helper.c
@@ -1616,7 +1367,7 @@ proximity_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 # Bluetooth sink / source
 module_bluetooth_discover_la_SOURCES = modules/bluetooth/module-bluetooth-discover.c
 module_bluetooth_discover_la_LDFLAGS = -module -avoid-version
-module_bluetooth_discover_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore.la libdbus-util.la
+module_bluetooth_discover_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
 module_bluetooth_discover_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 libbluetooth_sbc_la_SOURCES = modules/bluetooth/sbc.c modules/bluetooth/sbc.h modules/bluetooth/sbc_tables.h modules/bluetooth/sbc_math.h
@@ -1631,17 +1382,17 @@ libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS)
 
 module_bluetooth_device_la_SOURCES = modules/bluetooth/module-bluetooth-device.c modules/bluetooth/rtp.h
 module_bluetooth_device_la_LDFLAGS = -module -avoid-version
-module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libsocket-util.la
+module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libsocket-util.la
 module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 # Apple Airtunes/RAOP
 module_raop_sink_la_SOURCES = modules/module-raop-sink.c
 module_raop_sink_la_LDFLAGS = -module -avoid-version
-module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore.la libiochannel.la librtp.la libraop.la
+module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libraop.la
 
 module_raop_discover_la_SOURCES = modules/module-raop-discover.c
 module_raop_discover_la_LDFLAGS = -module -avoid-version
-module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore.la
+module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
 module_raop_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 

commit b978d842ab7f7f802598c9daa20cfa21bcf5f90a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 22 02:22:19 2008 +0200

    update map file

diff --git a/src/map-file b/src/map-file
index 7211914..ca523b9 100644
--- a/src/map-file
+++ b/src/map-file
@@ -105,7 +105,6 @@ pa_cvolume_max;
 pa_cvolume_remap;
 pa_cvolume_set;
 pa_cvolume_snprint;
-pa_sw_cvolume_snprint_dB;
 pa_cvolume_valid;
 pa_ext_stream_restore_delete;
 pa_ext_stream_restore_read;
@@ -228,7 +227,10 @@ pa_stream_update_timing_info;
 pa_stream_writable_size;
 pa_stream_write;
 pa_strerror;
+pa_sw_cvolume_divide;
 pa_sw_cvolume_multiply;
+pa_sw_cvolume_snprint_dB;
+pa_sw_volume_divide;
 pa_sw_volume_from_dB;
 pa_sw_volume_from_linear;
 pa_sw_volume_multiply;

commit 695d300156680d91438fe0086575baeb1da0c82a
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 22 02:22:40 2008 +0200

    make new build logic actually work

diff --git a/configure.ac b/configure.ac
index 6c21ca5..bd29f15 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,7 +34,6 @@ AM_INIT_AUTOMAKE([foreign 1.10 -Wall])
 
 AC_SUBST(PA_MAJORMINOR, PA_MAJOR.PA_MINOR)
 AC_SUBST(PA_MAJORMINORMICRO, PA_MAJOR.PA_MINOR.PA_MICRO)
-AC_SUBST(PA_MMM_USCORE, AS_TR_SH(PA_MAJOR.PA_MINOR.PA_MICRO))
 AC_SUBST(PACKAGE_URL, [http://pulseaudio.org/])
 
 AC_SUBST(PA_API_VERSION, 12)
diff --git a/src/Makefile.am b/src/Makefile.am
index 32ffbc5..f42584b 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -143,10 +143,9 @@ pulseaudio_SOURCES = \
 		daemon/main.c
 
 pulseaudio_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS) $(LIBSAMPLERATE_CFLAGS) $(LIBSPEEX_CFLAGS) $(LIBSNDFILE_CFLAGS) $(CAP_CFLAGS) $(LIBOIL_CFLAGS) $(DBUS_CFLAGS)
-pulseaudio_CPPFLAGS = $(AM_CPPFLAGS)
-pulseaudio_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la libpulse.la $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(CAP_LIBS) $(LIBOIL_LIBS) $(DBUS_LIBS)
+pulseaudio_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSPEEX_LIBS) $(LIBSNDFILE_LIBS) $(CAP_LIBS) $(LIBOIL_LIBS) $(DBUS_LIBS)
 # This is needed because automake doesn't properly expand the foreach below
-pulseaudio_DEPENDENCIES = libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la libpulse.la $(PREOPEN_LIBS)
+pulseaudio_DEPENDENCIES = libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la $(PREOPEN_LIBS)
 
 if PREOPEN_MODS
 PREOPEN_LIBS = $(PREOPEN_MODS)
@@ -203,23 +202,23 @@ paplay_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 paplay_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pactl_SOURCES = utils/pactl.c
-pactl_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la $(LIBSNDFILE_LIBS)
+pactl_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(LIBSNDFILE_LIBS)
 pactl_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 pactl_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pasuspender_SOURCES = utils/pasuspender.c
-pasuspender_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la $(LIBSNDFILE_LIBS)
+pasuspender_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(LIBSNDFILE_LIBS)
 pasuspender_CFLAGS = $(AM_CFLAGS) $(LIBSNDFILE_CFLAGS)
 pasuspender_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pacmd_SOURCES = utils/pacmd.c
 pacmd_CFLAGS = $(AM_CFLAGS)
-pacmd_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+pacmd_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 pacmd_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-pax11publish_SOURCES = utils/pax11publish.c
+pax11publish_SOURCES = utils/pax11publish.c pulse/client-conf.c pulse/client-conf.h
 pax11publish_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
-pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
 pax11publish_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pabrowse_SOURCES = utils/pabrowse.c
@@ -285,12 +284,12 @@ mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 thread_mainloop_test_SOURCES = tests/thread-mainloop-test.c
 thread_mainloop_test_CFLAGS = $(AM_CFLAGS)
-thread_mainloop_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulse.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+thread_mainloop_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 thread_mainloop_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 utf8_test_SOURCES = tests/utf8-test.c
 utf8_test_CFLAGS = $(AM_CFLAGS)
-utf8_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+utf8_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 utf8_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 get_binary_name_test_SOURCES = tests/get-binary-name-test.c
@@ -300,52 +299,52 @@ get_binary_name_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 ipacl_test_SOURCES = tests/ipacl-test.c
 ipacl_test_CFLAGS = $(AM_CFLAGS)
-ipacl_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+ipacl_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 ipacl_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 hook_list_test_SOURCES = tests/hook-list-test.c
 hook_list_test_CFLAGS = $(AM_CFLAGS)
-hook_list_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+hook_list_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 hook_list_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 memblock_test_SOURCES = tests/memblock-test.c
 memblock_test_CFLAGS = $(AM_CFLAGS)
-memblock_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+memblock_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 memblock_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 thread_test_SOURCES = tests/thread-test.c
 thread_test_CFLAGS = $(AM_CFLAGS)
-thread_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+thread_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 thread_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 flist_test_SOURCES = tests/flist-test.c
 flist_test_CFLAGS = $(AM_CFLAGS)
-flist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+flist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 flist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 asyncq_test_SOURCES = tests/asyncq-test.c
 asyncq_test_CFLAGS = $(AM_CFLAGS)
-asyncq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+asyncq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 asyncq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 asyncmsgq_test_SOURCES = tests/asyncmsgq-test.c
 asyncmsgq_test_CFLAGS = $(AM_CFLAGS)
-asyncmsgq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+asyncmsgq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 asyncmsgq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 queue_test_SOURCES = tests/queue-test.c
 queue_test_CFLAGS = $(AM_CFLAGS)
-queue_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+queue_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 queue_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 rtpoll_test_SOURCES = tests/rtpoll-test.c
 rtpoll_test_CFLAGS = $(AM_CFLAGS)
-rtpoll_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+rtpoll_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 rtpoll_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 mcalign_test_SOURCES = tests/mcalign-test.c
 mcalign_test_CFLAGS = $(AM_CFLAGS)
-mcalign_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+mcalign_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 mcalign_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pacat_simple_SOURCES = tests/pacat-simple.c
@@ -360,12 +359,12 @@ parec_simple_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 strlist_test_SOURCES = tests/strlist-test.c
 strlist_test_CFLAGS = $(AM_CFLAGS)
-strlist_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommmon- at PA_MAJORMINORMICRO@.la
+strlist_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 strlist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 close_test_SOURCES = tests/close-test.c
 close_test_CFLAGS = $(AM_CFLAGS)
-close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libstrlist.la
+close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 close_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 voltest_SOURCES = tests/voltest.c
@@ -468,14 +467,15 @@ prioq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 ###################################
 
 lib_LTLIBRARIES = \
-		libpulsecommon-$(PA_MAJORMINORMICRO).la
+		libpulsecommon- at PA_MAJORMINORMICRO@.la
 
-libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES = \
-		pulsecore/auth-cookie.c pulsecore/auth-cookie.h \
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
+		pulse/i18n.c pulse/i18n.h \
 		pulsecore/authkey.c pulsecore/authkey.h \
 		pulsecore/conf-parser.c pulsecore/conf-parser.h \
 		pulsecore/core-error.c pulsecore/core-error.h \
 		pulsecore/core-util.c pulsecore/core-util.h \
+		pulsecore/creds.h \
 		pulsecore/dynarray.c pulsecore/dynarray.h \
 		pulsecore/endianmacros.h \
 		pulsecore/flist.c pulsecore/flist.h \
@@ -519,29 +519,30 @@ libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES = \
 		pulsecore/time-smoother.c pulsecore/time-smoother.h \
 		pulsecore/tokenizer.c pulsecore/tokenizer.h \
 		pulsecore/winsock.h \
-		pulsecore/creds.h \
 		$(PA_THREAD_OBJS)
 
-libpulsecommon_ at PA_MMM_USCORE@_la_CFLAGS = $(AM_CFLAGS)
-libpulsecommon_ at PA_MMM_USCORE@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
-libpulsecommon_ at PA_MMM_USCORE@_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) $(LTLIBICONV)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS = $(AM_CFLAGS)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_LIBADD = $(AM_LIBADD) $(LIBWRAP_LIBS) $(WINSOCK_LIBS) $(LTLIBICONV)
 
-if HAVE_X11
-libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES += \
-		pulsecore/x11wrap.c pulsecore/x11wrap.h \
-		pulsecore/x11prop.c pulsecore/x11prop.h
+## Please note that libpulsecommon implicitly also depends on<
+## libpulse! i.e. we have a cyclic dependancy here. Which is intended
+## since libpulse only includes stable, official APIs, while
+## libpulsecommon only includes unofficial APIs.
 
-libpulsecommon_ at PA_MMM_USCORE@_la_CFLAGS += $(X_CFLAGS)
-libpulsecommon_ at PA_MMM_USCORE@_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+if HAVE_X11
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/x11prop.c pulsecore/x11prop.h
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X_CFLAGS)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
 endif
 
 if HAVE_LIBASYNCNS
-libpulsecommon_ at PA_MMM_USCORE@_la_CFLAGS += $(LIBASYNCNS_CFLAGS)
-libpulsecommon_ at PA_MMM_USCORE@_la_LIBADD += $(LIBASYNCNS_LIBS)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(LIBASYNCNS_CFLAGS)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_LIBADD += $(LIBASYNCNS_LIBS)
 endif
 
 if OS_IS_WIN32
-libpulsecommon_ at PA_MMM_USCORE@_la_SOURCES += pulsecore/dllmain.c
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/dllmain.c
 endif
 
 ###################################
@@ -606,7 +607,6 @@ libpulse_la_SOURCES = \
 		pulse/error.c pulse/error.h \
 		pulse/ext-stream-restore.c pulse/ext-stream-restore.h \
 		pulse/gccmacro.h \
-		pulse/i18n.c pulse/i18n.h \
 		pulse/internal.h \
 		pulse/introspect.c pulse/introspect.h \
 		pulse/mainloop-api.c pulse/mainloop-api.h \
@@ -669,12 +669,13 @@ libpulsedsp_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
 #      Daemon core library        #
 ###################################
 
-lib_LTLIBRARIES += libpulsecore-$(PA_MAJORMINORMICRO).la
+lib_LTLIBRARIES += libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # Pure core stuff
-libpulsecore_ at PA_MMM_USCORE@_la_SOURCES = \
+libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/asyncmsgq.c pulsecore/asyncmsgq.h \
 		pulsecore/asyncq.c pulsecore/asyncq.h \
+		pulsecore/auth-cookie.c pulsecore/auth-cookie.h \
 		pulsecore/autoload.c pulsecore/autoload.h \
 		pulsecore/cli-command.c pulsecore/cli-command.h \
 		pulsecore/cli-text.c pulsecore/cli-text.h \
@@ -684,6 +685,7 @@ libpulsecore_ at PA_MMM_USCORE@_la_SOURCES = \
 		pulsecore/core.c pulsecore/core.h \
 		pulsecore/envelope.c pulsecore/envelope.h \
 		pulsecore/fdsem.c pulsecore/fdsem.h \
+		pulsecore/ffmpeg/resample2.c pulsecore/ffmpeg/avcodec.h pulsecore/ffmpeg/dsputil.h \
 		pulsecore/g711.c pulsecore/g711.h \
 		pulsecore/hook-list.c pulsecore/hook-list.h \
 		pulsecore/ltdl-helper.c pulsecore/ltdl-helper.h \
@@ -714,12 +716,17 @@ libpulsecore_ at PA_MMM_USCORE@_la_SOURCES = \
 		pulsecore/start-child.c pulsecore/start-child.h \
 		pulsecore/thread-mq.c pulsecore/thread-mq.h \
 		pulsecore/time-smoother.c pulsecore/time-smoother.h \
-		pulsecore/ffmpeg/resample2.c pulsecore/ffmpeg/avcodec.h pulsecore/ffmpeg/dsputil.h
 		$(PA_THREAD_OBJS)
 
-libpulsecore_ at PA_MMM_USCORE@_la_CPPFLAGS = $(AM_CPPFLAGS) $(LIBOIL_CFLAGS)
-libpulsecore_ at PA_MMM_USCORE@_la_LDFLAGS = -avoid-version
-libpulsecore_ at PA_MMM_USCORE@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(LIBSPEEX_LIBS) $(WINSOCK_LIBS) $(LIBOIL_LIBS) $(LTLIBICONV)
+libpulsecore_ at PA_MAJORMINORMICRO@_la_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
+libpulsecore_ at PA_MAJORMINORMICRO@_la_LDFLAGS = -avoid-version
+libpulsecore_ at PA_MAJORMINORMICRO@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPLERATE_LIBS) $(LIBSNDFILE_LIBS) $(LIBSPEEX_LIBS) $(WINSOCK_LIBS) $(LIBOIL_LIBS) $(LTLIBICONV) libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
+
+if HAVE_X11
+libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/x11wrap.c pulsecore/x11wrap.h
+libpulsecore_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X_CFLAGS)
+libpulsecore_ at PA_MAJORMINORMICRO@_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+endif
 
 ###################################
 #   Plug-in support libraries     #
@@ -751,28 +758,27 @@ endif
 
 libprotocol_simple_la_SOURCES = pulsecore/protocol-simple.c pulsecore/protocol-simple.h
 libprotocol_simple_la_LDFLAGS = -avoid-version
-libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libsocket-server.la libiochannel.la
+libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libcli_la_SOURCES = pulsecore/cli.c pulsecore/cli.h
-libcli_la_CPPFLAGS = $(AM_CPPFLAGS)
 libcli_la_LDFLAGS = -avoid-version
-libcli_la_LIBADD = $(AM_LIBADD) libiochannel.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la
+libcli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libprotocol_cli_la_SOURCES = pulsecore/protocol-cli.c pulsecore/protocol-cli.h
 libprotocol_cli_la_LDFLAGS = -avoid-version
-libprotocol_cli_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la libcli.la libpulsecore- at PA_MAJORMINORMICRO@.la
+libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libprotocol_http_la_SOURCES = pulsecore/protocol-http.c pulsecore/protocol-http.h
 libprotocol_http_la_LDFLAGS = -avoid-version
-libprotocol_http_la_LIBADD = $(AM_LIBADD) libsocket-server.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la libiochannel.la
+libprotocol_http_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libprotocol_native_la_SOURCES = pulsecore/protocol-native.c pulsecore/protocol-native.h pulsecore/native-common.h
 libprotocol_native_la_LDFLAGS = -avoid-version
-libprotocol_native_la_LIBADD = $(AM_LIBADD) libsocket-server.la libpstream.la libpstream-util.la libpdispatch.la libtagstruct.la libauthkey.la libauth-cookie.la libstrlist.la libpulsecore- at PA_MAJORMINORMICRO@.la libiochannel.la libipacl.la
+libprotocol_native_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libprotocol_esound_la_SOURCES = pulsecore/protocol-esound.c pulsecore/protocol-esound.h pulsecore/esound.h
 libprotocol_esound_la_LDFLAGS = -avoid-version
-libprotocol_esound_la_LIBADD = $(AM_LIBADD) libsocket-server.la libiochannel.la libauthkey.la libauth-cookie.la libpulsecore- at PA_MAJORMINORMICRO@.la libipacl.la
+libprotocol_esound_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 librtp_la_SOURCES = \
 		modules/rtp/rtp.c modules/rtp/rtp.h \
@@ -781,14 +787,14 @@ librtp_la_SOURCES = \
 		modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
 		modules/rtp/headerlist.c modules/rtp/headerlist.h
 librtp_la_LDFLAGS = -avoid-version
-librtp_la_LIBADD = $(AM_LIBADD) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la
+librtp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 libraop_la_SOURCES = \
         modules/raop/raop_client.c modules/raop/raop_client.h \
         modules/raop/base64.c modules/raop/base64.h
 libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS)
 libraop_la_LDFLAGS = -avoid-version
-libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libsocket-util.la libiochannel.la libsocket-client.la libioline.la libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
+libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
 
 # Avahi
 libavahi_wrap_la_SOURCES = pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h
@@ -1053,7 +1059,7 @@ module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR
 
 module_cli_la_SOURCES = modules/module-cli.c
 module_cli_la_LDFLAGS = -module -avoid-version
-module_cli_la_LIBADD = $(AM_LIBADD) libcli.la libiochannel.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_cli_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
@@ -1171,17 +1177,17 @@ module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.
 module_x11_bell_la_SOURCES = modules/module-x11-bell.c
 module_x11_bell_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_bell_la_LDFLAGS = -module -avoid-version
-module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_x11_publish_la_SOURCES = modules/module-x11-publish.c
 module_x11_publish_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_publish_la_LDFLAGS = -module -avoid-version
-module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la
 
 module_x11_xsmp_la_SOURCES = modules/module-x11-xsmp.c
 module_x11_xsmp_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_xsmp_la_LDFLAGS = -module -avoid-version
-module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libx11wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
 
 # OSS
 
@@ -1382,7 +1388,7 @@ libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS)
 
 module_bluetooth_device_la_SOURCES = modules/bluetooth/module-bluetooth-device.c modules/bluetooth/rtp.h
 module_bluetooth_device_la_LDFLAGS = -module -avoid-version
-module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libsocket-util.la
+module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la
 module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 # Apple Airtunes/RAOP

commit ef0cc74567b3bb98378c17f6a523bf18ba132ed7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 22 20:36:21 2008 +0200

    a lot more build system updates

diff --git a/libpulse-browse.pc.in b/libpulse-browse.pc.in
index 66438b2..54705b3 100644
--- a/libpulse-browse.pc.in
+++ b/libpulse-browse.pc.in
@@ -1,11 +1,12 @@
 prefix=@prefix@
-exec_prefix=${prefix}
+exec_prefix=@exec_prefix@
 libdir=@libdir@
-includedir=${prefix}/include
+includedir=@includedir@
 
 Name: libpulse-browse
-Description: PulseAudio Network Browsing API
+Description: PulseAudio Network Browsing Interface
 Version: @PACKAGE_VERSION@
 Libs: -L${libdir} -lpulse-browse @PTHREAD_LIBS@
-Cflags: -D_REENTRANT -I${includedir}
+Libs.private: -lpulsecommon- at PA_MAJORMINORMICRO@
+Cflags: -I${includedir} -D_REENTRANT
 Requires: libpulse
diff --git a/libpulse-mainloop-glib.pc.in b/libpulse-mainloop-glib.pc.in
index 1a8bfa4..45ae47c 100644
--- a/libpulse-mainloop-glib.pc.in
+++ b/libpulse-mainloop-glib.pc.in
@@ -1,11 +1,12 @@
 prefix=@prefix@
-exec_prefix=${prefix}
+exec_prefix=@exec_prefix@
 libdir=@libdir@
-includedir=${prefix}/include
+includedir=@includedir@
 
 Name: libpulse-mainloop-glib
-Description: GLIB 2.0 Main Loop Wrapper for PulseAudio
+Description: PulseAudio GLib 2.0 Main Loop Wrapper
 Version: @PACKAGE_VERSION@
 Libs: -L${libdir} -lpulse-mainloop-glib @PTHREAD_LIBS@
-Cflags: -D_REENTRANT -I${includedir}
+Libs.private: -lpulsecommon- at PA_MAJORMINORMICRO@
+Cflags: -I${includedir} -D_REENTRANT
 Requires: libpulse glib-2.0
diff --git a/libpulse-simple.pc.in b/libpulse-simple.pc.in
index 00d1245..443be28 100644
--- a/libpulse-simple.pc.in
+++ b/libpulse-simple.pc.in
@@ -1,11 +1,12 @@
 prefix=@prefix@
-exec_prefix=${prefix}
+exec_prefix=@exec_prefix@
 libdir=@libdir@
-includedir=${prefix}/include
+includedir=@includedir@
 
 Name: libpulse-simple
-Description: Simplified Synchronous Client Interface to PulseAudio
+Description: PulseAudio Simplified Synchronous Client Interface
 Version: @PACKAGE_VERSION@
 Libs: -L${libdir} -lpulse-simple @PTHREAD_LIBS@
-Cflags: -D_REENTRANT -I${includedir}
+Libs.private: -lpulsecommon- at PA_MAJORMINORMICRO@
+Cflags: -I${includedir} -D_REENTRANT
 Requires: libpulse
diff --git a/libpulse.pc.in b/libpulse.pc.in
index 2193b2b..161599e 100644
--- a/libpulse.pc.in
+++ b/libpulse.pc.in
@@ -1,10 +1,11 @@
 prefix=@prefix@
-exec_prefix=${prefix}
+exec_prefix=@exec_prefix@
 libdir=@libdir@
-includedir=${prefix}/include
+includedir=@includedir@
 
 Name: libpulse
-Description: Client Interface to PulseAudio
+Description: PulseAudio Client Interface
 Version: @PACKAGE_VERSION@
 Libs: -L${libdir} -lpulse @PTHREAD_LIBS@
-Cflags: -D_REENTRANT -I${includedir}
+Libs.private: -lpulsecommon- at PA_MAJORMINORMICRO@
+Cflags: -I${includedir} -D_REENTRANT
diff --git a/src/Makefile.am b/src/Makefile.am
index f42584b..e1f2664 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,10 +66,7 @@ AM_CFLAGS = \
 
 AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
 AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)
-
-# Only required on some platforms but defined for all to avoid errors
 AM_LDFLAGS =
-#-Wl,-no-undefined -Wl,--gc-sections
 
 if STATIC_BINS
 BINLDFLAGS = -static
@@ -80,19 +77,6 @@ AM_LDFLAGS+=-Wl,--export-all-symbols
 WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet
 endif
 
-if OS_IS_WIN32
-PA_THREAD_OBJS = \
-		pulsecore/mutex-win32.c pulsecore/mutex.h \
-		pulsecore/thread-win32.c pulsecore/thread.h \
-		pulsecore/semaphore-win32.c pulsecore/semaphore.h
-else
-PA_THREAD_OBJS = \
-		pulsecore/mutex-posix.c pulsecore/mutex.h \
-		pulsecore/thread-posix.c pulsecore/thread.h \
-		pulsecore/semaphore-posix.c pulsecore/semaphore.h
-endif
-
-
 ###################################
 #          Extra files            #
 ###################################
@@ -216,7 +200,7 @@ pacmd_CFLAGS = $(AM_CFLAGS)
 pacmd_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 pacmd_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
-pax11publish_SOURCES = utils/pax11publish.c pulse/client-conf.c pulse/client-conf.h
+pax11publish_SOURCES = utils/pax11publish.c
 pax11publish_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
 pax11publish_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
@@ -364,7 +348,7 @@ strlist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 close_test_SOURCES = tests/close-test.c
 close_test_CFLAGS = $(AM_CFLAGS)
-close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+close_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 close_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 voltest_SOURCES = tests/voltest.c
@@ -379,12 +363,12 @@ channelmap_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 cpulimit_test_SOURCES = tests/cpulimit-test.c daemon/cpulimit.c daemon/cpulimit.h
 cpulimit_test_CFLAGS = $(AM_CFLAGS)
-cpulimit_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+cpulimit_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 cpulimit_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 cpulimit_test2_SOURCES = tests/cpulimit-test.c daemon/cpulimit.c daemon/cpulimit.h
 cpulimit_test2_CFLAGS = $(AM_CFLAGS) -DTEST2
-cpulimit_test2_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+cpulimit_test2_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 cpulimit_test2_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 mainloop_test_glib_SOURCES = $(mainloop_test_SOURCES)
@@ -394,7 +378,7 @@ mainloop_test_glib_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 memblockq_test_SOURCES = tests/memblockq-test.c
 memblockq_test_CFLAGS = $(AM_CFLAGS)
-memblockq_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+memblockq_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 memblockq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 sync_playback_SOURCES = tests/sync-playback.c
@@ -403,62 +387,62 @@ sync_playback_CFLAGS = $(AM_CFLAGS)
 sync_playback_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 interpol_test_SOURCES = tests/interpol-test.c
-interpol_test_LDADD = $(AM_LDADD) libpulse.la libpulsecore- at PA_MAJORMINORMICRO@.la
+interpol_test_LDADD = $(AM_LDADD) libpulse.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 interpol_test_CFLAGS = $(AM_CFLAGS)
 interpol_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 sig2str_test_SOURCES = tests/sig2str-test.c
-sig2str_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+sig2str_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 sig2str_test_CFLAGS = $(AM_CFLAGS)
 sig2str_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 resampler_test_SOURCES = tests/resampler-test.c
-resampler_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+resampler_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 resampler_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 resampler_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 mix_test_SOURCES = tests/mix-test.c
-mix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+mix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 mix_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 mix_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 remix_test_SOURCES = tests/remix-test.c
-remix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+remix_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 remix_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 remix_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 smoother_test_SOURCES = tests/smoother-test.c
-smoother_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+smoother_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 smoother_test_CFLAGS = $(AM_CFLAGS)
 smoother_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 envelope_test_SOURCES = tests/envelope-test.c
-envelope_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+envelope_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 envelope_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 envelope_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 proplist_test_SOURCES = tests/proplist-test.c
-proplist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+proplist_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 proplist_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 proplist_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 rtstutter_SOURCES = tests/rtstutter.c
-rtstutter_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+rtstutter_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 rtstutter_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 rtstutter_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 stripnul_SOURCES = tests/stripnul.c
-stripnul_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+stripnul_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 stripnul_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 stripnul_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 lock_autospawn_test_SOURCES = tests/lock-autospawn-test.c
-lock_autospawn_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+lock_autospawn_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 lock_autospawn_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 lock_autospawn_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
 prioq_test_SOURCES = tests/prioq-test.c
-prioq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+prioq_test_LDADD = $(AM_LDADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 prioq_test_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 prioq_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS) $(LIBOIL_LIBS)
 
@@ -470,6 +454,7 @@ lib_LTLIBRARIES = \
 		libpulsecommon- at PA_MAJORMINORMICRO@.la
 
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
+		pulse/client-conf.c pulse/client-conf.h \
 		pulse/i18n.c pulse/i18n.h \
 		pulsecore/authkey.c pulsecore/authkey.h \
 		pulsecore/conf-parser.c pulsecore/conf-parser.h \
@@ -518,8 +503,7 @@ libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/tagstruct.c pulsecore/tagstruct.h \
 		pulsecore/time-smoother.c pulsecore/time-smoother.h \
 		pulsecore/tokenizer.c pulsecore/tokenizer.h \
-		pulsecore/winsock.h \
-		$(PA_THREAD_OBJS)
+		pulsecore/winsock.h
 
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS = $(AM_CFLAGS)
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
@@ -530,6 +514,18 @@ libpulsecommon_ at PA_MAJORMINORMICRO@_la_LIBADD = $(AM_LIBADD) $(LIBWRAP_LIBS) $(W
 ## since libpulse only includes stable, official APIs, while
 ## libpulsecommon only includes unofficial APIs.
 
+if OS_IS_WIN32
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES += \
+		pulsecore/mutex-win32.c pulsecore/mutex.h \
+		pulsecore/thread-win32.c pulsecore/thread.h \
+		pulsecore/semaphore-win32.c pulsecore/semaphore.h
+else
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES += \
+		pulsecore/mutex-posix.c pulsecore/mutex.h \
+		pulsecore/thread-posix.c pulsecore/thread.h \
+		pulsecore/semaphore-posix.c pulsecore/semaphore.h
+endif
+
 if HAVE_X11
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/x11prop.c pulsecore/x11prop.h
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X_CFLAGS)
@@ -601,7 +597,6 @@ endif
 libpulse_la_SOURCES = \
 		pulse/cdecl.h \
 		pulse/channelmap.c pulse/channelmap.h \
-		pulse/client-conf.c pulse/client-conf.h \
 		pulse/context.c pulse/context.h \
 		pulse/def.h \
 		pulse/error.c pulse/error.h \
@@ -715,8 +710,7 @@ libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/source.c pulsecore/source.h \
 		pulsecore/start-child.c pulsecore/start-child.h \
 		pulsecore/thread-mq.c pulsecore/thread-mq.h \
-		pulsecore/time-smoother.c pulsecore/time-smoother.h \
-		$(PA_THREAD_OBJS)
+		pulsecore/time-smoother.c pulsecore/time-smoother.h
 
 libpulsecore_ at PA_MAJORMINORMICRO@_la_CFLAGS = $(AM_CFLAGS) $(LIBOIL_CFLAGS)
 libpulsecore_ at PA_MAJORMINORMICRO@_la_LDFLAGS = -avoid-version
@@ -758,27 +752,27 @@ endif
 
 libprotocol_simple_la_SOURCES = pulsecore/protocol-simple.c pulsecore/protocol-simple.h
 libprotocol_simple_la_LDFLAGS = -avoid-version
-libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 libcli_la_SOURCES = pulsecore/cli.c pulsecore/cli.h
 libcli_la_LDFLAGS = -avoid-version
-libcli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+libcli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 libprotocol_cli_la_SOURCES = pulsecore/protocol-cli.c pulsecore/protocol-cli.h
 libprotocol_cli_la_LDFLAGS = -avoid-version
-libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 libprotocol_http_la_SOURCES = pulsecore/protocol-http.c pulsecore/protocol-http.h
 libprotocol_http_la_LDFLAGS = -avoid-version
-libprotocol_http_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+libprotocol_http_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 libprotocol_native_la_SOURCES = pulsecore/protocol-native.c pulsecore/protocol-native.h pulsecore/native-common.h
 libprotocol_native_la_LDFLAGS = -avoid-version
-libprotocol_native_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+libprotocol_native_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 libprotocol_esound_la_SOURCES = pulsecore/protocol-esound.c pulsecore/protocol-esound.h pulsecore/esound.h
 libprotocol_esound_la_LDFLAGS = -avoid-version
-libprotocol_esound_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+libprotocol_esound_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 librtp_la_SOURCES = \
 		modules/rtp/rtp.c modules/rtp/rtp.h \
@@ -787,20 +781,20 @@ librtp_la_SOURCES = \
 		modules/rtp/rtsp_client.c modules/rtp/rtsp_client.h \
 		modules/rtp/headerlist.c modules/rtp/headerlist.h
 librtp_la_LDFLAGS = -avoid-version
-librtp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+librtp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 libraop_la_SOURCES = \
         modules/raop/raop_client.c modules/raop/raop_client.h \
         modules/raop/base64.c modules/raop/base64.h
 libraop_la_CFLAGS = $(AM_CFLAGS) $(OPENSSL_CFLAGS)
 libraop_la_LDFLAGS = -avoid-version
-libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
+libraop_la_LIBADD = $(AM_LIBADD) $(OPENSSL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Avahi
 libavahi_wrap_la_SOURCES = pulsecore/avahi-wrap.c pulsecore/avahi-wrap.h
 libavahi_wrap_la_LDFLAGS = -avoid-version
 libavahi_wrap_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
-libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore- at PA_MAJORMINORMICRO@.la
+libavahi_wrap_la_LIBADD = $(AM_LIBADD) $(AVAHI_CFLAGS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 ###################################
 #        Plug-in libraries        #
@@ -1041,328 +1035,328 @@ $(SYMDEF_FILES): modules/module-defs.h.m4
 
 module_flat_volume_la_SOURCES = modules/module-flat-volume.c
 module_flat_volume_la_LDFLAGS = -module -avoid-version
-module_flat_volume_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_flat_volume_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Simple protocol
 
 module_simple_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_simple_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_SIMPLE $(AM_CFLAGS)
 module_simple_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_simple_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la
+module_simple_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_simple_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_simple_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_SIMPLE $(AM_CFLAGS)
 module_simple_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la
+module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # CLI protocol
 
 module_cli_la_SOURCES = modules/module-cli.c
 module_cli_la_LDFLAGS = -module -avoid-version
-module_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libcli.la
 
 module_cli_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
 module_cli_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_cli_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la
+module_cli_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_cli_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
 module_cli_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_cli_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la
+module_cli_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # HTTP protocol
 
 module_http_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_http_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
 module_http_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_http_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la
+module_http_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_http_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_http_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
 module_http_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_http_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la
+module_http_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Native protocol
 
 module_native_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_native_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_NATIVE $(AM_CFLAGS)
 module_native_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_native_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la
+module_native_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_native_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_native_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_NATIVE $(AM_CFLAGS)
 module_native_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_native_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la
+module_native_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_native_protocol_fd_la_SOURCES = modules/module-native-protocol-fd.c
 module_native_protocol_fd_la_CFLAGS = $(AM_CFLAGS)
 module_native_protocol_fd_la_LDFLAGS = -module -avoid-version
-module_native_protocol_fd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la
+module_native_protocol_fd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # EsounD protocol
 
 module_esound_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_esound_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_ESOUND $(AM_CFLAGS)
 module_esound_protocol_tcp_la_LDFLAGS = -module -avoid-version
-module_esound_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la
+module_esound_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_esound_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_ESOUND $(AM_CFLAGS)
 module_esound_protocol_unix_la_LDFLAGS = -module -avoid-version
-module_esound_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la
+module_esound_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_compat_spawnfd_la_SOURCES = modules/module-esound-compat-spawnfd.c
 module_esound_compat_spawnfd_la_LDFLAGS = -module -avoid-version
-module_esound_compat_spawnfd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_esound_compat_spawnfd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_compat_spawnpid_la_SOURCES = modules/module-esound-compat-spawnpid.c
 module_esound_compat_spawnpid_la_LDFLAGS = -module -avoid-version
-module_esound_compat_spawnpid_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_esound_compat_spawnpid_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_sink_la_SOURCES = modules/module-esound-sink.c
 module_esound_sink_la_LDFLAGS = -module -avoid-version
-module_esound_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_esound_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Pipes
 
 module_pipe_sink_la_SOURCES = modules/module-pipe-sink.c
 module_pipe_sink_la_LDFLAGS = -module -avoid-version
-module_pipe_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_pipe_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_pipe_source_la_SOURCES = modules/module-pipe-source.c
 module_pipe_source_la_LDFLAGS = -module -avoid-version
-module_pipe_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_pipe_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Fake sources/sinks
 
 module_sine_la_SOURCES = modules/module-sine.c
 module_sine_la_LDFLAGS = -module -avoid-version
-module_sine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_sine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_null_sink_la_SOURCES = modules/module-null-sink.c
 module_null_sink_la_LDFLAGS = -module -avoid-version
-module_null_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_null_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Couplings
 
 module_combine_la_SOURCES = modules/module-combine.c
 module_combine_la_LDFLAGS = -module -avoid-version
-module_combine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_combine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_remap_sink_la_SOURCES = modules/module-remap-sink.c
 module_remap_sink_la_LDFLAGS = -module -avoid-version
-module_remap_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_remap_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_ladspa_sink_la_SOURCES = modules/module-ladspa-sink.c modules/ladspa.h
 module_ladspa_sink_la_CFLAGS = -DLADSPA_PATH=\"$(libdir)/ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa:/usr/local/lib64/ladspa:/usr/lib64/ladspa\" $(AM_CFLAGS)
 module_ladspa_sink_la_LDFLAGS = -module -avoid-version
-module_ladspa_sink_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_ladspa_sink_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_match_la_SOURCES = modules/module-match.c
 module_match_la_LDFLAGS = -module -avoid-version
-module_match_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_match_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_tunnel_sink_la_SOURCES = modules/module-tunnel.c
 module_tunnel_sink_la_CFLAGS = -DTUNNEL_SINK=1 $(AM_CFLAGS)
 module_tunnel_sink_la_LDFLAGS = -module -avoid-version
-module_tunnel_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_tunnel_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_tunnel_source_la_SOURCES = modules/module-tunnel.c
 module_tunnel_source_la_LDFLAGS = -module -avoid-version
-module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # X11
 
 module_x11_bell_la_SOURCES = modules/module-x11-bell.c
 module_x11_bell_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_bell_la_LDFLAGS = -module -avoid-version
-module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_x11_publish_la_SOURCES = modules/module-x11-publish.c
 module_x11_publish_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_publish_la_LDFLAGS = -module -avoid-version
-module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_x11_xsmp_la_SOURCES = modules/module-x11-xsmp.c
 module_x11_xsmp_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
 module_x11_xsmp_la_LDFLAGS = -module -avoid-version
-module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # OSS
 
 liboss_util_la_SOURCES = modules/oss-util.c modules/oss-util.h
 liboss_util_la_LDFLAGS = -avoid-version
-liboss_util_la_LIBADD = libpulsecore- at PA_MAJORMINORMICRO@.la
+liboss_util_la_LIBADD = libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_oss_la_SOURCES = modules/module-oss.c
 module_oss_la_LDFLAGS = -module -avoid-version
-module_oss_la_LIBADD = $(AM_LIBADD) liboss-util.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_oss_la_LIBADD = $(AM_LIBADD) liboss-util.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # ALSA
 
 libalsa_util_la_SOURCES = modules/alsa-util.c modules/alsa-util.h
 libalsa_util_la_LDFLAGS = -avoid-version
-libalsa_util_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+libalsa_util_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 libalsa_util_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 module_alsa_sink_la_SOURCES = modules/module-alsa-sink.c
 module_alsa_sink_la_LDFLAGS = -module -avoid-version
-module_alsa_sink_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_alsa_sink_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_alsa_sink_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 module_alsa_source_la_SOURCES = modules/module-alsa-source.c
 module_alsa_source_la_LDFLAGS = -module -avoid-version
-module_alsa_source_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_alsa_source_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_alsa_source_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 # Solaris
 
 module_solaris_la_SOURCES = modules/module-solaris.c
 module_solaris_la_LDFLAGS = -module -avoid-version
-module_solaris_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_solaris_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Avahi
 
 module_zeroconf_publish_la_SOURCES = modules/module-zeroconf-publish.c
 module_zeroconf_publish_la_LDFLAGS = -module -avoid-version
-module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 module_zeroconf_discover_la_SOURCES = modules/module-zeroconf-discover.c
 module_zeroconf_discover_la_LDFLAGS = -module -avoid-version
-module_zeroconf_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_zeroconf_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_zeroconf_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 # LIRC
 
 module_lirc_la_SOURCES = modules/module-lirc.c
 module_lirc_la_LDFLAGS = -module -avoid-version
-module_lirc_la_LIBADD = $(AM_LIBADD) $(LIRC_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_lirc_la_LIBADD = $(AM_LIBADD) $(LIRC_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_lirc_la_CFLAGS = $(AM_CFLAGS) $(LIRC_CFLAGS)
 
 # Linux evdev
 
 module_mmkbd_evdev_la_SOURCES = modules/module-mmkbd-evdev.c
 module_mmkbd_evdev_la_LDFLAGS = -module -avoid-version
-module_mmkbd_evdev_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_mmkbd_evdev_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_mmkbd_evdev_la_CFLAGS = $(AM_CFLAGS)
 
 # Windows waveout
 
 #module_waveout_la_SOURCES = modules/module-waveout.c
 #module_waveout_la_LDFLAGS = -module -avoid-version
-#module_waveout_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lwinmm
+#module_waveout_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lwinmm libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 #module_waveout_la_CFLAGS = $(AM_CFLAGS)
 
 # Hardware autodetection module
 module_detect_la_SOURCES = modules/module-detect.c
 module_detect_la_LDFLAGS = -module -avoid-version
-module_detect_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_detect_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_detect_la_CFLAGS = $(AM_CFLAGS)
 
 # Volume restore module
 module_volume_restore_la_SOURCES = modules/module-volume-restore.c
 module_volume_restore_la_LDFLAGS = -module -avoid-version
-module_volume_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_volume_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_volume_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Position event sounds in space
 module_position_event_sounds_la_SOURCES = modules/module-position-event-sounds.c
 module_position_event_sounds_la_LDFLAGS = -module -avoid-version
-module_position_event_sounds_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_position_event_sounds_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_position_event_sounds_CFLAGS = $(AM_CFLAGS)
 
 # Device volume/muted restore module
 module_device_restore_la_SOURCES = modules/module-device-restore.c
 module_device_restore_la_LDFLAGS = -module -avoid-version
-module_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm
+module_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_device_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Stream volume/muted/device restore module
 module_stream_restore_la_SOURCES = modules/module-stream-restore.c
 module_stream_restore_la_LDFLAGS = -module -avoid-version
-module_stream_restore_la_LIBADD = $(AM_LIBADD) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm
+module_stream_restore_la_LIBADD = $(AM_LIBADD) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_stream_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Default sink/source restore module
 module_default_device_restore_la_SOURCES = modules/module-default-device-restore.c
 module_default_device_restore_la_LDFLAGS = -module -avoid-version
-module_default_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_default_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_default_device_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Always Sink module
 module_always_sink_la_SOURCES = modules/module-always-sink.c
 module_always_sink_la_LDFLAGS = -module -avoid-version
-module_always_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_always_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_always_sink_la_CFLAGS = $(AM_CFLAGS)
 
 # Rescue streams module
 module_rescue_streams_la_SOURCES = modules/module-rescue-streams.c
 module_rescue_streams_la_LDFLAGS = -module -avoid-version
-module_rescue_streams_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_rescue_streams_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_rescue_streams_la_CFLAGS = $(AM_CFLAGS)
 
 # Suspend-on-idle module
 module_suspend_on_idle_la_SOURCES = modules/module-suspend-on-idle.c
 module_suspend_on_idle_la_LDFLAGS = -module -avoid-version
-module_suspend_on_idle_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_suspend_on_idle_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_suspend_on_idle_la_CFLAGS = $(AM_CFLAGS)
 
 # RTP modules
 module_rtp_send_la_SOURCES = modules/rtp/module-rtp-send.c
 module_rtp_send_la_LDFLAGS = -module -avoid-version
-module_rtp_send_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
+module_rtp_send_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_rtp_send_la_CFLAGS = $(AM_CFLAGS)
 
 module_rtp_recv_la_SOURCES = modules/rtp/module-rtp-recv.c
 module_rtp_recv_la_LDFLAGS = -module -avoid-version
-module_rtp_recv_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la
+module_rtp_recv_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_rtp_recv_la_CFLAGS = $(AM_CFLAGS)
 
 # JACK
 
 module_jack_sink_la_SOURCES = modules/module-jack-sink.c
 module_jack_sink_la_LDFLAGS = -module -avoid-version
-module_jack_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS)
+module_jack_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS) libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_jack_sink_la_CFLAGS = $(AM_CFLAGS) $(JACK_CFLAGS)
 
 module_jack_source_la_SOURCES = modules/module-jack-source.c
 module_jack_source_la_LDFLAGS = -module -avoid-version
-module_jack_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS)
+module_jack_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS) libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_jack_source_la_CFLAGS = $(AM_CFLAGS) $(JACK_CFLAGS)
 
 # HAL/D-Bus
 libdbus_util_la_SOURCES = modules/dbus-util.c modules/dbus-util.h
 libdbus_util_la_LDFLAGS = -avoid-version
-libdbus_util_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+libdbus_util_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 libdbus_util_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 module_hal_detect_la_SOURCES = modules/module-hal-detect.c
 module_hal_detect_la_LDFLAGS = -module -avoid-version
-module_hal_detect_la_LIBADD = $(AM_LIBADD) $(HAL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
+module_hal_detect_la_LIBADD = $(AM_LIBADD) $(HAL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_hal_detect_la_CFLAGS = $(AM_CFLAGS) $(HAL_CFLAGS)
 
 module_console_kit_la_SOURCES = modules/module-console-kit.c
 module_console_kit_la_LDFLAGS = -module -avoid-version
-module_console_kit_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
+module_console_kit_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_console_kit_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 # GConf support
 module_gconf_la_SOURCES = modules/gconf/module-gconf.c
 module_gconf_la_LDFLAGS = -module -avoid-version
-module_gconf_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la
+module_gconf_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_gconf_la_CFLAGS = $(AM_CFLAGS) -DPA_GCONF_HELPER=\"$(pulselibexecdir)/gconf-helper\"
 
 gconf_helper_SOURCES = modules/gconf/gconf-helper.c
-gconf_helper_LDADD = $(AM_LDADD) $(GCONF_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la
+gconf_helper_LDADD = $(AM_LDADD) $(GCONF_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 gconf_helper_CFLAGS = $(AM_CFLAGS) $(GCONF_CFLAGS)
 gconf_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 # Bluetooth proximity
 module_bluetooth_proximity_la_SOURCES = modules/bluetooth/module-bluetooth-proximity.c
 module_bluetooth_proximity_la_LDFLAGS = -module -avoid-version
-module_bluetooth_proximity_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
+module_bluetooth_proximity_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_bluetooth_proximity_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -DPA_BT_PROXIMITY_HELPER=\"$(pulselibexecdir)/proximity-helper\"
 
 proximity_helper_SOURCES = modules/bluetooth/proximity-helper.c
@@ -1373,32 +1367,32 @@ proximity_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 # Bluetooth sink / source
 module_bluetooth_discover_la_SOURCES = modules/bluetooth/module-bluetooth-discover.c
 module_bluetooth_discover_la_LDFLAGS = -module -avoid-version
-module_bluetooth_discover_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la
+module_bluetooth_discover_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_bluetooth_discover_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 libbluetooth_sbc_la_SOURCES = modules/bluetooth/sbc.c modules/bluetooth/sbc.h modules/bluetooth/sbc_tables.h modules/bluetooth/sbc_math.h
 libbluetooth_sbc_la_LDFLAGS = -avoid-version
-libbluetooth_sbc_la_LIBADD = $(AM_LIBADD)
+libbluetooth_sbc_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 libbluetooth_sbc_la_CFLAGS = $(AM_CFLAGS)
 
 libbluetooth_ipc_la_SOURCES = modules/bluetooth/ipc.c modules/bluetooth/ipc.h
 libbluetooth_ipc_la_LDFLAGS = -avoid-version
-libbluetooth_ipc_la_LIBADD = $(AM_LIBADD)
+libbluetooth_ipc_la_LIBADD = $(AM_LIBADD)libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS)
 
 module_bluetooth_device_la_SOURCES = modules/bluetooth/module-bluetooth-device.c modules/bluetooth/rtp.h
 module_bluetooth_device_la_LDFLAGS = -module -avoid-version
-module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la
+module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 # Apple Airtunes/RAOP
 module_raop_sink_la_SOURCES = modules/module-raop-sink.c
 module_raop_sink_la_LDFLAGS = -module -avoid-version
-module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libraop.la
+module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libraop.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_raop_discover_la_SOURCES = modules/module-raop-discover.c
 module_raop_discover_la_LDFLAGS = -module -avoid-version
-module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la
+module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_raop_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 

commit 1cd25f1485474282b989c271d51a4e957fc2ec22
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Oct 21 22:05:13 2008 +0200

    reorder setting of AM_CFLAGS a bit

diff --git a/src/Makefile.am b/src/Makefile.am
index 4d1812e..b911c43 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -45,26 +45,27 @@ endif
 #     Compiler/linker flags       #
 ###################################
 
-AM_CFLAGS = -I$(top_srcdir)/src -I$(top_builddir)/src/modules -I$(top_builddir)/src/modules/rtp -I$(top_builddir)/src/modules/gconf -I$(top_builddir)/src/modules/bluetooth
-AM_CFLAGS += $(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS
-AM_CFLAGS += $(LTDLINCL)
-AM_CFLAGS += $(LIBSAMPLERATE_CFLAGS) $(LIBSNDFILE_CFLAGS) $(LIBSPEEX_CFLAGS)
-AM_CFLAGS += -DPA_DLSEARCHPATH=\"$(modlibexecdir)\"
-AM_CFLAGS += -DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\"
-AM_CFLAGS += -DPA_BINARY=\"$(PA_BINARY)\"
-AM_CFLAGS += -DPA_SYSTEM_RUNTIME_PATH=\"$(PA_SYSTEM_RUNTIME_PATH)\"
-AM_CFLAGS += -DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\"
-AM_CFLAGS += -DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\"
-AM_CFLAGS += -DAO_REQUIRE_CAS
-AM_CFLAGS += -DPULSE_LOCALEDIR=\"$(pulselocaledir)\"
-AM_CFLAGS += -DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\"
-
-# This cool debug trap works on i386/gcc only
-AM_CFLAGS += '-DDEBUG_TRAP=__asm__("int $$3")'
-
-if HAVE_OPENSSL
-AM_CFLAGS += -I$(top_builddir)/src/modules/raop
-endif
+AM_CFLAGS = \
+	-I$(top_srcdir)/src \
+	-I$(top_builddir)/src/modules \
+	-I$(top_builddir)/src/modules/rtp \
+	-I$(top_builddir)/src/modules/gconf \
+	-I$(top_builddir)/src/modules/bluetooth \
+	-I$(top_builddir)/src/modules/raop \
+	$(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS \
+	$(LTDLINCL) \
+	$(LIBSAMPLERATE_CFLAGS) \
+	$(LIBSNDFILE_CFLAGS) \
+	$(LIBSPEEX_CFLAGS) \
+	-DPA_DLSEARCHPATH=\"$(modlibexecdir)\" \
+	-DPA_DEFAULT_CONFIG_DIR=\"$(PA_DEFAULT_CONFIG_DIR)\" \
+	-DPA_BINARY=\"$(PA_BINARY)\" \
+	-DPA_SYSTEM_RUNTIME_PATH=\"$(PA_SYSTEM_RUNTIME_PATH)\" \
+	-DPA_SYSTEM_CONFIG_PATH=\"$(PA_SYSTEM_CONFIG_PATH)\" \
+	-DPA_SYSTEM_STATE_PATH=\"$(PA_SYSTEM_STATE_PATH)\" \
+	-DAO_REQUIRE_CAS \
+	-DPULSE_LOCALEDIR=\"$(pulselocaledir)\" \
+	-DPA_MACHINE_ID=\"$(localstatedir)/lib/dbus/machine-id\"
 
 AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
 AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)

commit a2b3d252af673b7261198bb753375d40f9b5c0ee
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 22 02:22:19 2008 +0200

    update map file

diff --git a/src/map-file b/src/map-file
index 7211914..ca523b9 100644
--- a/src/map-file
+++ b/src/map-file
@@ -105,7 +105,6 @@ pa_cvolume_max;
 pa_cvolume_remap;
 pa_cvolume_set;
 pa_cvolume_snprint;
-pa_sw_cvolume_snprint_dB;
 pa_cvolume_valid;
 pa_ext_stream_restore_delete;
 pa_ext_stream_restore_read;
@@ -228,7 +227,10 @@ pa_stream_update_timing_info;
 pa_stream_writable_size;
 pa_stream_write;
 pa_strerror;
+pa_sw_cvolume_divide;
 pa_sw_cvolume_multiply;
+pa_sw_cvolume_snprint_dB;
+pa_sw_volume_divide;
 pa_sw_volume_from_dB;
 pa_sw_volume_from_linear;
 pa_sw_volume_multiply;

commit 6ff9c1fb62f642f79079510b5d85e67d9014c41f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 22 22:48:53 2008 +0200

    don't set the volume of pacat unless it is explicitly set

diff --git a/src/utils/pacat.c b/src/utils/pacat.c
index 99df5b9..ea736e2 100644
--- a/src/utils/pacat.c
+++ b/src/utils/pacat.c
@@ -57,6 +57,7 @@ static char *stream_name = NULL, *client_name = NULL, *device = NULL;
 
 static int verbose = 0;
 static pa_volume_t volume = PA_VOLUME_NORM;
+static int volume_is_set = 0;
 
 static pa_sample_spec sample_spec = {
     .format = PA_SAMPLE_S16LE,
@@ -283,7 +284,7 @@ static void context_state_callback(pa_context *c, void *userdata) {
 
             if (mode == PLAYBACK) {
                 pa_cvolume cv;
-                if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, pa_cvolume_set(&cv, sample_spec.channels, volume), NULL)) < 0) {
+                if ((r = pa_stream_connect_playback(stream, device, latency > 0 ? &buffer_attr : NULL, flags, volume_is_set ? pa_cvolume_set(&cv, sample_spec.channels, volume) : NULL, NULL)) < 0) {
                     fprintf(stderr, _("pa_stream_connect_playback() failed: %s\n"), pa_strerror(pa_context_errno(c)));
                     goto fail;
                 }
@@ -627,6 +628,7 @@ int main(int argc, char *argv[]) {
             case ARG_VOLUME: {
                 int v = atoi(optarg);
                 volume = v < 0 ? 0U : (pa_volume_t) v;
+                volume_is_set = 1;
                 break;
             }
 

commit 3294c89adba34d186591d98faa3a1f929b363e59
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Oct 22 23:55:52 2008 +0200

    warn if ALSA wakes us up and there is actually nothing to do

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 39cea49..20dc400 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -1051,6 +1051,12 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
         pa_log_warn("Got POLLNVAL from ALSA");
     if (revents & POLLHUP)
         pa_log_warn("Got POLLHUP from ALSA");
+    if (revents & POLLPRI)
+        pa_log_warn("Got POLLPRI from ALSA");
+    if (revents & POLLIN)
+        pa_log_warn("Got POLLIN from ALSA");
+    if (revents & POLLOUT)
+        pa_log_warn("Got POLLOUT from ALSA");
 
     state = snd_pcm_state(pcm);
     pa_log_warn("PCM state is %s", snd_pcm_state_name(state));
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index af83103..6dea172 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -241,7 +241,7 @@ static size_t check_left_to_play(struct userdata *u, snd_pcm_sframes_t n) {
     return left_to_play;
 }
 
-static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
+static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_play;
@@ -279,14 +279,23 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
             * need to guarantee that clients only have to keep around
             * a single hw buffer length. */
 
-            if (pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames))
+        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to write new data to the device, but there was actually nothing to write! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
             break;
+        }
 
         n -= u->hwbuf_unused_frames;
 
+        polled = FALSE;
+
 /*         pa_log_debug("Filling up"); */
 
         for (;;) {
@@ -357,7 +366,7 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec) {
     return work_done;
 }
 
-static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
+static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_play;
@@ -392,14 +401,23 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec) {
             * need to guarantee that clients only have to keep around
             * a single hw buffer length. */
 
-            if (pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames))
+        if (PA_UNLIKELY(n <= u->hwbuf_unused_frames)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to write new data to the device, but there was actually nothing to write! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
             break;
+        }
 
         n -= u->hwbuf_unused_frames;
 
+        polled = FALSE;
+
         for (;;) {
             snd_pcm_sframes_t frames;
             void *p;
@@ -1084,6 +1102,7 @@ finish:
 
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
+    unsigned short revents = 0;
 
     pa_assert(u);
 
@@ -1110,9 +1129,9 @@ static void thread_func(void *userdata) {
                         goto fail;
 
             if (u->use_mmap)
-                work_done = mmap_write(u, &sleep_usec);
+                work_done = mmap_write(u, &sleep_usec, revents & POLLOUT);
             else
-                work_done = unix_write(u, &sleep_usec);
+                work_done = unix_write(u, &sleep_usec, revents & POLLOUT);
 
             if (work_done < 0)
                 goto fail;
@@ -1180,7 +1199,6 @@ static void thread_func(void *userdata) {
         /* Tell ALSA about this and process its response */
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
             struct pollfd *pollfd;
-            unsigned short revents = 0;
             int err;
             unsigned n;
 
@@ -1191,7 +1209,7 @@ static void thread_func(void *userdata) {
                 goto fail;
             }
 
-            if (revents & (POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
+            if (revents & (POLLIN|POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
                 if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
                     goto fail;
 
@@ -1201,7 +1219,8 @@ static void thread_func(void *userdata) {
 
             if (revents && u->use_tsched)
                 pa_log_debug("Wakeup from ALSA!%s%s", (revents & POLLIN) ? " INPUT" : "", (revents & POLLOUT) ? " OUTPUT" : "");
-        }
+        } else
+            revents = 0;
     }
 
 fail:
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index dd6ca97..f796ef1 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -238,7 +238,7 @@ static size_t check_left_to_record(struct userdata *u, snd_pcm_sframes_t n) {
     return left_to_record;
 }
 
-static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
+static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_record;
@@ -266,11 +266,20 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
         left_to_record = check_left_to_record(u, n);
 
         if (u->use_tsched)
-            if (pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= 0))
+        if (PA_UNLIKELY(n <= 0)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to read new data from the device, but there was actually nothing to read! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio device.");
+
             break;
+        }
+
+        polled = FALSE;
 
         for (;;) {
             int err;
@@ -336,7 +345,7 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec) {
     return work_done;
 }
 
-static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
+static int unix_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled) {
     int work_done = 0;
     pa_usec_t max_sleep_usec = 0, process_usec = 0;
     size_t left_to_record;
@@ -364,11 +373,20 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec) {
         left_to_record = check_left_to_record(u, n);
 
         if (u->use_tsched)
-            if (pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
+            if (!polled &&
+                pa_bytes_to_usec(left_to_record, &u->source->sample_spec) > process_usec+max_sleep_usec/2)
                 break;
 
-        if (PA_UNLIKELY(n <= 0))
+        if (PA_UNLIKELY(n <= 0)) {
+
+            if (polled)
+                pa_log("ALSA woke us up to read new data from the device, but there was actually nothing to read! "
+                       "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.");
+
             return work_done;
+        }
+
+        polled = FALSE;
 
         for (;;) {
             void *p;
@@ -950,6 +968,7 @@ static void source_update_requested_latency_cb(pa_source *s) {
 
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
+    unsigned short revents = 0;
 
     pa_assert(u);
 
@@ -972,9 +991,9 @@ static void thread_func(void *userdata) {
             pa_usec_t sleep_usec = 0;
 
             if (u->use_mmap)
-                work_done = mmap_read(u, &sleep_usec);
+                work_done = mmap_read(u, &sleep_usec, revents & POLLIN);
             else
-                work_done = unix_read(u, &sleep_usec);
+                work_done = unix_read(u, &sleep_usec, revents & POLLIN);
 
             if (work_done < 0)
                 goto fail;
@@ -1016,7 +1035,6 @@ static void thread_func(void *userdata) {
         /* Tell ALSA about this and process its response */
         if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
             struct pollfd *pollfd;
-            unsigned short revents = 0;
             int err;
             unsigned n;
 
@@ -1027,7 +1045,7 @@ static void thread_func(void *userdata) {
                 goto fail;
             }
 
-            if (revents & (POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
+            if (revents & (POLLOUT|POLLERR|POLLNVAL|POLLHUP|POLLPRI)) {
                 if (pa_alsa_recover_from_poll(u->pcm_handle, revents) < 0)
                     goto fail;
 
@@ -1036,7 +1054,8 @@ static void thread_func(void *userdata) {
 
             if (revents && u->use_tsched)
                 pa_log_debug("Wakeup from ALSA!%s%s", (revents & POLLIN) ? " INPUT" : "", (revents & POLLOUT) ? " OUTPUT" : "");
-        }
+        } else
+            revents = 0;
     }
 
 fail:

commit b712e7b13dd6aed3e56eaee423ff071d6f0ce2c2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri Oct 24 04:34:10 2008 +0200

    make sure to use 64bit rounding even on 32bit machines when converting to pa_usec_t

diff --git a/src/pulsecore/time-smoother.c b/src/pulsecore/time-smoother.c
index 6a2ffaa..6562194 100644
--- a/src/pulsecore/time-smoother.c
+++ b/src/pulsecore/time-smoother.c
@@ -313,7 +313,7 @@ static void estimate(pa_smoother *s, pa_usec_t x, pa_usec_t *y, double *deriv) {
         /* Move back from origin */
         ty += (double) s->ey;
 
-        *y = ty >= 0 ? (pa_usec_t) lrint(ty) : 0;
+        *y = ty >= 0 ? (pa_usec_t) llrint(ty) : 0;
 
         /* Horner scheme */
         if (deriv)
@@ -360,7 +360,7 @@ void pa_smoother_put(pa_smoother *s, pa_usec_t x, pa_usec_t y) {
 
     /* And calculate when we want to be on track again */
     s->px = s->ex + s->adjust_time;
-    s->py = s->ry + (pa_usec_t) lrint(s->dp * (double) s->adjust_time);
+    s->py = s->ry + (pa_usec_t) llrint(s->dp * (double) s->adjust_time);
 
     s->abc_valid = FALSE;
 
@@ -456,7 +456,7 @@ pa_usec_t pa_smoother_translate(pa_smoother *s, pa_usec_t x, pa_usec_t y_delay)
 
 /*     pa_log_debug("translate(%llu) = %llu (%0.2f)", (unsigned long long) y_delay, (unsigned long long) ((double) y_delay / nde), nde); */
 
-    return (pa_usec_t) lrint((double) y_delay / nde);
+    return (pa_usec_t) llrint((double) y_delay / nde);
 }
 
 void pa_smoother_reset(pa_smoother *s) {

commit 1d978cea857a49710b28f6b906ee714ed6c5a492
Merge: b712e7b... ef0cc74...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Oct 25 01:23:02 2008 +0200

    Merge branch 'new-world-order'
    
    Conflicts:
    	src/Makefile.am


commit c180cb5c48737b60b14fee22f20edc906ae8fec6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Oct 25 17:45:21 2008 +0200

    bump micro version

diff --git a/configure.ac b/configure.ac
index bd29f15..955ee3b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ AC_PREREQ(2.62)
 
 m4_define(PA_MAJOR, [0])
 m4_define(PA_MINOR, [9])
-m4_define(PA_MICRO, [13])
+m4_define(PA_MICRO, [14])
 
 AC_INIT([pulseaudio],[PA_MAJOR.PA_MINOR.PA_MICRO],[mzchyfrnhqvb (at) 0pointer (dot) net])
 AC_CONFIG_SRCDIR([src/daemon/main.c])

commit adc2973c8dfab862d4333e0c1206995cd2df20c6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Oct 26 19:32:04 2008 +0100

    Implement new flags DONT_INHIBIT_AUTO_SUSPEND and START_UNMUTED

diff --git a/PROTOCOL b/PROTOCOL
index 1e2a832..80a0c33 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -153,3 +153,14 @@ New field for PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR,
 PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR at the end:
 
   early_requests (bool)
+
+
+### v15, implemented by >= 0.9.14
+
+PA_COMMAND_CREATE_PLAYBACK_STREAM
+
+  bool muted at the end
+
+PA_COMMAND_CREATE_PLAYBACK_STREAM, PA_COMMAND_CREATE_RECORD_STREAM:
+
+  bool dont_inhibit_auto_suspend ate the end
diff --git a/configure.ac b/configure.ac
index 955ee3b..c5930c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,7 @@ AC_SUBST(PA_MAJORMINORMICRO, PA_MAJOR.PA_MINOR.PA_MICRO)
 AC_SUBST(PACKAGE_URL, [http://pulseaudio.org/])
 
 AC_SUBST(PA_API_VERSION, 12)
-AC_SUBST(PA_PROTOCOL_VERSION, 14)
+AC_SUBST(PA_PROTOCOL_VERSION, 15)
 
 # The stable ABI for client applications, for the version info x:y:z
 # always will hold y=z
diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c
index 6cc28ec..8ab84e0 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -83,12 +83,12 @@ static void timeout_cb(pa_mainloop_api*a, pa_time_event* e, const struct timeval
 
     d->userdata->core->mainloop->time_restart(d->time_event, NULL);
 
-    if (d->sink && pa_sink_used_by(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
+    if (d->sink && pa_sink_check_suspend(d->sink) <= 0 && pa_sink_get_state(d->sink) != PA_SINK_SUSPENDED) {
         pa_log_info("Sink %s idle for too long, suspending ...", d->sink->name);
         pa_sink_suspend(d->sink, TRUE);
     }
 
-    if (d->source && pa_source_used_by(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
+    if (d->source && pa_source_check_suspend(d->source) <= 0 && pa_source_get_state(d->source) != PA_SOURCE_SUSPENDED) {
         pa_log_info("Source %s idle for too long, suspending ...", d->source->name);
         pa_source_suspend(d->source, TRUE);
     }
@@ -158,7 +158,7 @@ static pa_hook_result_t sink_input_unlink_hook_cb(pa_core *c, pa_sink_input *s,
     pa_sink_input_assert_ref(s);
     pa_assert(u);
 
-    if (pa_sink_used_by(s->sink) <= 0) {
+    if (pa_sink_check_suspend(s->sink) <= 0) {
         struct device_info *d;
         if ((d = pa_hashmap_get(u->device_infos, s->sink)))
             restart(d);
@@ -172,7 +172,7 @@ static pa_hook_result_t source_output_unlink_hook_cb(pa_core *c, pa_source_outpu
     pa_source_output_assert_ref(s);
     pa_assert(u);
 
-    if (pa_source_used_by(s->source) <= 0) {
+    if (pa_source_check_suspend(s->source) <= 0) {
         struct device_info *d;
         if ((d = pa_hashmap_get(u->device_infos, s->source)))
             restart(d);
@@ -191,7 +191,7 @@ static pa_hook_result_t sink_input_move_hook_cb(pa_core *c, pa_sink_input_move_h
     if ((d = pa_hashmap_get(u->device_infos, data->destination)))
         resume(d);
 
-    if (pa_sink_used_by(data->sink_input->sink) <= 1)
+    if (pa_sink_check_suspend(data->sink_input->sink) <= 1)
         if ((d = pa_hashmap_get(u->device_infos, data->sink_input->sink)))
             restart(d);
 
@@ -208,7 +208,7 @@ static pa_hook_result_t source_output_move_hook_cb(pa_core *c, pa_source_output_
     if ((d = pa_hashmap_get(u->device_infos, data->destination)))
         resume(d);
 
-    if (pa_source_used_by(data->source_output->source) <= 1)
+    if (pa_source_check_suspend(data->source_output->source) <= 1)
         if ((d = pa_hashmap_get(u->device_infos, data->source_output->source)))
             restart(d);
 
@@ -266,8 +266,8 @@ static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct user
     d->time_event = c->mainloop->time_new(c->mainloop, NULL, timeout_cb, d);
     pa_hashmap_put(u->device_infos, o, d);
 
-    if ((d->sink && pa_sink_used_by(d->sink) <= 0) ||
-        (d->source && pa_source_used_by(d->source) <= 0))
+    if ((d->sink && pa_sink_check_suspend(d->sink) <= 0) ||
+        (d->source && pa_source_check_suspend(d->source) <= 0))
         restart(d);
 
     return PA_HOOK_OK;
@@ -313,7 +313,7 @@ static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, s
         pa_sink *s = PA_SINK(o);
         pa_sink_state_t state = pa_sink_get_state(s);
 
-        if (pa_sink_used_by(s) <= 0) {
+        if (pa_sink_check_suspend(s) <= 0) {
 
             if (PA_SINK_IS_OPENED(state))
                 restart(d);
@@ -324,7 +324,7 @@ static pa_hook_result_t device_state_changed_hook_cb(pa_core *c, pa_object *o, s
         pa_source *s = PA_SOURCE(o);
         pa_source_state_t state = pa_source_get_state(s);
 
-        if (pa_source_used_by(s) <= 0) {
+        if (pa_source_check_suspend(s) <= 0) {
 
             if (PA_SOURCE_IS_OPENED(state))
                 restart(d);
diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c
index 280067a..8d1e92f 100644
--- a/src/modules/rtp/module-rtp-send.c
+++ b/src/modules/rtp/module-rtp-send.c
@@ -316,7 +316,7 @@ int pa__init(pa_module*m) {
     pa_source_output_new_data_set_sample_spec(&data, &ss);
     pa_source_output_new_data_set_channel_map(&data, &cm);
 
-    o = pa_source_output_new(m->core, &data, 0);
+    o = pa_source_output_new(m->core, &data, PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND);
     pa_source_output_new_data_done(&data);
 
     if (!o) {
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 66d9aff..ace5657 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -194,7 +194,10 @@ typedef enum pa_stream_flags {
     /**< Find peaks instead of resampling. \since 0.9.11 */
 
     PA_STREAM_START_MUTED = 0x1000U,
-    /**< Create in muted state. \since 0.9.11 */
+    /**< Create in muted state. If neither PA_STREAM_START_UNMUTED nor
+     * PA_STREAM_START_MUTED it is left to the server to decide
+     * whether to create the stream in muted or in unmuted
+     * state. \since 0.9.11 */
 
     PA_STREAM_ADJUST_LATENCY = 0x2000U,
     /**< Try to adjust the latency of the sink/source based on the
@@ -203,7 +206,7 @@ typedef enum pa_stream_flags {
      * specified at the same time as PA_STREAM_EARLY_REQUESTS. \since
      * 0.9.11 */
 
-    PA_STREAM_EARLY_REQUESTS = 0x4000U
+    PA_STREAM_EARLY_REQUESTS = 0x4000U,
     /**< Enable compatibility mode for legacy clients that rely on a
      * "classic" hardware device fragment-style playback model. If
      * this option is set, the minreq value of the buffer metrics gets
@@ -220,6 +223,17 @@ typedef enum pa_stream_flags {
      * not be specified at the same time as
      * PA_STREAM_ADJUST_LATENCY. \since 0.9.12 */
 
+    PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND = 0x8000U,
+    /**< If set this stream won't be taken into account when we it is
+     * checked whether the device this stream is connected to should
+     * auto-suspend. \ since 0.9.14 */
+
+    PA_STREAM_START_UNMUTED = 0x10000U
+    /**< Create in unmuted state. If neither PA_STREAM_START_UNMUTED
+     * nor PA_STREAM_START_MUTED it is left to the server to decide
+     * whether to create the stream in muted or in unmuted
+     * state. \since 0.9.14 */
+
 } pa_stream_flags_t;
 
 /** \cond fulldocs */
@@ -243,6 +257,8 @@ typedef enum pa_stream_flags {
 #define PA_STREAM_START_MUTED PA_STREAM_START_MUTED
 #define PA_STREAM_ADJUST_LATENCY PA_STREAM_ADJUST_LATENCY
 #define PA_STREAM_EARLY_REQUESTS PA_STREAM_EARLY_REQUESTS
+#define PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND
+#define PA_STREAM_START_UNMUTED PA_STREAM_START_UNMUTED
 
 /** \endcond */
 
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 00aa1cf..c0ae4ac 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -887,7 +887,9 @@ static int create_stream(
                                               PA_STREAM_PEAK_DETECT|
                                               PA_STREAM_START_MUTED|
                                               PA_STREAM_ADJUST_LATENCY|
-                                              PA_STREAM_EARLY_REQUESTS)), PA_ERR_INVALID);
+                                              PA_STREAM_EARLY_REQUESTS|
+                                              PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND|
+                                              PA_STREAM_START_UNMUTED)), PA_ERR_INVALID);
 
     PA_CHECK_VALIDITY(s->context, s->context->version >= 12 || !(flags & PA_STREAM_VARIABLE_RATE), PA_ERR_NOTSUPPORTED);
     PA_CHECK_VALIDITY(s->context, s->context->version >= 13 || !(flags & PA_STREAM_PEAK_DETECT), PA_ERR_NOTSUPPORTED);
@@ -1007,6 +1009,14 @@ static int create_stream(
         pa_tagstruct_put_boolean(t, flags & PA_STREAM_EARLY_REQUESTS);
     }
 
+    if (s->context->version >= 15) {
+
+        if (s->direction == PA_STREAM_PLAYBACK)
+            pa_tagstruct_put_boolean(t, flags & (PA_STREAM_START_MUTED|PA_STREAM_START_UNMUTED));
+
+        pa_tagstruct_put_boolean(t, flags & PA_STREAM_DONT_INHIBIT_AUTO_SUSPEND);
+    }
+
     pa_pstream_send_tagstruct(s->context->pstream, t);
     pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, pa_create_stream_callback, s, NULL);
 
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 46dcb14..56e86cb 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -959,6 +959,7 @@ static playback_stream* playback_stream_new(
         uint32_t *minreq,
         pa_cvolume *volume,
         pa_bool_t muted,
+        pa_bool_t muted_set,
         uint32_t syncid,
         uint32_t *missing,
         pa_sink_input_flags_t flags,
@@ -1013,7 +1014,8 @@ static playback_stream* playback_stream_new(
     pa_sink_input_new_data_set_channel_map(&data, map);
     if (volume)
         pa_sink_input_new_data_set_volume(&data, volume);
-    pa_sink_input_new_data_set_muted(&data, muted);
+    if (muted_set)
+        pa_sink_input_new_data_set_muted(&data, muted);
     data.sync_base = ssync ? ssync->sink_input : NULL;
 
     sink_input = pa_sink_input_new(c->protocol->core, &data, flags);
@@ -1688,7 +1690,9 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         variable_rate = FALSE,
         muted = FALSE,
         adjust_latency = FALSE,
-        early_requests = FALSE;
+        early_requests = FALSE,
+        dont_inhibit_auto_suspend = FALSE,
+        muted_set = FALSE;
 
     pa_sink_input_flags_t flags = 0;
     pa_proplist *p;
@@ -1769,6 +1773,16 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         }
     }
 
+    if (c->version >= 15) {
+
+        if (pa_tagstruct_get_boolean(t, &muted_set) < 0 ||
+            pa_tagstruct_get_boolean(t, &dont_inhibit_auto_suspend) < 0) {
+            protocol_error(c);
+            pa_proplist_free(p);
+            return;
+        }
+    }
+
     if (!pa_tagstruct_eof(t)) {
         protocol_error(c);
         pa_proplist_free(p);
@@ -1800,9 +1814,14 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         (fix_rate ?  PA_SINK_INPUT_FIX_RATE : 0) |
         (fix_channels ?  PA_SINK_INPUT_FIX_CHANNELS : 0) |
         (no_move ?  PA_SINK_INPUT_DONT_MOVE : 0) |
-        (variable_rate ?  PA_SINK_INPUT_VARIABLE_RATE : 0);
+        (variable_rate ?  PA_SINK_INPUT_VARIABLE_RATE : 0) |
+        (dont_inhibit_auto_suspend ? PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND : 0);
+
+    /* Only since protocol version 15 there's a seperate muted_set
+     * flag. For older versions we synthesize it here */
+    muted_set = muted_set || muted;
 
-    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, syncid, &missing, flags, p, adjust_latency, early_requests);
+    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, muted_set, syncid, &missing, flags, p, adjust_latency, early_requests);
     pa_proplist_free(p);
 
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
@@ -1923,7 +1942,8 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         variable_rate = FALSE,
         adjust_latency = FALSE,
         peak_detect = FALSE,
-        early_requests = FALSE;
+        early_requests = FALSE,
+        dont_inhibit_auto_suspend = FALSE;
     pa_source_output_flags_t flags = 0;
     pa_proplist *p;
     uint32_t direct_on_input_idx = PA_INVALID_INDEX;
@@ -1995,6 +2015,15 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         }
     }
 
+    if (c->version >= 15) {
+
+        if (pa_tagstruct_get_boolean(t, &dont_inhibit_auto_suspend) < 0) {
+            protocol_error(c);
+            pa_proplist_free(p);
+            return;
+        }
+    }
+
     if (!pa_tagstruct_eof(t)) {
         protocol_error(c);
         pa_proplist_free(p);
@@ -2035,7 +2064,8 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         (fix_rate ?  PA_SOURCE_OUTPUT_FIX_RATE : 0) |
         (fix_channels ?  PA_SOURCE_OUTPUT_FIX_CHANNELS : 0) |
         (no_move ?  PA_SOURCE_OUTPUT_DONT_MOVE : 0) |
-        (variable_rate ?  PA_SOURCE_OUTPUT_VARIABLE_RATE : 0);
+        (variable_rate ?  PA_SOURCE_OUTPUT_VARIABLE_RATE : 0) |
+        (dont_inhibit_auto_suspend ? PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND : 0);
 
     s = record_stream_new(c, source, &ss, &map, peak_detect, &maxlength, &fragment_size, flags, p, adjust_latency, direct_on_input, early_requests);
     pa_proplist_free(p);
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 97668c5..2712598 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -56,7 +56,8 @@ typedef enum pa_sink_input_flags {
     PA_SINK_INPUT_NO_REMIX = 16,
     PA_SINK_INPUT_FIX_FORMAT = 32,
     PA_SINK_INPUT_FIX_RATE = 64,
-    PA_SINK_INPUT_FIX_CHANNELS = 128
+    PA_SINK_INPUT_FIX_CHANNELS = 128,
+    PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND = 256,
 } pa_sink_input_flags_t;
 
 struct pa_sink_input {
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d8d1f79..a6027e7 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -991,7 +991,7 @@ unsigned pa_sink_linked_by(pa_sink *s) {
     ret = pa_idxset_size(s->inputs);
 
     /* We add in the number of streams connected to us here. Please
-     * not the asymmmetry to pa_sink_used_by()! */
+     * note the asymmmetry to pa_sink_used_by()! */
 
     if (s->monitor_source)
         ret += pa_source_linked_by(s->monitor_source);
@@ -1015,6 +1015,38 @@ unsigned pa_sink_used_by(pa_sink *s) {
     return ret - s->n_corked;
 }
 
+/* Called from main thread */
+unsigned pa_sink_check_suspend(pa_sink *s) {
+    unsigned ret;
+    pa_sink_input *i;
+    uint32_t idx;
+
+    pa_sink_assert_ref(s);
+    pa_assert(PA_SINK_IS_LINKED(s->state));
+
+    ret = 0;
+
+    for (i = PA_SINK_INPUT(pa_idxset_first(s->inputs, &idx)); i; i = PA_SINK_INPUT(pa_idxset_next(s->inputs, &idx))) {
+        pa_sink_input_state_t st;
+
+        st = pa_sink_input_get_state(i);
+        pa_assert(PA_SINK_INPUT_IS_LINKED(st));
+
+        if (st == PA_SINK_INPUT_CORKED)
+            continue;
+
+        if (i->flags & PA_SINK_INPUT_DONT_INHIBIT_AUTO_SUSPEND)
+            continue;
+
+        ret ++;
+    }
+
+    if (s->monitor_source)
+        ret += pa_source_check_suspend(s->monitor_source);
+
+    return ret;
+}
+
 /* Called from IO thread, except when it is not */
 int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offset, pa_memchunk *chunk) {
     pa_sink *s = PA_SINK(o);
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 74671b4..c5a7321 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -252,6 +252,7 @@ pa_bool_t pa_sink_get_mute(pa_sink *sink, pa_bool_t force_refres);
 
 unsigned pa_sink_linked_by(pa_sink *s); /* Number of connected streams */
 unsigned pa_sink_used_by(pa_sink *s); /* Number of connected streams which are not corked */
+unsigned pa_sink_check_suspend(pa_sink *s); /* Returns how many streams are active that don't allow suspensions */
 #define pa_sink_get_state(s) ((s)->state)
 
 /* To be called exclusively by the sink driver, from IO context */
diff --git a/src/pulsecore/source-output.h b/src/pulsecore/source-output.h
index 6ae10c6..f011f9b 100644
--- a/src/pulsecore/source-output.h
+++ b/src/pulsecore/source-output.h
@@ -52,7 +52,8 @@ typedef enum pa_source_output_flags {
     PA_SOURCE_OUTPUT_NO_REMIX = 16,
     PA_SOURCE_OUTPUT_FIX_FORMAT = 32,
     PA_SOURCE_OUTPUT_FIX_RATE = 64,
-    PA_SOURCE_OUTPUT_FIX_CHANNELS = 128
+    PA_SOURCE_OUTPUT_FIX_CHANNELS = 128,
+    PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND = 256
 } pa_source_output_flags_t;
 
 struct pa_source_output {
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index edbbf01..7d927fa 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -645,6 +645,35 @@ unsigned pa_source_used_by(pa_source *s) {
     return ret - s->n_corked;
 }
 
+/* Called from main thread */
+unsigned pa_source_check_suspend(pa_source *s) {
+    unsigned ret;
+    pa_source_output *o;
+    uint32_t idx;
+
+    pa_source_assert_ref(s);
+    pa_assert(PA_SOURCE_IS_LINKED(s->state));
+
+    ret = 0;
+
+    for (o = PA_SOURCE_OUTPUT(pa_idxset_first(s->outputs, &idx)); o; o = PA_SOURCE_OUTPUT(pa_idxset_next(s->outputs, &idx))) {
+        pa_source_output_state_t st;
+
+        st = pa_source_output_get_state(o);
+        pa_assert(PA_SOURCE_OUTPUT_IS_LINKED(st));
+
+        if (st == PA_SOURCE_OUTPUT_CORKED)
+            continue;
+
+        if (o->flags & PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND)
+            continue;
+
+        ret ++;
+    }
+
+    return ret;
+}
+
 /* Called from IO thread, except when it is not */
 int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_t offset, pa_memchunk *chunk) {
     pa_source *s = PA_SOURCE(object);
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index cae7869..aaf904b 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -234,6 +234,7 @@ pa_bool_t pa_source_get_mute(pa_source *source, pa_bool_t force_refresh);
 
 unsigned pa_source_linked_by(pa_source *s); /* Number of connected streams */
 unsigned pa_source_used_by(pa_source *s); /* Number of connected streams that are not corked */
+unsigned pa_source_check_suspend(pa_source *s); /* Returns how many streams are active that don't allow suspensions */
 #define pa_source_get_state(s) ((pa_source_state_t) (s)->state)
 
 /* To be called exclusively by the source driver, from IO context */

commit 58b53bbc1adb62f2a55e1654f97f90df7518f7fd
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Nov 1 21:10:26 2008 +0100

    a bit of pa_bool_t'ization

diff --git a/src/pulsecore/once.c b/src/pulsecore/once.c
index 989741d..3d4543c 100644
--- a/src/pulsecore/once.c
+++ b/src/pulsecore/once.c
@@ -28,13 +28,13 @@
 
 #include "once.h"
 
-int pa_once_begin(pa_once *control) {
+pa_bool_t pa_once_begin(pa_once *control) {
     pa_mutex *m;
 
     pa_assert(control);
 
     if (pa_atomic_load(&control->done))
-        return 0;
+        return FALSE;
 
     pa_atomic_inc(&control->ref);
 
@@ -50,15 +50,17 @@ int pa_once_begin(pa_once *control) {
              * wait until it is unlocked */
             pa_mutex_lock(m);
 
+            pa_assert(pa_atomic_load(&control->done));
+
             pa_once_end(control);
-            return 0;
+            return FALSE;
         }
 
         pa_assert_se(m = pa_mutex_new(FALSE, FALSE));
         pa_mutex_lock(m);
 
         if (pa_atomic_ptr_cmpxchg(&control->mutex, NULL, m))
-            return 1;
+            return TRUE;
 
         pa_mutex_unlock(m);
         pa_mutex_free(m);
@@ -91,4 +93,3 @@ void pa_run_once(pa_once *control, pa_once_func_t func) {
         pa_once_end(control);
     }
 }
-
diff --git a/src/pulsecore/once.h b/src/pulsecore/once.h
index 576d40f..c0191ef 100644
--- a/src/pulsecore/once.h
+++ b/src/pulsecore/once.h
@@ -38,7 +38,7 @@ typedef struct pa_once {
     }
 
 /* Not to be called directly, use the macros defined below instead */
-int pa_once_begin(pa_once *o);
+pa_bool_t pa_once_begin(pa_once *o);
 void pa_once_end(pa_once *o);
 
 #define PA_ONCE_BEGIN                                                   \

commit 84cd23303550cdc3aa605add9f8a2faa3fc1c3e1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Nov 1 21:11:48 2008 +0100

    Make sure libpulse never gets unloaded
    
    When an .so is unloaded during runtime all TLS keys it has registered
    need to be freed because the destructor callbacks of the TLS key might
    otherwise point to invalid code. Hence it would appear sensible to
    destruct the TLS keys from a function marked as __attribute__
    ((destructor)). However functions marked like that are also called when
    an application terminates, on exit(). If a thread continues to run until
    the very exit it might still want to access that TLS data. The
    destructor functions are called while all other threads are still
    running. If __attribute ((destructor)) is used to destruct TLS keys for
    such threads this might hence cause a crash when the application shuts
    down.
    
    To circumvent this problem we'll now compile libpulse with -z nodelete,
    to make it unnecessary to delete the TLS data ever and thus avoiding the
    problem. It's suboptimal, but for now I see no better solution.

diff --git a/src/Makefile.am b/src/Makefile.am
index 5ed0f6f..b9d0083 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -69,7 +69,7 @@ AM_CFLAGS = \
 
 AM_LIBADD = $(PTHREAD_LIBS) $(INTLLIBS)
 AM_LDADD = $(PTHREAD_LIBS) $(INTLLIBS)
-AM_LDFLAGS =
+AM_LDFLAGS = -Wl,-z,nodelete
 
 if STATIC_BINS
 BINLDFLAGS = -static

commit f826ded33d079ea7aead78c811f742cee98214e8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Nov 1 21:41:07 2008 +0100

    make shm marker architecture independant, patch from michich, closes #401

diff --git a/src/pulsecore/shm.c b/src/pulsecore/shm.c
index b299757..c59d247 100644
--- a/src/pulsecore/shm.c
+++ b/src/pulsecore/shm.c
@@ -73,10 +73,10 @@
 struct shm_marker PA_GCC_PACKED {
     pa_atomic_t marker; /* 0xbeefcafe */
     pa_atomic_t pid;
-    uint64_t *_reserverd1;
-    uint64_t *_reserverd2;
-    uint64_t *_reserverd3;
-    uint64_t *_reserverd4;
+    uint64_t _reserved1;
+    uint64_t _reserved2;
+    uint64_t _reserved3;
+    uint64_t _reserved4;
 };
 
 static char *segment_name(char *fn, size_t l, unsigned id) {

commit 2ee9276d97f15ea965fb8a88f2aa184355b9903a
Merge: f826ded... f8197cf...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 16 13:55:06 2008 +0100

    Merge commit 'flameeyes/libtool-2.2'

diff --cc configure.ac
index c5930c0,8bb3f8a..95ac9c2
--- a/configure.ac
+++ b/configure.ac
@@@ -194,44 -219,34 +194,24 @@@ els
      esac
  fi
  
 -AC_MSG_CHECKING([whether $CC knows __thread])
 -AC_LANG_CONFTEST([static __thread int a = 6; int main() { a = 5; }])
 -$CC conftest.c $CFLAGS -o conftest > /dev/null 2> /dev/null
 -ret=$?
 -rm -f conftest.o conftest
 -if test $ret -eq 0 ; then
 -    AC_DEFINE([HAVE_TLS_BUILTIN], 1, [Have __thread().])
 -    AC_MSG_RESULT([yes])
 -else
 -    AC_MSG_RESULT([no])
 -fi
 +CC_CHECK_TLS
 +
 +AC_CACHE_CHECK([whether $CC knows _Bool],
 +  pulseaudio_cv__Bool,
 +  [AC_COMPILE_IFELSE(
 +     AC_LANG_PROGRAM([], [[_Bool b;]]),
 +     [pulseaudio_cv__Bool=yes],
 +     [pulseaudio_cv__Bool=no])
 +  ])
  
 -AC_MSG_CHECKING([whether $CC knows _Bool])
 -AC_LANG_CONFTEST([int main() { _Bool b; }])
 -$CC conftest.c $CFLAGS -o conftest > /dev/null 2> /dev/null
 -ret=$?
 -rm -f conftest.o conftest
 -if test $ret -eq 0 ; then
 +AS_IF([test "$pulseaudio_cv__Bool" = "yes"], [
      AC_DEFINE([HAVE_STD_BOOL], 1, [Have _Bool.])
 -    AC_MSG_RESULT([yes])
 -else
 -    AC_MSG_RESULT([no])
 -fi
 +  ])
  
  #### libtool stuff ####
- 
- AC_LTDL_ENABLE_INSTALL
- AC_LIBLTDL_INSTALLABLE
- AC_LIBTOOL_DLOPEN
- AC_LIBTOOL_WIN32_DLL
- AC_PROG_LIBTOOL
- AC_SUBST(LTDLINCL)
- AC_SUBST(LIBLTDL)
- AC_CONFIG_SUBDIRS(libltdl)
- 
- old_LIBS=$LIBS
- LIBS="$LIBS $LIBLTDL"
- AC_CHECK_FUNCS([lt_dlmutex_register])
- LIBS=$old_LIBS
- AC_CHECK_TYPES([struct lt_user_dlloader, lt_dladvise], , , [#include <ltdl.h>])
- 
- if test "x$enable_ltdl_install" = "xno" && test "x$ac_cv_lib_ltdl_lt_dlinit" = "xno" ; then
-     AC_MSG_ERROR([[
- 
-         *** Cannot find the libltdl development files.
-         *** Maybe you need to install the libltdl-dev package.
-         ]])
- fi
+ LT_CONFIG_LTDL_DIR([libltdl])
+ LT_INIT([dlopen win32-dll])
+ LTDL_INIT([convenience recursive])
  
  #### Determine build environment ####
  

commit 701384935446a5705cb77a9da2f896b086a392be
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 16 14:03:40 2008 +0100

    Check if environ is actually set before we use it
    
    Some applications seem to set **environ to NULL for various reasons.
    Before we iterate through it we thus need to make sure it is actually
    set to make sure we don't segfault.
    
    Closes rhbz #473080

diff --git a/src/pulsecore/proplist-util.c b/src/pulsecore/proplist-util.c
index 4d505f5..35c9985 100644
--- a/src/pulsecore/proplist-util.c
+++ b/src/pulsecore/proplist-util.c
@@ -44,27 +44,34 @@ void pa_init_proplist(pa_proplist *p) {
 
     pa_assert(p);
 
-    for (e = environ; *e; e++) {
+    if (environ) {
 
-        if (pa_startswith(*e, "PULSE_PROP_")) {
-            size_t kl = strcspn(*e+11, "=");
-            char *k;
+        /* Some applications seem to reset environ to NULL for various
+         * reasons, hence we need to check for this explicitly. See
+         * rhbz #473080 */
 
-            if ((*e)[11+kl] != '=')
-                continue;
+        for (e = environ; *e; e++) {
 
-            if (!pa_utf8_valid(*e+11+kl+1))
-                continue;
+            if (pa_startswith(*e, "PULSE_PROP_")) {
+                size_t kl = strcspn(*e+11, "=");
+                char *k;
 
-            k = pa_xstrndup(*e+11, kl);
+                if ((*e)[11+kl] != '=')
+                    continue;
 
-            if (pa_proplist_contains(p, k)) {
+                if (!pa_utf8_valid(*e+11+kl+1))
+                    continue;
+
+                k = pa_xstrndup(*e+11, kl);
+
+                if (pa_proplist_contains(p, k)) {
+                    pa_xfree(k);
+                    continue;
+                }
+
+                pa_proplist_sets(p, k, *e+11+kl+1);
                 pa_xfree(k);
-                continue;
             }
-
-            pa_proplist_sets(p, k, *e+11+kl+1);
-            pa_xfree(k);
         }
     }
 

commit 8977b2e61dc2bf58c22d5b7e655a58b0c7ac1375
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 16 14:25:31 2008 +0100

    libtool 2.2 updates

diff --git a/bootstrap.sh b/bootstrap.sh
index 5dfcdf2..4eacc5a 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -57,7 +57,7 @@ else
     test "x$LIBTOOLIZE" = "x" && LIBTOOLIZE=libtoolize
 
     intltoolize --copy --force --automake
-    "$LIBTOOLIZE" -c --force --ltdl
+    "$LIBTOOLIZE" -c --force --ltdl --recursive
     run_versioned aclocal "$VERSION" -I m4
     run_versioned autoconf 2.62 -Wall
     run_versioned autoheader 2.62
diff --git a/configure.ac b/configure.ac
index 95ac9c2..b36fec3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@
 # along with PulseAudio; if not, write to the Free Software Foundation,
 # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
 
-AC_PREREQ(2.62)
+AC_PREREQ(2.63)
 
 m4_define(PA_MAJOR, [0])
 m4_define(PA_MINOR, [9])
@@ -209,8 +209,9 @@ AS_IF([test "$pulseaudio_cv__Bool" = "yes"], [
   ])
 
 #### libtool stuff ####
+LT_PREREQ(2.2)
 LT_CONFIG_LTDL_DIR([libltdl])
-LT_INIT([dlopen win32-dll])
+LT_INIT([dlopen win32-dll disable-static])
 LTDL_INIT([convenience recursive])
 
 #### Determine build environment ####
@@ -284,7 +285,7 @@ AC_TYPE_SIZE_T
 AC_CHECK_TYPES(ssize_t, , [AC_DEFINE([ssize_t], [signed long],
     [Define ssize_t if it is not done by the standard libs.])])
 AC_TYPE_OFF_T
-AC_TYPE_SIGNAL
+
 AC_TYPE_UID_T
 AC_CHECK_DECLS(environ)
 
@@ -980,7 +981,7 @@ AM_CONDITIONAL([HAVE_POLKIT], [test "x$HAVE_POLKIT" = x1])
 #### OpenSSL support (optional) ####
 
 AC_ARG_ENABLE([openssl],
-    AC_HELP_STRING([--disable-openssl], [Disable OpenSSL support (used for Airtunes/RAOP)]),
+    AS_HELP_STRING([--disable-openssl],[Disable OpenSSL support (used for Airtunes/RAOP)]),
         [
             case "${enableval}" in
                 yes) openssl=yes ;;

commit e4aa5f2115d7322e691474ccd1835a2f443c27b8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 16 18:17:21 2008 +0100

    Fix return value of --dump-resample-methods
    
    We should return 0 when --dump-resample-methods is called.
    
    Problem identified by "hchen59".
    
    Closes bug #407.

diff --git a/src/daemon/main.c b/src/daemon/main.c
index f6d2512..df8040b 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -580,6 +580,7 @@ int main(int argc, char *argv[]) {
                 if (pa_resample_method_supported(i))
                     printf("%s\n", pa_resample_method_to_string(i));
 
+            retval = 0;
             goto finish;
         }
 

commit b8fe1b683e9d373bb3475b30099593f00eaf4cff
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 16 19:11:16 2008 +0100

    fix implementation of bind now ltdl loader for libtool 2.2

diff --git a/src/daemon/ltdl-bind-now.c b/src/daemon/ltdl-bind-now.c
index 2d80fc7..8444cfb 100644
--- a/src/daemon/ltdl-bind-now.c
+++ b/src/daemon/ltdl-bind-now.c
@@ -1,7 +1,7 @@
 /***
   This file is part of PulseAudio.
 
-  Copyright 2004-2006 Lennart Poettering
+  Copyright 2004-2008 Lennart Poettering
   Copyright 2006 Pierre Ossman <ossman at cendio.se> for Cendio AB
 
   PulseAudio is free software; you can redistribute it and/or modify
@@ -39,8 +39,6 @@
 #include <pulse/i18n.h>
 
 #include <pulsecore/macro.h>
-#include <pulsecore/mutex.h>
-#include <pulsecore/thread.h>
 #include <pulsecore/log.h>
 
 #include "ltdl-bind-now.h"
@@ -67,16 +65,13 @@
   to set $LT_BIND_NOW before starting the pulsaudio binary.
 */
 
-static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise)
-{
+static lt_module bind_now_open(lt_user_data d, const char *fname, lt_dladvise advise) {
     lt_module m;
 
     pa_assert(fname);
 
     if (!(m = dlopen(fname, PA_BIND_NOW))) {
-#ifdef HAVE_LT_DLMUTEX_REGISTER
-        libtool_set_error(dlerror());
-#endif
+        lt_dlseterror(LT_ERROR_CANNOT_OPEN);
         return NULL;
     }
 
@@ -88,9 +83,7 @@ static int bind_now_close(lt_user_data d, lt_module m) {
     pa_assert(m);
 
     if (dlclose(m) != 0){
-#ifdef HAVE_LT_DLMUTEX_REGISTER
-        libtool_set_error(dlerror());
-#endif
+        lt_dlseterror(LT_ERROR_CANNOT_CLOSE);
         return 1;
     }
 
@@ -104,49 +97,61 @@ static lt_ptr bind_now_find_sym(lt_user_data d, lt_module m, const char *symbol)
     pa_assert(symbol);
 
     if (!(ptr = dlsym(m, symbol))) {
-#ifdef HAVE_LT_DLMUTEX_REGISTER
-        libtool_set_error(dlerror());
-#endif
+        lt_dlseterror(LT_ERROR_SYMBOL_NOT_FOUND);
         return NULL;
     }
 
     return ptr;
 }
 
+static lt_dlvtable *bindnow_loader = NULL;
 #endif
 
 void pa_ltdl_init(void) {
 
 #ifdef PA_BIND_NOW
-    static const lt_dlvtable *dlopen_loader;
-    static lt_dlvtable bindnow_loader;
+    const lt_dlvtable *dlopen_loader;
 #endif
 
     pa_assert_se(lt_dlinit() == 0);
 
 #ifdef PA_BIND_NOW
     /* Already initialised */
-    if (dlopen_loader)
+    if (bindnow_loader)
+        return;
+
+    if (!(dlopen_loader = lt_dlloader_find((char*) "lt_dlopen"))) {
+        pa_log_warn(_("Failed to find original lt_dlopen loader."));
         return;
+    }
 
-    if (!(dlopen_loader = lt_dlloader_find("dlopen"))) {
-        pa_log_warn(_("Failed to find original dlopen loader."));
+    if (!(bindnow_loader = malloc(sizeof(lt_dlvtable)))) {
+        pa_log_error(_("Failed to allocate new dl loader."));
         return;
     }
 
-    memcpy(&bindnow_loader, dlopen_loader, sizeof(bindnow_loader));
-    bindnow_loader.name = "bind-now-loader";
-    bindnow_loader.module_open = bind_now_open;
-    bindnow_loader.module_close = bind_now_close;
-    bindnow_loader.find_sym = bind_now_find_sym;
-    bindnow_loader.priority = LT_DLLOADER_PREPEND;
+    memcpy(bindnow_loader, dlopen_loader, sizeof(*bindnow_loader));
+    bindnow_loader->name = "bind-now-loader";
+    bindnow_loader->module_open = bind_now_open;
+    bindnow_loader->module_close = bind_now_close;
+    bindnow_loader->find_sym = bind_now_find_sym;
+    bindnow_loader->priority = LT_DLLOADER_PREPEND;
 
     /* Add our BIND_NOW loader as the default module loader. */
-    if (lt_dlloader_add(&bindnow_loader) != 0)
+    if (lt_dlloader_add(bindnow_loader) != 0) {
         pa_log_warn(_("Failed to add bind-now-loader."));
+        free(bindnow_loader);
+        bindnow_loader = NULL;
+    }
 #endif
 }
 
 void pa_ltdl_done(void) {
     pa_assert_se(lt_dlexit() == 0);
+
+#ifdef PA_BIND_NOW
+    /* lt_dlexit() will free our loader vtable, hence reset our
+     * pointer to it here */
+    bindnow_loader = NULL;
+#endif
 }

commit 209a8d7b5546e51ff1a88444c6d6282f6e74301b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 19:53:58 2008 +0100

    Don't mix front-center into rear channels
    
    If there's a center channel on input that is not available on output
    make sure we mix front-center only into front-left/right and rear-center
    into rear-left/right.
    
    Closes #400

diff --git a/src/pulsecore/resampler.c b/src/pulsecore/resampler.c
index b2d512c..f0515eb 100644
--- a/src/pulsecore/resampler.c
+++ b/src/pulsecore/resampler.c
@@ -510,6 +510,52 @@ static pa_bool_t on_lfe(pa_channel_position_t p) {
         p == PA_CHANNEL_POSITION_LFE;
 }
 
+static pa_bool_t on_front(pa_channel_position_t p) {
+    return
+        p == PA_CHANNEL_POSITION_FRONT_LEFT ||
+        p == PA_CHANNEL_POSITION_FRONT_RIGHT ||
+        p == PA_CHANNEL_POSITION_FRONT_CENTER ||
+        p == PA_CHANNEL_POSITION_TOP_FRONT_LEFT ||
+        p == PA_CHANNEL_POSITION_TOP_FRONT_RIGHT ||
+        p == PA_CHANNEL_POSITION_TOP_FRONT_CENTER ||
+        p == PA_CHANNEL_POSITION_FRONT_LEFT_OF_CENTER ||
+        p == PA_CHANNEL_POSITION_FRONT_RIGHT_OF_CENTER;
+}
+
+static pa_bool_t on_rear(pa_channel_position_t p) {
+    return
+        p == PA_CHANNEL_POSITION_REAR_LEFT ||
+        p == PA_CHANNEL_POSITION_REAR_RIGHT ||
+        p == PA_CHANNEL_POSITION_REAR_CENTER ||
+        p == PA_CHANNEL_POSITION_TOP_REAR_LEFT ||
+        p == PA_CHANNEL_POSITION_TOP_REAR_RIGHT ||
+        p == PA_CHANNEL_POSITION_TOP_REAR_CENTER;
+}
+
+static pa_bool_t on_side(pa_channel_position_t p) {
+    return
+        p == PA_CHANNEL_POSITION_SIDE_LEFT ||
+        p == PA_CHANNEL_POSITION_SIDE_RIGHT ||
+        p == PA_CHANNEL_POSITION_TOP_CENTER;
+}
+
+enum {
+    ON_FRONT,
+    ON_REAR,
+    ON_SIDE,
+    ON_OTHER
+};
+
+static int front_rear_side(pa_channel_position_t p) {
+    if (on_front(p))
+        return ON_FRONT;
+    if (on_rear(p))
+        return ON_REAR;
+    if (on_side(p))
+        return ON_SIDE;
+    return ON_OTHER;
+}
+
 static void calc_map_table(pa_resampler *r) {
     unsigned oc, ic;
     pa_bool_t ic_connected[PA_CHANNELS_MAX];
@@ -601,7 +647,9 @@ static void calc_map_table(pa_resampler *r) {
              *    D:left, all D:right, all D:center channels, gain is
              *    0.375. The current (as result of 1..6) factors
              *    should be multiplied by 0.75. (Alt. suggestion: 0.25
-             *    vs. 0.5)
+             *    vs. 0.5) If C-front is only mixed into
+             *    L-front/R-front if available, otherwise into all L/R
+             *    channels. Similarly for C-rear.
              *
              * S: and D: shall relate to the source resp. destination channels.
              *
@@ -629,6 +677,8 @@ static void calc_map_table(pa_resampler *r) {
         if (!oc_connected && remix) {
             /* OK, we shall remix */
 
+            /* Try to find matching input ports for this output port */
+
             if (on_left(b)) {
                 unsigned n = 0;
 
@@ -830,17 +880,54 @@ static void calc_map_table(pa_resampler *r) {
             }
 
             if (!mixed_in) {
+                unsigned ncenter[PA_CHANNELS_MAX];
+                pa_bool_t found_frs[PA_CHANNELS_MAX];
+
+                memset(ncenter, 0, sizeof(ncenter));
+                memset(found_frs, 0, sizeof(found_frs));
 
                 /* Hmm, as it appears there was no center channel we
                    could mix our center channel in. In this case, mix
                    it into left and right. Using .375 and 0.75 as
                    factors. */
 
+                for (ic = 0; ic < r->i_ss.channels; ic++) {
+
+                    if (ic_connected[ic])
+                        continue;
+
+                    if (!on_center(r->i_cm.map[ic]))
+                        continue;
+
+                    for (oc = 0; oc < r->o_ss.channels; oc++) {
+
+                        if (!on_left(r->o_cm.map[oc]) && !on_right(r->o_cm.map[oc]))
+                            continue;
+
+                        if (front_rear_side(r->i_cm.map[ic]) == front_rear_side(r->o_cm.map[oc])) {
+                            found_frs[ic] = TRUE;
+                            break;
+                        }
+                    }
+
+                    for (oc = 0; oc < r->o_ss.channels; oc++) {
+
+                        if (!on_left(r->o_cm.map[oc]) && !on_right(r->o_cm.map[oc]))
+                            continue;
+
+                        if (!found_frs[ic] || front_rear_side(r->i_cm.map[ic]) == front_rear_side(r->o_cm.map[oc]))
+                            ncenter[oc]++;
+                    }
+                }
+
                 for (oc = 0; oc < r->o_ss.channels; oc++) {
 
                     if (!on_left(r->o_cm.map[oc]) && !on_right(r->o_cm.map[oc]))
                         continue;
 
+                    if (ncenter[oc] <= 0)
+                        continue;
+
                     for (ic = 0; ic < r->i_ss.channels; ic++)  {
 
                         if (ic_connected[ic]) {
@@ -848,8 +935,11 @@ static void calc_map_table(pa_resampler *r) {
                             continue;
                         }
 
-                        if (on_center(r->i_cm.map[ic]))
-                            r->map_table[oc][ic] = .375f / (float) ic_unconnected_center;
+                        if (!on_center(r->i_cm.map[ic]))
+                            continue;
+
+                        if (!found_frs[ic] || front_rear_side(r->i_cm.map[ic]) == front_rear_side(r->o_cm.map[oc]))
+                            r->map_table[oc][ic] = .375f / (float) ncenter[oc];
                     }
                 }
             }

commit 3f20a152be5b57cb90cd4124cf60c29435cd1662
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 20:22:42 2008 +0100

    Pass GDBM_NOLOCK to gdbm
    
    gdbm still uses BSD lockf for locking which is incompatible with NFS.
    Since we don't need the locking here since the db files in question
    should never be accessed by more than one process since they are
    per-home-dir and per-machine we can disable locking without any ill
    results.
    
    This should fix rhbz #471279.

diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index 86a7881..c0cb0dc 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -332,7 +332,7 @@ int pa__init(pa_module*m) {
     if (!fname)
         goto fail;
 
-    if (!(u->gdbm_file = gdbm_open(fname, 0, GDBM_WRCREAT, 0600, NULL))) {
+    if (!(u->gdbm_file = gdbm_open(fname, 0, GDBM_WRCREAT|GDBM_NOLOCK, 0600, NULL))) {
         pa_log("Failed to open volume database '%s': %s", fname, gdbm_strerror(gdbm_errno));
         pa_xfree(fname);
         goto fail;
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 5589700..fdf69a2 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -741,7 +741,7 @@ int pa__init(pa_module*m) {
     if (!fname)
         goto fail;
 
-    if (!(u->gdbm_file = gdbm_open(fname, 0, GDBM_WRCREAT, 0600, NULL))) {
+    if (!(u->gdbm_file = gdbm_open(fname, 0, GDBM_WRCREAT|GDBM_NOLOCK, 0600, NULL))) {
         pa_log("Failed to open volume database '%s': %s", fname, gdbm_strerror(gdbm_errno));
         pa_xfree(fname);
         goto fail;

commit cb6a91973017160e9b10a8f86d831cbcf13bf53e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 20:30:01 2008 +0100

    Load module-volume-restore and module-device-restore before all other modules
    
    Since m-v-r and m-d-r become active in the FIXATE hooks for
    stream/device creation we need to make sure the modules are loaded
    before the first devices/streams are created.

diff --git a/src/daemon/default.pa.in b/src/daemon/default.pa.in
index a831876..7de4c07 100755
--- a/src/daemon/default.pa.in
+++ b/src/daemon/default.pa.in
@@ -29,6 +29,10 @@
 
 .fail
 
+### Automatically restore the volume of streams and devices
+load-module module-device-restore
+load-module module-stream-restore
+
 ### Load audio drivers statically (it's probably better to not load
 ### these drivers manually, but instead use module-hal-detect --
 ### see below -- for doing this automatically)
@@ -75,10 +79,6 @@ load-module module-native-protocol-unix
 ### Enable flat volumes where possible
 load-module module-flat-volume
 
-### Automatically restore the volume of streams and devices
-load-module module-device-restore
-load-module module-stream-restore
-
 ### Automatically restore the default sink/source when changed by the user during runtime
 load-module module-default-device-restore
 

commit 82f09b6d8ffcb51d3fdc7834762f45d887d44e70
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:03:17 2008 +0100

    Don't hit an assert when checking for idleness
    
    Closes #398

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 0e1224f..d4e0a9c 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -302,8 +302,6 @@ static void update_n_corked(pa_sink_input *i, pa_sink_input_state_t state) {
         pa_assert_se(i->sink->n_corked -- >= 1);
     else if (i->state != PA_SINK_INPUT_CORKED && state == PA_SINK_INPUT_CORKED)
         i->sink->n_corked++;
-
-    pa_sink_update_status(i->sink);
 }
 
 /* Called from main context */
@@ -341,6 +339,8 @@ static int sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) {
             pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED], ssync);
     }
 
+    pa_sink_update_status(i->sink);
+
     return 0;
 }
 
@@ -391,6 +391,8 @@ void pa_sink_input_unlink(pa_sink_input *i) {
         pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK_POST], i);
     }
 
+    pa_sink_update_status(i->sink);
+
     i->sink = NULL;
     pa_sink_input_unref(i);
 }
@@ -452,6 +454,8 @@ void pa_sink_input_put(pa_sink_input *i) {
 
     pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW, i->index);
     pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT], i);
+
+    pa_sink_update_status(i->sink);
 }
 
 /* Called from main context */
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index a6027e7..1580cf2 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1022,7 +1022,9 @@ unsigned pa_sink_check_suspend(pa_sink *s) {
     uint32_t idx;
 
     pa_sink_assert_ref(s);
-    pa_assert(PA_SINK_IS_LINKED(s->state));
+
+    if (!PA_SINK_IS_LINKED(s->state))
+        return 0;
 
     ret = 0;
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 376402f..c92c5ab 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -247,7 +247,6 @@ static void update_n_corked(pa_source_output *o, pa_source_output_state_t state)
     else if (o->state != PA_SOURCE_OUTPUT_CORKED && state == PA_SOURCE_OUTPUT_CORKED)
         o->source->n_corked++;
 
-    pa_source_update_status(o->source);
 }
 
 /* Called from main context */
@@ -265,6 +264,8 @@ static int source_output_set_state(pa_source_output *o, pa_source_output_state_t
     if (state != PA_SOURCE_OUTPUT_UNLINKED)
         pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED], o);
 
+    pa_source_update_status(o->source);
+
     return 0;
 }
 
@@ -303,6 +304,8 @@ void pa_source_output_unlink(pa_source_output*o) {
         pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST], o);
     }
 
+    pa_source_update_status(o->source);
+
     o->source = NULL;
     pa_source_output_unref(o);
 }
@@ -354,6 +357,8 @@ void pa_source_output_put(pa_source_output *o) {
 
     pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
     pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT], o);
+
+    pa_source_update_status(o->source);
 }
 
 /* Called from main context */
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 7d927fa..f113e29 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -652,7 +652,9 @@ unsigned pa_source_check_suspend(pa_source *s) {
     uint32_t idx;
 
     pa_source_assert_ref(s);
-    pa_assert(PA_SOURCE_IS_LINKED(s->state));
+
+    if (!PA_SOURCE_IS_LINKED(s->state))
+        return 0;
 
     ret = 0;
 

commit dcd498c5ad86bfdbda6d29e1b48aa8f02dc8ceaa
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Fri Dec 5 15:47:37 2008 -0300

    Fix bug walking on module list.

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index 36c0a35..ddf944a 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -94,7 +94,7 @@ static void module_free(struct module *m) {
 static struct module* module_find(struct device *d, const char *profile) {
     struct module *m;
 
-    for (m = d->module_list; d; d = d->next)
+    for (m = d->module_list; m; m = m->next)
         if (pa_streq(m->profile, profile))
             return m;
 

commit c5b8eb7edf73ecaccdce957b63f4113e34d5b291
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:19:34 2008 +0100

    introduce new function pa_module_unload_request_by_index

diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c
index 9b17cb9..56ed2c5 100644
--- a/src/pulsecore/module.c
+++ b/src/pulsecore/module.c
@@ -280,6 +280,16 @@ void pa_module_unload_request(pa_module *m, pa_bool_t force) {
     m->core->mainloop->defer_enable(m->core->module_defer_unload_event, 1);
 }
 
+void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force) {
+    pa_module *m;
+    pa_assert(c);
+
+    if (!(m = pa_idxset_get_by_index(c->modules, idx)))
+        return;
+
+    pa_module_unload_request(m, force);
+}
+
 void pa_module_set_used(pa_module*m, int used) {
     pa_assert(m);
 
diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h
index 365ab67..661b2dd 100644
--- a/src/pulsecore/module.h
+++ b/src/pulsecore/module.h
@@ -52,14 +52,16 @@ struct pa_module {
 };
 
 pa_module* pa_module_load(pa_core *c, const char *name, const char*argument);
+
 void pa_module_unload(pa_core *c, pa_module *m, pa_bool_t force);
 void pa_module_unload_by_index(pa_core *c, uint32_t idx, pa_bool_t force);
 
+void pa_module_unload_request(pa_module *m, pa_bool_t force);
+void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force);
+
 void pa_module_unload_all(pa_core *c);
 void pa_module_unload_unused(pa_core *c);
 
-void pa_module_unload_request(pa_module *m, pa_bool_t force);
-
 void pa_module_set_used(pa_module*m, int used);
 
 #define PA_MODULE_AUTHOR(s)                                     \

commit 86c6fd85f11d63ba1cf634124a0971a66f244139
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:19:53 2008 +0100

    Don't store pointer to pa_module
    
    pa_module pointers might become invalid at any time, so we use the
    stable uin32_t index of the module for identifying or modules instead.

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index ddf944a..2fe0937 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -44,7 +44,7 @@ PA_MODULE_USAGE("");
 
 struct module {
     char *profile;
-    pa_module *pa_m;
+    uint32_t index;
     PA_LLIST_FIELDS(struct module);
 };
 
@@ -78,7 +78,7 @@ static struct module *module_new(const char *profile, pa_module *pa_m) {
 
     m = pa_xnew(struct module, 1);
     m->profile = pa_xstrdup(profile);
-    m->pa_m = pa_m;
+    m->index = pa_m->index;
     PA_LLIST_INIT(struct module, m);
 
     return m;
@@ -364,7 +364,7 @@ static void unload_module_for_device(struct userdata *u, struct device *d, const
     if (!(m = module_find(d, profile)))
         return;
 
-    pa_module_unload_request(m->pa_m, TRUE);
+    pa_module_unload_request_by_index(u->module->core, m->index, TRUE);
 
     PA_LLIST_REMOVE(struct module, d->module_list, m);
     module_free(m);

commit b95539b18b50c7766ac824a1732aae2a4d92eaeb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:20:51 2008 +0100

    actually unload the modules from a new stack frame

diff --git a/src/modules/module-hal-detect.c b/src/modules/module-hal-detect.c
index c76a366..8c1ab32 100644
--- a/src/modules/module-hal-detect.c
+++ b/src/modules/module-hal-detect.c
@@ -511,7 +511,7 @@ static void device_removed_cb(LibHalContext* context, const char *udi) {
     pa_log_debug("Device removed: %s", udi);
 
     if ((d = pa_hashmap_remove(u->devices, udi))) {
-        pa_module_unload_by_index(u->core, d->index, TRUE);
+        pa_module_unload_request_by_index(u->core, d->index, TRUE);
         hal_device_free(d);
     }
 }

commit f5d40fa44851b39ebf14452d06fc7669d6bc4b88
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:27:07 2008 +0100

    unload tunnel modules from a new stack frame

diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c
index c8087ab..9a867cb 100644
--- a/src/modules/module-zeroconf-discover.c
+++ b/src/modules/module-zeroconf-discover.c
@@ -286,7 +286,7 @@ static void browser_cb(
         struct tunnel *t2;
 
         if ((t2 = pa_hashmap_get(u->tunnels, t))) {
-            pa_module_unload_by_index(u->core, t2->module_index, TRUE);
+            pa_module_unload_request_by_index(u->core, t2->module_index, TRUE);
             pa_hashmap_remove(u->tunnels, t2);
             tunnel_free(t2);
         }
@@ -427,7 +427,7 @@ void pa__done(pa_module*m) {
         struct tunnel *t;
 
         while ((t = pa_hashmap_steal_first(u->tunnels))) {
-            pa_module_unload_by_index(u->core, t->module_index, TRUE);
+            pa_module_unload_request_by_index(u->core, t->module_index, TRUE);
             tunnel_free(t);
         }
 

commit 906d06bd24b6a76003c101d83a08c030799ed037
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 21:32:40 2008 +0100

    it's better to always use the index of a module instead of the pa_module*

diff --git a/src/modules/module-always-sink.c b/src/modules/module-always-sink.c
index 9d60c29..cd3f311 100644
--- a/src/modules/module-always-sink.c
+++ b/src/modules/module-always-sink.c
@@ -50,7 +50,7 @@ static const char* const valid_modargs[] = {
 
 struct userdata {
     pa_hook_slot *put_slot, *unlink_slot;
-    pa_module* null_module;
+    uint32_t null_module;
     pa_bool_t ignore;
     char *sink_name;
 };
@@ -59,10 +59,11 @@ static void load_null_sink_if_needed(pa_core *c, pa_sink *sink, struct userdata*
     pa_sink *target;
     uint32_t idx;
     char *t;
+    pa_module *m;
 
     pa_assert(c);
     pa_assert(u);
-    pa_assert(!u->null_module);
+    pa_assert(u->null_module == PA_INVALID_INDEX);
 
     /* Loop through all sinks and check to see if we have *any*
      * sinks. Ignore the sink passed in (if it's not null) */
@@ -78,12 +79,13 @@ static void load_null_sink_if_needed(pa_core *c, pa_sink *sink, struct userdata*
     u->ignore = TRUE;
 
     t = pa_sprintf_malloc("sink_name=%s", u->sink_name);
-    u->null_module = pa_module_load(c, "module-null-sink", t);
+    m = pa_module_load(c, "module-null-sink", t);
+    u->null_module = m ? m->index : PA_INVALID_INDEX;
     pa_xfree(t);
 
     u->ignore = FALSE;
 
-    if (!u->null_module)
+    if (!m)
         pa_log_warn("Unable to load module-null-sink");
 }
 
@@ -99,17 +101,17 @@ static pa_hook_result_t put_hook_callback(pa_core *c, pa_sink *sink, void* userd
         return PA_HOOK_OK;
 
     /* Auto-loaded null-sink not active, so ignoring newly detected sink. */
-    if (!u->null_module)
+    if (u->null_module == PA_INVALID_INDEX)
         return PA_HOOK_OK;
 
     /* This is us detecting ourselves on load in a different way... just ignore this too. */
-    if (sink->module == u->null_module)
+    if (sink->module && sink->module->index == u->null_module)
         return PA_HOOK_OK;
 
     pa_log_info("A new sink has been discovered. Unloading null-sink.");
 
-    pa_module_unload_request(u->null_module, TRUE);
-    u->null_module = NULL;
+    pa_module_unload_request_by_index(c, u->null_module, TRUE);
+    u->null_module = PA_INVALID_INDEX;
 
     return PA_HOOK_OK;
 }
@@ -122,9 +124,9 @@ static pa_hook_result_t unlink_hook_callback(pa_core *c, pa_sink *sink, void* us
     pa_assert(u);
 
     /* First check to see if it's our own null-sink that's been removed... */
-    if (u->null_module && sink->module == u->null_module) {
+    if (u->null_module != PA_INVALID_INDEX && sink->module && sink->module->index == u->null_module) {
         pa_log_debug("Autoloaded null-sink removed");
-        u->null_module = NULL;
+        u->null_module = PA_INVALID_INDEX;
         return PA_HOOK_OK;
     }
 
@@ -148,7 +150,7 @@ int pa__init(pa_module*m) {
     u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME));
     u->put_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_LATE, (pa_hook_cb_t) put_hook_callback, u);
     u->unlink_slot = pa_hook_connect(&m->core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_EARLY, (pa_hook_cb_t) unlink_hook_callback, u);
-    u->null_module = NULL;
+    u->null_module = PA_INVALID_INDEX;
     u->ignore = FALSE;
 
     pa_modargs_free(ma);
@@ -170,8 +172,8 @@ void pa__done(pa_module*m) {
         pa_hook_slot_free(u->put_slot);
     if (u->unlink_slot)
         pa_hook_slot_free(u->unlink_slot);
-    if (u->null_module)
-        pa_module_unload_request(u->null_module, TRUE);
+    if (u->null_module != PA_INVALID_INDEX)
+        pa_module_unload_request_by_index(m->core, u->null_module, TRUE);
 
     pa_xfree(u->sink_name);
     pa_xfree(u);

commit d71d79cd45364dd4dd5ef34bbd311ef7f8ab59a0
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Dec 17 22:58:17 2008 +0100

    downgrade a few warnings

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 20dc400..7ae538a 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -1046,7 +1046,7 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
     pa_assert(pcm);
 
     if (revents & POLLERR)
-        pa_log_warn("Got POLLERR from ALSA");
+        pa_log_debug("Got POLLERR from ALSA");
     if (revents & POLLNVAL)
         pa_log_warn("Got POLLNVAL from ALSA");
     if (revents & POLLHUP)
@@ -1054,12 +1054,12 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) {
     if (revents & POLLPRI)
         pa_log_warn("Got POLLPRI from ALSA");
     if (revents & POLLIN)
-        pa_log_warn("Got POLLIN from ALSA");
+        pa_log_debug("Got POLLIN from ALSA");
     if (revents & POLLOUT)
-        pa_log_warn("Got POLLOUT from ALSA");
+        pa_log_debug("Got POLLOUT from ALSA");
 
     state = snd_pcm_state(pcm);
-    pa_log_warn("PCM state is %s", snd_pcm_state_name(state));
+    pa_log_debug("PCM state is %s", snd_pcm_state_name(state));
 
     /* Try to recover from this error */
 

commit 1d2e5cba52ce439dc755d354bccda2709679e9eb
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Dec 18 01:25:54 2008 +0100

    Make sure we drop CAP_NICE if RT is not allowed
    
    but make sure we still allow RT if RLIMIT_RTPRIO is properly set when PA
    is called.

diff --git a/src/daemon/main.c b/src/daemon/main.c
index df8040b..9c419ef 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -435,6 +435,9 @@ int main(int argc, char *argv[]) {
     pa_log_debug("Started as real root: %s, suid root: %s", pa_yes_no(real_root), pa_yes_no(suid_root));
 
     if (!real_root && pa_have_caps()) {
+#ifdef HAVE_SYS_RESOURCE_H
+        struct rlimit rl;
+#endif
         pa_bool_t allow_high_priority = FALSE, allow_realtime = FALSE;
 
         /* Let's better not enable high prio or RT by default */
@@ -477,12 +480,35 @@ int main(int argc, char *argv[]) {
              * let's give it up early */
 
             pa_drop_caps();
-
-            if (conf->high_priority || conf->realtime_scheduling)
-                pa_log_notice(_("Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
-                                "We are not in group '"PA_REALTIME_GROUP"' and PolicyKit refuse to grant us privileges. Dropping SUID again.\n"
-                                "For enabling real-time scheduling please acquire the appropriate PolicyKit privileges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
         }
+
+#ifdef RLIMIT_RTPRIO
+        if (getrlimit(RLIMIT_RTPRIO, &rl) >= 0)
+            if (rl.rlim_cur > 0) {
+                pa_log_info("RLIMIT_RTPRIO is set to %u, allowing real-time scheduling.", (unsigned) rl.rlim_cur);
+                allow_realtime = TRUE;
+            }
+#endif
+#ifdef RLIMIT_NICE
+        if (getrlimit(RLIMIT_NICE, &rl) >= 0)
+            if (rl.rlim_cur > 20 ) {
+                pa_log_info("RLIMIT_NICE is set to %u, allowing high-priority scheduling.", (unsigned) rl.rlim_cur);
+                allow_high_priority = TRUE;
+            }
+#endif
+
+        if ((conf->high_priority && !allow_high_priority) ||
+            (conf->realtime_scheduling && !allow_realtime))
+            pa_log_notice(_("Called SUID root and real-time and/or high-priority scheduling was requested in the configuration. However, we lack the necessary privileges:\n"
+                            "We are not in group '"PA_REALTIME_GROUP"', PolicyKit refuse to grant us the requested privileges and we have no increase RLIMIT_NICE/RLIMIT_RTPRIO resource limits.\n"
+                            "For enabling real-time/high-priority scheduling please acquire the appropriate PolicyKit privileges, or become a member of '"PA_REALTIME_GROUP"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."));
+
+
+        if (!allow_realtime)
+            conf->realtime_scheduling = FALSE;
+
+        if (!allow_high_priority)
+            conf->high_priority = FALSE;
     }
 
 #ifdef HAVE_SYS_RESOURCE_H
@@ -496,12 +522,16 @@ int main(int argc, char *argv[]) {
     set_all_rlimits(conf);
 #endif
 
-    if (conf->high_priority && !pa_can_high_priority())
+    if (conf->high_priority && !pa_can_high_priority()) {
         pa_log_warn(_("High-priority scheduling enabled in configuration but not allowed by policy."));
+        conf->high_priority = FALSE;
+    }
 
     if (conf->high_priority && (conf->cmd == PA_CMD_DAEMON || conf->cmd == PA_CMD_START))
         pa_raise_priority(conf->nice_level);
 
+    pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority()));
+
     if (!real_root && pa_have_caps()) {
         pa_bool_t drop;
 
@@ -538,8 +568,10 @@ int main(int argc, char *argv[]) {
         }
     }
 
-    if (conf->realtime_scheduling && !pa_can_realtime())
+    if (conf->realtime_scheduling && !pa_can_realtime()) {
         pa_log_warn(_("Real-time scheduling enabled in configuration but not allowed by policy."));
+        conf->realtime_scheduling = FALSE;
+    }
 
     pa_log_debug("Can realtime: %s, can high-priority: %s", pa_yes_no(pa_can_realtime()), pa_yes_no(pa_can_high_priority()));
 

commit 63fc26ed034846a8d2189e5cc2fe890ce3b4c7b3
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Dec 18 15:24:02 2008 +0100

    Allow access("/dev/dsp", W_OK) succeed
    
    Some stupid apps (such as X-lite Softphone) check for W_OK on /dev/dsp.
    This is of course crazy but easy for us to support.
    
    Closes rhbz #474313

diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index 2e6e557..046bae4 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -2382,15 +2382,15 @@ int access(const char *pathname, int mode) {
     debug(DEBUG_LEVEL_VERBOSE, __FILE__": access(%s)\n", pathname?pathname:"NULL");
 
     if (!pathname ||
-        ( strcmp(pathname, "/dev/dsp") != 0 &&
-          strcmp(pathname, "/dev/adsp") != 0 &&
-          strcmp(pathname, "/dev/sndstat") != 0 &&
-          strcmp(pathname, "/dev/mixer") != 0 )) {
+        (strcmp(pathname, "/dev/dsp") != 0 &&
+         strcmp(pathname, "/dev/adsp") != 0 &&
+         strcmp(pathname, "/dev/sndstat") != 0 &&
+         strcmp(pathname, "/dev/mixer") != 0 )) {
         LOAD_ACCESS_FUNC();
         return _access(pathname, mode);
     }
 
-    if (mode & (W_OK | X_OK)) {
+    if (mode & X_OK) {
         debug(DEBUG_LEVEL_NORMAL, __FILE__": access(%s, %x) = EACCESS\n", pathname, mode);
         errno = EACCES;
         return -1;

commit 10cc4ba1ca53b56b58f4f04b4c5d49fa4e2b22dc
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Dec 21 13:33:32 2008 +0100

    Use FIONREAD instead of TIOCINQ
    
    On Linux the two ioctls FIONREAD and TIOCINQ share the same number.
    However TIOCINQ is used for terminals while FIONREAD is used (among
    others) for sockets and pipes. Hence use FIONREAD here since it seems
    more appropriate.

diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index ae230b2..2b55c82 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -101,8 +101,8 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             size_t n = 0;
             int l;
 
-#ifdef TIOCINQ
-            if (ioctl(u->fd, TIOCINQ, &l) >= 0 && l > 0)
+#ifdef FIONREAD
+            if (ioctl(u->fd, FIONREAD, &l) >= 0 && l > 0)
                 n = (size_t) l;
 #endif
 

commit 606c9caa0b07ab0c8f18438a3fe24db2213188b5
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Dec 21 13:34:56 2008 +0100

    Implement PA_SOURCE_MESSAGE_GET_LATENCY
    
    The pipe source needs to implement PA_SOURCE_MESSAGE_GET_LATENCY since
    we'll otherwise hit an assert.
    
    Closes #424.

diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c
index 25151d9..e6437a0 100644
--- a/src/modules/module-pipe-source.c
+++ b/src/modules/module-pipe-source.c
@@ -31,6 +31,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <limits.h>
+#include <sys/ioctl.h>
 #include <sys/poll.h>
 
 #include <pulse/xmalloc.h>
@@ -89,6 +90,34 @@ static const char* const valid_modargs[] = {
     NULL
 };
 
+static int source_process_msg(
+        pa_msgobject *o,
+        int code,
+        void *data,
+        int64_t offset,
+        pa_memchunk *chunk) {
+
+    struct userdata *u = PA_SOURCE(o)->userdata;
+
+    switch (code) {
+
+        case PA_SOURCE_MESSAGE_GET_LATENCY: {
+            size_t n = 0;
+            int l;
+
+#ifdef FIONREAD
+            if (ioctl(u->fd, FIONREAD, &l) >= 0 && l > 0)
+                n = (size_t) l;
+#endif
+
+            *((pa_usec_t*) data) = pa_bytes_to_usec(n, &u->source->sample_spec);
+            return 0;
+        }
+    }
+
+    return pa_source_process_msg(o, code, data, offset, chunk);
+}
+
 static void thread_func(void *userdata) {
     struct userdata *u = userdata;
     int read_type = 0;
@@ -243,6 +272,7 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    u->source->parent.process_msg = source_process_msg;
     u->source->userdata = u;
 
     pa_source_set_asyncmsgq(u->source, u->thread_mq.inq);

commit 03aa91dea735a38aa0c3a581ede315b736ecc25b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Dec 21 17:55:29 2008 +0100

    make sure we don't hit an assert when we issue two rewind requests in a
    single iteration
    
    Closes rhbz 472757.

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index d4e0a9c..d25cd79 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1194,7 +1194,8 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sam
      * implementor. This implies 'flush' is TRUE. */
 
     pa_sink_input_assert_ref(i);
-    pa_assert(i->thread_info.rewrite_nbytes == 0);
+
+    nbytes = PA_MAX(i->thread_info.rewrite_nbytes, nbytes);
 
 /*     pa_log_debug("request rewrite %lu", (unsigned long) nbytes); */
 
@@ -1222,26 +1223,33 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sam
             nbytes = pa_resampler_request(i->thread_info.resampler, nbytes);
     }
 
-    if (rewrite) {
-        /* Make sure to not overwrite over underruns */
-        if (nbytes > i->thread_info.playing_for)
-            nbytes = (size_t) i->thread_info.playing_for;
+    if (i->thread_info.rewrite_nbytes != (size_t) -1) {
+        if (rewrite) {
+            /* Make sure to not overwrite over underruns */
+            if (nbytes > i->thread_info.playing_for)
+                nbytes = (size_t) i->thread_info.playing_for;
 
-        i->thread_info.rewrite_nbytes = nbytes;
-    } else
-        i->thread_info.rewrite_nbytes = (size_t) -1;
+            i->thread_info.rewrite_nbytes = nbytes;
+        } else
+            i->thread_info.rewrite_nbytes = (size_t) -1;
+    }
 
-    i->thread_info.rewrite_flush = flush && i->thread_info.rewrite_nbytes != 0;
+    i->thread_info.rewrite_flush =
+        i->thread_info.rewrite_flush ||
+        (flush && i->thread_info.rewrite_nbytes != 0);
 
-    /* Transform to sink domain */
-    if (i->thread_info.resampler)
-        nbytes = pa_resampler_result(i->thread_info.resampler, nbytes);
+    if (nbytes != (size_t) -1) {
 
-    if (nbytes > lbq)
-        pa_sink_request_rewind(i->sink, nbytes - lbq);
-    else
-        /* This call will make sure process_rewind() is called later */
-        pa_sink_request_rewind(i->sink, 0);
+        /* Transform to sink domain */
+        if (i->thread_info.resampler)
+            nbytes = pa_resampler_result(i->thread_info.resampler, nbytes);
+
+        if (nbytes > lbq)
+            pa_sink_request_rewind(i->sink, nbytes - lbq);
+        else
+            /* This call will make sure process_rewind() is called later */
+            pa_sink_request_rewind(i->sink, 0);
+    }
 }
 
 /* Called from main context */

commit 5db081a89887e968bdf7e44375f2e25189822c6f
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Wed Dec 17 10:47:08 2008 -0300

    Disable warnings for bluetooth-device-module.

diff --git a/src/Makefile.am b/src/Makefile.am
index b9d0083..f3bd550 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1381,12 +1381,12 @@ libbluetooth_sbc_la_CFLAGS = $(AM_CFLAGS)
 libbluetooth_ipc_la_SOURCES = modules/bluetooth/ipc.c modules/bluetooth/ipc.h
 libbluetooth_ipc_la_LDFLAGS = -avoid-version
 libbluetooth_ipc_la_LIBADD = $(AM_LIBADD)libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
-libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS)
+libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS) -w
 
 module_bluetooth_device_la_SOURCES = modules/bluetooth/module-bluetooth-device.c modules/bluetooth/rtp.h
 module_bluetooth_device_la_LDFLAGS = -module -avoid-version
 module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
-module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
+module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -w
 
 # Apple Airtunes/RAOP
 module_raop_sink_la_SOURCES = modules/module-raop-sink.c

commit 7323e1a0a85cb61f92749d9ca88339cea0bfa9c7
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Wed Dec 17 17:19:22 2008 -0300

    Update module-bluetooth-device to the new ipc.

diff --git a/src/modules/bluetooth/ipc.c b/src/modules/bluetooth/ipc.c
index 9825699..6778530 100644
--- a/src/modules/bluetooth/ipc.c
+++ b/src/modules/bluetooth/ipc.c
@@ -22,22 +22,26 @@
 
 #include "ipc.h"
 
-/* This table contains the string representation for messages */
-static const char *strmsg[] = {
-	"BT_GETCAPABILITIES_REQ",
-	"BT_GETCAPABILITIES_RSP",
-	"BT_SETCONFIGURATION_REQ",
-	"BT_SETCONFIGURATION_RSP",
-	"BT_STREAMSTART_REQ",
-	"BT_STREAMSTART_RSP",
-	"BT_STREAMSTOP_REQ",
-	"BT_STREAMSTOP_RSP",
-	"BT_STREAMSUSPEND_IND",
-	"BT_STREAMRESUME_IND",
-	"BT_CONTROL_REQ",
-	"BT_CONTROL_RSP",
-	"BT_CONTROL_IND",
-	"BT_STREAMFD_IND",
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
+
+/* This table contains the string representation for messages types */
+static const char *strtypes[] = {
+	"BT_REQUEST",
+	"BT_RESPONSE",
+	"BT_INDICATION",
+	"BT_ERROR",
+};
+
+/* This table contains the string representation for messages names */
+static const char *strnames[] = {
+	"BT_GET_CAPABILITIES",
+	"BT_SET_CONFIGURATION",
+	"BT_NEW_STREAM",
+	"BT_START_STREAM",
+	"BT_STOP_STREAM",
+	"BT_SUSPEND_STREAM",
+	"BT_RESUME_STREAM",
+	"BT_CONTROL",
 };
 
 int bt_audio_service_open(void)
@@ -88,7 +92,7 @@ int bt_audio_service_get_data_fd(int sk)
 	msgh.msg_control = &cmsg_b;
 	msgh.msg_controllen = CMSG_LEN(sizeof(int));
 
-	ret = (int) recvmsg(sk, &msgh, 0);
+	ret = recvmsg(sk, &msgh, 0);
 	if (ret < 0) {
 		err = errno;
 		fprintf(stderr, "%s: Unable to receive fd: %s (%d)\n",
@@ -109,10 +113,18 @@ int bt_audio_service_get_data_fd(int sk)
 	return -1;
 }
 
-const char *bt_audio_strmsg(int type)
+const char *bt_audio_strtype(uint8_t type)
+{
+	if (type >= ARRAY_SIZE(strtypes))
+		return NULL;
+
+	return strtypes[type];
+}
+
+const char *bt_audio_strname(uint8_t name)
 {
-    if (type < 0 || (size_t) type > (sizeof(strmsg) / sizeof(strmsg[0])))
+	if (name >= ARRAY_SIZE(strnames))
 		return NULL;
 
-	return strmsg[type];
+	return strnames[name];
 }
diff --git a/src/modules/bluetooth/ipc.h b/src/modules/bluetooth/ipc.h
index ae85e72..0e985c3 100644
--- a/src/modules/bluetooth/ipc.h
+++ b/src/modules/bluetooth/ipc.h
@@ -23,36 +23,36 @@
 /*
   Message sequence chart of streaming sequence for A2DP transport
 
-  Audio daemon                       User
-                             on snd_pcm_open
-                 <--BT_GETCAPABILITIES_REQ
+  Audio daemon			User
+				on snd_pcm_open
+				<--BT_GET_CAPABILITIES_REQ
 
-  BT_GETCAPABILITIES_RSP-->
+  BT_GET_CAPABILITIES_RSP-->
 
-                        on snd_pcm_hw_params
-                <--BT_SETCONFIGURATION_REQ
+				on snd_pcm_hw_params
+				<--BT_SETCONFIGURATION_REQ
 
-  BT_SETCONFIGURATION_RSP-->
+  BT_SET_CONFIGURATION_RSP-->
 
-			on snd_pcm_prepare
-                <--BT_STREAMSTART_REQ
+				on snd_pcm_prepare
+				<--BT_START_STREAM_REQ
 
   <Moves to streaming state>
-  BT_STREAMSTART_RSP-->
+  BT_START_STREAM_RSP-->
 
-  BT_STREAMFD_IND -->
+  BT_NEW_STREAM_IND -->
 
-                          <  streams data >
-                             ..........
+				<  streams data >
+				..........
 
-               on snd_pcm_drop/snd_pcm_drain
+				on snd_pcm_drop/snd_pcm_drain
 
-                <--BT_STREAMSTOP_REQ
+				<--BT_STOP_STREAM_REQ
 
   <Moves to open state>
-  BT_STREAMSTOP_RSP-->
+  BT_STOP_STREAM_RSP-->
 
-			on IPC close or appl crash
+				on IPC close or appl crash
   <Moves to idle>
 
  */
@@ -71,43 +71,36 @@ extern "C" {
 #include <sys/un.h>
 #include <errno.h>
 
-#define BT_AUDIO_IPC_PACKET_SIZE   128
+#define BT_SUGGESTED_BUFFER_SIZE   128
 #define BT_IPC_SOCKET_NAME "\0/org/bluez/audio"
 
-/* Generic message header definition, except for RSP messages */
+/* Generic message header definition, except for RESPONSE messages */
 typedef struct {
-	uint8_t msg_type;
+	uint8_t type;
+	uint8_t name;
+	uint16_t length;
 } __attribute__ ((packed)) bt_audio_msg_header_t;
 
-/* Generic message header definition, for all RSP messages */
 typedef struct {
-	bt_audio_msg_header_t	msg_h;
-	uint8_t			posix_errno;
-} __attribute__ ((packed)) bt_audio_rsp_msg_header_t;
-
-/* Messages list */
-#define BT_GETCAPABILITIES_REQ		0
-#define BT_GETCAPABILITIES_RSP		1
-
-#define BT_SETCONFIGURATION_REQ		2
-#define BT_SETCONFIGURATION_RSP		3
-
-#define BT_STREAMSTART_REQ		4
-#define BT_STREAMSTART_RSP		5
-
-#define BT_STREAMSTOP_REQ		6
-#define BT_STREAMSTOP_RSP		7
-
-#define BT_STREAMSUSPEND_IND		8
-#define BT_STREAMRESUME_IND		9
-
-#define BT_CONTROL_REQ		       10
-#define BT_CONTROL_RSP		       11
-#define BT_CONTROL_IND		       12
-
-#define BT_STREAMFD_IND		       13
-
-/* BT_GETCAPABILITIES_REQ */
+	bt_audio_msg_header_t h;
+	uint8_t posix_errno;
+} __attribute__ ((packed)) bt_audio_error_t;
+
+/* Message types */
+#define BT_REQUEST			0
+#define BT_RESPONSE			1
+#define BT_INDICATION			2
+#define BT_ERROR			3
+
+/* Messages names */
+#define BT_GET_CAPABILITIES		0
+#define BT_SET_CONFIGURATION		1
+#define BT_NEW_STREAM			2
+#define BT_START_STREAM			3
+#define BT_STOP_STREAM			4
+#define BT_SUSPEND_STREAM		5
+#define BT_RESUME_STREAM		6
+#define BT_CONTROL			7
 
 #define BT_CAPABILITIES_TRANSPORT_A2DP	0
 #define BT_CAPABILITIES_TRANSPORT_SCO	1
@@ -119,19 +112,22 @@ typedef struct {
 
 #define BT_FLAG_AUTOCONNECT	1
 
-struct bt_getcapabilities_req {
+struct bt_get_capabilities_req {
 	bt_audio_msg_header_t	h;
 	char			device[18];	/* Address of the remote Device */
 	uint8_t			transport;	/* Requested transport */
 	uint8_t			flags;		/* Requested flags */
 } __attribute__ ((packed));
 
-/* BT_GETCAPABILITIES_RSP */
-
 /**
  * SBC Codec parameters as per A2DP profile 1.0 § 4.3
  */
 
+#define BT_A2DP_CODEC_SBC			0x00
+#define BT_A2DP_CODEC_MPEG12			0x01
+#define BT_A2DP_CODEC_MPEG24			0x02
+#define BT_A2DP_CODEC_ATRAC			0x03
+
 #define BT_SBC_SAMPLING_FREQ_16000		(1 << 3)
 #define BT_SBC_SAMPLING_FREQ_32000		(1 << 2)
 #define BT_SBC_SAMPLING_FREQ_44100		(1 << 1)
@@ -164,7 +160,19 @@ struct bt_getcapabilities_req {
 #define BT_MPEG_LAYER_2				(1 << 1)
 #define BT_MPEG_LAYER_3				1
 
+#define BT_HFP_CODEC_PCM			0x00
+
+#define BT_PCM_FLAG_NREC			1
+
+typedef struct {
+	uint8_t transport;
+	uint8_t type;
+	uint8_t length;
+	uint8_t data[0];
+} __attribute__ ((packed)) codec_capabilities_t;
+
 typedef struct {
+	codec_capabilities_t capability;
 	uint8_t channel_mode;
 	uint8_t frequency;
 	uint8_t allocation_method;
@@ -175,6 +183,7 @@ typedef struct {
 } __attribute__ ((packed)) sbc_capabilities_t;
 
 typedef struct {
+	codec_capabilities_t capability;
 	uint8_t channel_mode;
 	uint8_t crc;
 	uint8_t layer;
@@ -183,75 +192,65 @@ typedef struct {
 	uint16_t bitrate;
 } __attribute__ ((packed)) mpeg_capabilities_t;
 
-struct bt_getcapabilities_rsp {
-	bt_audio_rsp_msg_header_t	rsp_h;
-	uint8_t				transport;	   /* Granted transport */
-	sbc_capabilities_t		sbc_capabilities;  /* A2DP only */
-	mpeg_capabilities_t		mpeg_capabilities; /* A2DP only */
-	uint16_t			sampling_rate;	   /* SCO only */
+typedef struct {
+	codec_capabilities_t capability;
+	uint8_t flags;
+	uint16_t sampling_rate;
+} __attribute__ ((packed)) pcm_capabilities_t;
+
+
+struct bt_get_capabilities_rsp {
+	bt_audio_msg_header_t	h;
+	uint8_t			data[0];	/* First codec_capabilities_t */
 } __attribute__ ((packed));
 
-/* BT_SETCONFIGURATION_REQ */
-struct bt_setconfiguration_req {
+struct bt_set_configuration_req {
 	bt_audio_msg_header_t	h;
-	char			device[18];		/* Address of the remote Device */
-	uint8_t			transport;		/* Requested transport */
-	uint8_t			access_mode;		/* Requested access mode */
-	sbc_capabilities_t	sbc_capabilities;	/* A2DP only - only one of this field
-							and next one must be filled */
-	mpeg_capabilities_t	mpeg_capabilities;	/* A2DP only */
+	char			device[18];	/* Address of the remote Device */
+	uint8_t			access_mode;	/* Requested access mode */
+	codec_capabilities_t	codec;		/* Requested codec */
 } __attribute__ ((packed));
 
-/* BT_SETCONFIGURATION_RSP */
-struct bt_setconfiguration_rsp {
-	bt_audio_rsp_msg_header_t	rsp_h;
-	uint8_t				transport;	/* Granted transport */
-	uint8_t				access_mode;	/* Granted access mode */
-	uint16_t			link_mtu;	/* Max length that transport supports */
+struct bt_set_configuration_rsp {
+	bt_audio_msg_header_t	h;
+	uint8_t			transport;	/* Granted transport */
+	uint8_t			access_mode;	/* Granted access mode */
+	uint16_t		link_mtu;	/* Max length that transport supports */
 } __attribute__ ((packed));
 
-/* BT_STREAMSTART_REQ */
 #define BT_STREAM_ACCESS_READ		0
 #define BT_STREAM_ACCESS_WRITE		1
 #define BT_STREAM_ACCESS_READWRITE	2
-struct bt_streamstart_req {
+struct bt_start_stream_req {
 	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_STREAMSTART_RSP */
-struct bt_streamstart_rsp {
-	bt_audio_rsp_msg_header_t	rsp_h;
+struct bt_start_stream_rsp {
+	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_STREAMFD_IND */
 /* This message is followed by one byte of data containing the stream data fd
    as ancilliary data */
-struct bt_streamfd_ind {
+struct bt_new_stream_ind {
 	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_STREAMSTOP_REQ */
-struct bt_streamstop_req {
+struct bt_stop_stream_req {
 	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_STREAMSTOP_RSP */
-struct bt_streamstop_rsp {
-	bt_audio_rsp_msg_header_t	rsp_h;
+struct bt_stop_stream_rsp {
+	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_STREAMSUSPEND_IND */
-struct bt_streamsuspend_ind {
+struct bt_suspend_stream_ind {
 	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_STREAMRESUME_IND */
-struct bt_streamresume_ind {
+struct bt_resume_stream_ind {
 	bt_audio_msg_header_t	h;
 } __attribute__ ((packed));
 
-/* BT_CONTROL_REQ */
-
 #define BT_CONTROL_KEY_POWER			0x40
 #define BT_CONTROL_KEY_VOL_UP			0x41
 #define BT_CONTROL_KEY_VOL_DOWN			0x42
@@ -272,14 +271,12 @@ struct bt_control_req {
 	uint8_t			key;		/* Control Key */
 } __attribute__ ((packed));
 
-/* BT_CONTROL_RSP */
 struct bt_control_rsp {
-	bt_audio_rsp_msg_header_t	rsp_h;
-	uint8_t				mode;	/* Control Mode */
-	uint8_t				key;	/* Control Key */
+	bt_audio_msg_header_t	h;
+	uint8_t			mode;		/* Control Mode */
+	uint8_t			key;		/* Control Key */
 } __attribute__ ((packed));
 
-/* BT_CONTROL_IND */
 struct bt_control_ind {
 	bt_audio_msg_header_t	h;
 	uint8_t			mode;		/* Control Mode */
@@ -299,7 +296,10 @@ BT_STREAMFD_IND message is returned */
 int bt_audio_service_get_data_fd(int sk);
 
 /* Human readable message type string */
-const char *bt_audio_strmsg(int type);
+const char *bt_audio_strtype(uint8_t type);
+
+/* Human readable message name string */
+const char *bt_audio_strname(uint8_t name);
 
 #ifdef __cplusplus
 }
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 3460fe9..5974d48 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -122,8 +122,12 @@ static const char* const valid_modargs[] = {
 
 static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) {
     int e;
-    pa_log_debug("sending %s", bt_audio_strmsg(msg->msg_type));
-    if (send(sk, msg, BT_AUDIO_IPC_PACKET_SIZE, 0) > 0)
+    const char *type, *name;
+
+    type = bt_audio_strtype(msg->type);
+    name = bt_audio_strname(msg->name);
+    pa_log_debug("sending: %s -> %s", type, name);
+    if (send(sk, msg, BT_SUGGESTED_BUFFER_SIZE, 0) > 0)
         e = 0;
     else {
         e = -errno;
@@ -132,20 +136,22 @@ static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) {
     return e;
 }
 
-static int bt_audioservice_recv(int sk, bt_audio_msg_header_t *inmsg) {
+static int bt_audioservice_recv(int sk, bt_audio_msg_header_t *inmsg, uint16_t expected_length) {
     int e;
-    const char *type;
+    const char *type, *name;
 
     pa_log_debug("trying to receive msg from audio service...");
-    if (recv(sk, inmsg, BT_AUDIO_IPC_PACKET_SIZE, 0) > 0) {
-        type = bt_audio_strmsg(inmsg->msg_type);
-        if (type) {
-            pa_log_debug("Received %s", type);
+    if (recv(sk, inmsg, expected_length ? : BT_SUGGESTED_BUFFER_SIZE, 0) > 0) {
+        type = bt_audio_strtype(inmsg->type);
+        name = bt_audio_strname(inmsg->name);
+        if (type && name) {
+            pa_log_debug("Received: %s <- %s", type, name);
             e = 0;
         }
         else {
             e = -EINVAL;
-            pa_log_error("Bogus message type %d received from audio service", inmsg->msg_type);
+            pa_log_error("Bogus message type %d name %d received from audio service",
+                        inmsg->type, inmsg->name);
         }
     }
     else {
@@ -156,29 +162,66 @@ static int bt_audioservice_recv(int sk, bt_audio_msg_header_t *inmsg) {
     return e;
 }
 
-static int bt_audioservice_expect(int sk, bt_audio_msg_header_t *rsp_hdr, int expected_type) {
-    int e = bt_audioservice_recv(sk, rsp_hdr);
-    if (e == 0) {
-        if (rsp_hdr->msg_type != expected_type) {
+static int bt_audioservice_expect(int sk, bt_audio_msg_header_t *rsp, uint8_t expected_name, uint16_t expected_length) {
+    int e = bt_audioservice_recv(sk, rsp, expected_length);
+
+    if (e < 0) {
+        if (rsp->name != expected_name) {
             e = -EINVAL;
-            pa_log_error("Bogus message %s received while %s was expected", bt_audio_strmsg(rsp_hdr->msg_type),
-                    bt_audio_strmsg(expected_type));
+            pa_log_error("Bogus message %s received while %s was expected",
+                    bt_audio_strname(rsp->name),
+                    bt_audio_strname(expected_name));
         }
     }
+
+    if (rsp->type == BT_ERROR) {
+        bt_audio_error_t *error = (void *) rsp;
+        pa_log_error("%s failed : %s(%d)", bt_audio_strname(rsp->name), pa_cstrerror(error->posix_errno), error->posix_errno);
+        return -error->posix_errno;
+    }
+
     return e;
 }
 
+static int bt_parsecaps(struct userdata *u, struct bt_get_capabilities_rsp *rsp) {
+    uint16_t bytes_left = rsp->h.length - sizeof(*rsp);
+    codec_capabilities_t *codec = (void *) rsp->data;
+
+    u->transport = codec->transport;
+
+    if (codec->transport != BT_CAPABILITIES_TRANSPORT_A2DP)
+        return 0;
+
+    while (bytes_left > 0) {
+        if (codec->type == BT_A2DP_CODEC_SBC)
+            break;
+
+        bytes_left -= codec->length;
+        codec = (void *) (codec + codec->length);
+    }
+
+    if (bytes_left <= 0 || codec->length != sizeof(u->a2dp.sbc_capabilities))
+        return -EINVAL;
+
+    memcpy(&u->a2dp.sbc_capabilities, codec, codec->length);
+
+    return 0;
+}
+
 static int bt_getcaps(struct userdata *u) {
     int e;
     union {
-        bt_audio_rsp_msg_header_t rsp_hdr;
-        struct bt_getcapabilities_req getcaps_req;
-        struct bt_getcapabilities_rsp getcaps_rsp;
-        uint8_t buf[BT_AUDIO_IPC_PACKET_SIZE];
+        bt_audio_msg_header_t rsp;
+        struct bt_get_capabilities_req getcaps_req;
+        struct bt_get_capabilities_rsp getcaps_rsp;
+        uint8_t buf[BT_SUGGESTED_BUFFER_SIZE];
     } msg;
 
-    memset(msg.buf, 0, BT_AUDIO_IPC_PACKET_SIZE);
-    msg.getcaps_req.h.msg_type = BT_GETCAPABILITIES_REQ;
+    memset(msg.buf, 0, BT_SUGGESTED_BUFFER_SIZE);
+    msg.getcaps_req.h.type = BT_REQUEST;
+    msg.getcaps_req.h.name = BT_GET_CAPABILITIES;
+    msg.getcaps_req.h.length = sizeof(msg.getcaps_req);
+
     strncpy(msg.getcaps_req.device, u->addr, 18);
     if (strcasecmp(u->profile, "a2dp") == 0)
         msg.getcaps_req.transport = BT_CAPABILITIES_TRANSPORT_A2DP;
@@ -196,20 +239,13 @@ static int bt_getcaps(struct userdata *u) {
         return e;
     }
 
-    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp_hdr.msg_h, BT_GETCAPABILITIES_RSP);
+    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp, BT_GET_CAPABILITIES, 0);
     if (e < 0) {
         pa_log_error("Failed to expect for GETCAPABILITIES_RSP");
         return e;
     }
-    if (msg.rsp_hdr.posix_errno != 0) {
-        pa_log_error("BT_GETCAPABILITIES failed : %s (%d)", pa_cstrerror(msg.rsp_hdr.posix_errno), msg.rsp_hdr.posix_errno);
-        return -msg.rsp_hdr.posix_errno;
-    }
-
-    if ((u->transport = msg.getcaps_rsp.transport) == BT_CAPABILITIES_TRANSPORT_A2DP)
-        u->a2dp.sbc_capabilities = msg.getcaps_rsp.sbc_capabilities;
 
-    return 0;
+    return bt_parsecaps(u, &msg.getcaps_rsp);
 }
 
 static uint8_t default_bitpool(uint8_t freq, uint8_t mode) {
@@ -393,10 +429,10 @@ static void bt_a2dp_setup(struct bt_a2dp *a2dp) {
 static int bt_setconf(struct userdata *u) {
     int e;
     union {
-        bt_audio_rsp_msg_header_t rsp_hdr;
-        struct bt_setconfiguration_req setconf_req;
-        struct bt_setconfiguration_rsp setconf_rsp;
-        uint8_t buf[BT_AUDIO_IPC_PACKET_SIZE];
+        bt_audio_msg_header_t rsp;
+        struct bt_set_configuration_req setconf_req;
+        struct bt_set_configuration_rsp setconf_rsp;
+        uint8_t buf[BT_SUGGESTED_BUFFER_SIZE];
     } msg;
 
     if (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP) {
@@ -410,12 +446,16 @@ static int bt_setconf(struct userdata *u) {
     else
         u->ss.format = PA_SAMPLE_U8;
 
-    memset(msg.buf, 0, BT_AUDIO_IPC_PACKET_SIZE);
-    msg.setconf_req.h.msg_type = BT_SETCONFIGURATION_REQ;
+    memset(msg.buf, 0, BT_SUGGESTED_BUFFER_SIZE);
+    msg.setconf_req.h.type = BT_REQUEST;
+    msg.setconf_req.h.name = BT_SET_CONFIGURATION;
+    msg.setconf_req.h.length = sizeof(msg.setconf_req);
+
     strncpy(msg.setconf_req.device, u->addr, 18);
-    msg.setconf_req.transport = u->transport;
+    msg.setconf_req.codec.transport = u->transport;
     if (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP)
-        msg.setconf_req.sbc_capabilities = u->a2dp.sbc_capabilities;
+        memcpy(&msg.setconf_req.codec, &u->a2dp.sbc_capabilities,
+                sizeof(u->a2dp.sbc_capabilities));
     msg.setconf_req.access_mode = BT_CAPABILITIES_ACCESS_MODE_WRITE;
 
     e = bt_audioservice_send(u->audioservice_fd, &msg.setconf_req.h);
@@ -424,17 +464,12 @@ static int bt_setconf(struct userdata *u) {
         return e;
     }
 
-    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp_hdr.msg_h, BT_SETCONFIGURATION_RSP);
+    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp, BT_SET_CONFIGURATION, sizeof(msg.setconf_rsp));
     if (e < 0) {
         pa_log_error("Failed to expect BT_SETCONFIGURATION_RSP");
         return e;
     }
 
-    if (msg.rsp_hdr.posix_errno != 0) {
-        pa_log_error("BT_SETCONFIGURATION failed : %s(%d)", pa_cstrerror(msg.rsp_hdr.posix_errno), msg.rsp_hdr.posix_errno);
-        return -msg.rsp_hdr.posix_errno;
-    }
-
     u->transport = msg.setconf_rsp.transport;
     u->strtransport = (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP ? pa_xstrdup("A2DP") : pa_xstrdup("SCO"));
     u->link_mtu = msg.setconf_rsp.link_mtu;
@@ -456,14 +491,17 @@ static int bt_getstreamfd(struct userdata *u) {
     int e;
 //    uint32_t period_count = io->buffer_size / io->period_size;
     union {
-        bt_audio_rsp_msg_header_t rsp_hdr;
-        struct bt_streamstart_req start_req;
-        struct bt_streamfd_ind streamfd_ind;
-        uint8_t buf[BT_AUDIO_IPC_PACKET_SIZE];
+        bt_audio_msg_header_t rsp;
+        struct bt_start_stream_req start_req;
+        struct bt_start_stream_rsp start_rsp;
+        struct bt_new_stream_ind streamfd_ind;
+        uint8_t buf[BT_SUGGESTED_BUFFER_SIZE];
     } msg;
 
-    memset(msg.buf, 0, BT_AUDIO_IPC_PACKET_SIZE);
-    msg.start_req.h.msg_type = BT_STREAMSTART_REQ;
+    memset(msg.buf, 0, BT_SUGGESTED_BUFFER_SIZE);
+    msg.start_req.h.type = BT_REQUEST;
+    msg.start_req.h.name = BT_START_STREAM;
+    msg.start_req.h.length = sizeof(msg.start_req);
 
     e = bt_audioservice_send(u->audioservice_fd, &msg.start_req.h);
     if (e < 0) {
@@ -471,18 +509,13 @@ static int bt_getstreamfd(struct userdata *u) {
         return e;
     }
 
-    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp_hdr.msg_h, BT_STREAMSTART_RSP);
+    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp, BT_START_STREAM, sizeof(msg.start_rsp));
     if (e < 0) {
         pa_log_error("Failed to expect BT_STREAMSTART_RSP");
         return e;
     }
 
-    if (msg.rsp_hdr.posix_errno != 0) {
-        pa_log_error("BT_START failed : %s(%d)", pa_cstrerror(msg.rsp_hdr.posix_errno), msg.rsp_hdr.posix_errno);
-        return -msg.rsp_hdr.posix_errno;
-    }
-
-    e = bt_audioservice_expect(u->audioservice_fd, &msg.streamfd_ind.h, BT_STREAMFD_IND);
+    e = bt_audioservice_expect(u->audioservice_fd, &msg.rsp, BT_NEW_STREAM, sizeof(msg.streamfd_ind));
     if (e < 0) {
         pa_log_error("Failed to expect BT_STREAMFD_IND");
         return e;

commit 22c3373713dabb0060ad1ee469ffa007ffe25846
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 23 15:14:28 2008 +0100

    If we cannot open an ALSA device with SND_PCM_NO_AUTO_FORMAT retry without
    
    This should fix compatibility with some sound cards which only support
    24 bit packed samples.

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 7ae538a..203bdcd 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -556,6 +556,7 @@ snd_pcm_t *pa_alsa_open_by_device_id(
 
     for (i = 0;; i += direction) {
         pa_sample_spec try_ss;
+        pa_bool_t reformat;
 
         if (i < 0) {
             pa_assert(direction == -1);
@@ -580,8 +581,9 @@ snd_pcm_t *pa_alsa_open_by_device_id(
 
         d = pa_sprintf_malloc("%s:%s", device_table[i].name, dev_id);
 
+        reformat = FALSE;
         for (;;) {
-            pa_log_debug("Trying %s...", d);
+            pa_log_debug("Trying %s %s SND_PCM_NO_AUTO_FORMAT ...", d, reformat ? "without" : "with");
 
             /* We don't pass SND_PCM_NONBLOCK here, since alsa-lib <=
              * 1.0.17a would then ignore the SND_PCM_NO_xxx
@@ -593,7 +595,7 @@ snd_pcm_t *pa_alsa_open_by_device_id(
                                     /* SND_PCM_NONBLOCK| */
                                     SND_PCM_NO_AUTO_RESAMPLE|
                                     SND_PCM_NO_AUTO_CHANNELS|
-                                    SND_PCM_NO_AUTO_FORMAT)) < 0) {
+                                    (reformat ? 0 : SND_PCM_NO_AUTO_FORMAT))) < 0) {
                 pa_log_info("Couldn't open PCM device %s: %s", d, snd_strerror(err));
                 break;
             }
@@ -604,6 +606,12 @@ snd_pcm_t *pa_alsa_open_by_device_id(
 
             if ((err = pa_alsa_set_hw_params(pcm_handle, &try_ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, TRUE)) < 0) {
 
+                if (!reformat) {
+                    reformat = TRUE;
+                    snd_pcm_close(pcm_handle);
+                    continue;
+                }
+
                 if (!pa_startswith(d, "plug:") && !pa_startswith(d, "plughw:")) {
                     char *t;
 
@@ -611,6 +619,8 @@ snd_pcm_t *pa_alsa_open_by_device_id(
                     pa_xfree(d);
                     d = t;
 
+                    reformat = FALSE;
+
                     snd_pcm_close(pcm_handle);
                     continue;
                 }
@@ -655,6 +665,7 @@ snd_pcm_t *pa_alsa_open_by_device_string(
     int err;
     char *d;
     snd_pcm_t *pcm_handle;
+    pa_bool_t reformat = FALSE;
 
     pa_assert(device);
     pa_assert(dev);
@@ -666,7 +677,7 @@ snd_pcm_t *pa_alsa_open_by_device_string(
     d = pa_xstrdup(device);
 
     for (;;) {
-        pa_log_debug("Trying %s...", d);
+        pa_log_debug("Trying %s %s SND_PCM_NO_AUTO_FORMAT ...", d, reformat ? "without" : "with");
 
         /* We don't pass SND_PCM_NONBLOCK here, since alsa-lib <=
          * 1.0.17a would then ignore the SND_PCM_NO_xxx flags. Instead
@@ -678,7 +689,7 @@ snd_pcm_t *pa_alsa_open_by_device_string(
                                 /*SND_PCM_NONBLOCK|*/
                                 SND_PCM_NO_AUTO_RESAMPLE|
                                 SND_PCM_NO_AUTO_CHANNELS|
-                                SND_PCM_NO_AUTO_FORMAT)) < 0) {
+                                (reformat ? 0 : SND_PCM_NO_AUTO_FORMAT))) < 0) {
             pa_log("Error opening PCM device %s: %s", d, snd_strerror(err));
             pa_xfree(d);
             return NULL;
@@ -686,6 +697,13 @@ snd_pcm_t *pa_alsa_open_by_device_string(
 
         if ((err = pa_alsa_set_hw_params(pcm_handle, ss, nfrags, period_size, tsched_size, use_mmap, use_tsched, FALSE)) < 0) {
 
+            if (!reformat) {
+                reformat = TRUE;
+
+                snd_pcm_close(pcm_handle);
+                continue;
+            }
+
             /* Hmm, some hw is very exotic, so we retry with plug, if without it didn't work */
 
             if (!pa_startswith(d, "plug:") && !pa_startswith(d, "plughw:")) {
@@ -695,6 +713,8 @@ snd_pcm_t *pa_alsa_open_by_device_string(
                 pa_xfree(d);
                 d = t;
 
+                reformat = FALSE;
+
                 snd_pcm_close(pcm_handle);
                 continue;
             }

commit c2bd8dc517f825858e747343bd9fc3a88ac75776
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 23 15:15:21 2008 +0100

    fix a gcc warning

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 203bdcd..75b84c4 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -1159,7 +1159,7 @@ snd_pcm_sframes_t pa_alsa_safe_avail_update(snd_pcm_t *pcm, size_t hwbuf_size, c
         k >= pa_bytes_per_second(ss)*10)
         pa_log("snd_pcm_avail_update() returned a value that is exceptionally large: %lu bytes (%lu ms) "
                "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
-               (unsigned long) k, (unsigned long) pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC);
+               (unsigned long) k, (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC));
 
     return n;
 }
@@ -1191,7 +1191,7 @@ int pa_alsa_safe_mmap_begin(snd_pcm_t *pcm, const snd_pcm_channel_area_t **areas
 
         pa_log("snd_pcm_mmap_begin() returned a value that is exceptionally large: %lu bytes (%lu ms) "
                "Most likely this is an ALSA driver bug. Please report this issue to the PulseAudio developers.",
-               (unsigned long) k, (unsigned long) pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC);
+               (unsigned long) k, (unsigned long) (pa_bytes_to_usec(k, ss) / PA_USEC_PER_MSEC));
 
     return r;
 }

commit f24e4c19c33b534e5f15d6ae227d07ae7755e644
Merge: c2bd8dc... 7323e1a...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Dec 23 18:31:12 2008 +0100

    Merge commit 'vudentz/master'


commit fe2b8c359b505dfa4c5fb75f223fc35c7ecdfd4b
Author: Tom Bamford <tom at tombamford.co.uk>
Date:   Sat Dec 20 23:44:09 2008 +0200

    Multicast SDP packets sent with same IP TTL as RTP packets
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/modules/rtp/module-rtp-send.c b/src/modules/rtp/module-rtp-send.c
index 8d1e92f..9c0f07f 100644
--- a/src/modules/rtp/module-rtp-send.c
+++ b/src/modules/rtp/module-rtp-send.c
@@ -296,6 +296,11 @@ int pa__init(pa_module*m) {
             pa_log("IP_MULTICAST_TTL failed: %s", pa_cstrerror(errno));
             goto fail;
         }
+
+        if (setsockopt(sap_fd, IPPROTO_IP, IP_MULTICAST_TTL, &_ttl, sizeof(_ttl)) < 0) {
+            pa_log("IP_MULTICAST_TTL (sap) failed: %s", pa_cstrerror(errno));
+            goto fail;
+        }
     }
 
     /* If the socket queue is full, let's drop packets */

commit be49c92a381d433704438c810ce8e1b09b9aa550
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Mon Jan 5 19:12:43 2009 -0300

    Send packets with proper size.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 5974d48..492ee20 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -127,7 +127,7 @@ static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) {
     type = bt_audio_strtype(msg->type);
     name = bt_audio_strname(msg->name);
     pa_log_debug("sending: %s -> %s", type, name);
-    if (send(sk, msg, BT_SUGGESTED_BUFFER_SIZE, 0) > 0)
+    if (send(sk, msg, msg->length, 0) > 0)
         e = 0;
     else {
         e = -errno;

commit 1a96c9b0a6dceeeb1701703fef8bdb15572662cf
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Tue Jan 6 11:00:44 2009 -0300

    Fix send and recv message sizes.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 492ee20..2546c69 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -123,11 +123,13 @@ static const char* const valid_modargs[] = {
 static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) {
     int e;
     const char *type, *name;
+    uint16_t length;
 
+    length = msg->length ? msg->length : BT_SUGGESTED_BUFFER_SIZE;
     type = bt_audio_strtype(msg->type);
     name = bt_audio_strname(msg->name);
     pa_log_debug("sending: %s -> %s", type, name);
-    if (send(sk, msg, msg->length, 0) > 0)
+    if (send(sk, msg, length, 0) > 0)
         e = 0;
     else {
         e = -errno;
@@ -139,9 +141,12 @@ static int bt_audioservice_send(int sk, const bt_audio_msg_header_t *msg) {
 static int bt_audioservice_recv(int sk, bt_audio_msg_header_t *inmsg, uint16_t expected_length) {
     int e;
     const char *type, *name;
+    uint16_t length;
+
+    length = expected_length ? expected_length : BT_SUGGESTED_BUFFER_SIZE;
 
     pa_log_debug("trying to receive msg from audio service...");
-    if (recv(sk, inmsg, expected_length ? : BT_SUGGESTED_BUFFER_SIZE, 0) > 0) {
+    if (recv(sk, inmsg, length, 0) > 0) {
         type = bt_audio_strtype(inmsg->type);
         name = bt_audio_strname(inmsg->name);
         if (type && name) {

commit e7e6f86bbe0dda37e906ed31144b44a83327ee02
Author: Luiz Augusto von Dentz <luiz.dentz at openbossa.org>
Date:   Tue Jan 6 11:02:16 2009 -0300

    Fix sending wrong codec capability length.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 2546c69..cb4746a 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -458,9 +458,12 @@ static int bt_setconf(struct userdata *u) {
 
     strncpy(msg.setconf_req.device, u->addr, 18);
     msg.setconf_req.codec.transport = u->transport;
-    if (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP)
+    if (u->transport == BT_CAPABILITIES_TRANSPORT_A2DP) {
         memcpy(&msg.setconf_req.codec, &u->a2dp.sbc_capabilities,
                 sizeof(u->a2dp.sbc_capabilities));
+        msg.setconf_req.h.length += msg.setconf_req.codec.length
+                                    - sizeof(msg.setconf_req.codec);
+    }
     msg.setconf_req.access_mode = BT_CAPABILITIES_ACCESS_MODE_WRITE;
 
     e = bt_audioservice_send(u->audioservice_fd, &msg.setconf_req.h);

commit 78e636e629518f67b667222bd92197f52c151b38
Author: chocolateboy <chocolate.boy at email.com>
Date:   Thu Nov 27 22:48:23 2008 +0000

    Fix typo in log message: s/Recevied/Received/
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/daemon/cpulimit.c b/src/daemon/cpulimit.c
index a909600..5f24474 100644
--- a/src/daemon/cpulimit.c
+++ b/src/daemon/cpulimit.c
@@ -167,7 +167,7 @@ static void callback(pa_mainloop_api*m, pa_io_event*e, int fd, pa_io_event_flags
     pa_assert(e == io_event);
     pa_assert(fd == the_pipe[0]);
 
-    pa_log("Recevied request to terminate due to CPU overload.");
+    pa_log("Received request to terminate due to CPU overload.");
 
     pa_read(the_pipe[0], &c, sizeof(c), NULL);
     m->quit(m, 1); /* Quit the main loop */

commit 2f681a3d18cf403eb8c3a3d2352ab5bfc0264cfd
Merge: 78e636e... e7e6f86...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Jan 7 22:59:25 2009 +0100

    Merge commit 'vudentz/master'


commit 81cd21969ade4d8f14dd0e4c99ec9a2857a15b79
Author: Sean McNamara <smcnam at gmail.com>
Date:   Wed Jan 7 23:29:16 2009 +0100

    --check: Updated manpage slightly and pulseaudio --help slightly.
    
    It's good for new users - I didn't know about the convention for
    daemon checks to only bump the exit code until, say, a year after I
    first installed Linux. Of course, we could also put an entire guide to
    using Linux in our manpage, or tell users how to check the exit code
    with $?, or how to get to the terminal, or an example script, ... (you
    can see how this would quickly get out of control). So just a little
    bit more hint should be good for now. John? Does this work for you?
    
    Sean
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/man/pulseaudio.1.xml.in b/man/pulseaudio.1.xml.in
index df82824..8810e90 100644
--- a/man/pulseaudio.1.xml.in
+++ b/man/pulseaudio.1.xml.in
@@ -72,7 +72,7 @@ USA.
     </option>
 
     <option>
-      <p><opt>--dump-resampe-methods</opt></p>
+      <p><opt>--dump-resample-methods</opt></p>
       <optdesc><p>List available audio resamplers.</p></optdesc>
     </option>
 
@@ -110,7 +110,9 @@ USA.
       <p><opt>--check</opt></p>
 
       <optdesc><p>Return 0 as return code when the PulseAudio daemon
-      is already running for the calling user.</p></optdesc>
+      is already running for the calling user, or non-zero
+      otherwise. Produces no output on the console except for errors
+      to stderr.</p></optdesc>
     </option>
 
 
diff --git a/src/daemon/cmdline.c b/src/daemon/cmdline.c
index 0bfc8a9..cc3d714 100644
--- a/src/daemon/cmdline.c
+++ b/src/daemon/cmdline.c
@@ -130,7 +130,7 @@ void pa_cmdline_help(const char *argv0) {
            "      --cleanup-shm                     Cleanup stale shared memory segments\n"
            "      --start                           Start the daemon if it is not running\n"
            "  -k  --kill                            Kill a running daemon\n"
-           "      --check                           Check for a running daemon\n\n"
+           "      --check                           Check for a running daemon (only returns exit code)\n\n"
 
            "OPTIONS:\n"
            "      --system[=BOOL]                   Run as system-wide instance\n"

commit e67bc1d752f768efb556b57aff8be4e1d82b173b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 8 01:00:39 2009 +0100

    -Wconvert is pain, let's drop it again
    
    Fascist compiler options are sometimes nice, but this one is a real
    Ober-Nazi. Let's get rid of it.

diff --git a/configure.ac b/configure.ac
index b36fec3..82f9205 100644
--- a/configure.ac
+++ b/configure.ac
@@ -95,7 +95,7 @@ if test "x$M4" = xno ; then
 fi
 
 dnl Compiler flags
-DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wno-long-long -Wvla -Wno-overlength-strings -Wconversion -Wundef -Wformat -Wlogical-op -Wpacked -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-unused-parameter -ffast-math"
+DESIRED_FLAGS="-Wall -W -Wextra -pedantic -pipe -Wno-long-long -Wvla -Wno-overlength-strings -Wundef -Wformat -Wlogical-op -Wpacked -Wformat-security -Wmissing-include-dirs -Wformat-nonliteral -Wold-style-definition -Wdeclaration-after-statement -Wfloat-equal -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wshadow -Wendif-labels -Wpointer-arith -Wcast-align -Wwrite-strings -Wno-unused-parameter -ffast-math"
 
 for flag in $DESIRED_FLAGS ; do
   CC_CHECK_CFLAGS([$flag], [CFLAGS="$CFLAGS $flag"])

commit c2450501af82d1c9d1994e4f4ce80d506d3c90ae
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 8 01:03:42 2009 +0100

    Prefer mixer controls with volumes over switches
    
    When we look for a mixer control prefer controls that have both volume
    and a mute switch over those that have only a volume switch over those
    that only have a mute switch.
    
    Originally pointed out by Adel Gadllah.

diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c
index 75b84c4..ff3af19 100644
--- a/src/modules/alsa-util.c
+++ b/src/modules/alsa-util.c
@@ -760,8 +760,32 @@ int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev) {
     return 0;
 }
 
-snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback) {
-    snd_mixer_elem_t *elem;
+static pa_bool_t elem_has_volume(snd_mixer_elem_t *elem, pa_bool_t playback) {
+    pa_assert(elem);
+
+    if (playback && snd_mixer_selem_has_playback_volume(elem))
+        return TRUE;
+
+    if (!playback && snd_mixer_selem_has_capture_volume(elem))
+        return TRUE;
+
+    return FALSE;
+}
+
+static pa_bool_t elem_has_switch(snd_mixer_elem_t *elem, pa_bool_t playback) {
+    pa_assert(elem);
+
+    if (playback && snd_mixer_selem_has_playback_switch(elem))
+        return TRUE;
+
+    if (!playback && snd_mixer_selem_has_capture_switch(elem))
+        return TRUE;
+
+    return FALSE;
+}
+
+snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback, pa_bool_t playback) {
+    snd_mixer_elem_t *elem = NULL, *fallback_elem = NULL;
     snd_mixer_selem_id_t *sid = NULL;
 
     snd_mixer_selem_id_alloca(&sid);
@@ -771,17 +795,57 @@ snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const
 
     snd_mixer_selem_id_set_name(sid, name);
 
-    if (!(elem = snd_mixer_find_selem(mixer, sid))) {
-        pa_log_info("Cannot find mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
+    if ((elem = snd_mixer_find_selem(mixer, sid))) {
+
+        if (elem_has_volume(elem, playback) &&
+            elem_has_switch(elem, playback))
+            goto success;
+
+        if (!elem_has_volume(elem, playback) &&
+            !elem_has_switch(elem, playback))
+            elem = NULL;
+    }
+
+    pa_log_info("Cannot find mixer control \"%s\" or mixer control is no combination of switch/volume.", snd_mixer_selem_id_get_name(sid));
+
+    if (fallback) {
+        snd_mixer_selem_id_set_name(sid, fallback);
+
+        if ((fallback_elem = snd_mixer_find_selem(mixer, sid))) {
+
+            if (elem_has_volume(fallback_elem, playback) &&
+                elem_has_switch(fallback_elem, playback)) {
+                elem = fallback_elem;
+                goto success;
+            }
+
+            if (!elem_has_volume(fallback_elem, playback) &&
+                !elem_has_switch(fallback_elem, playback))
+                fallback_elem = NULL;
+        }
+
+        pa_log_warn("Cannot find fallback mixer control \"%s\" or mixer control is no combination of switch/volume.", snd_mixer_selem_id_get_name(sid));
+    }
+
+    if (elem && fallback_elem) {
 
-        if (fallback) {
-            snd_mixer_selem_id_set_name(sid, fallback);
+        /* Hmm, so we have both elements, but neither has both mute
+         * and volume. Let's prefer the one with the volume */
 
-            if (!(elem = snd_mixer_find_selem(mixer, sid)))
-                pa_log_warn("Cannot find fallback mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
+        if (elem_has_volume(elem, playback))
+            goto success;
+
+        if (elem_has_volume(fallback_elem, playback)) {
+            elem = fallback_elem;
+            goto success;
         }
     }
 
+    if (!elem && fallback_elem)
+        elem = fallback_elem;
+
+success:
+
     if (elem)
         pa_log_info("Using mixer control \"%s\".", snd_mixer_selem_id_get_name(sid));
 
diff --git a/src/modules/alsa-util.h b/src/modules/alsa-util.h
index aaa01c7..95bb983 100644
--- a/src/modules/alsa-util.h
+++ b/src/modules/alsa-util.h
@@ -52,7 +52,7 @@ int pa_alsa_set_hw_params(
 int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min);
 
 int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev);
-snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback);
+snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback, pa_bool_t playback);
 
 snd_pcm_t *pa_alsa_open_by_device_id(
         const char *dev_id,
diff --git a/src/modules/module-alsa-sink.c b/src/modules/module-alsa-sink.c
index 6dea172..95a8c97 100644
--- a/src/modules/module-alsa-sink.c
+++ b/src/modules/module-alsa-sink.c
@@ -1409,7 +1409,7 @@ int pa__init(pa_module*m) {
         }
 
         if (found)
-            if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Master", "PCM")))
+            if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Master", "PCM", TRUE)))
                 found = FALSE;
 
         if (!found) {
diff --git a/src/modules/module-alsa-source.c b/src/modules/module-alsa-source.c
index f796ef1..b6c6ed1 100644
--- a/src/modules/module-alsa-source.c
+++ b/src/modules/module-alsa-source.c
@@ -1236,7 +1236,7 @@ int pa__init(pa_module*m) {
         }
 
         if (found)
-            if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Capture", "Mic")))
+            if (!(u->mixer_elem = pa_alsa_find_elem(u->mixer_handle, "Capture", "Mic", FALSE)))
                 found = FALSE;
 
         if (!found) {

commit dd9ca70759b8370db5df50ae8e84f86d01555106
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Wed Jan 7 16:33:43 2009 +0200

    build: use pkg-config for X11
    
    According to Daniel, AC_PATH_XTRA is sort-of deprecated.
    
    This patch changes the configure arguments, --x-includes=dir and
    --x-libraries=dir, which are now removed and use standard pkg-config.
    
    It also replaces --with{,out}-x with --{dis,en}able-x11, which is the
    same as other optionnal dependencies.
    
    (this patch was done in an attempt to solve a build issue on maemo, it
    turns out it didn't help)

diff --git a/configure.ac b/configure.ac
index 82f9205..ae6dd96 100644
--- a/configure.ac
+++ b/configure.ac
@@ -411,21 +411,52 @@ AC_SUBST(pulselocaledir)
 #      External libraries         #
 ###################################
 
+#### pkg-config ####
+
+# Check for pkg-config manually first, as if its not installed the
+# PKG_PROG_PKG_CONFIG macro won't be defined.
+AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
+
+if test x"$have_pkg_config" = "xno"; then
+    AC_MSG_ERROR(pkg-config is required to install this program)
+fi
+
+PKG_PROG_PKG_CONFIG
+
 #### X11 (optional) ####
 
-HAVE_X11=0
+AC_ARG_ENABLE([x11],
+    AS_HELP_STRING([--disable-x11],[Disable optional X11 support]),
+        [
+            case "${enableval}" in
+                yes) x11=yes ;;
+                no) x11=no ;;
+                *) AC_MSG_ERROR(bad value ${enableval} for --disable-x11) ;;
+            esac
+        ],
+        [x11=auto])
+
+if test "x${x11}" != xno ; then
+    PKG_CHECK_MODULES(X11, [ x11 ],
+        HAVE_X11=1,
+        [
+            HAVE_X11=0
+            if test "x$x11" = xyes ; then
+                AC_MSG_ERROR([*** X11 not found])
+            fi
+        ])
+else
+    HAVE_X11=0
+fi
 
-# The macro tests the host, not the build target
-if test "x$os_is_win32" != "x1" ; then
-    AC_PATH_XTRA
-    test "x$no_x" != "xyes" && HAVE_X11=1
+if test "x${HAVE_X11}" = x1 ; then
+   AC_DEFINE([HAVE_X11], 1, [Have X11?])
 fi
 
+AC_SUBST(X11_CFLAGS)
+AC_SUBST(X11_LIBS)
 AC_SUBST(HAVE_X11)
-AM_CONDITIONAL(HAVE_X11, test "x$HAVE_X11" = "x1")
-if test "x$HAVE_X11" = "x1" ; then
-    AC_DEFINE([HAVE_X11], 1, [Have X11])
-fi
+AM_CONDITIONAL([HAVE_X11], [test "x$HAVE_X11" = x1])
 
 #### Capabilities (optional) ####
 
@@ -450,18 +481,6 @@ fi
 
 AC_CHECK_HEADERS([valgrind/memcheck.h])
 
-#### pkg-config ####
-
-# Check for pkg-config manually first, as if its not installed the
-# PKG_PROG_PKG_CONFIG macro won't be defined.
-AC_CHECK_PROG(have_pkg_config, pkg-config, yes, no)
-
-if test x"$have_pkg_config" = "xno"; then
-    AC_MSG_ERROR(pkg-config is required to install this program)
-fi
-
-PKG_PROG_PKG_CONFIG
-
 #### Sound file ####
 
 PKG_CHECK_MODULES(LIBSNDFILE, [ sndfile >= 1.0.10 ])
diff --git a/src/Makefile.am b/src/Makefile.am
index f3bd550..0b5abb2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -204,8 +204,8 @@ pacmd_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
 pacmd_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pax11publish_SOURCES = utils/pax11publish.c
-pax11publish_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
-pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+pax11publish_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
+pax11publish_LDADD = $(AM_LDADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la $(X11_LIBS)
 pax11publish_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 pabrowse_SOURCES = utils/pabrowse.c
@@ -531,8 +531,8 @@ endif
 
 if HAVE_X11
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/x11prop.c pulsecore/x11prop.h
-libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X_CFLAGS)
-libpulsecommon_ at PA_MAJORMINORMICRO@_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X11_CFLAGS)
+libpulsecommon_ at PA_MAJORMINORMICRO@_la_LDFLAGS += $(X11_LIBS)
 endif
 
 if HAVE_LIBASYNCNS
@@ -630,8 +630,8 @@ libpulse_la_LIBADD = $(AM_LIBADD) $(WINSOCK_LIBS) $(LTLIBICONV) libpulsecommon-@
 
 if HAVE_X11
 libpulse_la_SOURCES += pulse/client-conf-x11.c pulse/client-conf-x11.h
-libpulse_la_CFLAGS += $(X_CFLAGS)
-libpulse_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+libpulse_la_CFLAGS += $(X11_CFLAGS)
+libpulse_la_LDFLAGS += $(X11_LIBS)
 endif
 
 libpulse_simple_la_SOURCES = pulse/simple.c pulse/simple.h
@@ -721,8 +721,8 @@ libpulsecore_ at PA_MAJORMINORMICRO@_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) $(LIBSAMPL
 
 if HAVE_X11
 libpulsecore_ at PA_MAJORMINORMICRO@_la_SOURCES += pulsecore/x11wrap.c pulsecore/x11wrap.h
-libpulsecore_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X_CFLAGS)
-libpulsecore_ at PA_MAJORMINORMICRO@_la_LDFLAGS += $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS)
+libpulsecore_ at PA_MAJORMINORMICRO@_la_CFLAGS += $(X11_CFLAGS)
+libpulsecore_ at PA_MAJORMINORMICRO@_la_LDFLAGS += $(X11_LIBS)
 endif
 
 ###################################
@@ -1172,19 +1172,19 @@ module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.
 # X11
 
 module_x11_bell_la_SOURCES = modules/module-x11-bell.c
-module_x11_bell_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
+module_x11_bell_la_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
 module_x11_bell_la_LDFLAGS = -module -avoid-version
-module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
+module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X11_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_x11_publish_la_SOURCES = modules/module-x11-publish.c
-module_x11_publish_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
+module_x11_publish_la_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
 module_x11_publish_la_LDFLAGS = -module -avoid-version
-module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
+module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X11_LIBS) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_x11_xsmp_la_SOURCES = modules/module-x11-xsmp.c
-module_x11_xsmp_la_CFLAGS = $(AM_CFLAGS) $(X_CFLAGS)
+module_x11_xsmp_la_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
 module_x11_xsmp_la_LDFLAGS = -module -avoid-version
-module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X_PRE_LIBS) -lX11 $(X_LIBS) $(X_EXTRA_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
+module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X11_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # OSS
 

commit e92b0ae3f0c25ae5985327ef10a1b6d4ac146dca
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 11:56:16 2009 +0200

    build: compile libltdl directory first
    
    This change solves a compilation issue on maemo, and the "make dist"
    on Debian with autofoo from "experimental" repositories.

diff --git a/Makefile.am b/Makefile.am
index b27f9e6..bc46cac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -18,7 +18,7 @@
 ACLOCAL_AMFLAGS = -I m4
 
 EXTRA_DIST = bootstrap.sh LICENSE GPL LGPL doxygen/Makefile.am doxygen/Makefile.in doxygen/doxygen.conf.in README todo
-SUBDIRS=src doxygen man po libltdl
+SUBDIRS = libltdl src doxygen man po
 
 MAINTAINERCLEANFILES =
 noinst_DATA =

commit a206ac0fb58d757da30897ca9a64ae642d1865d1
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 12:28:20 2009 +0200

    build: Don't include builddir, but only srcdir.
    
    I guess it used to be builddir because some of the files under
    src/modules are generated. However, they are generated at dist time,
    not at compile time.

diff --git a/src/Makefile.am b/src/Makefile.am
index 0b5abb2..48f2222 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,11 +47,11 @@ endif
 
 AM_CFLAGS = \
 	-I$(top_srcdir)/src \
-	-I$(top_builddir)/src/modules \
-	-I$(top_builddir)/src/modules/rtp \
-	-I$(top_builddir)/src/modules/gconf \
-	-I$(top_builddir)/src/modules/bluetooth \
-	-I$(top_builddir)/src/modules/raop \
+	-I$(top_srcdir)/src/modules \
+	-I$(top_srcdir)/src/modules/rtp \
+	-I$(top_srcdir)/src/modules/gconf \
+	-I$(top_srcdir)/src/modules/bluetooth \
+	-I$(top_srcdir)/src/modules/raop \
 	$(PTHREAD_CFLAGS) -D_POSIX_PTHREAD_SEMANTICS \
 	$(LTDLINCL) \
 	$(LIBSAMPLERATE_CFLAGS) \

commit db193f17200d63bfe59bc3a9196f15d5d59efaee
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 12:29:09 2009 +0200

    build: introduce $SKIP_GIT for make dist (off-line or behind a proxy).
    
    There might be a better way doing that, but 'alias git=echo' is not a
    solution, :(

diff --git a/Makefile.am b/Makefile.am
index bc46cac..f4dd998 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -56,7 +56,7 @@ fedora-snapshot: dist
 
 dist-hook:
 	if test -d .git ; then \
-		git pull ; \
+		test -z $$SKIP_GIT && git pull ; \
 		chmod u+w ${distdir}/ChangeLog || true ; \
 		( git-changelog.perl || echo "git-changelog.perl failed." ) > ${distdir}/ChangeLog 2>&1 ; \
 	fi

commit c8b3d8b79c0d6e41aad430a08b683d7c327ccf16
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 12:45:56 2009 +0200

    build: add atomic.h and refcnt.h to libpulsecommon
    
    I choose libpulsecommon over libpulsecore because some files
    from libpulsecommon (eg. once.{c,h}) include them.

diff --git a/src/Makefile.am b/src/Makefile.am
index 48f2222..ac3c614 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -459,6 +459,7 @@ lib_LTLIBRARIES = \
 libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulse/client-conf.c pulse/client-conf.h \
 		pulse/i18n.c pulse/i18n.h \
+		pulsecore/atomic.h \
 		pulsecore/authkey.c pulsecore/authkey.h \
 		pulsecore/conf-parser.c pulsecore/conf-parser.h \
 		pulsecore/core-error.c pulsecore/core-error.h \
@@ -496,6 +497,7 @@ libpulsecommon_ at PA_MAJORMINORMICRO@_la_SOURCES = \
 		pulsecore/pstream.c pulsecore/pstream.h \
 		pulsecore/queue.c pulsecore/queue.h \
 		pulsecore/random.c pulsecore/random.h \
+		pulsecore/refcnt.h \
 		pulsecore/rtclock.c pulsecore/rtclock.h \
 		pulsecore/shm.c pulsecore/shm.h \
 		pulsecore/socket-client.c pulsecore/socket-client.h \

commit de57edd5d83bf22a339c34639c1315f8b4ddc864
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 14:55:33 2009 +0200

    build: Use proper -disable-static instead of removing .a
    
    Don't mess up with autofoo, to pass 'make distcheck' again.
    
    Note: I am not convinced by the 'rm -f *.la', I know it can solve
    issue, but it should be handled by distributions probably...

diff --git a/src/Makefile.am b/src/Makefile.am
index ac3c614..1f63490 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -80,6 +80,8 @@ AM_LDFLAGS+=-Wl,--export-all-symbols
 WINSOCK_LIBS=-lwsock32 -lws2_32 -lwininet
 endif
 
+MODULE_LDFLAGS = -module -disable-static -avoid-version
+
 ###################################
 #          Extra files            #
 ###################################
@@ -663,7 +665,7 @@ endif
 libpulsedsp_la_SOURCES = utils/padsp.c
 libpulsedsp_la_CFLAGS = $(AM_CFLAGS)
 libpulsedsp_la_LIBADD = $(AM_LIBADD) libpulse.la libpulsecommon- at PA_MAJORMINORMICRO@.la
-libpulsedsp_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
+libpulsedsp_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version -disable-static
 
 ###################################
 #      Daemon core library        #
@@ -1039,153 +1041,153 @@ $(SYMDEF_FILES): modules/module-defs.h.m4
 # Flat volume
 
 module_flat_volume_la_SOURCES = modules/module-flat-volume.c
-module_flat_volume_la_LDFLAGS = -module -avoid-version
+module_flat_volume_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_flat_volume_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Simple protocol
 
 module_simple_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_simple_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_SIMPLE $(AM_CFLAGS)
-module_simple_protocol_tcp_la_LDFLAGS = -module -avoid-version
+module_simple_protocol_tcp_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_simple_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_simple_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_simple_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_SIMPLE $(AM_CFLAGS)
-module_simple_protocol_unix_la_LDFLAGS = -module -avoid-version
+module_simple_protocol_unix_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_simple_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-simple.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # CLI protocol
 
 module_cli_la_SOURCES = modules/module-cli.c
-module_cli_la_LDFLAGS = -module -avoid-version
+module_cli_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libcli.la
 
 module_cli_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
-module_cli_protocol_tcp_la_LDFLAGS = -module -avoid-version
+module_cli_protocol_tcp_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_cli_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_cli_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
-module_cli_protocol_unix_la_LDFLAGS = -module -avoid-version
+module_cli_protocol_unix_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_cli_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-cli.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # HTTP protocol
 
 module_http_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_http_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
-module_http_protocol_tcp_la_LDFLAGS = -module -avoid-version
+module_http_protocol_tcp_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_http_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_http_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_http_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_HTTP $(AM_CFLAGS)
-module_http_protocol_unix_la_LDFLAGS = -module -avoid-version
+module_http_protocol_unix_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_http_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-http.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Native protocol
 
 module_native_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_native_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_NATIVE $(AM_CFLAGS)
-module_native_protocol_tcp_la_LDFLAGS = -module -avoid-version
+module_native_protocol_tcp_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_native_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_native_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_native_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_NATIVE $(AM_CFLAGS)
-module_native_protocol_unix_la_LDFLAGS = -module -avoid-version
+module_native_protocol_unix_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_native_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_native_protocol_fd_la_SOURCES = modules/module-native-protocol-fd.c
 module_native_protocol_fd_la_CFLAGS = $(AM_CFLAGS)
-module_native_protocol_fd_la_LDFLAGS = -module -avoid-version
+module_native_protocol_fd_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_native_protocol_fd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-native.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # EsounD protocol
 
 module_esound_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_esound_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_ESOUND $(AM_CFLAGS)
-module_esound_protocol_tcp_la_LDFLAGS = -module -avoid-version
+module_esound_protocol_tcp_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_esound_protocol_tcp_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_protocol_unix_la_SOURCES = modules/module-protocol-stub.c
 module_esound_protocol_unix_la_CFLAGS = -DUSE_UNIX_SOCKETS -DUSE_PROTOCOL_ESOUND $(AM_CFLAGS)
-module_esound_protocol_unix_la_LDFLAGS = -module -avoid-version
+module_esound_protocol_unix_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_esound_protocol_unix_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libprotocol-esound.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_compat_spawnfd_la_SOURCES = modules/module-esound-compat-spawnfd.c
-module_esound_compat_spawnfd_la_LDFLAGS = -module -avoid-version
+module_esound_compat_spawnfd_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_esound_compat_spawnfd_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_compat_spawnpid_la_SOURCES = modules/module-esound-compat-spawnpid.c
-module_esound_compat_spawnpid_la_LDFLAGS = -module -avoid-version
+module_esound_compat_spawnpid_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_esound_compat_spawnpid_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_esound_sink_la_SOURCES = modules/module-esound-sink.c
-module_esound_sink_la_LDFLAGS = -module -avoid-version
+module_esound_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_esound_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Pipes
 
 module_pipe_sink_la_SOURCES = modules/module-pipe-sink.c
-module_pipe_sink_la_LDFLAGS = -module -avoid-version
+module_pipe_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_pipe_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_pipe_source_la_SOURCES = modules/module-pipe-source.c
-module_pipe_source_la_LDFLAGS = -module -avoid-version
+module_pipe_source_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_pipe_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Fake sources/sinks
 
 module_sine_la_SOURCES = modules/module-sine.c
-module_sine_la_LDFLAGS = -module -avoid-version
+module_sine_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_sine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_null_sink_la_SOURCES = modules/module-null-sink.c
-module_null_sink_la_LDFLAGS = -module -avoid-version
+module_null_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_null_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Couplings
 
 module_combine_la_SOURCES = modules/module-combine.c
-module_combine_la_LDFLAGS = -module -avoid-version
+module_combine_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_combine_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_remap_sink_la_SOURCES = modules/module-remap-sink.c
-module_remap_sink_la_LDFLAGS = -module -avoid-version
+module_remap_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_remap_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_ladspa_sink_la_SOURCES = modules/module-ladspa-sink.c modules/ladspa.h
 module_ladspa_sink_la_CFLAGS = -DLADSPA_PATH=\"$(libdir)/ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa:/usr/local/lib64/ladspa:/usr/lib64/ladspa\" $(AM_CFLAGS)
-module_ladspa_sink_la_LDFLAGS = -module -avoid-version
+module_ladspa_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_ladspa_sink_la_LIBADD = $(AM_LIBADD) $(LIBLTDL) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_match_la_SOURCES = modules/module-match.c
-module_match_la_LDFLAGS = -module -avoid-version
+module_match_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_match_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_tunnel_sink_la_SOURCES = modules/module-tunnel.c
 module_tunnel_sink_la_CFLAGS = -DTUNNEL_SINK=1 $(AM_CFLAGS)
-module_tunnel_sink_la_LDFLAGS = -module -avoid-version
+module_tunnel_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_tunnel_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_tunnel_source_la_SOURCES = modules/module-tunnel.c
-module_tunnel_source_la_LDFLAGS = -module -avoid-version
+module_tunnel_source_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_tunnel_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # X11
 
 module_x11_bell_la_SOURCES = modules/module-x11-bell.c
 module_x11_bell_la_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
-module_x11_bell_la_LDFLAGS = -module -avoid-version
+module_x11_bell_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_x11_bell_la_LIBADD = $(AM_LIBADD) $(X11_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_x11_publish_la_SOURCES = modules/module-x11-publish.c
 module_x11_publish_la_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
-module_x11_publish_la_LDFLAGS = -module -avoid-version
+module_x11_publish_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_x11_publish_la_LIBADD = $(AM_LIBADD) $(X11_LIBS) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_x11_xsmp_la_SOURCES = modules/module-x11-xsmp.c
 module_x11_xsmp_la_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS)
-module_x11_xsmp_la_LDFLAGS = -module -avoid-version
+module_x11_xsmp_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_x11_xsmp_la_LIBADD = $(AM_LIBADD) $(X11_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # OSS
@@ -1195,7 +1197,7 @@ liboss_util_la_LDFLAGS = -avoid-version
 liboss_util_la_LIBADD = libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_oss_la_SOURCES = modules/module-oss.c
-module_oss_la_LDFLAGS = -module -avoid-version
+module_oss_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_oss_la_LIBADD = $(AM_LIBADD) liboss-util.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # ALSA
@@ -1206,128 +1208,128 @@ libalsa_util_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libpulsecore- at PA_MAJORMI
 libalsa_util_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 module_alsa_sink_la_SOURCES = modules/module-alsa-sink.c
-module_alsa_sink_la_LDFLAGS = -module -avoid-version
+module_alsa_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_alsa_sink_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_alsa_sink_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 module_alsa_source_la_SOURCES = modules/module-alsa-source.c
-module_alsa_source_la_LDFLAGS = -module -avoid-version
+module_alsa_source_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_alsa_source_la_LIBADD = $(AM_LIBADD) $(ASOUNDLIB_LIBS) libalsa-util.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_alsa_source_la_CFLAGS = $(AM_CFLAGS) $(ASOUNDLIB_CFLAGS)
 
 # Solaris
 
 module_solaris_la_SOURCES = modules/module-solaris.c
-module_solaris_la_LDFLAGS = -module -avoid-version
+module_solaris_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_solaris_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 # Avahi
 
 module_zeroconf_publish_la_SOURCES = modules/module-zeroconf-publish.c
-module_zeroconf_publish_la_LDFLAGS = -module -avoid-version
+module_zeroconf_publish_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_zeroconf_publish_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_zeroconf_publish_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 module_zeroconf_discover_la_SOURCES = modules/module-zeroconf-discover.c
-module_zeroconf_discover_la_LDFLAGS = -module -avoid-version
+module_zeroconf_discover_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_zeroconf_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_zeroconf_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
 # LIRC
 
 module_lirc_la_SOURCES = modules/module-lirc.c
-module_lirc_la_LDFLAGS = -module -avoid-version
+module_lirc_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_lirc_la_LIBADD = $(AM_LIBADD) $(LIRC_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_lirc_la_CFLAGS = $(AM_CFLAGS) $(LIRC_CFLAGS)
 
 # Linux evdev
 
 module_mmkbd_evdev_la_SOURCES = modules/module-mmkbd-evdev.c
-module_mmkbd_evdev_la_LDFLAGS = -module -avoid-version
+module_mmkbd_evdev_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_mmkbd_evdev_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_mmkbd_evdev_la_CFLAGS = $(AM_CFLAGS)
 
 # Windows waveout
 
 #module_waveout_la_SOURCES = modules/module-waveout.c
-#module_waveout_la_LDFLAGS = -module -avoid-version
+#module_waveout_la_LDFLAGS = $(MODULE_LDFLAGS)
 #module_waveout_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lwinmm libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 #module_waveout_la_CFLAGS = $(AM_CFLAGS)
 
 # Hardware autodetection module
 module_detect_la_SOURCES = modules/module-detect.c
-module_detect_la_LDFLAGS = -module -avoid-version
+module_detect_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_detect_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_detect_la_CFLAGS = $(AM_CFLAGS)
 
 # Volume restore module
 module_volume_restore_la_SOURCES = modules/module-volume-restore.c
-module_volume_restore_la_LDFLAGS = -module -avoid-version
+module_volume_restore_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_volume_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_volume_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Position event sounds in space
 module_position_event_sounds_la_SOURCES = modules/module-position-event-sounds.c
-module_position_event_sounds_la_LDFLAGS = -module -avoid-version
+module_position_event_sounds_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_position_event_sounds_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_position_event_sounds_CFLAGS = $(AM_CFLAGS)
 
 # Device volume/muted restore module
 module_device_restore_la_SOURCES = modules/module-device-restore.c
-module_device_restore_la_LDFLAGS = -module -avoid-version
+module_device_restore_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_device_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Stream volume/muted/device restore module
 module_stream_restore_la_SOURCES = modules/module-stream-restore.c
-module_stream_restore_la_LDFLAGS = -module -avoid-version
+module_stream_restore_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_stream_restore_la_LIBADD = $(AM_LIBADD) libprotocol-native.la libpulsecore- at PA_MAJORMINORMICRO@.la -lgdbm libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_stream_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Default sink/source restore module
 module_default_device_restore_la_SOURCES = modules/module-default-device-restore.c
-module_default_device_restore_la_LDFLAGS = -module -avoid-version
+module_default_device_restore_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_default_device_restore_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_default_device_restore_la_CFLAGS = $(AM_CFLAGS)
 
 # Always Sink module
 module_always_sink_la_SOURCES = modules/module-always-sink.c
-module_always_sink_la_LDFLAGS = -module -avoid-version
+module_always_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_always_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_always_sink_la_CFLAGS = $(AM_CFLAGS)
 
 # Rescue streams module
 module_rescue_streams_la_SOURCES = modules/module-rescue-streams.c
-module_rescue_streams_la_LDFLAGS = -module -avoid-version
+module_rescue_streams_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_rescue_streams_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_rescue_streams_la_CFLAGS = $(AM_CFLAGS)
 
 # Suspend-on-idle module
 module_suspend_on_idle_la_SOURCES = modules/module-suspend-on-idle.c
-module_suspend_on_idle_la_LDFLAGS = -module -avoid-version
+module_suspend_on_idle_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_suspend_on_idle_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_suspend_on_idle_la_CFLAGS = $(AM_CFLAGS)
 
 # RTP modules
 module_rtp_send_la_SOURCES = modules/rtp/module-rtp-send.c
-module_rtp_send_la_LDFLAGS = -module -avoid-version
+module_rtp_send_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_rtp_send_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_rtp_send_la_CFLAGS = $(AM_CFLAGS)
 
 module_rtp_recv_la_SOURCES = modules/rtp/module-rtp-recv.c
-module_rtp_recv_la_LDFLAGS = -module -avoid-version
+module_rtp_recv_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_rtp_recv_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_rtp_recv_la_CFLAGS = $(AM_CFLAGS)
 
 # JACK
 
 module_jack_sink_la_SOURCES = modules/module-jack-sink.c
-module_jack_sink_la_LDFLAGS = -module -avoid-version
+module_jack_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_jack_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS) libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_jack_sink_la_CFLAGS = $(AM_CFLAGS) $(JACK_CFLAGS)
 
 module_jack_source_la_SOURCES = modules/module-jack-source.c
-module_jack_source_la_LDFLAGS = -module -avoid-version
+module_jack_source_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_jack_source_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la $(JACK_LIBS) libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_jack_source_la_CFLAGS = $(AM_CFLAGS) $(JACK_CFLAGS)
 
@@ -1338,18 +1340,18 @@ libdbus_util_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMI
 libdbus_util_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 module_hal_detect_la_SOURCES = modules/module-hal-detect.c
-module_hal_detect_la_LDFLAGS = -module -avoid-version
+module_hal_detect_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_hal_detect_la_LIBADD = $(AM_LIBADD) $(HAL_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_hal_detect_la_CFLAGS = $(AM_CFLAGS) $(HAL_CFLAGS)
 
 module_console_kit_la_SOURCES = modules/module-console-kit.c
-module_console_kit_la_LDFLAGS = -module -avoid-version
+module_console_kit_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_console_kit_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_console_kit_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
 # GConf support
 module_gconf_la_SOURCES = modules/gconf/module-gconf.c
-module_gconf_la_LDFLAGS = -module -avoid-version
+module_gconf_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_gconf_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_gconf_la_CFLAGS = $(AM_CFLAGS) -DPA_GCONF_HELPER=\"$(pulselibexecdir)/gconf-helper\"
 
@@ -1360,7 +1362,7 @@ gconf_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 # Bluetooth proximity
 module_bluetooth_proximity_la_SOURCES = modules/bluetooth/module-bluetooth-proximity.c
-module_bluetooth_proximity_la_LDFLAGS = -module -avoid-version
+module_bluetooth_proximity_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_bluetooth_proximity_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_bluetooth_proximity_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -DPA_BT_PROXIMITY_HELPER=\"$(pulselibexecdir)/proximity-helper\"
 
@@ -1371,7 +1373,7 @@ proximity_helper_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 
 # Bluetooth sink / source
 module_bluetooth_discover_la_SOURCES = modules/bluetooth/module-bluetooth-discover.c
-module_bluetooth_discover_la_LDFLAGS = -module -avoid-version
+module_bluetooth_discover_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_bluetooth_discover_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_bluetooth_discover_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS)
 
@@ -1386,17 +1388,17 @@ libbluetooth_ipc_la_LIBADD = $(AM_LIBADD)libpulsecore- at PA_MAJORMINORMICRO@.la li
 libbluetooth_ipc_la_CFLAGS = $(AM_CFLAGS) -w
 
 module_bluetooth_device_la_SOURCES = modules/bluetooth/module-bluetooth-device.c modules/bluetooth/rtp.h
-module_bluetooth_device_la_LDFLAGS = -module -avoid-version
+module_bluetooth_device_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_bluetooth_device_la_LIBADD = $(AM_LIBADD) $(DBUS_LIBS) libpulsecore- at PA_MAJORMINORMICRO@.la libdbus-util.la libbluetooth-ipc.la libbluetooth-sbc.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_bluetooth_device_la_CFLAGS = $(AM_CFLAGS) $(DBUS_CFLAGS) -w
 
 # Apple Airtunes/RAOP
 module_raop_sink_la_SOURCES = modules/module-raop-sink.c
-module_raop_sink_la_LDFLAGS = -module -avoid-version
+module_raop_sink_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_raop_sink_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la librtp.la libraop.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 
 module_raop_discover_la_SOURCES = modules/module-raop-discover.c
-module_raop_discover_la_LDFLAGS = -module -avoid-version
+module_raop_discover_la_LDFLAGS = $(MODULE_LDFLAGS)
 module_raop_discover_la_LIBADD = $(AM_LIBADD) $(AVAHI_LIBS) libavahi-wrap.la libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 module_raop_discover_la_CFLAGS = $(AM_CFLAGS) $(AVAHI_CFLAGS)
 
@@ -1450,11 +1452,14 @@ install-exec-hook:
 	chmod u+s $(DESTDIR)$(bindir)/pulseaudio
 	-chmod u+s $(DESTDIR)$(pulselibexecdir)/proximity-helper
 	ln -sf pacat $(DESTDIR)$(bindir)/parec
-	rm -f $(DESTDIR)$(modlibexecdir)/*.a
-	rm -f $(DESTDIR)$(libdir)/libpulsedsp.a
 	rm -f $(DESTDIR)$(libdir)/libpulsedsp.la
 	rm -f $(DESTDIR)$(modlibexecdir)/*.la
 
+uninstall-hook:
+	rm -f $(DESTDIR)$(bindir)/parec
+	rm -f $(DESTDIR)$(libdir)/libpulsedsp.*
+	rm -f $(DESTDIR)$(modlibexecdir)/*.so
+
 massif: pulseaudio
 	libtool --mode=execute valgrind --tool=massif --depth=6  --alloc-fn=pa_xmalloc --alloc-fn=pa_xmalloc0 --alloc-fn=pa_xrealloc --alloc-fn=dbus_realloc --alloc-fn=pa_xnew0_internal --alloc-fn=pa_xnew_internal ./pulseaudio
 

commit 8e200ed0ce071cba686251b42cdbc5356f8fee75
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 17:19:20 2009 +0200

    build: run some tests during make check (and distcheck)
    
    Run simple core tests during 'check'.
    
    I plan to add more automated tests, including pulseaudio instances. I
    did some for maemo, they still need some love.
    
    Note: it would be funky to enable Automake 'color-tests' option when
    this will be released (1.10.2 and from automake git)

diff --git a/src/Makefile.am b/src/Makefile.am
index 1f63490..e4ec488 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -219,6 +219,35 @@ pabrowse_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
 #         Test programs           #
 ###################################
 
+# missing: mcalign-test flist-test pacat-simple parec-simple sync-playback rtstutter stripnul interpol-test thread-test
+
+TESTS = \
+		mainloop-test \
+		strlist-test \
+		close-test \
+		voltest \
+		memblockq-test \
+		channelmap-test \
+		thread-mainloop-test \
+		utf8-test \
+		get-binary-name-test \
+		ipacl-test \
+		hook-list-test \
+		memblock-test \
+		asyncq-test \
+		asyncmsgq-test \
+		queue-test \
+		rtpoll-test \
+		sig2str-test \
+		resampler-test \
+		smoother-test \
+		mix-test \
+		remix-test \
+		envelope-test \
+		proplist-test \
+		lock-autospawn-test \
+		prioq-test
+
 noinst_PROGRAMS = \
 		mainloop-test \
 		mcalign-test \
@@ -256,12 +285,17 @@ noinst_PROGRAMS = \
 		prioq-test
 
 if HAVE_SIGXCPU
+#TESTS += \
+#		cpulimit-test \
+#		cpulimit-test2
 noinst_PROGRAMS += \
 		cpulimit-test \
 		cpulimit-test2
 endif
 
 if HAVE_GLIB20
+TESTS += \
+		mainloop-test-glib
 noinst_PROGRAMS += \
 		mainloop-test-glib
 endif

commit d096ad78d35156cb61f5c2aee4bb3f58a055da56
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 18:25:12 2009 +0200

    bluetooth: add update-sbc and friends
    
    Grr.. You can't do:
    
    SBC_FILES = a b c
    libsbc_SOURCES = $(addprefix modules/bluetooth/,$(SBC_FILES))
    
    With automake...
    
    So I $(strip 'modules/bluetooth/') instead.

diff --git a/src/Makefile.am b/src/Makefile.am
index e4ec488..608e678 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1415,6 +1415,7 @@ libbluetooth_sbc_la_SOURCES = modules/bluetooth/sbc.c modules/bluetooth/sbc.h mo
 libbluetooth_sbc_la_LDFLAGS = -avoid-version
 libbluetooth_sbc_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINORMICRO@.la libpulsecommon- at PA_MAJORMINORMICRO@.la libpulse.la
 libbluetooth_sbc_la_CFLAGS = $(AM_CFLAGS)
+SBC_FILES = $(subst modules/bluetooth/,,$(libbluetooth_sbc_la_SOURCES))
 
 libbluetooth_ipc_la_SOURCES = modules/bluetooth/ipc.c modules/bluetooth/ipc.h
 libbluetooth_ipc_la_LDFLAGS = -avoid-version
@@ -1500,6 +1501,11 @@ massif: pulseaudio
 update-ffmpeg:
 	wget -O pulsecore/ffmpeg/resample2.c http://svn.mplayerhq.hu/ffmpeg/trunk/libavcodec/resample2.c?view=co
 
+update-sbc:
+	for i in $(SBC_FILES); do \
+		wget -O modules/bluetooth/$$i http://git.kernel.org/\?p=bluetooth/bluez.git\;a=blob_plain\;f=sbc/$$i ; \
+	done
+
 # Automatically generate linker version script. We use the same one for all public .sos
 update-map-file:
 	( echo "PULSE_0 {" ; \
@@ -1509,4 +1515,6 @@ update-map-file:
 	  echo "*;" ; \
 	  echo "};" ) > $(srcdir)/map-file
 
-.PHONY: utils/padsp
+update-all: update-ffmpeg update-sbc update-map-file
+
+.PHONY: utils/padsp massif update-all update-ffmpeg update-sbc update-map-file

commit 7e6309c77cefee8c447266df4bab25e544000011
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 19:13:49 2009 +0200

    bluetooth: Update sbc from git upstream.
    
    It contains encoding fixes, pass the conformance tests, and is now
    vectorizable. Next update might include SSE and/or Neon code.

diff --git a/src/modules/bluetooth/sbc.c b/src/modules/bluetooth/sbc.c
index 02a6143..651981f 100644
--- a/src/modules/bluetooth/sbc.c
+++ b/src/modules/bluetooth/sbc.c
@@ -2,7 +2,7 @@
  *
  *  Bluetooth low-complexity, subband codec (SBC) library
  *
- *  Copyright (C) 2004-2008  Marcel Holtmann <marcel at holtmann.org>
+ *  Copyright (C) 2004-2009  Marcel Holtmann <marcel at holtmann.org>
  *  Copyright (C) 2004-2005  Henryk Ploetz <henryk at ploetzli.ch>
  *  Copyright (C) 2005-2008  Brad Midgley <bmidgley at xmission.com>
  *
@@ -40,6 +40,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <sys/types.h>
+#include <limits.h>
 
 #include "sbc_math.h"
 #include "sbc_tables.h"
@@ -68,7 +69,7 @@ struct sbc_frame {
 	uint8_t subband_mode;
 	uint8_t subbands;
 	uint8_t bitpool;
-	uint8_t codesize;
+	uint16_t codesize;
 	uint8_t length;
 
 	/* bit number x set means joint stereo has been used in subband x */
@@ -93,7 +94,11 @@ struct sbc_decoder_state {
 struct sbc_encoder_state {
 	int subbands;
 	int position[2];
-	int32_t X[2][160];
+	int16_t X[2][256];
+	void (*sbc_analyze_4b_4s)(int16_t *pcm, int16_t *x,
+				  int32_t *out, int out_stride);
+	void (*sbc_analyze_4b_8s)(int16_t *pcm, int16_t *x,
+				  int32_t *out, int out_stride);
 };
 
 /*
@@ -145,7 +150,7 @@ static uint8_t sbc_crc8(const uint8_t *data, size_t len)
 
 	octet = data[i];
 	for (i = 0; i < len % 8; i++) {
-		unsigned char bit = ((octet ^ crc) & 0x80) >> 7;
+		char bit = ((octet ^ crc) & 0x80) >> 7;
 
 		crc = ((crc & 0x7f) << 1) ^ (bit ? 0x1d : 0);
 
@@ -563,7 +568,7 @@ static inline void sbc_synthesize_four(struct sbc_decoder_state *state,
 		k = (i + 4) & 0xf;
 
 		/* Store in output, Q0 */
-		frame->pcm_sample[ch][blk * 4 + i] = SCALE4_STAGED2(
+		frame->pcm_sample[ch][blk * 4 + i] = SCALE4_STAGED1(
 			MULA(v[offset[i] + 0], sbc_proto_4_40m0[idx + 0],
 			MULA(v[offset[k] + 1], sbc_proto_4_40m1[idx + 0],
 			MULA(v[offset[i] + 2], sbc_proto_4_40m0[idx + 1],
@@ -609,7 +614,7 @@ static inline void sbc_synthesize_eight(struct sbc_decoder_state *state,
 		k = (i + 8) & 0xf;
 
 		/* Store in output */
-		frame->pcm_sample[ch][blk * 8 + i] = SCALE8_STAGED2( // Q0
+		frame->pcm_sample[ch][blk * 8 + i] = SCALE8_STAGED1( // Q0
 			MULA(state->V[ch][offset[i] + 0], sbc_proto_8_80m0[idx + 0],
 			MULA(state->V[ch][offset[k] + 1], sbc_proto_8_80m1[idx + 0],
 			MULA(state->V[ch][offset[i] + 2], sbc_proto_8_80m0[idx + 1],
@@ -648,242 +653,144 @@ static int sbc_synthesize_audio(struct sbc_decoder_state *state,
 	}
 }
 
-static void sbc_encoder_init(struct sbc_encoder_state *state,
-				const struct sbc_frame *frame)
+static inline void _sbc_analyze_four(const int16_t *in, int32_t *out)
 {
-	memset(&state->X, 0, sizeof(state->X));
-	state->subbands = frame->subbands;
-	state->position[0] = state->position[1] = 9 * frame->subbands;
-}
+	FIXED_A t1[4];
+	FIXED_T t2[4];
+	int i = 0, hop = 0;
+
+	/* rounding coefficient */
+	t1[0] = t1[1] = t1[2] = t1[3] =
+		(FIXED_A) 1 << (SBC_PROTO_FIXED4_SCALE - 1);
+
+	/* low pass polyphase filter */
+	for (hop = 0; hop < 40; hop += 8) {
+		t1[0] += (FIXED_A) in[hop] * _sbc_proto_fixed4[hop];
+		t1[1] += (FIXED_A) in[hop + 1] * _sbc_proto_fixed4[hop + 1];
+		t1[2] += (FIXED_A) in[hop + 2] * _sbc_proto_fixed4[hop + 2];
+		t1[1] += (FIXED_A) in[hop + 3] * _sbc_proto_fixed4[hop + 3];
+		t1[0] += (FIXED_A) in[hop + 4] * _sbc_proto_fixed4[hop + 4];
+		t1[3] += (FIXED_A) in[hop + 5] * _sbc_proto_fixed4[hop + 5];
+		t1[3] += (FIXED_A) in[hop + 7] * _sbc_proto_fixed4[hop + 7];
+	}
 
-static inline void _sbc_analyze_four(const int32_t *in, int32_t *out)
-{
-	sbc_fixed_t t[8], s[5];
-
-	t[0] = SCALE4_STAGE1( /* Q8 */
-		MULA(_sbc_proto_4[0], in[8] - in[32], /* Q18 */
-		MUL( _sbc_proto_4[1], in[16] - in[24])));
-
-	t[1] = SCALE4_STAGE1(
-		MULA(_sbc_proto_4[2], in[1],
-		MULA(_sbc_proto_4[3], in[9],
-		MULA(_sbc_proto_4[4], in[17],
-		MULA(_sbc_proto_4[5], in[25],
-		MUL( _sbc_proto_4[6], in[33]))))));
-
-	t[2] = SCALE4_STAGE1(
-		MULA(_sbc_proto_4[7], in[2],
-		MULA(_sbc_proto_4[8], in[10],
-		MULA(_sbc_proto_4[9], in[18],
-		MULA(_sbc_proto_4[10], in[26],
-		MUL( _sbc_proto_4[11], in[34]))))));
-
-	t[3] = SCALE4_STAGE1(
-		MULA(_sbc_proto_4[12], in[3],
-		MULA(_sbc_proto_4[13], in[11],
-		MULA(_sbc_proto_4[14], in[19],
-		MULA(_sbc_proto_4[15], in[27],
-		MUL( _sbc_proto_4[16], in[35]))))));
-
-	t[4] = SCALE4_STAGE1(
-		MULA(_sbc_proto_4[17], in[4] + in[36],
-		MULA(_sbc_proto_4[18], in[12] + in[28],
-		MUL( _sbc_proto_4[19], in[20]))));
-
-	t[5] = SCALE4_STAGE1(
-		MULA(_sbc_proto_4[16], in[5],
-		MULA(_sbc_proto_4[15], in[13],
-		MULA(_sbc_proto_4[14], in[21],
-		MULA(_sbc_proto_4[13], in[29],
-		MUL( _sbc_proto_4[12], in[37]))))));
-
-	/* don't compute t[6]... this term always multiplies
-	 * with cos(pi/2) = 0 */
-
-	t[7] = SCALE4_STAGE1(
-		MULA(_sbc_proto_4[6], in[7],
-		MULA(_sbc_proto_4[5], in[15],
-		MULA(_sbc_proto_4[4], in[23],
-		MULA(_sbc_proto_4[3], in[31],
-		MUL( _sbc_proto_4[2], in[39]))))));
-
-	s[0] = MUL( _anamatrix4[0], t[0] + t[4]);
-	s[1] = MUL( _anamatrix4[2], t[2]);
-	s[2] = MULA(_anamatrix4[1], t[1] + t[3],
-		MUL(_anamatrix4[3], t[5]));
-	s[3] = MULA(_anamatrix4[3], t[1] + t[3],
-		MUL(_anamatrix4[1], -t[5] + t[7]));
-	s[4] = MUL( _anamatrix4[3], t[7]);
-
-	out[0] = SCALE4_STAGE2( s[0] + s[1] + s[2] + s[4]); /* Q0 */
-	out[1] = SCALE4_STAGE2(-s[0] + s[1] + s[3]);
-	out[2] = SCALE4_STAGE2(-s[0] + s[1] - s[3]);
-	out[3] = SCALE4_STAGE2( s[0] + s[1] - s[2] - s[4]);
+	/* scaling */
+	t2[0] = t1[0] >> SBC_PROTO_FIXED4_SCALE;
+	t2[1] = t1[1] >> SBC_PROTO_FIXED4_SCALE;
+	t2[2] = t1[2] >> SBC_PROTO_FIXED4_SCALE;
+	t2[3] = t1[3] >> SBC_PROTO_FIXED4_SCALE;
+
+	/* do the cos transform */
+	for (i = 0, hop = 0; i < 4; hop += 8, i++) {
+		out[i] = ((FIXED_A) t2[0] * cos_table_fixed_4[0 + hop] +
+			  (FIXED_A) t2[1] * cos_table_fixed_4[1 + hop] +
+			  (FIXED_A) t2[2] * cos_table_fixed_4[2 + hop] +
+			  (FIXED_A) t2[3] * cos_table_fixed_4[5 + hop]) >>
+			(SBC_COS_TABLE_FIXED4_SCALE - SCALE_OUT_BITS);
+	}
 }
 
-static inline void sbc_analyze_four(struct sbc_encoder_state *state,
-				struct sbc_frame *frame, int ch, int blk)
+static void sbc_analyze_4b_4s(int16_t *pcm, int16_t *x,
+			      int32_t *out, int out_stride)
 {
-	int32_t *x = &state->X[ch][state->position[ch]];
-	int16_t *pcm = &frame->pcm_sample[ch][blk * 4];
-
-	/* Input 4 Audio Samples */
-	x[40] = x[0] = pcm[3];
-	x[41] = x[1] = pcm[2];
-	x[42] = x[2] = pcm[1];
-	x[43] = x[3] = pcm[0];
-
-	_sbc_analyze_four(x, frame->sb_sample_f[blk][ch]);
+	int i;
+
+	/* Input 4 x 4 Audio Samples */
+	for (i = 0; i < 16; i += 4) {
+		x[64 + i] = x[0 + i] = pcm[15 - i];
+		x[65 + i] = x[1 + i] = pcm[14 - i];
+		x[66 + i] = x[2 + i] = pcm[13 - i];
+		x[67 + i] = x[3 + i] = pcm[12 - i];
+	}
 
-	state->position[ch] -= 4;
-	if (state->position[ch] < 0)
-		state->position[ch] = 36;
+	/* Analyze four blocks */
+	_sbc_analyze_four(x + 12, out);
+	out += out_stride;
+	_sbc_analyze_four(x + 8, out);
+	out += out_stride;
+	_sbc_analyze_four(x + 4, out);
+	out += out_stride;
+	_sbc_analyze_four(x, out);
 }
 
-static inline void _sbc_analyze_eight(const int32_t *in, int32_t *out)
+static inline void _sbc_analyze_eight(const int16_t *in, int32_t *out)
 {
-	sbc_fixed_t t[8], s[8];
-
-	t[0] = SCALE8_STAGE1( /* Q10 */
-		MULA(_sbc_proto_8[0], (in[16] - in[64]), /* Q18 = Q18 * Q0 */
-		MULA(_sbc_proto_8[1], (in[32] - in[48]),
-		MULA(_sbc_proto_8[2], in[4],
-		MULA(_sbc_proto_8[3], in[20],
-		MULA(_sbc_proto_8[4], in[36],
-		MUL( _sbc_proto_8[5], in[52])))))));
-
-	t[1] = SCALE8_STAGE1(
-		MULA(_sbc_proto_8[6], in[2],
-		MULA(_sbc_proto_8[7], in[18],
-		MULA(_sbc_proto_8[8], in[34],
-		MULA(_sbc_proto_8[9], in[50],
-		MUL(_sbc_proto_8[10], in[66]))))));
-
-	t[2] = SCALE8_STAGE1(
-		MULA(_sbc_proto_8[11], in[1],
-		MULA(_sbc_proto_8[12], in[17],
-		MULA(_sbc_proto_8[13], in[33],
-		MULA(_sbc_proto_8[14], in[49],
-		MULA(_sbc_proto_8[15], in[65],
-		MULA(_sbc_proto_8[16], in[3],
-		MULA(_sbc_proto_8[17], in[19],
-		MULA(_sbc_proto_8[18], in[35],
-		MULA(_sbc_proto_8[19], in[51],
-		MUL( _sbc_proto_8[20], in[67])))))))))));
-
-	t[3] = SCALE8_STAGE1(
-		MULA( _sbc_proto_8[21], in[5],
-		MULA( _sbc_proto_8[22], in[21],
-		MULA( _sbc_proto_8[23], in[37],
-		MULA( _sbc_proto_8[24], in[53],
-		MULA( _sbc_proto_8[25], in[69],
-		MULA(-_sbc_proto_8[15], in[15],
-		MULA(-_sbc_proto_8[14], in[31],
-		MULA(-_sbc_proto_8[13], in[47],
-		MULA(-_sbc_proto_8[12], in[63],
-		MUL( -_sbc_proto_8[11], in[79])))))))))));
-
-	t[4] = SCALE8_STAGE1(
-		MULA( _sbc_proto_8[26], in[6],
-		MULA( _sbc_proto_8[27], in[22],
-		MULA( _sbc_proto_8[28], in[38],
-		MULA( _sbc_proto_8[29], in[54],
-		MULA( _sbc_proto_8[30], in[70],
-		MULA(-_sbc_proto_8[10], in[14],
-		MULA(-_sbc_proto_8[9], in[30],
-		MULA(-_sbc_proto_8[8], in[46],
-		MULA(-_sbc_proto_8[7], in[62],
-		MUL( -_sbc_proto_8[6], in[78])))))))))));
-
-	t[5] = SCALE8_STAGE1(
-		MULA( _sbc_proto_8[31], in[7],
-		MULA( _sbc_proto_8[32], in[23],
-		MULA( _sbc_proto_8[33], in[39],
-		MULA( _sbc_proto_8[34], in[55],
-		MULA( _sbc_proto_8[35], in[71],
-		MULA(-_sbc_proto_8[20], in[13],
-		MULA(-_sbc_proto_8[19], in[29],
-		MULA(-_sbc_proto_8[18], in[45],
-		MULA(-_sbc_proto_8[17], in[61],
-		MUL( -_sbc_proto_8[16], in[77])))))))))));
-
-	t[6] = SCALE8_STAGE1(
-		MULA( _sbc_proto_8[36], (in[8] + in[72]),
-		MULA( _sbc_proto_8[37], (in[24] + in[56]),
-		MULA( _sbc_proto_8[38], in[40],
-		MULA(-_sbc_proto_8[39], in[12],
-		MULA(-_sbc_proto_8[5], in[28],
-		MULA(-_sbc_proto_8[4], in[44],
-		MULA(-_sbc_proto_8[3], in[60],
-		MUL( -_sbc_proto_8[2], in[76])))))))));
-
-	t[7] = SCALE8_STAGE1(
-		MULA( _sbc_proto_8[35], in[9],
-		MULA( _sbc_proto_8[34], in[25],
-		MULA( _sbc_proto_8[33], in[41],
-		MULA( _sbc_proto_8[32], in[57],
-		MULA( _sbc_proto_8[31], in[73],
-		MULA(-_sbc_proto_8[25], in[11],
-		MULA(-_sbc_proto_8[24], in[27],
-		MULA(-_sbc_proto_8[23], in[43],
-		MULA(-_sbc_proto_8[22], in[59],
-		MUL( -_sbc_proto_8[21], in[75])))))))))));
-
-	s[0] = MULA(  _anamatrix8[0], t[0],
-		MUL(  _anamatrix8[1], t[6]));
-	s[1] = MUL(   _anamatrix8[7], t[1]);
-	s[2] = MULA(  _anamatrix8[2], t[2],
-		MULA( _anamatrix8[3], t[3],
-		MULA( _anamatrix8[4], t[5],
-		MUL(  _anamatrix8[5], t[7]))));
-	s[3] = MUL(   _anamatrix8[6], t[4]);
-	s[4] = MULA(  _anamatrix8[3], t[2],
-		MULA(-_anamatrix8[5], t[3],
-		MULA(-_anamatrix8[2], t[5],
-		MUL( -_anamatrix8[4], t[7]))));
-	s[5] = MULA(  _anamatrix8[4], t[2],
-		MULA(-_anamatrix8[2], t[3],
-		MULA( _anamatrix8[5], t[5],
-		MUL(  _anamatrix8[3], t[7]))));
-	s[6] = MULA(  _anamatrix8[1], t[0],
-		MUL( -_anamatrix8[0], t[6]));
-	s[7] = MULA(  _anamatrix8[5], t[2],
-		MULA(-_anamatrix8[4], t[3],
-		MULA( _anamatrix8[3], t[5],
-		MUL( -_anamatrix8[2], t[7]))));
-
-	out[0] = SCALE8_STAGE2( s[0] + s[1] + s[2] + s[3]);
-	out[1] = SCALE8_STAGE2( s[1] - s[3] + s[4] + s[6]);
-	out[2] = SCALE8_STAGE2( s[1] - s[3] + s[5] - s[6]);
-	out[3] = SCALE8_STAGE2(-s[0] + s[1] + s[3] + s[7]);
-	out[4] = SCALE8_STAGE2(-s[0] + s[1] + s[3] - s[7]);
-	out[5] = SCALE8_STAGE2( s[1] - s[3] - s[5] - s[6]);
-	out[6] = SCALE8_STAGE2( s[1] - s[3] - s[4] + s[6]);
-	out[7] = SCALE8_STAGE2( s[0] + s[1] - s[2] + s[3]);
+	FIXED_A t1[8];
+	FIXED_T t2[8];
+	int i, hop;
+
+	/* rounding coefficient */
+	t1[0] = t1[1] = t1[2] = t1[3] = t1[4] = t1[5] = t1[6] = t1[7] =
+		(FIXED_A) 1 << (SBC_PROTO_FIXED8_SCALE-1);
+
+	/* low pass polyphase filter */
+	for (hop = 0; hop < 80; hop += 16) {
+		t1[0] += (FIXED_A) in[hop] * _sbc_proto_fixed8[hop];
+		t1[1] += (FIXED_A) in[hop + 1] * _sbc_proto_fixed8[hop + 1];
+		t1[2] += (FIXED_A) in[hop + 2] * _sbc_proto_fixed8[hop + 2];
+		t1[3] += (FIXED_A) in[hop + 3] * _sbc_proto_fixed8[hop + 3];
+		t1[4] += (FIXED_A) in[hop + 4] * _sbc_proto_fixed8[hop + 4];
+		t1[3] += (FIXED_A) in[hop + 5] * _sbc_proto_fixed8[hop + 5];
+		t1[2] += (FIXED_A) in[hop + 6] * _sbc_proto_fixed8[hop + 6];
+		t1[1] += (FIXED_A) in[hop + 7] * _sbc_proto_fixed8[hop + 7];
+		t1[0] += (FIXED_A) in[hop + 8] * _sbc_proto_fixed8[hop + 8];
+		t1[5] += (FIXED_A) in[hop + 9] * _sbc_proto_fixed8[hop + 9];
+		t1[6] += (FIXED_A) in[hop + 10] * _sbc_proto_fixed8[hop + 10];
+		t1[7] += (FIXED_A) in[hop + 11] * _sbc_proto_fixed8[hop + 11];
+		t1[7] += (FIXED_A) in[hop + 13] * _sbc_proto_fixed8[hop + 13];
+		t1[6] += (FIXED_A) in[hop + 14] * _sbc_proto_fixed8[hop + 14];
+		t1[5] += (FIXED_A) in[hop + 15] * _sbc_proto_fixed8[hop + 15];
+	}
+
+	/* scaling */
+	t2[0] = t1[0] >> SBC_PROTO_FIXED8_SCALE;
+	t2[1] = t1[1] >> SBC_PROTO_FIXED8_SCALE;
+	t2[2] = t1[2] >> SBC_PROTO_FIXED8_SCALE;
+	t2[3] = t1[3] >> SBC_PROTO_FIXED8_SCALE;
+	t2[4] = t1[4] >> SBC_PROTO_FIXED8_SCALE;
+	t2[5] = t1[5] >> SBC_PROTO_FIXED8_SCALE;
+	t2[6] = t1[6] >> SBC_PROTO_FIXED8_SCALE;
+	t2[7] = t1[7] >> SBC_PROTO_FIXED8_SCALE;
+
+	/* do the cos transform */
+	for (i = 0, hop = 0; i < 8; hop += 16, i++) {
+		out[i] = ((FIXED_A) t2[0] * cos_table_fixed_8[0 + hop] +
+			  (FIXED_A) t2[1] * cos_table_fixed_8[1 + hop] +
+			  (FIXED_A) t2[2] * cos_table_fixed_8[2 + hop] +
+			  (FIXED_A) t2[3] * cos_table_fixed_8[3 + hop] +
+			  (FIXED_A) t2[4] * cos_table_fixed_8[4 + hop] +
+			  (FIXED_A) t2[5] * cos_table_fixed_8[9 + hop] +
+			  (FIXED_A) t2[6] * cos_table_fixed_8[10 + hop] +
+			  (FIXED_A) t2[7] * cos_table_fixed_8[11 + hop]) >>
+			(SBC_COS_TABLE_FIXED8_SCALE - SCALE_OUT_BITS);
+	}
 }
 
-static inline void sbc_analyze_eight(struct sbc_encoder_state *state,
-					struct sbc_frame *frame, int ch,
-					int blk)
+static void sbc_analyze_4b_8s(int16_t *pcm, int16_t *x,
+			      int32_t *out, int out_stride)
 {
-	int32_t *x = &state->X[ch][state->position[ch]];
-	int16_t *pcm = &frame->pcm_sample[ch][blk * 8];
-
-	/* Input 8 Audio Samples */
-	x[80] = x[0] = pcm[7];
-	x[81] = x[1] = pcm[6];
-	x[82] = x[2] = pcm[5];
-	x[83] = x[3] = pcm[4];
-	x[84] = x[4] = pcm[3];
-	x[85] = x[5] = pcm[2];
-	x[86] = x[6] = pcm[1];
-	x[87] = x[7] = pcm[0];
-
-	_sbc_analyze_eight(x, frame->sb_sample_f[blk][ch]);
-
-	state->position[ch] -= 8;
-	if (state->position[ch] < 0)
-		state->position[ch] = 72;
+	int i;
+
+	/* Input 4 x 8 Audio Samples */
+	for (i = 0; i < 32; i += 8) {
+		x[128 + i] = x[0 + i] = pcm[31 - i];
+		x[129 + i] = x[1 + i] = pcm[30 - i];
+		x[130 + i] = x[2 + i] = pcm[29 - i];
+		x[131 + i] = x[3 + i] = pcm[28 - i];
+		x[132 + i] = x[4 + i] = pcm[27 - i];
+		x[133 + i] = x[5 + i] = pcm[26 - i];
+		x[134 + i] = x[6 + i] = pcm[25 - i];
+		x[135 + i] = x[7 + i] = pcm[24 - i];
+	}
+
+	/* Analyze four blocks */
+	_sbc_analyze_eight(x + 24, out);
+	out += out_stride;
+	_sbc_analyze_eight(x + 16, out);
+	out += out_stride;
+	_sbc_analyze_eight(x + 8, out);
+	out += out_stride;
+	_sbc_analyze_eight(x, out);
 }
 
 static int sbc_analyze_audio(struct sbc_encoder_state *state,
@@ -894,14 +801,32 @@ static int sbc_analyze_audio(struct sbc_encoder_state *state,
 	switch (frame->subbands) {
 	case 4:
 		for (ch = 0; ch < frame->channels; ch++)
-			for (blk = 0; blk < frame->blocks; blk++)
-				sbc_analyze_four(state, frame, ch, blk);
+			for (blk = 0; blk < frame->blocks; blk += 4) {
+				state->sbc_analyze_4b_4s(
+					&frame->pcm_sample[ch][blk * 4],
+					&state->X[ch][state->position[ch]],
+					frame->sb_sample_f[blk][ch],
+					frame->sb_sample_f[blk + 1][ch] -
+					frame->sb_sample_f[blk][ch]);
+				state->position[ch] -= 16;
+				if (state->position[ch] < 0)
+					state->position[ch] = 64 - 16;
+			}
 		return frame->blocks * 4;
 
 	case 8:
 		for (ch = 0; ch < frame->channels; ch++)
-			for (blk = 0; blk < frame->blocks; blk++)
-				sbc_analyze_eight(state, frame, ch, blk);
+			for (blk = 0; blk < frame->blocks; blk += 4) {
+				state->sbc_analyze_4b_8s(
+					&frame->pcm_sample[ch][blk * 8],
+					&state->X[ch][state->position[ch]],
+					frame->sb_sample_f[blk][ch],
+					frame->sb_sample_f[blk + 1][ch] -
+					frame->sb_sample_f[blk][ch]);
+				state->position[ch] -= 32;
+				if (state->position[ch] < 0)
+					state->position[ch] = 128 - 32;
+			}
 		return frame->blocks * 8;
 
 	default:
@@ -909,6 +834,26 @@ static int sbc_analyze_audio(struct sbc_encoder_state *state,
 	}
 }
 
+/* Supplementary bitstream writing macros for 'sbc_pack_frame' */
+
+#define PUT_BITS(v, n)\
+	bits_cache = (v) | (bits_cache << (n));\
+	bits_count += (n);\
+	if (bits_count >= 16) {\
+		bits_count -= 8;\
+		*data_ptr++ = (uint8_t) (bits_cache >> bits_count);\
+		bits_count -= 8;\
+		*data_ptr++ = (uint8_t) (bits_cache >> bits_count);\
+	}\
+
+#define FLUSH_BITS()\
+	while (bits_count >= 8) {\
+		bits_count -= 8;\
+		*data_ptr++ = (uint8_t) (bits_cache >> bits_count);\
+	}\
+	if (bits_count > 0)\
+	    *data_ptr++ = (uint8_t) (bits_cache << (8 - bits_count));\
+
 /*
  * Packs the SBC frame from frame into the memory at data. At most len
  * bytes will be used, should more memory be needed an appropriate
@@ -926,16 +871,21 @@ static int sbc_analyze_audio(struct sbc_encoder_state *state,
 
 static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 {
-	int produced;
+	/* Bitstream writer starts from the fourth byte */
+	uint8_t *data_ptr = data + 4;
+	uint32_t bits_cache = 0;
+	uint32_t bits_count = 0;
+
 	/* Will copy the header parts for CRC-8 calculation here */
 	uint8_t crc_header[11] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
 	int crc_pos = 0;
 
-	uint16_t audio_sample;
+	uint32_t audio_sample;
 
-	int ch, sb, blk, bit;	/* channel, subband, block and bit counters */
+	int ch, sb, blk;	/* channel, subband, block and bit counters */
 	int bits[2][8];		/* bits distribution */
-	int levels[2][8];	/* levels are derived from that */
+	uint32_t levels[2][8];	/* levels are derived from that */
+	uint32_t sb_sample_delta[2][8];
 
 	u_int32_t scalefactor[2][8];	/* derived from frame->scale_factor */
 
@@ -973,8 +923,6 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 
 	/* Can't fill in crc yet */
 
-	produced = 32;
-
 	crc_header[0] = data[1];
 	crc_header[1] = data[2];
 	crc_pos = 16;
@@ -982,7 +930,7 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 	for (ch = 0; ch < frame->channels; ch++) {
 		for (sb = 0; sb < frame->subbands; sb++) {
 			frame->scale_factor[ch][sb] = 0;
-			scalefactor[ch][sb] = 2;
+			scalefactor[ch][sb] = 2 << SCALE_OUT_BITS;
 			for (blk = 0; blk < frame->blocks; blk++) {
 				while (scalefactor[ch][sb] < fabs(frame->sb_sample_f[blk][ch][sb])) {
 					frame->scale_factor[ch][sb]++;
@@ -999,22 +947,23 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 		u_int32_t scalefactor_j[2];
 		uint8_t scale_factor_j[2];
 
+		uint8_t joint = 0;
 		frame->joint = 0;
 
 		for (sb = 0; sb < frame->subbands - 1; sb++) {
 			scale_factor_j[0] = 0;
-			scalefactor_j[0] = 2;
+			scalefactor_j[0] = 2 << SCALE_OUT_BITS;
 			scale_factor_j[1] = 0;
-			scalefactor_j[1] = 2;
+			scalefactor_j[1] = 2 << SCALE_OUT_BITS;
 
 			for (blk = 0; blk < frame->blocks; blk++) {
 				/* Calculate joint stereo signal */
 				sb_sample_j[blk][0] =
-					(frame->sb_sample_f[blk][0][sb] +
-						frame->sb_sample_f[blk][1][sb]) >> 1;
+					ASR(frame->sb_sample_f[blk][0][sb], 1) +
+					ASR(frame->sb_sample_f[blk][1][sb], 1);
 				sb_sample_j[blk][1] =
-					(frame->sb_sample_f[blk][0][sb] -
-						frame->sb_sample_f[blk][1][sb]) >> 1;
+					ASR(frame->sb_sample_f[blk][0][sb], 1) -
+					ASR(frame->sb_sample_f[blk][1][sb], 1);
 
 				/* calculate scale_factor_j and scalefactor_j for joint case */
 				while (scalefactor_j[0] < fabs(sb_sample_j[blk][0])) {
@@ -1028,14 +977,15 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 			}
 
 			/* decide whether to join this subband */
-			if ((scalefactor[0][sb] + scalefactor[1][sb]) >
-					(scalefactor_j[0] + scalefactor_j[1]) ) {
+			if ((frame->scale_factor[0][sb] +
+					frame->scale_factor[1][sb]) >
+					(scale_factor_j[0] +
+					scale_factor_j[1])) {
 				/* use joint stereo for this subband */
+				joint |= 1 << (frame->subbands - 1 - sb);
 				frame->joint |= 1 << sb;
 				frame->scale_factor[0][sb] = scale_factor_j[0];
 				frame->scale_factor[1][sb] = scale_factor_j[1];
-				scalefactor[0][sb] = scalefactor_j[0];
-				scalefactor[1][sb] = scalefactor_j[1];
 				for (blk = 0; blk < frame->blocks; blk++) {
 					frame->sb_sample_f[blk][0][sb] =
 							sb_sample_j[blk][0];
@@ -1045,24 +995,16 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 			}
 		}
 
-		data[4] = 0;
-		for (sb = 0; sb < frame->subbands - 1; sb++)
-			data[4] |= ((frame->joint >> sb) & 0x01) << (frame->subbands - 1 - sb);
-
-		crc_header[crc_pos >> 3] = data[4];
-
-		produced += frame->subbands;
+		PUT_BITS(joint, frame->subbands);
+		crc_header[crc_pos >> 3] = joint;
 		crc_pos += frame->subbands;
 	}
 
 	for (ch = 0; ch < frame->channels; ch++) {
 		for (sb = 0; sb < frame->subbands; sb++) {
-			data[produced >> 3] <<= 4;
+			PUT_BITS(frame->scale_factor[ch][sb] & 0x0F, 4);
 			crc_header[crc_pos >> 3] <<= 4;
-			data[produced >> 3] |= frame->scale_factor[ch][sb] & 0x0F;
 			crc_header[crc_pos >> 3] |= frame->scale_factor[ch][sb] & 0x0F;
-
-			produced += 4;
 			crc_pos += 4;
 		}
 	}
@@ -1076,37 +1018,47 @@ static int sbc_pack_frame(uint8_t *data, struct sbc_frame *frame, size_t len)
 	sbc_calculate_bits(frame, bits);
 
 	for (ch = 0; ch < frame->channels; ch++) {
-		for (sb = 0; sb < frame->subbands; sb++)
-			levels[ch][sb] = (1 << bits[ch][sb]) - 1;
+		for (sb = 0; sb < frame->subbands; sb++) {
+			levels[ch][sb] = ((1 << bits[ch][sb]) - 1) <<
+				(32 - (frame->scale_factor[ch][sb] +
+					SCALE_OUT_BITS + 2));
+			sb_sample_delta[ch][sb] = (uint32_t) 1 <<
+				(frame->scale_factor[ch][sb] +
+					SCALE_OUT_BITS + 1);
+		}
 	}
 
 	for (blk = 0; blk < frame->blocks; blk++) {
 		for (ch = 0; ch < frame->channels; ch++) {
 			for (sb = 0; sb < frame->subbands; sb++) {
-				if (levels[ch][sb] > 0) {
-					audio_sample =
-						(uint16_t) ((((frame->sb_sample_f[blk][ch][sb]*levels[ch][sb]) >>
-									(frame->scale_factor[ch][sb] + 1)) +
-								levels[ch][sb]) >> 1);
-					audio_sample <<= 16 - bits[ch][sb];
-					for (bit = 0; bit < bits[ch][sb]; bit++) {
-						data[produced >> 3] <<= 1;
-						if (audio_sample & 0x8000)
-							data[produced >> 3] |= 0x1;
-						audio_sample <<= 1;
-						produced++;
-					}
-				}
+
+				if (bits[ch][sb] == 0)
+					continue;
+
+				audio_sample = ((uint64_t) levels[ch][sb] *
+					(sb_sample_delta[ch][sb] +
+					frame->sb_sample_f[blk][ch][sb])) >> 32;
+
+				PUT_BITS(audio_sample, bits[ch][sb]);
 			}
 		}
 	}
 
-	/* align the last byte */
-	if (produced % 8) {
-		data[produced >> 3] <<= 8 - (produced % 8);
-	}
+	FLUSH_BITS();
+
+	return data_ptr - data;
+}
+
+static void sbc_encoder_init(struct sbc_encoder_state *state,
+				const struct sbc_frame *frame)
+{
+	memset(&state->X, 0, sizeof(state->X));
+	state->subbands = frame->subbands;
+	state->position[0] = state->position[1] = 12 * frame->subbands;
 
-	return (produced + 7) >> 3;
+	/* Default implementation for analyze function */
+	state->sbc_analyze_4b_4s = sbc_analyze_4b_4s;
+	state->sbc_analyze_4b_8s = sbc_analyze_4b_8s;
 }
 
 struct sbc_priv {
@@ -1190,6 +1142,9 @@ int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output,
 	if (written)
 		*written = 0;
 
+	if (framelen <= 0)
+		return framelen;
+
 	samples = sbc_synthesize_audio(&priv->dec_state, &priv->frame);
 
 	ptr = output;
@@ -1202,13 +1157,7 @@ int sbc_decode(sbc_t *sbc, void *input, int input_len, void *output,
 			int16_t s;
 			s = priv->frame.pcm_sample[ch][i];
 
-#if __BYTE_ORDER == __LITTLE_ENDIAN
 			if (sbc->endian == SBC_BE) {
-#elif __BYTE_ORDER == __BIG_ENDIAN
-			if (sbc->endian == SBC_LE) {
-#else
-#error "Unknown byte order"
-#endif
 				*ptr++ = (s & 0xff00) >> 8;
 				*ptr++ = (s & 0x00ff);
 			} else {
@@ -1269,13 +1218,7 @@ int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output,
 	for (i = 0; i < priv->frame.subbands * priv->frame.blocks; i++) {
 		for (ch = 0; ch < priv->frame.channels; ch++) {
 			int16_t s;
-#if __BYTE_ORDER == __LITTLE_ENDIAN
 			if (sbc->endian == SBC_BE)
-#elif __BYTE_ORDER == __BIG_ENDIAN
-			if (sbc->endian == SBC_LE)
-#else
-#error "Unknown byte order"
-#endif
 				s = (ptr[0] & 0xff) << 8 | (ptr[1] & 0xff);
 			else
 				s = (ptr[0] & 0xff) | (ptr[1] & 0xff) << 8;
@@ -1374,9 +1317,9 @@ int sbc_get_frame_duration(sbc_t *sbc)
 	return (1000000 * blocks * subbands) / frequency;
 }
 
-int sbc_get_codesize(sbc_t *sbc)
+uint16_t sbc_get_codesize(sbc_t *sbc)
 {
-	uint8_t subbands, channels, blocks;
+	uint16_t subbands, channels, blocks;
 	struct sbc_priv *priv;
 
 	priv = sbc->priv;
diff --git a/src/modules/bluetooth/sbc.h b/src/modules/bluetooth/sbc.h
index ab47e32..8ac5930 100644
--- a/src/modules/bluetooth/sbc.h
+++ b/src/modules/bluetooth/sbc.h
@@ -2,7 +2,7 @@
  *
  *  Bluetooth low-complexity, subband codec (SBC) library
  *
- *  Copyright (C) 2004-2008  Marcel Holtmann <marcel at holtmann.org>
+ *  Copyright (C) 2004-2009  Marcel Holtmann <marcel at holtmann.org>
  *  Copyright (C) 2004-2005  Henryk Ploetz <henryk at ploetzli.ch>
  *  Copyright (C) 2005-2006  Brad Midgley <bmidgley at xmission.com>
  *
@@ -87,7 +87,7 @@ int sbc_encode(sbc_t *sbc, void *input, int input_len, void *output,
 		int output_len, int *written);
 int sbc_get_frame_length(sbc_t *sbc);
 int sbc_get_frame_duration(sbc_t *sbc);
-int sbc_get_codesize(sbc_t *sbc);
+uint16_t sbc_get_codesize(sbc_t *sbc);
 void sbc_finish(sbc_t *sbc);
 
 #ifdef __cplusplus
diff --git a/src/modules/bluetooth/sbc_math.h b/src/modules/bluetooth/sbc_math.h
index b3d87a6..6ca4f52 100644
--- a/src/modules/bluetooth/sbc_math.h
+++ b/src/modules/bluetooth/sbc_math.h
@@ -2,7 +2,7 @@
  *
  *  Bluetooth low-complexity, subband codec (SBC) library
  *
- *  Copyright (C) 2004-2008  Marcel Holtmann <marcel at holtmann.org>
+ *  Copyright (C) 2004-2009  Marcel Holtmann <marcel at holtmann.org>
  *  Copyright (C) 2004-2005  Henryk Ploetz <henryk at ploetzli.ch>
  *  Copyright (C) 2005-2008  Brad Midgley <bmidgley at xmission.com>
  *
@@ -29,31 +29,21 @@
 #define ASR(val, bits) ((-2 >> 1 == -1) ? \
 		 ((int32_t)(val)) >> (bits) : ((int32_t) (val)) / (1 << (bits)))
 
-#define SCALE_PROTO4_TBL	15
-#define SCALE_ANA4_TBL		17
-#define SCALE_PROTO8_TBL	16
-#define SCALE_ANA8_TBL		17
+#define SCALE_OUT_BITS 15
+
 #define SCALE_SPROTO4_TBL	12
 #define SCALE_SPROTO8_TBL	14
 #define SCALE_NPROTO4_TBL	11
 #define SCALE_NPROTO8_TBL	11
-#define SCALE4_STAGE1_BITS	15
-#define SCALE4_STAGE2_BITS	16
 #define SCALE4_STAGED1_BITS	15
 #define SCALE4_STAGED2_BITS	16
-#define SCALE8_STAGE1_BITS	15
-#define SCALE8_STAGE2_BITS	15
 #define SCALE8_STAGED1_BITS	15
 #define SCALE8_STAGED2_BITS	16
 
 typedef int32_t sbc_fixed_t;
 
-#define SCALE4_STAGE1(src)  ASR(src, SCALE4_STAGE1_BITS)
-#define SCALE4_STAGE2(src)  ASR(src, SCALE4_STAGE2_BITS)
 #define SCALE4_STAGED1(src) ASR(src, SCALE4_STAGED1_BITS)
 #define SCALE4_STAGED2(src) ASR(src, SCALE4_STAGED2_BITS)
-#define SCALE8_STAGE1(src)  ASR(src, SCALE8_STAGE1_BITS)
-#define SCALE8_STAGE2(src)  ASR(src, SCALE8_STAGE2_BITS)
 #define SCALE8_STAGED1(src) ASR(src, SCALE8_STAGED1_BITS)
 #define SCALE8_STAGED2(src) ASR(src, SCALE8_STAGED2_BITS)
 
diff --git a/src/modules/bluetooth/sbc_tables.h b/src/modules/bluetooth/sbc_tables.h
index 7ac4e68..f1dfe6c 100644
--- a/src/modules/bluetooth/sbc_tables.h
+++ b/src/modules/bluetooth/sbc_tables.h
@@ -2,7 +2,7 @@
  *
  *  Bluetooth low-complexity, subband codec (SBC) library
  *
- *  Copyright (C) 2004-2008  Marcel Holtmann <marcel at holtmann.org>
+ *  Copyright (C) 2004-2009  Marcel Holtmann <marcel at holtmann.org>
  *  Copyright (C) 2004-2005  Henryk Ploetz <henryk at ploetzli.ch>
  *  Copyright (C) 2005-2006  Brad Midgley <bmidgley at xmission.com>
  *
@@ -39,40 +39,12 @@ static const int sbc_offset8[4][8] = {
 	{ -4, 0, 0, 0, 0, 0, 1, 2 }
 };
 
-#define SP4(val) ASR(val, SCALE_PROTO4_TBL)
-#define SA4(val) ASR(val, SCALE_ANA4_TBL)
-#define SP8(val) ASR(val, SCALE_PROTO8_TBL)
-#define SA8(val) ASR(val, SCALE_ANA8_TBL)
+
 #define SS4(val) ASR(val, SCALE_SPROTO4_TBL)
 #define SS8(val) ASR(val, SCALE_SPROTO8_TBL)
 #define SN4(val) ASR(val, SCALE_NPROTO4_TBL)
 #define SN8(val) ASR(val, SCALE_NPROTO8_TBL)
 
-static const int32_t _sbc_proto_4[20] = {
-	SP4(0x02cb3e8c), SP4(0x22b63dc0), SP4(0x002329cc), SP4(0x053b7548),
-	SP4(0x31eab940), SP4(0xec1f5e60), SP4(0xff3773a8), SP4(0x0061c5a7),
-	SP4(0x07646680), SP4(0x3f239480), SP4(0xf89f23a8), SP4(0x007a4737),
-	SP4(0x00b32807), SP4(0x083ddc80), SP4(0x4825e480), SP4(0x0191e578),
-	SP4(0x00ff11ca), SP4(0x00fb7991), SP4(0x069fdc58), SP4(0x4b584000)
-};
-
-static const int32_t _anamatrix4[4] = {
-	SA4(0x2d413cc0), SA4(0x3b20d780), SA4(0x40000000), SA4(0x187de2a0)
-};
-
-static const int32_t _sbc_proto_8[40] = {
-	SP8(0x02e5cd20), SP8(0x22d0c200), SP8(0x006bfe27), SP8(0x07808930),
-	SP8(0x3f1c8800), SP8(0xf8810d70), SP8(0x002cfdc6), SP8(0x055acf28),
-	SP8(0x31f566c0), SP8(0xebfe57e0), SP8(0xff27c437), SP8(0x001485cc),
-	SP8(0x041c6e58), SP8(0x2a7cfa80), SP8(0xe4c4a240), SP8(0xfe359e4c),
-	SP8(0x0048b1f8), SP8(0x0686ce30), SP8(0x38eec5c0), SP8(0xf2a1b9f0),
-	SP8(0xffe8904a), SP8(0x0095698a), SP8(0x0824a480), SP8(0x443b3c00),
-	SP8(0xfd7badc8), SP8(0x00d3e2d9), SP8(0x00c183d2), SP8(0x084e1950),
-	SP8(0x4810d800), SP8(0x017f43fe), SP8(0x01056dd8), SP8(0x00e9cb9f),
-	SP8(0x07d7d090), SP8(0x4a708980), SP8(0x0488fae8), SP8(0x0113bd20),
-	SP8(0x0107b1a8), SP8(0x069fb3c0), SP8(0x4b3db200), SP8(0x00763f48)
-};
-
 static const int32_t sbc_proto_4_40m0[] = {
 	SS4(0x00000000), SS4(0xffa6982f), SS4(0xfba93848), SS4(0x0456c7b8),
 	SS4(0x005967d1), SS4(0xfffb9ac7), SS4(0xff589157), SS4(0xf9c2a8d8),
@@ -115,11 +87,6 @@ static const int32_t sbc_proto_8_80m1[] = {
 	SS8(0x0d9daee0), SS8(0xeac182c0), SS8(0xfdf1c8d4), SS8(0xfff5bd1a)
 };
 
-static const int32_t _anamatrix8[8] = {
-	SA8(0x3b20d780), SA8(0x187de2a0), SA8(0x3ec52f80), SA8(0x3536cc40),
-	SA8(0x238e7680), SA8(0x0c7c5c20), SA8(0x2d413cc0), SA8(0x40000000)
-};
-
 static const int32_t synmatrix4[8][4] = {
 	{ SN4(0x05a82798), SN4(0xfa57d868), SN4(0xfa57d868), SN4(0x05a82798) },
 	{ SN4(0x030fbc54), SN4(0xf89be510), SN4(0x07641af0), SN4(0xfcf043ac) },
@@ -165,3 +132,216 @@ static const int32_t synmatrix8[16][8] = {
 	{ SN8(0xf9592678), SN8(0x018f8b84), SN8(0x07d8a5f0), SN8(0x0471ced0),
 	  SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) }
 };
+
+/* Uncomment the following line to enable high precision build of SBC encoder */
+
+/* #define SBC_HIGH_PRECISION */
+
+#ifdef SBC_HIGH_PRECISION
+#define FIXED_A int64_t /* data type for fixed point accumulator */
+#define FIXED_T int32_t /* data type for fixed point constants */
+#define SBC_FIXED_EXTRA_BITS 16
+#else
+#define FIXED_A int32_t /* data type for fixed point accumulator */
+#define FIXED_T int16_t /* data type for fixed point constants */
+#define SBC_FIXED_EXTRA_BITS 0
+#endif
+
+/* A2DP specification: Section 12.8 Tables
+ *
+ * Original values are premultiplied by 2 for better precision (that is the
+ * maximum which is possible without overflows)
+ *
+ * Note: in each block of 8 numbers sign was changed for elements 2 and 7
+ * in order to compensate the same change applied to cos_table_fixed_4
+ */
+#define SBC_PROTO_FIXED4_SCALE \
+	((sizeof(FIXED_T) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 1)
+#define F(x) (FIXED_A) ((x * 2) * \
+	((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
+static const FIXED_T _sbc_proto_fixed4[40] = {
+	 F(0.00000000E+00),  F(5.36548976E-04),
+	-F(1.49188357E-03),  F(2.73370904E-03),
+	 F(3.83720193E-03),  F(3.89205149E-03),
+	 F(1.86581691E-03),  F(3.06012286E-03),
+
+	 F(1.09137620E-02),  F(2.04385087E-02),
+	-F(2.88757392E-02),  F(3.21939290E-02),
+	 F(2.58767811E-02),  F(6.13245186E-03),
+	-F(2.88217274E-02),  F(7.76463494E-02),
+
+	 F(1.35593274E-01),  F(1.94987841E-01),
+	-F(2.46636662E-01),  F(2.81828203E-01),
+	 F(2.94315332E-01),  F(2.81828203E-01),
+	 F(2.46636662E-01), -F(1.94987841E-01),
+
+	-F(1.35593274E-01), -F(7.76463494E-02),
+	 F(2.88217274E-02),  F(6.13245186E-03),
+	 F(2.58767811E-02),  F(3.21939290E-02),
+	 F(2.88757392E-02), -F(2.04385087E-02),
+
+	-F(1.09137620E-02), -F(3.06012286E-03),
+	-F(1.86581691E-03),  F(3.89205149E-03),
+	 F(3.83720193E-03),  F(2.73370904E-03),
+	 F(1.49188357E-03), -F(5.36548976E-04),
+};
+#undef F
+
+/*
+ * To produce this cosine matrix in Octave:
+ *
+ * b = zeros(4, 8);
+ * for i = 0:3
+ * for j = 0:7 b(i+1, j+1) = cos((i + 0.5) * (j - 2) * (pi/4))
+ * endfor
+ * endfor;
+ * printf("%.10f, ", b');
+ *
+ * Note: in each block of 8 numbers sign was changed for elements 2 and 7
+ *
+ * Change of sign for element 2 allows to replace constant 1.0 (not
+ * representable in Q15 format) with -1.0 (fine with Q15).
+ * Changed sign for element 7 allows to have more similar constants
+ * and simplify subband filter function code.
+ */
+#define SBC_COS_TABLE_FIXED4_SCALE \
+	((sizeof(FIXED_T) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
+#define F(x) (FIXED_A) ((x) * \
+	((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
+static const FIXED_T cos_table_fixed_4[32] = {
+	 F(0.7071067812),  F(0.9238795325), -F(1.0000000000),  F(0.9238795325),
+	 F(0.7071067812),  F(0.3826834324),  F(0.0000000000),  F(0.3826834324),
+
+	-F(0.7071067812),  F(0.3826834324), -F(1.0000000000),  F(0.3826834324),
+	-F(0.7071067812), -F(0.9238795325), -F(0.0000000000), -F(0.9238795325),
+
+	-F(0.7071067812), -F(0.3826834324), -F(1.0000000000), -F(0.3826834324),
+	-F(0.7071067812),  F(0.9238795325),  F(0.0000000000),  F(0.9238795325),
+
+	 F(0.7071067812), -F(0.9238795325), -F(1.0000000000), -F(0.9238795325),
+	 F(0.7071067812), -F(0.3826834324), -F(0.0000000000), -F(0.3826834324),
+};
+#undef F
+
+/* A2DP specification: Section 12.8 Tables
+ *
+ * Original values are premultiplied by 4 for better precision (that is the
+ * maximum which is possible without overflows)
+ *
+ * Note: in each block of 16 numbers sign was changed for elements 4, 13, 14, 15
+ * in order to compensate the same change applied to cos_table_fixed_8
+ */
+#define SBC_PROTO_FIXED8_SCALE \
+	((sizeof(FIXED_T) * CHAR_BIT - 1) - SBC_FIXED_EXTRA_BITS + 2)
+#define F(x) (FIXED_A) ((x * 4) * \
+	((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
+static const FIXED_T _sbc_proto_fixed8[80] = {
+	 F(0.00000000E+00),  F(1.56575398E-04),
+	 F(3.43256425E-04),  F(5.54620202E-04),
+	-F(8.23919506E-04),  F(1.13992507E-03),
+	 F(1.47640169E-03),  F(1.78371725E-03),
+	 F(2.01182542E-03),  F(2.10371989E-03),
+	 F(1.99454554E-03),  F(1.61656283E-03),
+	 F(9.02154502E-04),  F(1.78805361E-04),
+	 F(1.64973098E-03),  F(3.49717454E-03),
+
+	 F(5.65949473E-03),  F(8.02941163E-03),
+	 F(1.04584443E-02),  F(1.27472335E-02),
+	-F(1.46525263E-02),  F(1.59045603E-02),
+	 F(1.62208471E-02),  F(1.53184106E-02),
+	 F(1.29371806E-02),  F(8.85757540E-03),
+	 F(2.92408442E-03), -F(4.91578024E-03),
+	-F(1.46404076E-02),  F(2.61098752E-02),
+	 F(3.90751381E-02),  F(5.31873032E-02),
+
+	 F(6.79989431E-02),  F(8.29847578E-02),
+	 F(9.75753918E-02),  F(1.11196689E-01),
+	-F(1.23264548E-01),  F(1.33264415E-01),
+	 F(1.40753505E-01),  F(1.45389847E-01),
+	 F(1.46955068E-01),  F(1.45389847E-01),
+	 F(1.40753505E-01),  F(1.33264415E-01),
+	 F(1.23264548E-01), -F(1.11196689E-01),
+	-F(9.75753918E-02), -F(8.29847578E-02),
+
+	-F(6.79989431E-02), -F(5.31873032E-02),
+	-F(3.90751381E-02), -F(2.61098752E-02),
+	 F(1.46404076E-02), -F(4.91578024E-03),
+	 F(2.92408442E-03),  F(8.85757540E-03),
+	 F(1.29371806E-02),  F(1.53184106E-02),
+	 F(1.62208471E-02),  F(1.59045603E-02),
+	 F(1.46525263E-02), -F(1.27472335E-02),
+	-F(1.04584443E-02), -F(8.02941163E-03),
+
+	-F(5.65949473E-03), -F(3.49717454E-03),
+	-F(1.64973098E-03), -F(1.78805361E-04),
+	-F(9.02154502E-04),  F(1.61656283E-03),
+	 F(1.99454554E-03),  F(2.10371989E-03),
+	 F(2.01182542E-03),  F(1.78371725E-03),
+	 F(1.47640169E-03),  F(1.13992507E-03),
+	 F(8.23919506E-04), -F(5.54620202E-04),
+	-F(3.43256425E-04), -F(1.56575398E-04),
+};
+#undef F
+
+/*
+ * To produce this cosine matrix in Octave:
+ *
+ * b = zeros(8, 16);
+ * for i = 0:7
+ * for j = 0:15 b(i+1, j+1) = cos((i + 0.5) * (j - 4) * (pi/8))
+ * endfor endfor;
+ * printf("%.10f, ", b');
+ *
+ * Note: in each block of 16 numbers sign was changed for elements 4, 13, 14, 15
+ *
+ * Change of sign for element 4 allows to replace constant 1.0 (not
+ * representable in Q15 format) with -1.0 (fine with Q15).
+ * Changed signs for elements 13, 14, 15 allow to have more similar constants
+ * and simplify subband filter function code.
+ */
+#define SBC_COS_TABLE_FIXED8_SCALE \
+	((sizeof(FIXED_T) * CHAR_BIT - 1) + SBC_FIXED_EXTRA_BITS)
+#define F(x) (FIXED_A) ((x) * \
+	((FIXED_A) 1 << (sizeof(FIXED_T) * CHAR_BIT - 1)) + 0.5)
+static const FIXED_T cos_table_fixed_8[128] = {
+	 F(0.7071067812),  F(0.8314696123),  F(0.9238795325),  F(0.9807852804),
+	-F(1.0000000000),  F(0.9807852804),  F(0.9238795325),  F(0.8314696123),
+	 F(0.7071067812),  F(0.5555702330),  F(0.3826834324),  F(0.1950903220),
+	 F(0.0000000000),  F(0.1950903220),  F(0.3826834324),  F(0.5555702330),
+
+	-F(0.7071067812), -F(0.1950903220),  F(0.3826834324),  F(0.8314696123),
+	-F(1.0000000000),  F(0.8314696123),  F(0.3826834324), -F(0.1950903220),
+	-F(0.7071067812), -F(0.9807852804), -F(0.9238795325), -F(0.5555702330),
+	-F(0.0000000000), -F(0.5555702330), -F(0.9238795325), -F(0.9807852804),
+
+	-F(0.7071067812), -F(0.9807852804), -F(0.3826834324),  F(0.5555702330),
+	-F(1.0000000000),  F(0.5555702330), -F(0.3826834324), -F(0.9807852804),
+	-F(0.7071067812),  F(0.1950903220),  F(0.9238795325),  F(0.8314696123),
+	 F(0.0000000000),  F(0.8314696123),  F(0.9238795325),  F(0.1950903220),
+
+	 F(0.7071067812), -F(0.5555702330), -F(0.9238795325),  F(0.1950903220),
+	-F(1.0000000000),  F(0.1950903220), -F(0.9238795325), -F(0.5555702330),
+	 F(0.7071067812),  F(0.8314696123), -F(0.3826834324), -F(0.9807852804),
+	-F(0.0000000000), -F(0.9807852804), -F(0.3826834324),  F(0.8314696123),
+
+	 F(0.7071067812),  F(0.5555702330), -F(0.9238795325), -F(0.1950903220),
+	-F(1.0000000000), -F(0.1950903220), -F(0.9238795325),  F(0.5555702330),
+	 F(0.7071067812), -F(0.8314696123), -F(0.3826834324),  F(0.9807852804),
+	 F(0.0000000000),  F(0.9807852804), -F(0.3826834324), -F(0.8314696123),
+
+	-F(0.7071067812),  F(0.9807852804), -F(0.3826834324), -F(0.5555702330),
+	-F(1.0000000000), -F(0.5555702330), -F(0.3826834324),  F(0.9807852804),
+	-F(0.7071067812), -F(0.1950903220),  F(0.9238795325), -F(0.8314696123),
+	-F(0.0000000000), -F(0.8314696123),  F(0.9238795325), -F(0.1950903220),
+
+	-F(0.7071067812),  F(0.1950903220),  F(0.3826834324), -F(0.8314696123),
+	-F(1.0000000000), -F(0.8314696123),  F(0.3826834324),  F(0.1950903220),
+	-F(0.7071067812),  F(0.9807852804), -F(0.9238795325),  F(0.5555702330),
+	-F(0.0000000000),  F(0.5555702330), -F(0.9238795325),  F(0.9807852804),
+
+	 F(0.7071067812), -F(0.8314696123),  F(0.9238795325), -F(0.9807852804),
+	-F(1.0000000000), -F(0.9807852804),  F(0.9238795325), -F(0.8314696123),
+	 F(0.7071067812), -F(0.5555702330),  F(0.3826834324), -F(0.1950903220),
+	-F(0.0000000000), -F(0.1950903220),  F(0.3826834324), -F(0.5555702330),
+};
+#undef F

commit a1a1119afe6647099f69d7ae95de9f34b766fa75
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Thu Jan 8 19:38:38 2009 +0200

    build: fix missing x11 modules dependencies

diff --git a/configure.ac b/configure.ac
index ae6dd96..277ae2a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -437,7 +437,7 @@ AC_ARG_ENABLE([x11],
         [x11=auto])
 
 if test "x${x11}" != xno ; then
-    PKG_CHECK_MODULES(X11, [ x11 ],
+    PKG_CHECK_MODULES(X11, [ x11 ice sm ],
         HAVE_X11=1,
         [
             HAVE_X11=0

commit 6b9056c61a174cd8fa085f85afa60f4e4ef3b5ed
Merge: a1a1119... 17ae579...
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 8 19:35:58 2009 +0100

    Merge commit 'origin/master-tx'


commit 7ca0f384c8b122f6acb3547d20ca3a838507a038
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 8 19:37:29 2009 +0100

    run "make update-po"

diff --git a/po/ca.po b/po/ca.po
index 4098336..825e13a 100644
--- a/po/ca.po
+++ b/po/ca.po
@@ -19,7 +19,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: pulseaudio\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-07 13:48+0000\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 1008-11-08 HO:MI+ZONE\n"
 "Last-Translator: Xavier Conde Rueda <xavi.conde at gmail.com>\n"
 "Language-Team: Catalan <fedora at softcatala.net>\n"
@@ -27,14 +27,20 @@ msgstr ""
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177 ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
-msgstr ""
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "No s'ha trobat el carregador dlopen original."
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
 msgstr "No s'ha trobat el carregador dlopen original."
 
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
+msgstr ""
+
 #: ../src/daemon/polkit.c:55
 #, c-format
 msgid "Cannot connect to system bus: %s"
@@ -160,259 +166,247 @@ msgstr ""
 msgid "Failed to parse command line."
 msgstr ""
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the "
-"configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
 
-#: ../src/daemon/main.c:480
-msgid ""
-"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-"For enabling real-time scheduling please acquire the appropriate PolicyKit "
-"priviliges, or become a member of '"
-msgstr ""
-
-#: ../src/daemon/main.c:481
-msgid ""
-"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."
-msgstr ""
-
-#: ../src/daemon/main.c:497
+#: ../src/daemon/main.c:526
 msgid ""
 "High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr ""
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr ""
 
-#: ../src/daemon/main.c:539
+#: ../src/daemon/main.c:572
 msgid ""
 "Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr ""
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr ""
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:627
+#: ../src/daemon/main.c:663
 msgid ""
 "This program is not intended to be run as root (unless --system is "
 "specified)."
 msgstr ""
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+msgid "Root privileges required."
 msgstr ""
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr ""
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr ""
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr ""
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr ""
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr ""
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr ""
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr ""
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr ""
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr ""
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr ""
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr ""
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr ""
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr ""
 
-#: ../src/daemon/main.c:850
+#: ../src/daemon/main.c:886
 msgid ""
 "Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
 "resolution timers enabled!"
 msgstr ""
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr ""
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr ""
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr ""
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr ""
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr ""
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:117
+#: ../src/daemon/cmdline.c:123
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -428,7 +422,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
@@ -458,6 +453,10 @@ msgid ""
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
 "  -p, --dl-search-path=PATH             Set the search path for dynamic "
 "shared\n"
 "                                        objects (plugins)\n"
@@ -481,58 +480,66 @@ msgid ""
 "  -n                                    Don't load default script file\n"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:262
+#: ../src/daemon/cmdline.c:271
 msgid ""
 "--log-level expects log level argument (either numeric in range 0..4 or one "
 "of debug, info, notice, warn, error)."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:335
+msgid "--log-time boolean argument"
+msgstr ""
+
+#: ../src/daemon/cmdline.c:342
+msgid "--log-meta boolean argument"
+msgstr ""
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr ""
 
@@ -576,73 +583,73 @@ msgstr ""
 msgid "Path: %s\n"
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr ""
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+msgid "Dropping root privileges."
 msgstr ""
 
 #: ../src/daemon/caps.c:103
@@ -978,177 +985,177 @@ msgstr ""
 msgid "Received message for unknown extension '%s'"
 msgstr ""
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr ""
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:307 ../src/utils/pasuspender.c:159
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
 #: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:328 ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:333 ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:343 ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr ""
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1201,7 +1208,7 @@ msgid ""
 "per request in bytes.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1209,87 +1216,87 @@ msgid ""
 "Linked with libpulse %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr ""
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:742 ../src/utils/pasuspender.c:280
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
 #: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:769 ../src/utils/pasuspender.c:293
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
 #: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr ""
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:795 ../src/utils/pasuspender.c:301
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
 #: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
diff --git a/po/cs.po b/po/cs.po
index b955646..7b8ccc7 100644
--- a/po/cs.po
+++ b/po/cs.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: pulseaudio\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-19 02:21+0000\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-10-19 22:31+0200\n"
 "Last-Translator: Petr Kovar <pknbe at volny.cz>\n"
 "Language-Team: Czech <translation-team-cs at lists.sourceforge.net>\n"
@@ -17,14 +17,20 @@ msgstr ""
 "X-Generator: KBabel 1.11.4\n"
 "Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177 ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
-msgstr "Nezdařilo se přidat bind-now-loader."
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "Nezdařilo se nalezení původního nahrávacího programu dlopen."
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
 msgstr "Nezdařilo se nalezení původního nahrávacího programu dlopen."
 
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
+msgstr "Nezdařilo se přidat bind-now-loader."
+
 #: ../src/daemon/polkit.c:55
 #, c-format
 msgid "Cannot connect to system bus: %s"
@@ -150,90 +156,84 @@ msgstr "setrlimit(%s, (%u, %u)) selhalo: %s"
 msgid "Failed to parse command line."
 msgstr "Nezdařila se analýza příkazového řádku."
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
-msgstr "Nacházíme se ve skupině \"%s\", což umožňuje plánování o vysoké prioritě."
+msgstr ""
+"Nacházíme se ve skupině \"%s\", což umožňuje plánování o vysoké prioritě."
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr "Nacházíme se ve skupině \"%s\", což umožňuje plánování v reálném čase."
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr "PolicyKit nám udělil oprávnění acquire-high-priority."
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr "PolicyKit nám neudělil oprávnění acquire-high-priority."
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr "PolicyKit nám udělil oprávnění acquire-real-time."
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr "PolicyKit nám neudělil oprávnění acquire-real-time."
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
+#, fuzzy
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the "
-"configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
-"Volaný SUID root a plánování v reálném čase / o vysoké prioritě bylo zažádáno v konfiguraci. Nedisponujeme ovšem potřebnými oprávněními:\n"
+"Volaný SUID root a plánování v reálném čase / o vysoké prioritě bylo "
+"zažádáno v konfiguraci. Nedisponujeme ovšem potřebnými oprávněními:\n"
 "Nejsme ve skupinÄ› \""
 
-#: ../src/daemon/main.c:480
+#: ../src/daemon/main.c:526
 msgid ""
-"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-"For enabling real-time scheduling please acquire the appropriate PolicyKit "
-"priviliges, or become a member of '"
+"High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
-"\" a PolicyKit odmítl udělit oprávnění. Opětovné zahazování SUID.\n"
-"Chcete-li zapnout plánování v reálném čase, obstarejte prosím příslušná oprávnění PolicyKit, nebo se staňte členem \""
-
-#: ../src/daemon/main.c:481
-msgid "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."
-msgstr "\", či zvyšte zdrojové limity RLIMIT_NICE/RLIMIT_RTPRIO tohoto uživatele."
+"Plánování o vysoké prioritě v konfiguraci zapnuto, ale nepovoleno pravidly."
 
-#: ../src/daemon/main.c:497
-msgid "High-priority scheduling enabled in configuration but not allowed by policy."
-msgstr "Plánování o vysoké prioritě v konfiguraci zapnuto, ale nepovoleno pravidly."
-
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr "Úspěšně zvýšeno RLIMIT_RTPRIO"
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr "RLIMIT_RTPRIO selhalo: %s"
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr "Vzdávání se CAP_NICE"
 
-#: ../src/daemon/main.c:539
-msgid "Real-time scheduling enabled in configuration but not allowed by policy."
-msgstr "Plánování v reálném čase v konfiguraci zapnuto, ale nepovoleno pravidly."
+#: ../src/daemon/main.c:572
+msgid ""
+"Real-time scheduling enabled in configuration but not allowed by policy."
+msgstr ""
+"Plánování v reálném čase v konfiguraci zapnuto, ale nepovoleno pravidly."
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr "Démon neběží"
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr "Démon běží jako PID %u"
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr "Zabití démona se nezdařilo: %s"
 
-#: ../src/daemon/main.c:627
+#: ../src/daemon/main.c:663
 msgid ""
 "This program is not intended to be run as root (unless --system is "
 "specified)."
@@ -241,173 +241,176 @@ msgstr ""
 "Tento program není určen ke spuštění pod superuživatelem (není-li zadáno --"
 "system)."
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+#, fuzzy
+msgid "Root privileges required."
 msgstr "Jsou vyžadována oprávnění superuživatele."
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr "--start nepodporováno u systémových instancí."
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr "Běží v systémovém režimu, ale nenastaveno --disallow-exit!"
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr "Běží v systémovém režimu, ale nenastaveno --disallow-module-loading!"
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr "Běží v systémovém režimu, vynuceně se vypíná režim SHM!"
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr "Běží v systémovém režimu, vynuceně se vypíná čas nečinnosti ukončení!"
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr "Nezdařilo se získání stdio."
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr "pipe selhalo: %s"
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr "fork() selhalo: %s"
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr "read() selhalo: %s"
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr "Spuštění démona selhalo."
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr "Spuštění démona bylo úspěšné."
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Toto je PulseAudio %s"
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr "Překladový počítač: %s"
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr "Překladové CFLAGS: %s"
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr "Běží na počítači: %s"
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr "Velikost stránky je %lu bajtů"
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr "Přeloženo s podporou Valgrind: ano"
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr "Přeloženo s podporou Valgrind: ne"
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr "Běží v režimu valgrind: %s"
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr "Optimalizované sestavení: ano"
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr "Optimalizované sestavení: ne"
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr "Nezdařilo se získání ID počítače"
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr "ID počítače je %s."
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr "Používán běhový adresář %s."
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr "Používán stavový adresář %s."
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr "Běží v systémovém režimu: %s"
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr "pa_pid_file_create() selhalo."
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
-msgstr "Jsou dostupné výtečné časovače o vysokém rozlišení. Tak s chutí do toho!"
+msgstr ""
+"Jsou dostupné výtečné časovače o vysokém rozlišení. Tak s chutí do toho!"
 
-#: ../src/daemon/main.c:850
+#: ../src/daemon/main.c:886
 msgid ""
 "Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
 "resolution timers enabled!"
-msgstr "Sorry, vole, kernel error! Tip šéfkuchaře na dnešní den zní: Linux se zapnutými časovači o vysokém rozlišení."
+msgstr ""
+"Sorry, vole, kernel error! Tip šéfkuchaře na dnešní den zní: Linux se "
+"zapnutými časovači o vysokém rozlišení."
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr "pa_core_new() selhalo."
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr "Selhalo spuštění démona."
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr "Spuštění démona bez jakýchkoliv nahraných modulů, běh bude odmítnut."
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr "Výchozí jméno cíle (%s) ve jmenném registru neexistuje."
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr "Spuštění démona dokončeno."
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr "Vypínání démona spuštěno."
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr "Démon ukončen."
 
-#: ../src/daemon/cmdline.c:117
-#, c-format
-#, fuzzy
+#: ../src/daemon/cmdline.c:123
+#, fuzzy, c-format
 msgid ""
 "%s [options]\n"
 "\n"
@@ -422,7 +425,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
@@ -452,6 +456,10 @@ msgid ""
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
 "  -p, --dl-search-path=PATH             Set the search path for dynamic "
 "shared\n"
 "                                        objects (plugins)\n"
@@ -521,58 +529,71 @@ msgstr ""
 " po n\n"
 " n implicitní skript soubor n"
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr "--daemonize předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr "--fail předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:262
+#: ../src/daemon/cmdline.c:271
 msgid ""
 "--log-level expects log level argument (either numeric in range 0..4 or one "
 "of debug, info, notice, warn, error)."
-msgstr "--log-level předpokládá argument protokolovací úrovně (buď číselný v rozmezí 0..4, nebo jeden z debug, info, notice, warn, error)."
+msgstr ""
+"--log-level předpokládá argument protokolovací úrovně (buď číselný v rozmezí "
+"0..4, nebo jeden z debug, info, notice, warn, error)."
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr "--high-priority předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr "--realtime předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr "--disallow-module-loading předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr "--disallow-exit booleovský argument"
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr "--use-pid-file předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
-msgstr "Neplatný cíl protokolu: použijte buďto \"syslog\", \"stderr\" nebo \"auto\"."
+msgstr ""
+"Neplatný cíl protokolu: použijte buďto \"syslog\", \"stderr\" nebo \"auto\"."
+
+#: ../src/daemon/cmdline.c:335
+#, fuzzy
+msgid "--log-time boolean argument"
+msgstr "--disallow-exit booleovský argument"
+
+#: ../src/daemon/cmdline.c:342
+#, fuzzy
+msgid "--log-meta boolean argument"
+msgstr "--disallow-exit booleovský argument"
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr "Neplatná metoda převzorkování \"%s\"."
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr "--system předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr "--no-cpu-limit předpokládá booleovský argument"
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr "--disable-shm předpokládá booleovský argument"
 
@@ -607,8 +628,7 @@ msgid "Usage: %s\n"
 msgstr "Použití: %s\n"
 
 #: ../src/daemon/dumpmodules.c:73
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Load Once: %s\n"
 msgstr "Načíst Jednou s n"
 
@@ -617,73 +637,74 @@ msgstr "Načíst Jednou s n"
 msgid "Path: %s\n"
 msgstr "Cesta: %s\n"
 
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr "[%s:%u] Neplatný protokolovací cíl \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr "[%s:%u] Neplatná protokolovací úroveň \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr "[%s:%u] Neplatná metoda převzorkování \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr "[%s:%u] Neplatné rlimit \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr "[%s:%u] rlimit na této platformě není podporováno."
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr "[%s:%u] Neplatný vzorkovací formát \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr "[%s:%u] Neplatná vzorkovací frekvence \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr "[%s:%u] Neplatné vzorkovací kanály \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr "[%s:%u] Neplatný počet fragmentů \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr "[%s:%u] Neplatná velikost fragmentu \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr "[%s:%u] Neplatná úroveň nice \"%s\"."
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr "Nezdařilo se otevřít konfigurační soubor: %s"
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr "### Čtení z konfiguračního souboru: %s ###\n"
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+#, fuzzy
+msgid "Dropping root privileges."
 msgstr "Rušení superuživatelských oprávnění."
 
 #: ../src/daemon/caps.c:103
@@ -1020,179 +1041,179 @@ msgstr "waitpid(): %s"
 msgid "Received message for unknown extension '%s'"
 msgstr "Přijata zpráva pro neznámé rozšíření \"%s\""
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr "pa_stream_write() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr "pa_stream_peek() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr "Přeběh vyrovnávací paměti, zahazují se příchozí data\n"
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr "pa_stream_drop() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr "Proud úspěšně vytvořen.\n"
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr "pa_stream_get_buffer_attr() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
-msgstr "Metrika vyrovnávací paměti: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
+msgstr ""
+"Metrika vyrovnávací paměti: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr "Metrika vyrovnávací paměti: maxlength=%u, fragsize=%u\n"
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr "Používána vzorkovací specifikace \"%s\", mapa kanálů \"%s\".\n"
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr "Připojeno k zařízení %s (%u, %ssuspended).\n"
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr "Chyba proudu: %s\n"
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr "Proudové zařízení pozastaveno.%s \n"
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr "Proudové zařízení obnoveno.%s \n"
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr "Podběhnutí proudu.%s \n"
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr "Přeběhnutí proudu.%s \n"
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr "Proud spuštěn.%s \n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr "Proud přesunut na zařízení %s (%u, %ssuspended).%s \n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr "nikoliv "
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr "Spojení navázáno.%s \n"
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr "pa_stream_new() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr "pa_stream_connect_playback() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr "pa_stream_connect_record() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:307 ../src/utils/pasuspender.c:159
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
 #: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr "Spojení selhalo: %s\n"
 
-#: ../src/utils/pacat.c:328 ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr "Nezdařilo se vyprázdnit proud: %s\n"
 
-#: ../src/utils/pacat.c:333 ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr "Proud přehrávání vyprázdněn.\n"
 
-#: ../src/utils/pacat.c:343 ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr "Vyprazdňování spojení se serverem.\n"
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr "Získáno EOF.\n"
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr "pa_stream_drain(): %s\n"
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr "read() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr "write() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr "Získán signál, ukončování.\n"
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr "Nezdařilo se získat latenci: %s\n"
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr "Čas: %0.3f sekund; latence: %0.0f μs.  \r"
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr "pa_stream_update_timing_info() selhalo: %s\n"
 
-#: ../src/utils/pacat.c:490
-#, c-format
-#, fuzzy
+#: ../src/utils/pacat.c:491
+#, fuzzy, c-format
 msgid ""
 "%s [options]\n"
 "\n"
@@ -1271,7 +1292,7 @@ msgstr ""
 " Požadavek in bajty\n"
 " čas Požadavek čas in bajty n"
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1282,87 +1303,87 @@ msgstr ""
 "Přeloženo s libpulse %s\n"
 "Propojeno s libpulse %s\n"
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr "Neplatná mapa kanálů \"%s\"\n"
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr "Neplatné upřesnění latence \"%s\"\n"
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr "Neplatné upřesnění času zpracování \"%s\"\n"
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr "Neplatné upřesnění vzorkování\n"
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr "Mapa kanálů se neshoduje s upřesněním vzorkování\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr "Otevírání proudu %s s upřesněním vzorkování \"%s\".\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr "nahrávání"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr "přehrávání"
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr "open(): %s\n"
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr "dup2(): %s\n"
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr "Příliš mnoho argumentů.\n"
 
-#: ../src/utils/pacat.c:742 ../src/utils/pasuspender.c:280
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
 #: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr "pa_mainloop_new() selhalo.\n"
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr "io_new() selhalo.\n"
 
-#: ../src/utils/pacat.c:769 ../src/utils/pasuspender.c:293
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
 #: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr "pa_context_new() selhalo.\n"
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr "pa_context_connect() selhalo: %s"
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr "time_new() selhalo.\n"
 
-#: ../src/utils/pacat.c:795 ../src/utils/pasuspender.c:301
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
 #: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
@@ -1405,8 +1426,7 @@ msgid "WARNING: Child process terminated by signal %u\n"
 msgstr "VAROVÁNÍ: Proces potomka ukončen signálem %u\n"
 
 #: ../src/utils/pasuspender.c:212
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "%s [options] ... \n"
 "\n"
@@ -1603,8 +1623,7 @@ msgid "Failed to get sink input information: %s\n"
 msgstr "Nezdařilo se získání cílových vstupních informací: %s\n"
 
 #: ../src/utils/pactl.c:352
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "*** Sink Input #%u ***\n"
 "Driver: %s\n"
@@ -1622,14 +1641,12 @@ msgid ""
 msgstr "Vstup s Modul s s s s s s n s"
 
 #: ../src/utils/pactl.c:385
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Failed to get source output information: %s\n"
 msgstr "Selhalo až get zdroj s n"
 
 #: ../src/utils/pactl.c:405
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "*** Source Output #%u ***\n"
 "Driver: %s\n"
@@ -1646,14 +1663,12 @@ msgid ""
 msgstr "Zdroj Výstup s Modul s s s s s n s"
 
 #: ../src/utils/pactl.c:436
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Failed to get sample information: %s\n"
 msgstr "Selhalo až get s n"
 
 #: ../src/utils/pactl.c:455
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "*** Sample #%u ***\n"
 "Name: %s\n"
@@ -1669,14 +1684,12 @@ msgid ""
 msgstr "Ukázka s s s s s s s n s"
 
 #: ../src/utils/pactl.c:481
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Failed to get autoload information: %s\n"
 msgstr "Selhalo až get s n"
 
 #: ../src/utils/pactl.c:497
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "*** Autoload Entry #%u ***\n"
 "Name: %s\n"
@@ -1699,8 +1712,7 @@ msgid "Failure: %s\n"
 msgstr "Selhání: %s\n"
 
 #: ../src/utils/pactl.c:545
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Failed to upload sample: %s\n"
 msgstr "Selhalo až s n"
 
@@ -1710,8 +1722,7 @@ msgid "Premature end of file\n"
 msgstr "Předčasný konec souboru\n"
 
 #: ../src/utils/pactl.c:678
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "%s [options] stat\n"
 "%s [options] list\n"
@@ -1734,7 +1745,9 @@ msgid ""
 "  -n, --client-name=NAME                How to call this client on the "
 "server\n"
 msgstr ""
-"s n s seznam n s n s NÁZEVSOUBORU NÁZEV n s NÁZEV n s odstranit NÁZEV n s přesunout cíl ID n s přesunout zdroj ID ZDROJ n s modul NÁZEV n s modul ID n s cíl n s zdroj ZDROJ n\n"
+"s n s seznam n s n s NÁZEVSOUBORU NÁZEV n s NÁZEV n s odstranit NÁZEV n s "
+"přesunout cíl ID n s přesunout zdroj ID ZDROJ n s modul NÁZEV n s modul ID n "
+"s cíl n s zdroj ZDROJ n\n"
 " h nápověda Zobrazit nápověda\n"
 " verze Zobrazit verze n\n"
 " s SERVER název z až až\n"
@@ -1752,8 +1765,7 @@ msgstr ""
 "Propojeno s libpulse %s\n"
 
 #: ../src/utils/pactl.c:768
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Please specify a sample file to load\n"
 msgstr "Prosím a soubor až n"
 
@@ -1763,52 +1775,44 @@ msgid "Failed to open sound file.\n"
 msgstr "Selhalo otevření zvukového souboru.\n"
 
 #: ../src/utils/pactl.c:802
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "You have to specify a sample name to play\n"
 msgstr "Vy až a název až n"
 
 #: ../src/utils/pactl.c:814
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "You have to specify a sample name to remove\n"
 msgstr "Vy až a název až odstranit n"
 
 #: ../src/utils/pactl.c:822
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "You have to specify a sink input index and a sink\n"
 msgstr "Vy až a cíl rejstřík a a cíl n"
 
 #: ../src/utils/pactl.c:831
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "You have to specify a source output index and a source\n"
 msgstr "Vy až a zdroj rejstřík a a zdroj n"
 
 #: ../src/utils/pactl.c:845
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "You have to specify a module name and arguments.\n"
 msgstr "Vy až a modul název a n"
 
 #: ../src/utils/pactl.c:865
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "You have to specify a module index\n"
 msgstr "Vy až a modul rejstřík n"
 
 #: ../src/utils/pactl.c:875
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "You may not specify more than one sink. You have to specify at least one "
 "boolean value.\n"
 msgstr "Vy ne cíl Vy až při booleovská hodnota hodnota n"
 
 #: ../src/utils/pactl.c:888
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "You may not specify more than one source. You have to specify at least one "
 "boolean value.\n"
@@ -1820,8 +1824,7 @@ msgid "No valid command specified.\n"
 msgstr "Nezadán žádný platný příkaz.\n"
 
 #: ../src/utils/pax11publish.c:61
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "%s [-D display] [-S server] [-O sink] [-I source] [-c file]  [-d|-e|-i|-r]\n"
 "\n"
@@ -1946,8 +1949,7 @@ msgid "Connection established.\n"
 msgstr "Spojení navázáno.\n"
 
 #: ../src/utils/paplay.c:198
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid ""
 "%s [options] [FILE]\n"
 "\n"
@@ -1990,8 +1992,7 @@ msgstr ""
 "Propojeno s libpulse %s\n"
 
 #: ../src/utils/paplay.c:292
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Invalid channel map\n"
 msgstr "Neplatné kanál mapa n"
 
@@ -2001,14 +2002,12 @@ msgid "Failed to open file '%s'\n"
 msgstr "Selhalo otevření souboru \"%s\"\n"
 
 #: ../src/utils/paplay.c:350
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Channel map doesn't match file.\n"
 msgstr "Kanál mapa soubor n"
 
 #: ../src/utils/paplay.c:376
-#, c-format
-#, fuzzy
+#, fuzzy, c-format
 msgid "Using sample spec '%s'\n"
 msgstr "s n"
 
@@ -2017,3 +2016,17 @@ msgstr "s n"
 msgid "Cannot access autospawn lock."
 msgstr "přístup."
 
+#~ msgid ""
+#~ "' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
+#~ "For enabling real-time scheduling please acquire the appropriate "
+#~ "PolicyKit priviliges, or become a member of '"
+#~ msgstr ""
+#~ "\" a PolicyKit odmítl udělit oprávnění. Opětovné zahazování SUID.\n"
+#~ "Chcete-li zapnout plánování v reálném čase, obstarejte prosím příslušná "
+#~ "oprávnění PolicyKit, nebo se staňte členem \""
+
+#~ msgid ""
+#~ "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this "
+#~ "user."
+#~ msgstr ""
+#~ "\", či zvyšte zdrojové limity RLIMIT_NICE/RLIMIT_RTPRIO tohoto uživatele."
diff --git a/po/de.po b/po/de.po
index 423fe33..b6c6dfa 100644
--- a/po/de.po
+++ b/po/de.po
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: pulseaudio\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-21 13:49+0000\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-10-22 00:58+0100\n"
 "Last-Translator: Fabian Affolter <fab at fedoraproject.org>\n"
 "Language-Team: German <fedora-trans-de at redhat.com>\n"
@@ -18,15 +18,20 @@ msgstr ""
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 "X-Poedit-Language: German\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177
-#: ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
-msgstr "Hinzufügen von Bind-Now-Loader fehlgeschlagen."
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "Konnte ursprünglichen dlopen-Loader nicht finden."
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
 msgstr "Konnte ursprünglichen dlopen-Loader nicht finden."
 
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
+msgstr "Hinzufügen von Bind-Now-Loader fehlgeschlagen."
+
 #: ../src/daemon/polkit.c:55
 #, c-format
 msgid "Cannot connect to system bus: %s"
@@ -115,8 +120,7 @@ msgstr "GID von Benutzer '%s' und Gruppe '%s' stimmen nicht überein."
 msgid "Home directory of user '%s' is not '%s', ignoring."
 msgstr "Benutzerverzeichnis von Benutzer '%s' ist nicht '%s', ignoriere."
 
-#: ../src/daemon/main.c:201
-#: ../src/daemon/main.c:206
+#: ../src/daemon/main.c:201 ../src/daemon/main.c:206
 #, c-format
 msgid "Failed to create '%s': %s"
 msgstr "Konnte '%s' nciht erzeugen: %s"
@@ -153,255 +157,258 @@ msgstr "setrlimit(%s, (%u, %u)) fehlgeschlagen: %s"
 msgid "Failed to parse command line."
 msgstr "Parsen der Kommandzeile fehlgeschlagen."
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
-msgstr "Wir befinden uns in der Gruppe '%s', was Scheduling höchster Priorität ermöglicht."
+msgstr ""
+"Wir befinden uns in der Gruppe '%s', was Scheduling höchster Priorität "
+"ermöglicht."
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
-msgstr "Wir befinden uns in der Gruppe '%s', was Echtzeit-Scheduling ermöglicht."
+msgstr ""
+"Wir befinden uns in der Gruppe '%s', was Echtzeit-Scheduling ermöglicht."
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr "Richtlinien gewähren das Recht aquire-high-priority."
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr "Richtlinien verweigern das Recht acquire-high-priority."
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr "Richtlinien gewähren das Recht aquire-real-time."
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr "Richtlinien verweigern das Recht acquire-real-time."
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
+#, fuzzy
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
-"Konfiguration fordert Aufruf der SUID root und Echtzeit-Scheduling höchster Priorität. Allerdings fehlen die nötigen Rechte:\n"
+"Konfiguration fordert Aufruf der SUID root und Echtzeit-Scheduling höchster "
+"Priorität. Allerdings fehlen die nötigen Rechte:\n"
 "Wir befinden uns nicht in der Gruppe '"
 
-#: ../src/daemon/main.c:480
+#: ../src/daemon/main.c:526
 msgid ""
-"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-"For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"
-msgstr ""
-"' und Richtlinien verweigern diese Rechte. Verwerfe SUID wieder.\n"
-"Erlangen Sie die den Richtlinien entsprechenden Rechte, um Echtzeit-Scheduling zu aktivieren oder werden Sie Mitglied der Gruppe '"
-
-#: ../src/daemon/main.c:481
-msgid "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."
-msgstr "' oder erhöhen sie die RLIMIT_NICE/RLIMIT_RTPRIO-Ressourcenbegrenzungen für diesen Nutzer."
-
-#: ../src/daemon/main.c:497
-msgid "High-priority scheduling enabled in configuration but not allowed by policy."
+"High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr "Scheduling höchster Priorität konfiguriert, jedoch nicht erlaubt."
 
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr "RLIMIT_RTPRIO erfolgreich erhöht"
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr "RLIMIT_RTPRIO fehlgeschlagen: %s"
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr "Verwerfe CAP_NICE"
 
-#: ../src/daemon/main.c:539
-msgid "Real-time scheduling enabled in configuration but not allowed by policy."
+#: ../src/daemon/main.c:572
+msgid ""
+"Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr "Echtzeit-Scheduling konfiguriert, jedoch nicht erlaubt."
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr "Daemon läuft nicht"
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr "Daemon läuft als PID %u"
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr "Konnte Prozess nicht abbrechen: %s"
 
-#: ../src/daemon/main.c:627
-msgid "This program is not intended to be run as root (unless --system is specified)."
-msgstr "Dieses Programm sollte ohne die Option --system nicht als Administrator ausgeführt werden."
+#: ../src/daemon/main.c:663
+msgid ""
+"This program is not intended to be run as root (unless --system is "
+"specified)."
+msgstr ""
+"Dieses Programm sollte ohne die Option --system nicht als Administrator "
+"ausgeführt werden."
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+#, fuzzy
+msgid "Root privileges required."
 msgstr "Root-Berechtigungen benötigt."
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr "--start nicht unterstützt für System-Instanzen."
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr "System-Modus aktiv, jeodch --disallow-exit nicht gesetzt!"
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr "System-Modus aktiv, jedoch --disallow-module-loading nicht gesetzt!"
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr "System-Modus aktiv, SHM-Modus gezwungenermaßen deaktiviert!"
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr "System-Modus aktiv, Exit-Idle-Time gezwungenermaßen deaktiviert!"
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr "Reservieren von STDIO fehlgeschlagen."
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr "pipe fehlgeschlagen: %s"
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr "fork() fehlgeschlagen: %s"
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr "read() fehlgeschlagen: %s"
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr "Start des Daemons fehlgeschlagen."
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr "Start des Daemons erfolgreich."
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Dies ist PulseAudio %s"
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr "Kompilier-Host: %s"
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr "Kompilier-CFLAGS: %s"
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr "Laufe auf Host: %s"
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr "Seitengröße ist %lu Bytes."
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr "Kompiliere mit Valgrind-Unterstützung: ja"
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr "Kompiliere mit Valgrind-Unterstützung: nein"
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr "Läuft im Valgrind-Modus: %s"
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr "Optimiertes Build: ja"
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr "Optimiertes Build: nein"
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr "Beziehen der Maschinen-ID fehlgeschlagen"
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr "System- ID ist %s."
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr "Nutze Laufzeit-Verzeichnis %s."
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr "Nutze Zustands-Verzeichnis %s."
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr "Laufe im System-Modus: %s"
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr "pa_pid_file_create() fehlgeschlagen."
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr "Neue hochauslösende Timer verfügbar! Guten Appetit!"
 
-#: ../src/daemon/main.c:850
-msgid "Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"
+#: ../src/daemon/main.c:886
+msgid ""
+"Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
+"resolution timers enabled!"
 msgstr "Der Chefkoch empfiehlt: Linux mit aktivierten hochauslösenden Timern!"
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr "pa_core_new() fehlgeschlagen."
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr "Konnte Daemon nicht initialisieren."
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr "Daemon verweigert Ausführung, da keine Module geladen."
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr "Vorgabename für Sink (%s) existiert nicht im Namensregister."
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr "Start des Daemons abgeschlossen."
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr "Herunterfahren des Daemon gestartet."
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr "Daemon beendet."
 
-#: ../src/daemon/cmdline.c:117
-#, c-format
+#: ../src/daemon/cmdline.c:123
+#, fuzzy, c-format
 msgid ""
 "%s [options]\n"
 "\n"
@@ -411,34 +418,48 @@ msgid ""
 "      --dump-conf                       Dump default configuration\n"
 "      --dump-modules                    Dump list of available modules\n"
 "      --dump-resample-methods           Dump available resample methods\n"
-"      --cleanup-shm                     Cleanup stale shared memory segments\n"
-"      --start                           Start the daemon if it is not running\n"
+"      --cleanup-shm                     Cleanup stale shared memory "
+"segments\n"
+"      --start                           Start the daemon if it is not "
+"running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
 "  -D, --daemonize[=BOOL]                Daemonize after startup\n"
 "      --fail[=BOOL]                     Quit when startup fails\n"
 "      --high-priority[=BOOL]            Try to set high nice level\n"
-"                                        (only available as root, when SUID or\n"
+"                                        (only available as root, when SUID "
+"or\n"
 "                                        with elevated RLIMIT_NICE)\n"
 "      --realtime[=BOOL]                 Try to enable realtime scheduling\n"
-"                                        (only available as root, when SUID or\n"
+"                                        (only available as root, when SUID "
+"or\n"
 "                                        with elevated RLIMIT_RTPRIO)\n"
-"      --disallow-module-loading[=BOOL]  Disallow module user requested module\n"
+"      --disallow-module-loading[=BOOL]  Disallow module user requested "
+"module\n"
 "                                        loading/unloading after startup\n"
 "      --disallow-exit[=BOOL]            Disallow user requested exit\n"
-"      --exit-idle-time=SECS             Terminate the daemon when idle and this\n"
+"      --exit-idle-time=SECS             Terminate the daemon when idle and "
+"this\n"
 "                                        time passed\n"
-"      --module-idle-time=SECS           Unload autoloaded modules when idle and\n"
+"      --module-idle-time=SECS           Unload autoloaded modules when idle "
+"and\n"
 "                                        this time passed\n"
-"      --scache-idle-time=SECS           Unload autoloaded samples when idle and\n"
+"      --scache-idle-time=SECS           Unload autoloaded samples when idle "
+"and\n"
 "                                        this time passed\n"
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
-"  -p, --dl-search-path=PATH             Set the search path for dynamic shared\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
+"  -p, --dl-search-path=PATH             Set the search path for dynamic "
+"shared\n"
 "                                        objects (plugins)\n"
 "      --resample-method=METHOD          Use the specified resampling method\n"
 "                                        (See --dump-resample-methods for\n"
@@ -449,10 +470,12 @@ msgid ""
 "      --disable-shm[=BOOL]              Disable shared memory support.\n"
 "\n"
 "STARTUP SCRIPT:\n"
-"  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module with\n"
+"  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module "
+"with\n"
 "                                        the specified argument\n"
 "  -F, --file=FILENAME                   Run the specified script\n"
-"  -C                                    Open a command line on the running TTY\n"
+"  -C                                    Open a command line on the running "
+"TTY\n"
 "                                        after startup\n"
 "\n"
 "  -n                                    Don't load default script file\n"
@@ -465,8 +488,10 @@ msgstr ""
 "      --dump-conf                       Zeige Standardkonfiguration\n"
 "      --dump-modules                    Zeige Liste verfügbarer Module\n"
 "      --dump-resample-methods           Zeige verfügbare Resample-Methoden\n"
-"      --cleanup-shm                     Cleanup stale shared memory segments\n"
-"      --start                           Starte Daemon, falls noch nicht geschehen\n"
+"      --cleanup-shm                     Cleanup stale shared memory "
+"segments\n"
+"      --start                           Starte Daemon, falls noch nicht "
+"geschehen\n"
 "  -k  --kill                            Laufenden Daemon beenden\n"
 "      --check                           Prüfe laufende Daemone\n"
 "\n"
@@ -475,31 +500,41 @@ msgstr ""
 "  -D, --daemonize[=BOOL]                Nach Start zum Daemon machen\n"
 "      --fail[=BOOL]                     Beenden, wenn Start fehlschlägt\n"
 "      --high-priority[=BOOL]            Nutze höchste Priorität\n"
-"                                        (Nur verfügbar als root, wenn SUID oder\n"
+"                                        (Nur verfügbar als root, wenn SUID "
+"oder\n"
 "                                        mit erhöhtem RLIMIT_NICE)\n"
-"      --realtime[=BOOL]                 Versuche, Echtzeit-Scheduling zu aktivieren\n"
-"                                        (Nur verfügbar als root, wenn SUID oder\n"
+"      --realtime[=BOOL]                 Versuche, Echtzeit-Scheduling zu "
+"aktivieren\n"
+"                                        (Nur verfügbar als root, wenn SUID "
+"oder\n"
 "                                        mit erhöhtem RLIMIT_RTPRIO)\n"
-"      --disallow-module-loading[=BOOL]  Verbiete (Ent-)laden durch Nutzer angeforderter\n"
+"      --disallow-module-loading[=BOOL]  Verbiete (Ent-)laden durch Nutzer "
+"angeforderter\n"
 "                                        Module nach dem Start\n"
-"      --disallow-exit[=BOOL]            Verbiete Beenden auf Anfrage des Nutzers\n"
+"      --disallow-exit[=BOOL]            Verbiete Beenden auf Anfrage des "
+"Nutzers\n"
 "      --exit-idle-time=SECS             Beende Daemon, wenn für diese Zeit \n"
 "                                        untätig\n"
-"      --module-idle-time=SECS           Entlade untätige Module nach dieser Zeit\n"
-"      --scache-idle-time=SECS           Entlade untätige automatisch geladene \n"
+"      --module-idle-time=SECS           Entlade untätige Module nach dieser "
+"Zeit\n"
+"      --scache-idle-time=SECS           Entlade untätige automatisch "
+"geladene \n"
 "                                        Samples nach dieser Zeit\n"
 "      --log-level[=STUFE]               Grad der Ausführlichkeit angeben\n"
 "  -v                                    Ausführliche Meldungen\n"
 "      --log-target={auto,syslog,stderr} Protokoll-Ziel angeben\n"
-"  -p, --dl-search-path=PFAD             Suchpfad für dynamisch freigegebene \n"
+"  -p, --dl-search-path=PFAD             Suchpfad für dynamisch "
+"freigegebene \n"
 "                                        Objekte (Plugins)\n"
 "      --resample-method=METHODE          Nutze diese Resampling-Methode\n"
 "                                        (Siehe --dump-resample-methods für\n"
 "                                        mögliche Werte)\n"
 "      --use-pid-file[=BOOL]             Eine PID-Datei erstellen\n"
-"      --no-cpu-limit[=BOOL]             CPU-Lastbegrenzung auf unterstützten\n"
+"      --no-cpu-limit[=BOOL]             CPU-Lastbegrenzung auf "
+"unterstützten\n"
 "                                        Systemen nicht installieren.\n"
-"      --disable-shm[=BOOL]              Keine Unterstützung für Shared Memory.\n"
+"      --disable-shm[=BOOL]              Keine Unterstützung für Shared "
+"Memory.\n"
 "\n"
 "STARTUP-SCRIPT:\n"
 "  -L, --load=\"MODUL-ARGUMENTE\"       Plugin-Modul mit diesen Parametern \n"
@@ -510,56 +545,71 @@ msgstr ""
 "\n"
 "  -n                                    Standardskript nicht laden\n"
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr "Option --daemonize erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr "Option --fail erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:262
-msgid "--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."
-msgstr "--log-level erfordert Wert für Grad der Protokollierung (entweder numerisch im Bereich 0..4 or einen dieser: debug, info, notice, warn, error)."
+#: ../src/daemon/cmdline.c:271
+msgid ""
+"--log-level expects log level argument (either numeric in range 0..4 or one "
+"of debug, info, notice, warn, error)."
+msgstr ""
+"--log-level erfordert Wert für Grad der Protokollierung (entweder numerisch "
+"im Bereich 0..4 or einen dieser: debug, info, notice, warn, error)."
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr "Option --high-priority erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr "Option --realtime erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr "Option --disallow-module-loading erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr "Option --disallow-exit erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr "Option --use-pid-file erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
-msgstr "Ungültiges Log-Ziel: Benutzen Sie entweder 'syslog', 'stderr' oder 'auto'."
+msgstr ""
+"Ungültiges Log-Ziel: Benutzen Sie entweder 'syslog', 'stderr' oder 'auto'."
+
+#: ../src/daemon/cmdline.c:335
+#, fuzzy
+msgid "--log-time boolean argument"
+msgstr "Option --disallow-exit erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:342
+#, fuzzy
+msgid "--log-meta boolean argument"
+msgstr "Option --disallow-exit erfordert bool'schen Wert"
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr "Ungültige Resample-Methode '%s'."
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr "--System erwartet Boolean-Argument"
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr "Option --no-cpu-limit erfordert bool'schen Wert"
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr "Option --disable-shm erfordert bool'schen Wert"
 
@@ -603,73 +653,74 @@ msgstr "Lade einmalig: %s\n"
 msgid "Path: %s\n"
 msgstr "Pfad: %s\n"
 
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr "[%s:%u] Ungültiges Log-Ziel '%s'."
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr "[%s:%u] Ungültige Log-Stufe '%s'."
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr "[%s:%u] Ungültige Resample-Methode '%s'."
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr "[%s:%u] Ungültiges rlimit '%s'."
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr "[%s:%u] rlimit auf dieser Plattform nicht unterstützt."
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr "[%s:%u] Ungültiges Sample-Format '%s'."
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr "[%s:%u] Ungültige Sample-Rate '%s'."
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr "[%s:%u] Ungültige Sample-Kanäle '%s'."
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr "[%s:%u] Ungültige Anzahl von Fragmenten '%s'."
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr "[%s:%u] Ungültige Fragmentgröße '%s'."
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr "[%s:%u] Ungültige Nice-Stufe '%s'."
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr "Öffnen der Konfigurationsdatei fehlgeschlagen : %s"
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr "### Lese von Konfigurationsdatei: %s ###\n"
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+#, fuzzy
+msgid "Dropping root privileges."
 msgstr "Gebe Root-Privilegien auf."
 
 #: ../src/daemon/caps.c:103
@@ -880,10 +931,8 @@ msgstr "Oben Hinten Links"
 msgid "Top Rear Right"
 msgstr "Oben Hinten Rechts"
 
-#: ../src/pulse/channelmap.c:472
-#: ../src/pulse/sample.c:144
-#: ../src/pulse/volume.c:163
-#: ../src/pulse/volume.c:194
+#: ../src/pulse/channelmap.c:472 ../src/pulse/sample.c:144
+#: ../src/pulse/volume.c:163 ../src/pulse/volume.c:194
 msgid "(invalid)"
 msgstr "(ungültig)"
 
@@ -975,8 +1024,7 @@ msgstr "Unbekannter Fehlercode"
 msgid "No such extension"
 msgstr "Erweiterung nicht vorhanden"
 
-#: ../src/pulse/client-conf-x11.c:55
-#: ../src/utils/pax11publish.c:100
+#: ../src/pulse/client-conf-x11.c:55 ../src/utils/pax11publish.c:100
 msgid "XOpenDisplay() failed"
 msgstr "XOpenDisplay() fehlgeschlagen"
 
@@ -1008,182 +1056,177 @@ msgstr "waitpid(): %s"
 msgid "Received message for unknown extension '%s'"
 msgstr "Nachricht für unbekannte Erweiterung '%s' erhalten"
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr "pa_stream_write() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr "pa_stream_peek() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr "Pufferüberlauf, verwerfe eingehende Daten\n"
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr "pa_stream_drop() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr "Stream wurde erfolgreich erstellt.\n"
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr "pa_stream_get_buffer_attr() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr "Pufferdaten: maxlenght=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr "Pufferdaten: maxlength=%u, fragsize=%u\n"
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr "Benutze Sample-Angabe '%s', Kanalzuordnung '%s'.\n"
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr "Verbunden mit Gerät %s (%u, %sausgesetzt).\n"
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr "Stream-Fehler: %s\n"
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr "Stream-Gerät ausgesetzt.%s\n"
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr "Stream-Gerät reaktiviert.%s\n"
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr "Stream unterlaufen.%s \n"
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr "Stream überlief.%s \n"
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr "Stream gestartet: %s\n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr "Stream an Gerät %s übergeben (%u, %sausgesetzt).%s \n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr "nicht "
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr "Verbindung hergestellt.%s \n"
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr "pa_stream_new() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr "pa_stream_connect_playback() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr "pa_stream_connect_record() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:307
-#: ../src/utils/pasuspender.c:159
-#: ../src/utils/pactl.c:666
-#: ../src/utils/paplay.c:183
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
+#: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr "Verbindungsfehler: %s\n"
 
-#: ../src/utils/pacat.c:328
-#: ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr "Entleeren des Streams fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:333
-#: ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr "Wiedergabe-Stream entleert.\n"
 
-#: ../src/utils/pacat.c:343
-#: ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr "Draining connection to server.\n"
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr "EOF empfangen.\n"
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr "pa_stream_drain(): %s\n"
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr "read() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr "write() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr "Signal empfangen, beende.\n"
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr "Erhalten der Latenz fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr "Zeit: %0.3f sec; Latenz: %0.0f usec.  \r"
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr "pa_stream_update_timing_info() fehlgeschlagen: %s\n"
 
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1196,27 +1239,44 @@ msgid ""
 "\n"
 "  -v, --verbose                         Enable verbose operations\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
-"  -d, --device=DEVICE                   The name of the sink/source to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
-"      --stream-name=NAME                How to call this stream on the server\n"
-"      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
-"      --rate=SAMPLERATE                 The sample rate in Hz (defaults to 44100)\n"
-"      --format=SAMPLEFORMAT             The sample type, one of s16le, s16be, u8, float32le,\n"
-"                                        float32be, ulaw, alaw, s32le, s32be (defaults to s16ne)\n"
-"      --channels=CHANNELS               The number of channels, 1 for mono, 2 for stereo\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
+"  -d, --device=DEVICE                   The name of the sink/source to "
+"connect to\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
+"      --stream-name=NAME                How to call this stream on the "
+"server\n"
+"      --volume=VOLUME                   Specify the initial (linear) volume "
+"in range 0...65536\n"
+"      --rate=SAMPLERATE                 The sample rate in Hz (defaults to "
+"44100)\n"
+"      --format=SAMPLEFORMAT             The sample type, one of s16le, "
+"s16be, u8, float32le,\n"
+"                                        float32be, ulaw, alaw, s32le, s32be "
+"(defaults to s16ne)\n"
+"      --channels=CHANNELS               The number of channels, 1 for mono, "
+"2 for stereo\n"
 "                                        (defaults to 2)\n"
-"      --channel-map=CHANNELMAP          Channel map to use instead of the default\n"
-"      --fix-format                      Take the sample format from the sink the stream is\n"
+"      --channel-map=CHANNELMAP          Channel map to use instead of the "
+"default\n"
+"      --fix-format                      Take the sample format from the sink "
+"the stream is\n"
 "                                        being connected to.\n"
-"      --fix-rate                        Take the sampling rate from the sink the stream is\n"
+"      --fix-rate                        Take the sampling rate from the sink "
+"the stream is\n"
 "                                        being connected to.\n"
-"      --fix-channels                    Take the number of channels and the channel map\n"
-"                                        from the sink the stream is being connected to.\n"
+"      --fix-channels                    Take the number of channels and the "
+"channel map\n"
+"                                        from the sink the stream is being "
+"connected to.\n"
 "      --no-remix                        Don't upmix or downmix channels.\n"
-"      --no-remap                        Map channels by index instead of name.\n"
-"      --latency=BYTES                   Request the specified latency in bytes.\n"
-"      --process-time=BYTES              Request the specified process time per request in bytes.\n"
+"      --no-remap                        Map channels by index instead of "
+"name.\n"
+"      --latency=BYTES                   Request the specified latency in "
+"bytes.\n"
+"      --process-time=BYTES              Request the specified process time "
+"per request in bytes.\n"
 msgstr ""
 "%s [options]\n"
 "\n"
@@ -1232,13 +1292,18 @@ msgstr ""
 "  -d, --device=DEVICE                   Name zu verbindender Sink/Quelle\n"
 "  -n, --client-name=NAME                Rufname des Clients auf dem Server\n"
 "      --stream-name=NAME                Rufname des Streams auf dem Server\n"
-"      --volume=VOLUME                   Initiale (lineare) Lautstärke zwischen 0...65536 angeben\n"
+"      --volume=VOLUME                   Initiale (lineare) Lautstärke "
+"zwischen 0...65536 angeben\n"
 "      --rate=SAMPLERATE                 Sample-Rate in Hz (Standard 44100)\n"
-"      --format=SAMPLEFORMAT             Ein Sample-Format von s16le, s16be, u8, float32le,\n"
-"                                        float32be, ulaw, alaw, s32le, s32be (defaults to s16ne)\n"
-"      --channels=CHANNELS               Anzahl Kanäle, 1 für mono, 2 für stereo\n"
+"      --format=SAMPLEFORMAT             Ein Sample-Format von s16le, s16be, "
+"u8, float32le,\n"
+"                                        float32be, ulaw, alaw, s32le, s32be "
+"(defaults to s16ne)\n"
+"      --channels=CHANNELS               Anzahl Kanäle, 1 für mono, 2 für "
+"stereo\n"
 "                                        (Standard ist 2)\n"
-"      --channel-map=CHANNELMAP          Diese geänderte Kanalzuordnung nutzen\n"
+"      --channel-map=CHANNELMAP          Diese geänderte Kanalzuordnung "
+"nutzen\n"
 "      --fix-format                      Sample-Format des mit Sink\n"
 "                                        verbundenen Streams nutzen.\n"
 "      --fix-rate                        Sample-Rate des mit Sink\n"
@@ -1247,11 +1312,13 @@ msgstr ""
 "                                        des mit Sink verbundenen\n"
 "                                        Streams nutzen.\n"
 "      --no-remix                        Kanäle nicht up-/down-mischen.\n"
-"      --no-remap                        Kanäle nach Index statt Name zuordnen.\n"
+"      --no-remap                        Kanäle nach Index statt Name "
+"zuordnen.\n"
 "      --latency=BYTES                   Diese Latenz verwenden.\n"
-"      --process-time=BYTES              Diese Prozesszeit pro Anfrage verwenden.\n"
+"      --process-time=BYTES              Diese Prozesszeit pro Anfrage "
+"verwenden.\n"
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1262,94 +1329,88 @@ msgstr ""
 "Kompiliert mit libpulse %s\n"
 "Gelinkt mit libpulse %s\n"
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr "Ungültige Kanal-Zuweisung '%s'\n"
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr "Ungültige Latenz-Angaben '%s'\n"
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr "Ungültige Prozesszeit-Angaben '%s'\n"
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr "Ungültige Sample-Angaben\n"
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr "Kanalzuordnung entspricht nicht Einstellungen des Samples\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr "Öffne eine %s-Stream mit Sample-Angabe '%s'.\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr "aufnehmen"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr "abspielen"
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr "open(): %s\n"
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr "dup2(): %s\n"
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr "Zu viele Argumente.\n"
 
-#: ../src/utils/pacat.c:742
-#: ../src/utils/pasuspender.c:280
-#: ../src/utils/pactl.c:909
-#: ../src/utils/paplay.c:381
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
+#: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr "pa_mainloop_new() fehlgeschlagen.\n"
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr "io_new() fehlgeschlagen.\n"
 
-#: ../src/utils/pacat.c:769
-#: ../src/utils/pasuspender.c:293
-#: ../src/utils/pactl.c:923
-#: ../src/utils/paplay.c:396
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
+#: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr "pa_context_new() fehlgeschlagen.\n"
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr "pa_context_new() fehlgeschlagen: %s"
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr "time_new() fehlgeschlagen.\n"
 
-#: ../src/utils/pacat.c:795
-#: ../src/utils/pasuspender.c:301
-#: ../src/utils/pactl.c:931
-#: ../src/utils/paplay.c:407
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
+#: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
 msgstr "pa_mainloop_run() fehlgeschlagen.\n"
@@ -1379,8 +1440,7 @@ msgstr "Resume fehlgeschlagen: %s\n"
 msgid "WARNING: Sound server is not local, not suspending.\n"
 msgstr "WARNUNG: Sound-Server läuft nicht lokal, nicht ausgesetzt.\n"
 
-#: ../src/utils/pasuspender.c:176
-#: ../src/utils/pactl.c:672
+#: ../src/utils/pasuspender.c:176 ../src/utils/pactl.c:672
 #: ../src/utils/paplay.c:191
 #, c-format
 msgid "Got SIGINT, exiting.\n"
@@ -1398,7 +1458,8 @@ msgid ""
 "\n"
 "  -h, --help                            Show this help\n"
 "      --version                         Show version\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
 "\n"
 msgstr ""
 "%s [options] ... \n"
@@ -1499,8 +1560,7 @@ msgstr ""
 "Eigenschaften:\n"
 "%s"
 
-#: ../src/utils/pactl.c:193
-#: ../src/utils/pactl.c:371
+#: ../src/utils/pactl.c:193 ../src/utils/pactl.c:371
 msgid "muted"
 msgstr "stumm"
 
@@ -1538,18 +1598,10 @@ msgstr ""
 "Eigenschaften:\n"
 "%s"
 
-#: ../src/utils/pactl.c:246
-#: ../src/utils/pactl.c:289
-#: ../src/utils/pactl.c:322
-#: ../src/utils/pactl.c:366
-#: ../src/utils/pactl.c:367
-#: ../src/utils/pactl.c:374
-#: ../src/utils/pactl.c:418
-#: ../src/utils/pactl.c:419
-#: ../src/utils/pactl.c:425
-#: ../src/utils/pactl.c:468
-#: ../src/utils/pactl.c:469
-#: ../src/utils/pactl.c:473
+#: ../src/utils/pactl.c:246 ../src/utils/pactl.c:289 ../src/utils/pactl.c:322
+#: ../src/utils/pactl.c:366 ../src/utils/pactl.c:367 ../src/utils/pactl.c:374
+#: ../src/utils/pactl.c:418 ../src/utils/pactl.c:419 ../src/utils/pactl.c:425
+#: ../src/utils/pactl.c:468 ../src/utils/pactl.c:469 ../src/utils/pactl.c:473
 msgid "n/a"
 msgstr "k. A."
 
@@ -1723,8 +1775,7 @@ msgstr "Sink"
 msgid "source"
 msgstr "Quelle"
 
-#: ../src/utils/pactl.c:511
-#: ../src/utils/pactl.c:521
+#: ../src/utils/pactl.c:511 ../src/utils/pactl.c:521
 #, c-format
 msgid "Failure: %s\n"
 msgstr "Fehlgeschlagen: %s\n"
@@ -1758,8 +1809,10 @@ msgid ""
 "  -h, --help                            Show this help\n"
 "      --version                         Show version\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
 msgstr ""
 "%s [options] stat\n"
 "%s [options] list\n"
@@ -1819,7 +1872,8 @@ msgstr "Sie müssen einen Sink-Eingabe-Indexwert und einen Sink angeben\n"
 #: ../src/utils/pactl.c:831
 #, c-format
 msgid "You have to specify a source output index and a source\n"
-msgstr "Sie müssen eine Indexwert für die Quell-Ausgabe und eine Quelle angeben\n"
+msgstr ""
+"Sie müssen eine Indexwert für die Quell-Ausgabe und eine Quelle angeben\n"
 
 #: ../src/utils/pactl.c:845
 #, c-format
@@ -1833,13 +1887,21 @@ msgstr "Sie müssen einen Indexwert für ein Modul angeben\n"
 
 #: ../src/utils/pactl.c:875
 #, c-format
-msgid "You may not specify more than one sink. You have to specify at least one boolean value.\n"
-msgstr "Sie sollten nur ein Sink angeben. Sie müssen zumindest einen bool'schen Wert übergeben.\n"
+msgid ""
+"You may not specify more than one sink. You have to specify at least one "
+"boolean value.\n"
+msgstr ""
+"Sie sollten nur ein Sink angeben. Sie müssen zumindest einen bool'schen Wert "
+"übergeben.\n"
 
 #: ../src/utils/pactl.c:888
 #, c-format
-msgid "You may not specify more than one source. You have to specify at least one boolean value.\n"
-msgstr "Sie sollten nur eine Quelle angeben. Sie müssen zumindest einen bool'schen Wert übergeben.\n"
+msgid ""
+"You may not specify more than one source. You have to specify at least one "
+"boolean value.\n"
+msgstr ""
+"Sie sollten nur eine Quelle angeben. Sie müssen zumindest einen bool'schen "
+"Wert übergeben.\n"
 
 #: ../src/utils/pactl.c:904
 #, c-format
@@ -1853,14 +1915,16 @@ msgid ""
 "\n"
 " -d    Show current PulseAudio data attached to X11 display (default)\n"
 " -e    Export local PulseAudio data to X11 display\n"
-" -i    Import PulseAudio data from X11 display to local environment variables and cookie file.\n"
+" -i    Import PulseAudio data from X11 display to local environment "
+"variables and cookie file.\n"
 " -r    Remove PulseAudio data from X11 display\n"
 msgstr ""
 "%s [-D display] [-S server] [-O sink] [-I source] [-c file]  [-d|-e|-i|-r]\n"
 "\n"
 " -d    Zeige aktuell mit X11-Anzeige verbundene PulseAudio-Daten (Standard)\n"
 " -e    Lokale PulseAudio-Daten an X11-Anzeige exportieren\n"
-" -i    PulseAudio-Daten von X11-Anzeige in lokale Umgebungsvariablen und Cookie importieren.\n"
+" -i    PulseAudio-Daten von X11-Anzeige in lokale Umgebungsvariablen und "
+"Cookie importieren.\n"
 " -r    PulseAudio-Daten von X11-Anzeige löschen\n"
 
 #: ../src/utils/pax11publish.c:94
@@ -1946,14 +2010,12 @@ msgstr "Daemon antwortet nicht."
 msgid "select(): %s"
 msgstr "select(): %s"
 
-#: ../src/utils/pacmd.c:124
-#: ../src/utils/pacmd.c:140
+#: ../src/utils/pacmd.c:124 ../src/utils/pacmd.c:140
 #, c-format
 msgid "read(): %s"
 msgstr "read(): %s"
 
-#: ../src/utils/pacmd.c:153
-#: ../src/utils/pacmd.c:167
+#: ../src/utils/pacmd.c:153 ../src/utils/pacmd.c:167
 #, c-format
 msgid "write(): %s"
 msgstr "write(): %s"
@@ -1983,11 +2045,15 @@ msgid ""
 "\n"
 "  -v, --verbose                         Enable verbose operation\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
 "  -d, --device=DEVICE                   The name of the sink to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
-"      --stream-name=NAME                How to call this stream on the server\n"
-"      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
+"      --stream-name=NAME                How to call this stream on the "
+"server\n"
+"      --volume=VOLUME                   Specify the initial (linear) volume "
+"in range 0...65536\n"
 "      --channel-map=CHANNELMAP          Set the channel map to the use\n"
 msgstr ""
 "%s [options] [FILE]\n"
@@ -2001,7 +2067,8 @@ msgstr ""
 "  -d, --device=DEVICE                   Name des Ziel-Sink\n"
 "  -n, --client-name=NAME                Rufname des Clients auf dem Server\n"
 "      --stream-name=NAME                Rufname des Streams auf dem Server\n"
-"      --volume=VOLUME                   Initiale (lineare) Lautstärke zwischen 0...65536\n"
+"      --volume=VOLUME                   Initiale (lineare) Lautstärke "
+"zwischen 0...65536\n"
 "      --channel-map=CHANNELMAP          Diese Kanalzuordnung nutzen\n"
 
 #: ../src/utils/paplay.c:255
@@ -2035,11 +2102,25 @@ msgstr "Kanal-Zuweisung stimmt mit Datei nicht überein.\n"
 msgid "Using sample spec '%s'\n"
 msgstr "Sampling-Angabe '%s' wird benutzt\n"
 
-#: ../src/pulsecore/lock-autospawn.c:126
-#: ../src/pulsecore/lock-autospawn.c:207
+#: ../src/pulsecore/lock-autospawn.c:126 ../src/pulsecore/lock-autospawn.c:207
 msgid "Cannot access autospawn lock."
 msgstr "Fehler beim Zugriff auf Autostart -Sperre."
 
+#~ msgid ""
+#~ "' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
+#~ "For enabling real-time scheduling please acquire the appropriate "
+#~ "PolicyKit priviliges, or become a member of '"
+#~ msgstr ""
+#~ "' und Richtlinien verweigern diese Rechte. Verwerfe SUID wieder.\n"
+#~ "Erlangen Sie die den Richtlinien entsprechenden Rechte, um Echtzeit-"
+#~ "Scheduling zu aktivieren oder werden Sie Mitglied der Gruppe '"
+
+#~ msgid ""
+#~ "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this "
+#~ "user."
+#~ msgstr ""
+#~ "' oder erhöhen sie die RLIMIT_NICE/RLIMIT_RTPRIO-Ressourcenbegrenzungen "
+#~ "für diesen Nutzer."
+
 #~ msgid "socketpair(): %s"
 #~ msgstr "socketpair(): %s"
-
diff --git a/po/el.po b/po/el.po
index 79ccda7..79549e0 100644
--- a/po/el.po
+++ b/po/el.po
@@ -6,7 +6,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: el\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-07 21:03+0200\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-08-22 19:40+0300\n"
 "Last-Translator: Dimitris Glezos <dimitris at glezos.com>\n"
 "Language-Team: Greek <fedora-trans-el at redhat.com>\n"
@@ -16,12 +16,16 @@ msgstr ""
 "X-Generator: KAider 0.1\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177 ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
+#: ../src/daemon/ltdl-bind-now.c:124
+msgid "Failed to find original lt_dlopen loader."
+msgstr ""
+
+#: ../src/daemon/ltdl-bind-now.c:129
+msgid "Failed to allocate new dl loader."
 msgstr ""
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
 msgstr ""
 
 #: ../src/daemon/polkit.c:55
@@ -149,212 +153,212 @@ msgstr ""
 msgid "Failed to parse command line."
 msgstr ""
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the "
-"configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
 
-#: ../src/daemon/main.c:497
+#: ../src/daemon/main.c:526
 msgid ""
 "High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr ""
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr ""
 
-#: ../src/daemon/main.c:539
+#: ../src/daemon/main.c:572
 msgid ""
 "Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr ""
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr ""
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:627
+#: ../src/daemon/main.c:663
 msgid ""
 "This program is not intended to be run as root (unless --system is "
 "specified)."
 msgstr ""
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+msgid "Root privileges required."
 msgstr ""
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr ""
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr ""
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr ""
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr ""
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr ""
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr ""
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Αυτό είναι το PulseAudio %s"
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr ""
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr ""
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr ""
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr ""
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr ""
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr ""
 
-#: ../src/daemon/main.c:850
+#: ../src/daemon/main.c:886
 msgid ""
 "Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
 "resolution timers enabled!"
@@ -362,36 +366,36 @@ msgstr ""
 "Δικέ μου, ο πυρήνας σου είναι για τα μπάζα! Η πρόταση του σεφ σήμερα είναι "
 "Linux με ενεργοποιημένα τα high-resolution timers!"
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr ""
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr ""
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr ""
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr ""
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr ""
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:117
+#: ../src/daemon/cmdline.c:123
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -407,7 +411,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
@@ -437,6 +442,10 @@ msgid ""
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
 "  -p, --dl-search-path=PATH             Set the search path for dynamic "
 "shared\n"
 "                                        objects (plugins)\n"
@@ -460,58 +469,66 @@ msgid ""
 "  -n                                    Don't load default script file\n"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:262
+#: ../src/daemon/cmdline.c:271
 msgid ""
 "--log-level expects log level argument (either numeric in range 0..4 or one "
 "of debug, info, notice, warn, error)."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:335
+msgid "--log-time boolean argument"
+msgstr ""
+
+#: ../src/daemon/cmdline.c:342
+msgid "--log-meta boolean argument"
+msgstr ""
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr ""
 
@@ -555,73 +572,73 @@ msgstr ""
 msgid "Path: %s\n"
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr ""
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+msgid "Dropping root privileges."
 msgstr ""
 
 #: ../src/daemon/caps.c:103
@@ -957,177 +974,177 @@ msgstr ""
 msgid "Received message for unknown extension '%s'"
 msgstr ""
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr ""
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:307 ../src/utils/pasuspender.c:159
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
 #: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:328 ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:333 ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:343 ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr ""
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1180,7 +1197,7 @@ msgid ""
 "per request in bytes.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1188,87 +1205,87 @@ msgid ""
 "Linked with libpulse %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr ""
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:742 ../src/utils/pasuspender.c:280
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
 #: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:769 ../src/utils/pasuspender.c:293
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
 #: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr ""
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:795 ../src/utils/pasuspender.c:301
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
 #: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
diff --git a/po/es.po b/po/es.po
index 845c85c..7edc21a 100644
--- a/po/es.po
+++ b/po/es.po
@@ -2,7 +2,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PulseAudio\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-02 01:30+0000\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-10-12 12:02-0300\n"
 "Last-Translator: Domingo Becker <domingobecker at gmail.com>\n"
 "Language-Team: Fedora Spanish <fedora-trans-es at redhat.com>\n"
@@ -11,15 +11,20 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "X-Poedit-Language: Spanish\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177
-#: ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
-msgstr "Falló al agregar bind-now-loader."
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "Falló al buscar cargador dlopen original."
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
 msgstr "Falló al buscar cargador dlopen original."
 
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
+msgstr "Falló al agregar bind-now-loader."
+
 #: ../src/daemon/polkit.c:55
 #, c-format
 msgid "Cannot connect to system bus: %s"
@@ -108,8 +113,7 @@ msgstr "GID del usuario '%s' y del grupo '%s' no son similares."
 msgid "Home directory of user '%s' is not '%s', ignoring."
 msgstr "El directorio de inicio del usuario '%s' no es '%s', ignorando."
 
-#: ../src/daemon/main.c:201
-#: ../src/daemon/main.c:206
+#: ../src/daemon/main.c:201 ../src/daemon/main.c:206
 #, c-format
 msgid "Failed to create '%s': %s"
 msgstr "Falló al crear '%s': %s"
@@ -146,245 +150,248 @@ msgstr "setrlimit(%s, (%u, %u)) falló: %s"
 msgid "Failed to parse command line."
 msgstr "Falló al analizar la línea de comando."
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
-msgstr "Estamos en el grupo '%s', permitiendo la planificación de alta prioridad."
+msgstr ""
+"Estamos en el grupo '%s', permitiendo la planificación de alta prioridad."
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr "Estamos en el grupo '%s', permitiendo la planificación de tiempo real."
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr "PolicyKit garantiza que se obtenga el privilegio de alta prioridad."
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr "PolicyKit se niega a dar acceso al privilegio de alta prioridad."
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr "PolicyKit garantiza el acceso al privilegio de tiempo real."
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr "PolicyKit se niega a dar acceso al privilegio de tiempo real."
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
 
-#: ../src/daemon/main.c:480
+#: ../src/daemon/main.c:526
 msgid ""
-"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-"For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"
-msgstr ""
-
-#: ../src/daemon/main.c:481
-msgid "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."
+"High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:497
-msgid "High-priority scheduling enabled in configuration but not allowed by policy."
-msgstr ""
-
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr ""
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr ""
 
-#: ../src/daemon/main.c:539
-msgid "Real-time scheduling enabled in configuration but not allowed by policy."
+#: ../src/daemon/main.c:572
+msgid ""
+"Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr ""
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr ""
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:627
-msgid "This program is not intended to be run as root (unless --system is specified)."
+#: ../src/daemon/main.c:663
+msgid ""
+"This program is not intended to be run as root (unless --system is "
+"specified)."
 msgstr ""
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+msgid "Root privileges required."
 msgstr ""
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr ""
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr ""
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr ""
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr ""
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr ""
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr ""
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr ""
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr ""
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr ""
 
-#: ../src/daemon/main.c:797
+#: ../src/daemon/main.c:832
+#, c-format
+msgid "Running in valgrind mode: %s"
+msgstr ""
+
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr ""
 
-#: ../src/daemon/main.c:803
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr ""
 
-#: ../src/daemon/main.c:806
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr ""
 
-#: ../src/daemon/main.c:811
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:816
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:819
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:834
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:846
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr ""
 
-#: ../src/daemon/main.c:848
-msgid "Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"
+#: ../src/daemon/main.c:886
+msgid ""
+"Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
+"resolution timers enabled!"
 msgstr ""
 
-#: ../src/daemon/main.c:858
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:919
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr ""
 
-#: ../src/daemon/main.c:924
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr ""
 
-#: ../src/daemon/main.c:929
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr ""
 
-#: ../src/daemon/main.c:942
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr ""
 
-#: ../src/daemon/main.c:948
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr ""
 
-#: ../src/daemon/main.c:969
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:117
+#: ../src/daemon/cmdline.c:123
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -395,34 +402,48 @@ msgid ""
 "      --dump-conf                       Dump default configuration\n"
 "      --dump-modules                    Dump list of available modules\n"
 "      --dump-resample-methods           Dump available resample methods\n"
-"      --cleanup-shm                     Cleanup stale shared memory segments\n"
-"      --start                           Start the daemon if it is not running\n"
+"      --cleanup-shm                     Cleanup stale shared memory "
+"segments\n"
+"      --start                           Start the daemon if it is not "
+"running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
 "  -D, --daemonize[=BOOL]                Daemonize after startup\n"
 "      --fail[=BOOL]                     Quit when startup fails\n"
 "      --high-priority[=BOOL]            Try to set high nice level\n"
-"                                        (only available as root, when SUID or\n"
+"                                        (only available as root, when SUID "
+"or\n"
 "                                        with elevated RLIMIT_NICE)\n"
 "      --realtime[=BOOL]                 Try to enable realtime scheduling\n"
-"                                        (only available as root, when SUID or\n"
+"                                        (only available as root, when SUID "
+"or\n"
 "                                        with elevated RLIMIT_RTPRIO)\n"
-"      --disallow-module-loading[=BOOL]  Disallow module user requested module\n"
+"      --disallow-module-loading[=BOOL]  Disallow module user requested "
+"module\n"
 "                                        loading/unloading after startup\n"
 "      --disallow-exit[=BOOL]            Disallow user requested exit\n"
-"      --exit-idle-time=SECS             Terminate the daemon when idle and this\n"
+"      --exit-idle-time=SECS             Terminate the daemon when idle and "
+"this\n"
 "                                        time passed\n"
-"      --module-idle-time=SECS           Unload autoloaded modules when idle and\n"
+"      --module-idle-time=SECS           Unload autoloaded modules when idle "
+"and\n"
 "                                        this time passed\n"
-"      --scache-idle-time=SECS           Unload autoloaded samples when idle and\n"
+"      --scache-idle-time=SECS           Unload autoloaded samples when idle "
+"and\n"
 "                                        this time passed\n"
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
-"  -p, --dl-search-path=PATH             Set the search path for dynamic shared\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
+"  -p, --dl-search-path=PATH             Set the search path for dynamic "
+"shared\n"
 "                                        objects (plugins)\n"
 "      --resample-method=METHOD          Use the specified resampling method\n"
 "                                        (See --dump-resample-methods for\n"
@@ -433,65 +454,77 @@ msgid ""
 "      --disable-shm[=BOOL]              Disable shared memory support.\n"
 "\n"
 "STARTUP SCRIPT:\n"
-"  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module with\n"
+"  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module "
+"with\n"
 "                                        the specified argument\n"
 "  -F, --file=FILENAME                   Run the specified script\n"
-"  -C                                    Open a command line on the running TTY\n"
+"  -C                                    Open a command line on the running "
+"TTY\n"
 "                                        after startup\n"
 "\n"
 "  -n                                    Don't load default script file\n"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:262
-msgid "--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."
+#: ../src/daemon/cmdline.c:271
+msgid ""
+"--log-level expects log level argument (either numeric in range 0..4 or one "
+"of debug, info, notice, warn, error)."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:335
+msgid "--log-time boolean argument"
+msgstr ""
+
+#: ../src/daemon/cmdline.c:342
+msgid "--log-meta boolean argument"
+msgstr ""
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr ""
 
@@ -535,76 +568,77 @@ msgstr ""
 msgid "Path: %s\n"
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:204
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:220
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:236
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:259
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:266
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:282
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:300
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:318
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:336
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:354
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:372
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:567
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:641
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr ""
 
-#: ../src/daemon/caps.c:62
-msgid "Dropping root priviliges."
-msgstr ""
+#: ../src/daemon/caps.c:63
+#, fuzzy
+msgid "Dropping root privileges."
+msgstr "Se han liberado con éxitos los privilegios de root."
 
-#: ../src/daemon/caps.c:102
+#: ../src/daemon/caps.c:103
 msgid "Limited capabilities successfully to CAP_SYS_NICE."
 msgstr ""
 
@@ -812,6 +846,11 @@ msgstr ""
 msgid "Top Rear Right"
 msgstr ""
 
+#: ../src/pulse/channelmap.c:472 ../src/pulse/sample.c:144
+#: ../src/pulse/volume.c:163 ../src/pulse/volume.c:194
+msgid "(invalid)"
+msgstr ""
+
 #: ../src/pulse/error.c:43
 msgid "OK"
 msgstr ""
@@ -900,12 +939,7 @@ msgstr ""
 msgid "No such extension"
 msgstr ""
 
-#: ../src/pulse/sample.c:134
-msgid "Invalid"
-msgstr ""
-
-#: ../src/pulse/client-conf-x11.c:55
-#: ../src/utils/pax11publish.c:100
+#: ../src/pulse/client-conf-x11.c:55 ../src/utils/pax11publish.c:100
 msgid "XOpenDisplay() failed"
 msgstr ""
 
@@ -913,7 +947,7 @@ msgstr ""
 msgid "Failed to parse cookie data"
 msgstr ""
 
-#: ../src/pulse/client-conf.c:117
+#: ../src/pulse/client-conf.c:120
 #, c-format
 msgid "Failed to open configuration file '%s': %s"
 msgstr ""
@@ -937,182 +971,177 @@ msgstr ""
 msgid "Received message for unknown extension '%s'"
 msgstr ""
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr ""
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:307
-#: ../src/utils/pasuspender.c:159
-#: ../src/utils/pactl.c:666
-#: ../src/utils/paplay.c:183
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
+#: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:328
-#: ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:333
-#: ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:343
-#: ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr ""
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1125,30 +1154,47 @@ msgid ""
 "\n"
 "  -v, --verbose                         Enable verbose operations\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
-"  -d, --device=DEVICE                   The name of the sink/source to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
-"      --stream-name=NAME                How to call this stream on the server\n"
-"      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
-"      --rate=SAMPLERATE                 The sample rate in Hz (defaults to 44100)\n"
-"      --format=SAMPLEFORMAT             The sample type, one of s16le, s16be, u8, float32le,\n"
-"                                        float32be, ulaw, alaw, s32le, s32be (defaults to s16ne)\n"
-"      --channels=CHANNELS               The number of channels, 1 for mono, 2 for stereo\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
+"  -d, --device=DEVICE                   The name of the sink/source to "
+"connect to\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
+"      --stream-name=NAME                How to call this stream on the "
+"server\n"
+"      --volume=VOLUME                   Specify the initial (linear) volume "
+"in range 0...65536\n"
+"      --rate=SAMPLERATE                 The sample rate in Hz (defaults to "
+"44100)\n"
+"      --format=SAMPLEFORMAT             The sample type, one of s16le, "
+"s16be, u8, float32le,\n"
+"                                        float32be, ulaw, alaw, s32le, s32be "
+"(defaults to s16ne)\n"
+"      --channels=CHANNELS               The number of channels, 1 for mono, "
+"2 for stereo\n"
 "                                        (defaults to 2)\n"
-"      --channel-map=CHANNELMAP          Channel map to use instead of the default\n"
-"      --fix-format                      Take the sample format from the sink the stream is\n"
+"      --channel-map=CHANNELMAP          Channel map to use instead of the "
+"default\n"
+"      --fix-format                      Take the sample format from the sink "
+"the stream is\n"
 "                                        being connected to.\n"
-"      --fix-rate                        Take the sampling rate from the sink the stream is\n"
+"      --fix-rate                        Take the sampling rate from the sink "
+"the stream is\n"
 "                                        being connected to.\n"
-"      --fix-channels                    Take the number of channels and the channel map\n"
-"                                        from the sink the stream is being connected to.\n"
+"      --fix-channels                    Take the number of channels and the "
+"channel map\n"
+"                                        from the sink the stream is being "
+"connected to.\n"
 "      --no-remix                        Don't upmix or downmix channels.\n"
-"      --no-remap                        Map channels by index instead of name.\n"
-"      --latency=BYTES                   Request the specified latency in bytes.\n"
-"      --process-time=BYTES              Request the specified process time per request in bytes.\n"
+"      --no-remap                        Map channels by index instead of "
+"name.\n"
+"      --latency=BYTES                   Request the specified latency in "
+"bytes.\n"
+"      --process-time=BYTES              Request the specified process time "
+"per request in bytes.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1156,94 +1202,88 @@ msgid ""
 "Linked with libpulse %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr ""
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:742
-#: ../src/utils/pasuspender.c:280
-#: ../src/utils/pactl.c:909
-#: ../src/utils/paplay.c:381
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
+#: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:769
-#: ../src/utils/pasuspender.c:293
-#: ../src/utils/pactl.c:923
-#: ../src/utils/paplay.c:396
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
+#: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr ""
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:795
-#: ../src/utils/pasuspender.c:301
-#: ../src/utils/pactl.c:931
-#: ../src/utils/paplay.c:407
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
+#: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
 msgstr ""
@@ -1273,8 +1313,7 @@ msgstr ""
 msgid "WARNING: Sound server is not local, not suspending.\n"
 msgstr ""
 
-#: ../src/utils/pasuspender.c:176
-#: ../src/utils/pactl.c:672
+#: ../src/utils/pasuspender.c:176 ../src/utils/pactl.c:672
 #: ../src/utils/paplay.c:191
 #, c-format
 msgid "Got SIGINT, exiting.\n"
@@ -1292,7 +1331,8 @@ msgid ""
 "\n"
 "  -h, --help                            Show this help\n"
 "      --version                         Show version\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
 "\n"
 msgstr ""
 
@@ -1364,8 +1404,7 @@ msgid ""
 "%s"
 msgstr ""
 
-#: ../src/utils/pactl.c:193
-#: ../src/utils/pactl.c:371
+#: ../src/utils/pactl.c:193 ../src/utils/pactl.c:371
 msgid "muted"
 msgstr ""
 
@@ -1391,18 +1430,10 @@ msgid ""
 "%s"
 msgstr ""
 
-#: ../src/utils/pactl.c:246
-#: ../src/utils/pactl.c:289
-#: ../src/utils/pactl.c:322
-#: ../src/utils/pactl.c:366
-#: ../src/utils/pactl.c:367
-#: ../src/utils/pactl.c:374
-#: ../src/utils/pactl.c:418
-#: ../src/utils/pactl.c:419
-#: ../src/utils/pactl.c:425
-#: ../src/utils/pactl.c:468
-#: ../src/utils/pactl.c:469
-#: ../src/utils/pactl.c:473
+#: ../src/utils/pactl.c:246 ../src/utils/pactl.c:289 ../src/utils/pactl.c:322
+#: ../src/utils/pactl.c:366 ../src/utils/pactl.c:367 ../src/utils/pactl.c:374
+#: ../src/utils/pactl.c:418 ../src/utils/pactl.c:419 ../src/utils/pactl.c:425
+#: ../src/utils/pactl.c:468 ../src/utils/pactl.c:469 ../src/utils/pactl.c:473
 msgid "n/a"
 msgstr ""
 
@@ -1525,8 +1556,7 @@ msgstr ""
 msgid "source"
 msgstr ""
 
-#: ../src/utils/pactl.c:511
-#: ../src/utils/pactl.c:521
+#: ../src/utils/pactl.c:511 ../src/utils/pactl.c:521
 #, c-format
 msgid "Failure: %s\n"
 msgstr ""
@@ -1560,8 +1590,10 @@ msgid ""
 "  -h, --help                            Show this help\n"
 "      --version                         Show version\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
 msgstr ""
 
 #: ../src/utils/pactl.c:729
@@ -1614,12 +1646,16 @@ msgstr ""
 
 #: ../src/utils/pactl.c:875
 #, c-format
-msgid "You may not specify more than one sink. You have to specify at least one boolean value.\n"
+msgid ""
+"You may not specify more than one sink. You have to specify at least one "
+"boolean value.\n"
 msgstr ""
 
 #: ../src/utils/pactl.c:888
 #, c-format
-msgid "You may not specify more than one source. You have to specify at least one boolean value.\n"
+msgid ""
+"You may not specify more than one source. You have to specify at least one "
+"boolean value.\n"
 msgstr ""
 
 #: ../src/utils/pactl.c:904
@@ -1634,7 +1670,8 @@ msgid ""
 "\n"
 " -d    Show current PulseAudio data attached to X11 display (default)\n"
 " -e    Export local PulseAudio data to X11 display\n"
-" -i    Import PulseAudio data from X11 display to local environment variables and cookie file.\n"
+" -i    Import PulseAudio data from X11 display to local environment "
+"variables and cookie file.\n"
 " -r    Remove PulseAudio data from X11 display\n"
 msgstr ""
 
@@ -1721,14 +1758,12 @@ msgstr ""
 msgid "select(): %s"
 msgstr ""
 
-#: ../src/utils/pacmd.c:124
-#: ../src/utils/pacmd.c:140
+#: ../src/utils/pacmd.c:124 ../src/utils/pacmd.c:140
 #, c-format
 msgid "read(): %s"
 msgstr ""
 
-#: ../src/utils/pacmd.c:153
-#: ../src/utils/pacmd.c:167
+#: ../src/utils/pacmd.c:153 ../src/utils/pacmd.c:167
 #, c-format
 msgid "write(): %s"
 msgstr ""
@@ -1758,11 +1793,15 @@ msgid ""
 "\n"
 "  -v, --verbose                         Enable verbose operation\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
 "  -d, --device=DEVICE                   The name of the sink to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
-"      --stream-name=NAME                How to call this stream on the server\n"
-"      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
+"      --stream-name=NAME                How to call this stream on the "
+"server\n"
+"      --volume=VOLUME                   Specify the initial (linear) volume "
+"in range 0...65536\n"
 "      --channel-map=CHANNELMAP          Set the channel map to the use\n"
 msgstr ""
 
@@ -1794,8 +1833,6 @@ msgstr ""
 msgid "Using sample spec '%s'\n"
 msgstr ""
 
-#: ../src/pulsecore/lock-autospawn.c:126
-#: ../src/pulsecore/lock-autospawn.c:207
+#: ../src/pulsecore/lock-autospawn.c:126 ../src/pulsecore/lock-autospawn.c:207
 msgid "Cannot access autospawn lock."
 msgstr ""
-
diff --git a/po/fi.po b/po/fi.po
index 171ff16..c2ecfd6 100644
--- a/po/fi.po
+++ b/po/fi.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: git trunk\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-12-01 18:40+0200\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-12-01 18:40+0200\n"
 "Last-Translator: Timo Jyrinki <timo.jyrinki at iki.fi>\n"
 "Language-Team: Finnish <laatu at lokalisointi.org>\n"
@@ -15,12 +15,17 @@ msgstr ""
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177 ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "Taustaprosessin alustus epäonnistui."
+
+#: ../src/daemon/ltdl-bind-now.c:129
+msgid "Failed to allocate new dl loader."
 msgstr ""
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
 msgstr ""
 
 #: ../src/daemon/polkit.c:55
@@ -148,79 +153,79 @@ msgstr ""
 msgid "Failed to parse command line."
 msgstr ""
 
-#: ../src/daemon/main.c:444
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:451
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:462
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:470
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:482
+#: ../src/daemon/main.c:502
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the "
-"configuration. However, we lack the necessary privileges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
 
-#: ../src/daemon/main.c:500
+#: ../src/daemon/main.c:526
 msgid ""
 "High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr ""
 
-#: ../src/daemon/main.c:528
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:535
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr ""
 
-#: ../src/daemon/main.c:542
+#: ../src/daemon/main.c:572
 msgid ""
 "Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 "Tosiaikainen ajoitus otettu käyttöön asetuksissa, mutta käytännöt eivät "
 "salli sitä."
 
-#: ../src/daemon/main.c:600
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr "Taustaprosessi ei ole käynnissä"
 
-#: ../src/daemon/main.c:602
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr "Taustaprosessi käynnissä prosessitunnisteella %u"
 
-#: ../src/daemon/main.c:612
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr "Taustaprosessin lopettaminen epäonnistui: %s"
 
-#: ../src/daemon/main.c:630
+#: ../src/daemon/main.c:663
 msgid ""
 "This program is not intended to be run as root (unless --system is "
 "specified)."
@@ -228,139 +233,139 @@ msgstr ""
 "Tätä ohjelmaa ei ole tarkoitettu suoritettavaksi pääkäyttäjänä (ellei --"
 "system ole määritelty)."
 
-#: ../src/daemon/main.c:632
+#: ../src/daemon/main.c:665
 msgid "Root privileges required."
 msgstr "Pääkäyttäjän (root) oikeudet vaaditaan."
 
-#: ../src/daemon/main.c:637
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr ""
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:648
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr ""
 "Suoritetaan järjestelmätilassa, otetaan SHM-tila pakotetusti pois käytöstä."
 
-#: ../src/daemon/main.c:653
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr ""
 "Suoritetaan järjestelmätilassa, otetaan poistumisen joutenoloaika "
 "pakotetusti pois käytöstä."
 
-#: ../src/daemon/main.c:680
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr ""
 
-#: ../src/daemon/main.c:686
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:691
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:705
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:711
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr "Taustaprosessin käynnistys epäonnistui."
 
-#: ../src/daemon/main.c:713
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr "Taustaprosessin käynnistys onnistui."
 
-#: ../src/daemon/main.c:783
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Tämä on PulseAudio %s"
 
-#: ../src/daemon/main.c:784
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr "Käännöksen isäntäkone: %s"
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr "Käännösaikaiset C-liput (CFLAGS): %s"
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr "Käynnissä isäntäkoneella: %s"
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr "Sivun koko on %lu tavua"
 
-#: ../src/daemon/main.c:794
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr "Käännetty Valgrind-tuella: kyllä"
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr "Käännetty Valgrind-tuella: ei"
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr "Käynnissä valgrind-tilassa: %s"
 
-#: ../src/daemon/main.c:802
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr "Optimoitu rakentaminen: kyllä"
 
-#: ../src/daemon/main.c:804
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr "Optimoitu rakentaminen: ei"
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr "Konetunnisteen nouto epäonnistui"
 
-#: ../src/daemon/main.c:811
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr "Konetunniste on %s."
 
-#: ../src/daemon/main.c:816
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr "Käytetään ajonaikaista hakemistoa %s."
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr "Käytetään tilahakemistoa %s."
 
-#: ../src/daemon/main.c:824
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr "Suoritetaan järjestelmätilassa: %s"
 
-#: ../src/daemon/main.c:839
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:851
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr "Korkean tarkkuuden ajastimet käytettävissä."
 
-#: ../src/daemon/main.c:853
+#: ../src/daemon/main.c:886
 msgid ""
 "Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
 "resolution timers enabled!"
@@ -368,32 +373,32 @@ msgstr ""
 "Hei, ytimesi on kehno! Linux korkean tarkkuuden ajastimien tuella on hyvin "
 "suositeltava!"
 
-#: ../src/daemon/main.c:863
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr ""
 
-#: ../src/daemon/main.c:924
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr "Taustaprosessin alustus epäonnistui."
 
-#: ../src/daemon/main.c:929
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr ""
 
-#: ../src/daemon/main.c:934
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr ""
 
-#: ../src/daemon/main.c:947
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr "Taustaprosessin käynnistys valmis."
 
-#: ../src/daemon/main.c:953
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr "Taustaprosessin sulkeminen käynnistetty."
 
-#: ../src/daemon/main.c:974
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr "Taustaprosessi lopetettu."
 
@@ -413,7 +418,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
diff --git a/po/fr.po b/po/fr.po
index ff7aa16..11b7557 100644
--- a/po/fr.po
+++ b/po/fr.po
@@ -4,29 +4,35 @@
 # Robert-André Mauchin <zebob.m at pengzone.org>, 2008.
 # Michaël Ughetto <telimektar esraonline com>, 2008.
 # Pablo Martin-Gomez <pablo.martin-gomez at laposte.net>, 2008.
-# 
-# 
+#
+#
 msgid ""
 msgstr ""
 "Project-Id-Version: pulseaudio trunk\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-14 02:29+0000\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-10-18 20:34+0200\n"
 "Last-Translator: Pablo Martin-Gomez <pablo.martin-gomez at laposte.net>\n"
 "Language-Team: Français <fedora-trans-fr at redhat.com>\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=n>1;"
+"Plural-Forms: nplurals=2; plural=n>1;\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177 ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
-msgstr "Échec lors de l'ajout du chargeur bind-now."
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "Échec lors de la recherche du chargeur dlopen original."
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
 msgstr "Échec lors de la recherche du chargeur dlopen original."
 
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
+msgstr "Échec lors de l'ajout du chargeur bind-now."
+
 #: ../src/daemon/polkit.c:55
 #, c-format
 msgid "Cannot connect to system bus: %s"
@@ -153,40 +159,40 @@ msgstr "setrlimit(%s, (%u, %u)) a échoué : %s"
 msgid "Failed to parse command line."
 msgstr "Échec lors de l'analyse de la ligne de commande"
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
 msgstr ""
 "Nous sommes dans le groupe « %s », permettant une planification à haute "
 "priorité."
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr ""
-"Nous sommes dans le groupe « %s », permettant une planification en temps "
-"réel."
+"Nous sommes dans le groupe « %s », permettant une planification en temps réel."
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr "PolicyKit a accordé l'acquisition des permissions de haute priorité."
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr "PolicyKit a refusé l'acquisition des permissions de haute priorité."
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr "PolicyKit a accordé l'acquisition des permissions de temps réel."
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr "PolicyKit a refusé l'acquisition des permissions de temps réel."
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
+#, fuzzy
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the "
-"configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
 "Le SUID root a été appelé et la planification à haute priorité/en temps réel "
@@ -194,66 +200,48 @@ msgstr ""
 "nécessaires :\n"
 "nous ne somme pas dans le groupe "
 
-#: ../src/daemon/main.c:480
-msgid ""
-"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-"For enabling real-time scheduling please acquire the appropriate PolicyKit "
-"priviliges, or become a member of '"
-msgstr ""
-" et PolicyKit refuse de nous accorder les permissions. Abandon du SUID à "
-"nouveau.\n"
-"Pour activer la planification en temps réel, veuillez aquérir les "
-"permissions PolicyKit appropriées, ou devenez membre de "
-
-#: ../src/daemon/main.c:481
-msgid ""
-"', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."
-msgstr ""
-", ou augmentez les limites de ressource RLIMIT_NICE/RLIMIT_RTPRIO pour cet "
-"utilisateur."
-
-#: ../src/daemon/main.c:497
+#: ../src/daemon/main.c:526
 msgid ""
 "High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 "La planification à haute priorité est activée dans la configuration mais "
 "n'est pas permise par la politique."
 
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr "Augmentation de RLIMIT_RTPRIO réussie"
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr "RLIMIT_RTPRIO a échoué : %s"
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr "Abandon de CAP_NICE"
 
-#: ../src/daemon/main.c:539
+#: ../src/daemon/main.c:572
 msgid ""
 "Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 "La planification en temps réel est activée mais n'est pas permise par la "
 "politique."
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr "Lé démon n'est pas lancé"
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr "Le démon est lancé avec le PID %u"
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr "Impossible de tuer le démon : %s"
 
-#: ../src/daemon/main.c:627
+#: ../src/daemon/main.c:663
 msgid ""
 "This program is not intended to be run as root (unless --system is "
 "specified)."
@@ -261,142 +249,143 @@ msgstr ""
 "Le programme n'est pas conçu pour être lancé en tant que root (sauf si --"
 "system est renseigné)."
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+#, fuzzy
+msgid "Root privileges required."
 msgstr "Les permissions root sont nécessaires."
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr "--start n'est pas pris en charge pour les instances système."
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr ""
 "Le démon s'exécute en mode système, mais --disallow-exit n'est pas défini."
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr ""
 "Le démon s'exécute en mode système, mais --disallow-module-loading n'est pas "
 "défini."
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr "Le démon s'exécute en mode système, désactivation forcée du mode SHM."
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr ""
 "Le démon s'exécute en mode système, désactivation forcée de la fermeture "
 "après délai d'inactivité."
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr "Échec lors de l'acquisition de stdio."
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr "Échec du tube : %s"
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr "Échec de fork() : %s"
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr "Échec de read() : %s"
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr "Échec lors du démarrage du démon."
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr "Démarrage du démon réussi."
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Pulseaudio %s"
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr "Hôte de compilation : %s"
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr "CFLAGS de compilation : %s"
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr "Exécution sur l'hôte : %s"
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr "La taille de la page est de %lu octets"
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr "Compilé avec la prise en charge Valgrind : oui"
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr "Compilé avec la prise en charge Valgrind : non"
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr "Exécution en mode valgrind : %s"
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr "Construction optimisée : oui"
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr "Construction optimisée : non"
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr "Échec lors de l'obtention de l'ID de la machine"
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr "L'ID de la machine est %s."
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr "Utilisation du répertoire d'exécution %s."
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr "Utilisation du répertoire d'état %s."
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr "Exécution en mode système : %s"
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr "Échec de pa_pid_file_create()."
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr ""
 "De nouvelles horloges à haute résolution sont disponibles ! Bon appétit !"
 
-#: ../src/daemon/main.c:850
+#: ../src/daemon/main.c:886
 msgid ""
 "Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
 "resolution timers enabled!"
@@ -404,39 +393,39 @@ msgstr ""
 "Eh mec, ton noyau il pue ! La recommandation d'aujourd'hui du patron est "
 "d'activer les horloges à haute résolution sur ton Linux."
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr "Échec de pa_core_new()."
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr "Échec lors de l'initialisation du démon"
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr "Démarrage du démon sans aucun module chargé : refus de fonctionner."
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr ""
 "Le nom de la destination par défaut (%s) n'existe pas dans le registre des "
 "noms."
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr "Démarrage du démon effectué."
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr "Fermeture du démon initiée."
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr "Démon terminé."
 
-#: ../src/daemon/cmdline.c:117
-#, c-format
+#: ../src/daemon/cmdline.c:123
+#, fuzzy, c-format
 msgid ""
 "%s [options]\n"
 "\n"
@@ -451,7 +440,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
@@ -481,6 +471,10 @@ msgid ""
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
 "  -p, --dl-search-path=PATH             Set the search path for dynamic "
 "shared\n"
 "                                        objects (plugins)\n"
@@ -585,15 +579,15 @@ msgstr ""
 "  -n                                    Ne pas charger les fichiers de "
 "scripts par défaut\n"
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr "--daemonize requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr "--fail requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:262
+#: ../src/daemon/cmdline.c:271
 msgid ""
 "--log-level expects log level argument (either numeric in range 0..4 or one "
 "of debug, info, notice, warn, error)."
@@ -601,45 +595,54 @@ msgstr ""
 "--log-level requiert un paramètre de niveau de journal (soit numérique entre "
 "0 et 4, soit de débogage : info, notice, warn , error)."
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr "--high-priority requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr "--realtime requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr "--disallow-module-loading requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr "--disallow-exit requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr "--use-pid-file requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
-msgstr ""
-"Cible du journal invalide : utilisez « syslog », « stderr » ou « auto »."
+msgstr "Cible du journal invalide : utilisez « syslog », « stderr » ou « auto »."
+
+#: ../src/daemon/cmdline.c:335
+#, fuzzy
+msgid "--log-time boolean argument"
+msgstr "--disallow-exit requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:342
+#, fuzzy
+msgid "--log-meta boolean argument"
+msgstr "--disallow-exit requiert un paramètre booléen"
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr "Méthode de rééchantillonnage invalide « %s »."
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr "--system requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr "--no-cpu-limit requiert un paramètre booléen"
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr "--disable-shm requiert un paramètre booléen"
 
@@ -684,73 +687,74 @@ msgid "Path: %s\n"
 msgstr "Chemin : %s\n"
 
 # dans les lignes suivantes [%s = nom de fichier: %u = ligne dans celui-ci]
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr "[%s:%u] Cible du journal « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr "[%s:%u] Niveau du journal « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr "[%s:%u] Méthode de rééchantillonnage « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr "[%s:%u] rlimit « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr "[%s:%u] rlimit n'est pas pris en charge sur cette plateforme."
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr "[%s:%u] Format d'échantillon « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr "[%s:%u] Taux d'échantillonnage « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr "[%s:%u] Canaux d'échantillonnage « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr "[%s:%u] Nombre de fragments « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr "[%s:%u] Taille du fragment « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr "[%s:%u] Niveau de priorité (nice) « %s » invalide."
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr "Échec lors de l'ouverture du fichier de configuration : %s"
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr "### Lecture à partir du fichier de configuration : %s ###\n"
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+#, fuzzy
+msgid "Dropping root privileges."
 msgstr "Abandon des permissions root."
 
 #: ../src/daemon/caps.c:103
@@ -1086,176 +1090,175 @@ msgstr "waitpid() : %s"
 msgid "Received message for unknown extension '%s'"
 msgstr "Message reçu pour une extension inconnue « %s »"
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr "Échec de pa_stream_write() : %s\n"
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr "Échec de pa_stream_peek() : %s\n"
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr "Saturation du tampon, abandon des données entrantes\n"
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr "Échec de pa_stream_drop() : %s\n"
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr "Création du flux réussie.\n"
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr "Échec de pa_stream_get_buffer_attr() : %s\n"
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr "Mesures du tampon : maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr "Mesures du tampon : maxlength=%u, fragsize=%u\n"
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr ""
-"Utilisation de la spécification d'échantillon « %s », plan des canaux « %"
-"s ».\n"
+"Utilisation de la spécification d'échantillon « %s », plan des canaux « %s ».\n"
 
 # l'espace manquant entre %s et suspended est voulu
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr "Connecté au périphérique %s (%u, %ssuspendu).\n"
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr "Erreur du flux : %s\n"
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr "Périphérique de flux suspendu %s \n"
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr "Périphérique de flux repris %s \n"
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr "Flux vide %s \n"
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr "Flux saturé %s \n"
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr "Flux démarré %s \n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr "Flux déplacé vers le périphérique %s (%u, %ssuspendu).%s \n"
 
 # suspendu ou non suspendu
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr "non "
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr "Connection établie.%s \n"
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr "Échec de pa_stream_new() : %s\n"
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr "Échec de pa_stream_connect_playback() : %s\n"
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr "Échec de pa_stream_connect_record() : %s\n"
 
-#: ../src/utils/pacat.c:307 ../src/utils/pasuspender.c:159
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
 #: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr "Échec lors de la connexion : %s\n"
 
-#: ../src/utils/pacat.c:328 ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr "Échec lors du vidage du flux : %s\n"
 
-#: ../src/utils/pacat.c:333 ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr "Flux de lecture vidé.\n"
 
-#: ../src/utils/pacat.c:343 ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr "Vidage de la connexion au serveur.\n"
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr "EOF obtenu.\n"
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr "pa_stream_drain() : %s\n"
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr "Échec de read() : %s\n"
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr "Échec de write() : %s\n"
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr "Signal obtenu, fermeture.\n"
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr "Échec lors de l'obtention de la latence : %s\n"
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr "Durée : %0.3f s ; Latency : %0.0f µs.  \r"
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr "Échec de pa_stream_update_timing_info() : %s\n"
@@ -1263,7 +1266,7 @@ msgstr "Échec de pa_stream_update_timing_info() : %s\n"
 # downmix = par ex. convertir 5 canaux en 2 canaux
 # upmixer = par ex. convertir 2 canaux en 5 canaux
 # https://bugzilla.redhat.com/show_bug.cgi?id=460798
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1322,7 +1325,8 @@ msgstr ""
 "\n"
 "  -r, --record                          Crée une connexion pour "
 "l'enregistrement\n"
-"  -p, --playback                        Crée une connexion pour la relecture\n"
+"  -p, --playback                        Crée une connexion pour la "
+"relecture\n"
 "\n"
 "  -v, --verbose                         Active le mode verbeux\n"
 "\n"
@@ -1366,7 +1370,7 @@ msgstr ""
 "      --process-time=OCTETS             Demande le temps de traitement "
 "indiqué par requête en octets.\n"
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1377,88 +1381,88 @@ msgstr ""
 "Compilé avec libpulse %s\n"
 "Lié avec libpulse %s\n"
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr "Plan des canaux invalide « %s »\n"
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr "Spécification de latence invalide « %s »\n"
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr "Spécification de temps de traitement invalide « %s »\n"
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr "Spécification d'échantillon invalide\n"
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr ""
 "Le plan des canaux ne correspond pas à la spécification d'échantillon\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr "Ouverture d'un flux %s avec une spécification d'échantillon « %s ».\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr "enregistrement"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr "lecture"
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr "open() : %s\n"
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr "dup2() : %s\n"
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr "Trop de paramètres.\n"
 
-#: ../src/utils/pacat.c:742 ../src/utils/pasuspender.c:280
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
 #: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr "Échec de pa_mainloop_new().\n"
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr "Échec de io_new().\n"
 
-#: ../src/utils/pacat.c:769 ../src/utils/pasuspender.c:293
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
 #: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr "Échec de pa_context_new().\n"
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr "Échec de pa_context_connect() : %s"
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr "Échec de time_new().\n"
 
-#: ../src/utils/pacat.c:795 ../src/utils/pasuspender.c:301
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
 #: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
@@ -2178,5 +2182,22 @@ msgstr "Utilisation de la spécification de l'échantillon « %s »\n"
 msgid "Cannot access autospawn lock."
 msgstr "Impossible d'accèder au verrou autonome."
 
+#~ msgid ""
+#~ "' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
+#~ "For enabling real-time scheduling please acquire the appropriate "
+#~ "PolicyKit priviliges, or become a member of '"
+#~ msgstr ""
+#~ " et PolicyKit refuse de nous accorder les permissions. Abandon du SUID à "
+#~ "nouveau.\n"
+#~ "Pour activer la planification en temps réel, veuillez aquérir les "
+#~ "permissions PolicyKit appropriées, ou devenez membre de "
+
+#~ msgid ""
+#~ "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this "
+#~ "user."
+#~ msgstr ""
+#~ ", ou augmentez les limites de ressource RLIMIT_NICE/RLIMIT_RTPRIO pour "
+#~ "cet utilisateur."
+
 #~ msgid "socketpair(): %s"
 #~ msgstr "socketpair() : %s"
diff --git a/po/pl.po b/po/pl.po
index cf5970e..67ed263 100644
--- a/po/pl.po
+++ b/po/pl.po
@@ -5,7 +5,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: pl\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-12-30 22:54+0100\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-12-30 22:55+0100\n"
 "Last-Translator: Piotr DrÄ…g <piotrdrag at gmail.com>\n"
 "Language-Team: Polish <pl at li.org>\n"
@@ -411,7 +411,7 @@ msgid "Daemon terminated."
 msgstr "Demon został zniszczony."
 
 #: ../src/daemon/cmdline.c:123
-#, c-format
+#, fuzzy, c-format
 msgid ""
 "%s [options]\n"
 "\n"
@@ -426,7 +426,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 94113b0..88a4893 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: pulseaudio\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-11-18 13:43+0000\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-11-21 01:21-0300\n"
 "Last-Translator: Henrique (LonelySpooky) Junior <lspooky at fedoraproject.org>\n"
 "Language-Team: Brazilian-Portuguese <fedora-trans-pt_br at redhat.com>\n"
@@ -18,15 +18,20 @@ msgstr ""
 "X-Poedit-Language: Brazilian Portuguese\n"
 "X-Poedit-Country: Brazil\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177
-#: ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
-msgstr "Falha em adicionar o bind-now-loader."
+#: ../src/daemon/ltdl-bind-now.c:124
+#, fuzzy
+msgid "Failed to find original lt_dlopen loader."
+msgstr "Falha em encontrar o carregador original dlopen"
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
 msgstr "Falha em encontrar o carregador original dlopen"
 
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
+msgstr "Falha em adicionar o bind-now-loader."
+
 #: ../src/daemon/polkit.c:55
 #, c-format
 msgid "Cannot connect to system bus: %s"
@@ -115,8 +120,7 @@ msgstr "O GID do usuário'%s' e do grupo '%s' não combinam."
 msgid "Home directory of user '%s' is not '%s', ignoring."
 msgstr "O diretório Home do usuário '%s' não é '%s', ignorando."
 
-#: ../src/daemon/main.c:201
-#: ../src/daemon/main.c:206
+#: ../src/daemon/main.c:201 ../src/daemon/main.c:206
 #, c-format
 msgid "Failed to create '%s': %s"
 msgstr "Falha em criar '%s': %s"
@@ -153,255 +157,265 @@ msgstr "setrlimit(%s, (%u, %u)) falhou: %s"
 msgid "Failed to parse command line."
 msgstr "Falha em interpretar a linha de comando."
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
 msgstr "Estamos no grupo '%s', permitindo escalonamento de alta prioridade."
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr "Estamos no grupo '%s', permitindo escalonamento em tempo real."
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr "O PolicyKit assegura-nos a aquisição de privilégio de alta prioridade."
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr "O PolicyKit recusa a aquisição de privilégios de alta prioridade."
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr "O PolicyKit assegura-nos a aquisição de privilégios de tempo-real."
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr "O PolicyKit recusa a aquisição de privilégios de tempo real."
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
+#, fuzzy
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
-"A chamada de SUID root e tempo real/alta prioridade no escalonamento foi requisitada pela configuração. Todavia, falta-nos os privilégios necessários:\n"
+"A chamada de SUID root e tempo real/alta prioridade no escalonamento foi "
+"requisitada pela configuração. Todavia, falta-nos os privilégios "
+"necessários:\n"
 "Não estamos no grupo'"
 
-#: ../src/daemon/main.c:480
+#: ../src/daemon/main.c:526
 msgid ""
-"' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
-"For enabling real-time scheduling please acquire the appropriate PolicyKit priviliges, or become a member of '"
+"High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
-"' e o PolicyKit recusa-nos a garantia de privilégios. Retirando o SUID outra vez.\n"
-" Para habilitar o escalonamento em tempo real, por favo, adquira os privilégios adequados pelo PolicyKit, ou torne-se membro do'"
-
-#: ../src/daemon/main.c:481
-msgid "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this user."
-msgstr "', ou eleve o RLIMIT_NICE/RLIMIT_RTPRIO dos limites do recurso para este usuário."
-
-#: ../src/daemon/main.c:497
-msgid "High-priority scheduling enabled in configuration but not allowed by policy."
-msgstr "O escalonamento de alta prioridade foi habilitado para esta configuração, mas não é permitida pela política."
+"O escalonamento de alta prioridade foi habilitado para esta configuração, "
+"mas não é permitida pela política."
 
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr "RLIMIT_RTPRIO aumentado com sucesso"
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr "RLIMIT_RTPRIO falhou: %s"
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr "Abandonando CAP_NICE"
 
-#: ../src/daemon/main.c:539
-msgid "Real-time scheduling enabled in configuration but not allowed by policy."
-msgstr "O escalonamento de tempo real foi habilitado pela configuração, mas não é permitido pela política."
+#: ../src/daemon/main.c:572
+msgid ""
+"Real-time scheduling enabled in configuration but not allowed by policy."
+msgstr ""
+"O escalonamento de tempo real foi habilitado pela configuração, mas não é "
+"permitido pela política."
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr "O daemon não está em execução"
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr "Daemon executando como PID %u"
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr "Falha em encerrar o daemon: %s"
 
-#: ../src/daemon/main.c:627
-msgid "This program is not intended to be run as root (unless --system is specified)."
-msgstr "Este programa não é para ser executado como root (a não ser que --system seja especificado)."
+#: ../src/daemon/main.c:663
+msgid ""
+"This program is not intended to be run as root (unless --system is "
+"specified)."
+msgstr ""
+"Este programa não é para ser executado como root (a não ser que --system "
+"seja especificado)."
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+#, fuzzy
+msgid "Root privileges required."
 msgstr "Privilégios de rot são requeridos."
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr "--start não tem suporte para instâncias de sistemas."
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr "Executando em no modo system, mas --disallow-exit não foi configurado!"
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
-msgstr "Executando no modo system, mas --disallow-module-loading não foi configurado!"
+msgstr ""
+"Executando no modo system, mas --disallow-module-loading não foi configurado!"
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr "Executando no modo system, desabilitando forçadamente o modo SHM!"
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
-msgstr "Executando no modo system, desabilitando forçadamente o exit idle time!"
+msgstr ""
+"Executando no modo system, desabilitando forçadamente o exit idle time!"
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr "Falha em adquirir o stdio."
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr "O pipe falhou: %s"
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr "O fork() falhou: %s"
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr "A operação read() falhou: %s"
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr "Falha na partida do daemon."
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr "Os daemons foram iniciados com sucesso."
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Este é o PulseAudio %s"
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr "Host de compilação: %s"
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr "Compilação CFLAGS: %s"
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr "Executando no host: %s"
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr "O tamanho da página é %lu bytes"
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr "Compilado com suporte do Valgrind: sim"
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr "Compilado com suporte do Valgrind: não"
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr "Executando em modo valgrind: %s"
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr "Build otimizado: sim"
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr "Build otimizado: não"
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr "Falha em obter o ID da máquina"
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr "A ID da máquina é %s."
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr "Usando o diretório de runtime %s."
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr "Usando o diretório de estado %s."
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr "Executando em modo do sistema: %s"
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr "pa_pid_file_create() falhou."
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr "Timers de alta resolução frequinhos disponíveis! Bon appetit!"
 
-#: ../src/daemon/main.c:850
-msgid "Dude, your kernel stinks! The chef's recommendation today is Linux with high-resolution timers enabled!"
-msgstr "Cara, teu kernel fede! A recomendação do chef hoje é Linux com timers de alta resolução habilitados!"
+#: ../src/daemon/main.c:886
+msgid ""
+"Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
+"resolution timers enabled!"
+msgstr ""
+"Cara, teu kernel fede! A recomendação do chef hoje é Linux com timers de "
+"alta resolução habilitados!"
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr "pa_core_new() falhou."
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr "Falha em iniciar o daemon."
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
-msgstr "O Daemon iniciou sem qualquer módulo carregado, recusando-se a trabalhar."
+msgstr ""
+"O Daemon iniciou sem qualquer módulo carregado, recusando-se a trabalhar."
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr "O nome padrão do destino (%s) não existe no registro de nomes."
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr "A partida dos Daemon está completa."
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr "O encerramento do Daemon foi iniciado."
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr "Daemon terminado."
 
-#: ../src/daemon/cmdline.c:117
-#, c-format
+#: ../src/daemon/cmdline.c:123
+#, fuzzy, c-format
 msgid ""
 "%s [options]\n"
 "\n"
@@ -411,34 +425,48 @@ msgid ""
 "      --dump-conf                       Dump default configuration\n"
 "      --dump-modules                    Dump list of available modules\n"
 "      --dump-resample-methods           Dump available resample methods\n"
-"      --cleanup-shm                     Cleanup stale shared memory segments\n"
-"      --start                           Start the daemon if it is not running\n"
+"      --cleanup-shm                     Cleanup stale shared memory "
+"segments\n"
+"      --start                           Start the daemon if it is not "
+"running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
 "  -D, --daemonize[=BOOL]                Daemonize after startup\n"
 "      --fail[=BOOL]                     Quit when startup fails\n"
 "      --high-priority[=BOOL]            Try to set high nice level\n"
-"                                        (only available as root, when SUID or\n"
+"                                        (only available as root, when SUID "
+"or\n"
 "                                        with elevated RLIMIT_NICE)\n"
 "      --realtime[=BOOL]                 Try to enable realtime scheduling\n"
-"                                        (only available as root, when SUID or\n"
+"                                        (only available as root, when SUID "
+"or\n"
 "                                        with elevated RLIMIT_RTPRIO)\n"
-"      --disallow-module-loading[=BOOL]  Disallow module user requested module\n"
+"      --disallow-module-loading[=BOOL]  Disallow module user requested "
+"module\n"
 "                                        loading/unloading after startup\n"
 "      --disallow-exit[=BOOL]            Disallow user requested exit\n"
-"      --exit-idle-time=SECS             Terminate the daemon when idle and this\n"
+"      --exit-idle-time=SECS             Terminate the daemon when idle and "
+"this\n"
 "                                        time passed\n"
-"      --module-idle-time=SECS           Unload autoloaded modules when idle and\n"
+"      --module-idle-time=SECS           Unload autoloaded modules when idle "
+"and\n"
 "                                        this time passed\n"
-"      --scache-idle-time=SECS           Unload autoloaded samples when idle and\n"
+"      --scache-idle-time=SECS           Unload autoloaded samples when idle "
+"and\n"
 "                                        this time passed\n"
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
-"  -p, --dl-search-path=PATH             Set the search path for dynamic shared\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
+"  -p, --dl-search-path=PATH             Set the search path for dynamic "
+"shared\n"
 "                                        objects (plugins)\n"
 "      --resample-method=METHOD          Use the specified resampling method\n"
 "                                        (See --dump-resample-methods for\n"
@@ -449,10 +477,12 @@ msgid ""
 "      --disable-shm[=BOOL]              Disable shared memory support.\n"
 "\n"
 "STARTUP SCRIPT:\n"
-"  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module with\n"
+"  -L, --load=\"MODULE ARGUMENTS\"         Load the specified plugin module "
+"with\n"
 "                                        the specified argument\n"
 "  -F, --file=FILENAME                   Run the specified script\n"
-"  -C                                    Open a command line on the running TTY\n"
+"  -C                                    Open a command line on the running "
+"TTY\n"
 "                                        after startup\n"
 "\n"
 "  -n                                    Don't load default script file\n"
@@ -463,104 +493,139 @@ msgstr ""
 "  -h, --help                            Mostra esta ajuda\n"
 "      --version                        Mostra a versão\n"
 "      --dump-conf                       Descarrega a configuração padrão\n"
-"      --dump-modules                   Descarrega a lista de módulos disponíveis\n"
-"      --dump-resample-methods           Descarrega os métodos de reamostragem (resample)\n"
-"      --cleanup-shm                     Limpa os segmentos de memória compartilhados\n"
-"      --start                           Inicia o daemon se ele não estiver em execução\n"
+"      --dump-modules                   Descarrega a lista de módulos "
+"disponíveis\n"
+"      --dump-resample-methods           Descarrega os métodos de "
+"reamostragem (resample)\n"
+"      --cleanup-shm                     Limpa os segmentos de memória "
+"compartilhados\n"
+"      --start                           Inicia o daemon se ele não estiver "
+"em execução\n"
 "  -k  --kill                            Encerra um daemon em execução\n"
 "      --check                           Verifica um daemon em execução\n"
 "\n"
 "OPÇÕES:\n"
-"      --system[=BOOL]                   Executa como uma instância do sistema em escala ampla \n"
-"  -D, --daemonize[=BOOL]                Torna um daemom (daemonize) depois da partida\n"
+"      --system[=BOOL]                   Executa como uma instância do "
+"sistema em escala ampla \n"
+"  -D, --daemonize[=BOOL]                Torna um daemom (daemonize) depois "
+"da partida\n"
 "      --fail[=BOOL]                     Sai quando a partida falha\n"
 "      --high-priority[=BOOL]            Tenta definir um nível alto de nice\n"
 "                                        (disponível apenas, quando SUID ou\n"
 "                                        com RLIMIT_NICE) elevado\n"
-"      --realtime[=BOOL]                 Tenta habilidar o escalonamento em tempo real\n"
-"                                        (disponível apenas como root, quando SUID ou\n"
+"      --realtime[=BOOL]                 Tenta habilidar o escalonamento em "
+"tempo real\n"
+"                                        (disponível apenas como root, quando "
+"SUID ou\n"
 "                                        com  RLIMIT_RTPRIO) elevado\n"
-"      --disallow-module-loading[=BOOL]  Não permite carga/descarga de módulo requerido pelo usuário\n"
+"      --disallow-module-loading[=BOOL]  Não permite carga/descarga de módulo "
+"requerido pelo usuário\n"
 "                                        depois da partida\n"
-"      --disallow-exit[=BOOL]            Não permite saída requisitada pelo usuário\n"
-"      --exit-idle-time=SECS             Termina um daemon quando ocioso e este\n"
+"      --disallow-exit[=BOOL]            Não permite saída requisitada pelo "
+"usuário\n"
+"      --exit-idle-time=SECS             Termina um daemon quando ocioso e "
+"este\n"
 "                                        tempo foi decorrido\n"
-"      --module-idle-time=SECS           Descarrega os modulos autocarregáveis quando ociosos e\n"
+"      --module-idle-time=SECS           Descarrega os modulos "
+"autocarregáveis quando ociosos e\n"
 "                                        tempo foi decorrido\n"
-"      --scache-idle-time=SECS           Descarrega amostras quando ociosas e\n"
+"      --scache-idle-time=SECS           Descarrega amostras quando ociosas "
+"e\n"
 "                                        este tempo tenha passado\n"
-"      --log-level[=LEVEL]               Aumenta ou define o grau de verbosidade\n"
+"      --log-level[=LEVEL]               Aumenta ou define o grau de "
+"verbosidade\n"
 "  -v                                    Aumenta o nível de verbosidade\n"
 "      --log-target={auto,syslog,stderr} Especifica o alvo do log\n"
-"  -p, --dl-search-path=PATH             Define o caminho de busca (search paht)para objetos (plugins)\n"
+"  -p, --dl-search-path=PATH             Define o caminho de busca (search "
+"paht)para objetos (plugins)\n"
 "                                            dinamicamente commpartilhados\n"
-"      --resample-method=METHOD         Usa o método de reamostragem especificado\n"
+"      --resample-method=METHOD         Usa o método de reamostragem "
+"especificado\n"
 "                                        (Veja --dump-resample-methods para\n"
 "                                        valores possíveis)\n"
 "      --use-pid-file[=BOOL]             Cria um arquivo PID file\n"
-"      --no-cpu-limit[=BOOL]            Não instala um limitador de carga de CPU load em\n"
+"      --no-cpu-limit[=BOOL]            Não instala um limitador de carga de "
+"CPU load em\n"
 "                                        plataformas que o suportem.\n"
-"      --disable-shm[=BOOL]              Desabilita o suporte a memória compartilhada.\n"
+"      --disable-shm[=BOOL]              Desabilita o suporte a memória "
+"compartilhada.\n"
 "\n"
 "STARTUP SCRIPT:\n"
-"  -L, --load=\"MODULE ARGUMENTS\"         Carrega um plugin especificado com\n"
+"  -L, --load=\"MODULE ARGUMENTS\"         Carrega um plugin especificado "
+"com\n"
 "                                        o argumento especificado\n"
 "  -F, --file=FILENAME                  Executa o script especificado\n"
-"  -C                                    Abre uma linha de comando no TTY em execução\n"
+"  -C                                    Abre uma linha de comando no TTY em "
+"execução\n"
 "                                       depois da partida\n"
 "\n"
-"  -n                                    Não carrega o arquivo de script padrão\n"
+"  -n                                    Não carrega o arquivo de script "
+"padrão\n"
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr "--daemonize espera argumento booleano"
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr "--fail espera argumento booleano"
 
-#: ../src/daemon/cmdline.c:262
-msgid "--log-level expects log level argument (either numeric in range 0..4 or one of debug, info, notice, warn, error)."
-msgstr "--log-level espera um argumento em nível de log  (seja numérico na faixa de 0..4 seja algum entre debug, info, notice, warn, error)."
+#: ../src/daemon/cmdline.c:271
+msgid ""
+"--log-level expects log level argument (either numeric in range 0..4 or one "
+"of debug, info, notice, warn, error)."
+msgstr ""
+"--log-level espera um argumento em nível de log  (seja numérico na faixa de "
+"0..4 seja algum entre debug, info, notice, warn, error)."
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr "--high-priority espera um argumento booleano"
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr "--realtime espera um argumento booleano"
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr "--disallow-module-loading espera um argumento booleano"
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr "--disallow-exit argumento booleano"
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr "--use-pid-file espera argumento booleano"
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
 msgstr "Log target inválido: use 'syslog', 'stderr' ou 'auto'."
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:335
+#, fuzzy
+msgid "--log-time boolean argument"
+msgstr "--disallow-exit argumento booleano"
+
+#: ../src/daemon/cmdline.c:342
+#, fuzzy
+msgid "--log-meta boolean argument"
+msgstr "--disallow-exit argumento booleano"
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr "Método de reamostragem inválido '%s'."
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr "--system espera argumento booleano"
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr "--no-cpu-limit espera argumento booleano"
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr "--disable-shm espera argumento booleano"
 
@@ -604,73 +669,74 @@ msgstr "Carrega uma vez: %s\n"
 msgid "Path: %s\n"
 msgstr "Caminho: %s\n"
 
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr "[%s:%u] Alvo do log inválido '%s'."
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr "[%s:%u] Nível de log inválido '%s'."
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr "[%s:%u] Método de reamostragem inválido '%s'."
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr "[%s:%u] rlimit inválido '%s'."
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr "[%s:%u] rlimit não tem suporte nessa plataforma."
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr "[%s:%u] Formato de amostragem inválido '%s'."
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr "[%s:%u] Taxa de amostragem inválida '%s'."
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr "[%s:%u] Canais de amostragem inválidos'%s'."
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr "[%s:%u] Números de fragmentos inválidos '%s'."
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr "[%s:%u] Tamanho de fragmentos inválido '%s'."
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr "[%s:%u] Número de nice inválido'%s'."
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr "Falha em abrir o arquivo de configuração: %s"
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr "### Lido do arquivo de configuração: %s ###\n"
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+#, fuzzy
+msgid "Dropping root privileges."
 msgstr "Descartando os privilégios de root."
 
 #: ../src/daemon/caps.c:103
@@ -881,10 +947,8 @@ msgstr "Posterior Superior Esquerdo"
 msgid "Top Rear Right"
 msgstr "Posterior Superior Direito"
 
-#: ../src/pulse/channelmap.c:472
-#: ../src/pulse/sample.c:144
-#: ../src/pulse/volume.c:163
-#: ../src/pulse/volume.c:194
+#: ../src/pulse/channelmap.c:472 ../src/pulse/sample.c:144
+#: ../src/pulse/volume.c:163 ../src/pulse/volume.c:194
 msgid "(invalid)"
 msgstr "(Inválido)"
 
@@ -976,8 +1040,7 @@ msgstr "Código de erro desconhecido"
 msgid "No such extension"
 msgstr "Não existe tal extensão"
 
-#: ../src/pulse/client-conf-x11.c:55
-#: ../src/utils/pax11publish.c:100
+#: ../src/pulse/client-conf-x11.c:55 ../src/utils/pax11publish.c:100
 msgid "XOpenDisplay() failed"
 msgstr "XOpenDisplay() falhou"
 
@@ -1009,182 +1072,177 @@ msgstr "waitpid(): %s"
 msgid "Received message for unknown extension '%s'"
 msgstr "Foi recebida uma mensagem para uma extensão desconhecida '%s'"
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr "pa_stream_write() falhou: %s\n"
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr "pa_stream_peek() falhou: %s\n"
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr "Houve estouro de buffer, os dados que chegaram foram descartados\n"
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr "pa_stream_drop() falhou: %s\n"
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr "O fluxo (stream) foi criado com sucesso.\n"
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr "pa_stream_get_buffer_attr() falhou: %s\n"
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr "Metrica do buffer: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr "Métrica do buffer: maxlength=%u, fragsize=%u\n"
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr "Usando a espeficifação de amostragem '%s', mapa do canal '%s'.\n"
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr "Conectado ao dispositivo %s (%u, %ssuspended).\n"
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr "Erro de fluxo: %s\n"
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr "Dispositivo de fluxo suspenso.%s \n"
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr "Dispositivo de fluxo prosseguiu.%s \n"
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr "Extravazamento do fluxo. %s\n"
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr "O fluxo extravazou.%s \n"
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr "O fluxo iniciou: %s\n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr "O fluxo foi movido para o dispositivo %s (%u, %ssuspended).%s \n"
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr "não"
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr "Conexão estabelecida.%s \n"
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr "pa_stream_new() falhou: %s\n"
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr "pa_stream_connect_playback() falhou: %s\n"
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr "pa_stream_connect_record() falhou: %s\n"
 
-#: ../src/utils/pacat.c:307
-#: ../src/utils/pasuspender.c:159
-#: ../src/utils/pactl.c:666
-#: ../src/utils/paplay.c:183
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
+#: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr "Falha na conexão: %s\n"
 
-#: ../src/utils/pacat.c:328
-#: ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr "Falha em drenar o fluxo: %s\n"
 
-#: ../src/utils/pacat.c:333
-#: ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr "Drenado o fluxo de playback.\n"
 
-#: ../src/utils/pacat.c:343
-#: ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr "Drenando a conexão par ao servidor.\n"
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr "Atingiu EOF.\n"
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr "pa_stream_drain(): %s\n"
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr "read() falhou: %s\n"
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr "write() falhou: %s\n"
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr "Sinal recebido, saindo (exiting).\n"
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr "Falhou em obter a latência: %s\n"
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr "Tempo: %0.3f s; Latência: %0.0f us.  \r"
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr "Falha em pa_stream_update_timing_info(): %s\n"
 
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1197,27 +1255,44 @@ msgid ""
 "\n"
 "  -v, --verbose                         Enable verbose operations\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
-"  -d, --device=DEVICE                   The name of the sink/source to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
-"      --stream-name=NAME                How to call this stream on the server\n"
-"      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
-"      --rate=SAMPLERATE                 The sample rate in Hz (defaults to 44100)\n"
-"      --format=SAMPLEFORMAT             The sample type, one of s16le, s16be, u8, float32le,\n"
-"                                        float32be, ulaw, alaw, s32le, s32be (defaults to s16ne)\n"
-"      --channels=CHANNELS               The number of channels, 1 for mono, 2 for stereo\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
+"  -d, --device=DEVICE                   The name of the sink/source to "
+"connect to\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
+"      --stream-name=NAME                How to call this stream on the "
+"server\n"
+"      --volume=VOLUME                   Specify the initial (linear) volume "
+"in range 0...65536\n"
+"      --rate=SAMPLERATE                 The sample rate in Hz (defaults to "
+"44100)\n"
+"      --format=SAMPLEFORMAT             The sample type, one of s16le, "
+"s16be, u8, float32le,\n"
+"                                        float32be, ulaw, alaw, s32le, s32be "
+"(defaults to s16ne)\n"
+"      --channels=CHANNELS               The number of channels, 1 for mono, "
+"2 for stereo\n"
 "                                        (defaults to 2)\n"
-"      --channel-map=CHANNELMAP          Channel map to use instead of the default\n"
-"      --fix-format                      Take the sample format from the sink the stream is\n"
+"      --channel-map=CHANNELMAP          Channel map to use instead of the "
+"default\n"
+"      --fix-format                      Take the sample format from the sink "
+"the stream is\n"
 "                                        being connected to.\n"
-"      --fix-rate                        Take the sampling rate from the sink the stream is\n"
+"      --fix-rate                        Take the sampling rate from the sink "
+"the stream is\n"
 "                                        being connected to.\n"
-"      --fix-channels                    Take the number of channels and the channel map\n"
-"                                        from the sink the stream is being connected to.\n"
+"      --fix-channels                    Take the number of channels and the "
+"channel map\n"
+"                                        from the sink the stream is being "
+"connected to.\n"
 "      --no-remix                        Don't upmix or downmix channels.\n"
-"      --no-remap                        Map channels by index instead of name.\n"
-"      --latency=BYTES                   Request the specified latency in bytes.\n"
-"      --process-time=BYTES              Request the specified process time per request in bytes.\n"
+"      --no-remap                        Map channels by index instead of "
+"name.\n"
+"      --latency=BYTES                   Request the specified latency in "
+"bytes.\n"
+"      --process-time=BYTES              Request the specified process time "
+"per request in bytes.\n"
 msgstr ""
 "%s [opções]\n"
 "\n"
@@ -1232,25 +1307,39 @@ msgstr ""
 "  -s, --server=SERVER                   Nome do servidor a ser conectado\n"
 "  -d, --device=DEVICE                   O nome do destino/fonte a conectar\n"
 "  -n, --client-name=NAME                Como chamar o cliente no servidor\n"
-"      --stream-name=NAME               Como chamar este fluxo no servidorn      --volume=VOLUME                   Especifica a faixa (linear) inicial de volume no intervalo 0...65536\n"
-"      --rate=SAMPLERATE                 Taxa de amostragem em Hz (o padrão é 44100)\n"
-"      --format=SAMPLEFORMAT             Tipo de amostragem, um de s16le, s16be, u8, float32le,\n"
-"                                        float32be, ulaw, alaw, s32le, s32be (o padrão é s16ne)\n"
-"      --channels=CHANNELS               O número de canais, 1 para mono, 2 para estéreo\n"
+"      --stream-name=NAME               Como chamar este fluxo no "
+"servidorn      --volume=VOLUME                   Especifica a faixa (linear) "
+"inicial de volume no intervalo 0...65536\n"
+"      --rate=SAMPLERATE                 Taxa de amostragem em Hz (o padrão é "
+"44100)\n"
+"      --format=SAMPLEFORMAT             Tipo de amostragem, um de s16le, "
+"s16be, u8, float32le,\n"
+"                                        float32be, ulaw, alaw, s32le, s32be "
+"(o padrão é s16ne)\n"
+"      --channels=CHANNELS               O número de canais, 1 para mono, 2 "
+"para estéreo\n"
 "                                        (o padrão é 2)\n"
-"      --channel-map=CHANNELMAP          Mapeamento de canais a ser usando em lugar do padrão\n"
-"      --fix-format                      Obtém o formato da amostragem do destino onde o fluxo\n"
+"      --channel-map=CHANNELMAP          Mapeamento de canais a ser usando em "
+"lugar do padrão\n"
+"      --fix-format                      Obtém o formato da amostragem do "
+"destino onde o fluxo\n"
 " está sendo conectado.\n"
-"            --fix-rate                        Obtém o taxa de amostragem do destino onde o fluxo está\n"
+"            --fix-rate                        Obtém o taxa de amostragem do "
+"destino onde o fluxo está\n"
 "                                        sendo conectado.\n"
-"      --fix-channels                    Obtém o número de canais e o mapa de canais\n"
-"                                      do destino onde o fluxo está sendo conectado.\n"
+"      --fix-channels                    Obtém o número de canais e o mapa de "
+"canais\n"
+"                                      do destino onde o fluxo está sendo "
+"conectado.\n"
 "      --no-remix                        Don't upmix or downmix channels.\n"
-"      --no-remap                        Map channels by index instead of name.\n"
-"      --latency=BYTES                   Request the specified latency in bytes.\n"
-"      --process-time=BYTES              Request the specified process time per request in bytes.\n"
+"      --no-remap                        Map channels by index instead of "
+"name.\n"
+"      --latency=BYTES                   Request the specified latency in "
+"bytes.\n"
+"      --process-time=BYTES              Request the specified process time "
+"per request in bytes.\n"
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1261,94 +1350,88 @@ msgstr ""
 "Compilado com  libpulse %s\n"
 "Linkado com libpulse %s\n"
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr "Mapa de canal inválido '%s'\n"
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr "Especificação de latência inválida '%s'\n"
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr "Especificação do tempo do processo inválida '%s'\n"
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr "Especificação de amostragem inválida\n"
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr "O mapeamento do canal não casa com a especificação da amostragem\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr "Abrindo um %s fluxo com a especificação de amostragem '%s'.\n"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr "gravando"
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr "playback"
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr "open(): %s\n"
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr "dup2(): %s\n"
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr "Argumentos em excesso.\n"
 
-#: ../src/utils/pacat.c:742
-#: ../src/utils/pasuspender.c:280
-#: ../src/utils/pactl.c:909
-#: ../src/utils/paplay.c:381
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
+#: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr "pa_mainloop_new() falhou.\n"
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr "io_new() falhou.\n"
 
-#: ../src/utils/pacat.c:769
-#: ../src/utils/pasuspender.c:293
-#: ../src/utils/pactl.c:923
-#: ../src/utils/paplay.c:396
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
+#: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr "pa_context_new() falhou.\n"
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr "pa_context_new() falhou: %s"
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr "time_new() falhou.\n"
 
-#: ../src/utils/pacat.c:795
-#: ../src/utils/pasuspender.c:301
-#: ../src/utils/pactl.c:931
-#: ../src/utils/paplay.c:407
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
+#: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"
 msgstr "pa_mainloop_run() falhou.\n"
@@ -1376,10 +1459,11 @@ msgstr "Falha ao prosseguir: %s\n"
 #: ../src/utils/pasuspender.c:147
 #, c-format
 msgid "WARNING: Sound server is not local, not suspending.\n"
-msgstr "AVISO: O servidor de som não é local, Sound server is not local, não está em suspenso.\n"
+msgstr ""
+"AVISO: O servidor de som não é local, Sound server is not local, não está em "
+"suspenso.\n"
 
-#: ../src/utils/pasuspender.c:176
-#: ../src/utils/pactl.c:672
+#: ../src/utils/pasuspender.c:176 ../src/utils/pactl.c:672
 #: ../src/utils/paplay.c:191
 #, c-format
 msgid "Got SIGINT, exiting.\n"
@@ -1397,7 +1481,8 @@ msgid ""
 "\n"
 "  -h, --help                            Show this help\n"
 "      --version                         Show version\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
 "\n"
 msgstr ""
 "%s [options] ... \n"
@@ -1498,8 +1583,7 @@ msgstr ""
 "Propriedades:\n"
 "%s"
 
-#: ../src/utils/pactl.c:193
-#: ../src/utils/pactl.c:371
+#: ../src/utils/pactl.c:193 ../src/utils/pactl.c:371
 msgid "muted"
 msgstr "mudo"
 
@@ -1537,18 +1621,10 @@ msgstr ""
 "Propriedades:\n"
 "%s"
 
-#: ../src/utils/pactl.c:246
-#: ../src/utils/pactl.c:289
-#: ../src/utils/pactl.c:322
-#: ../src/utils/pactl.c:366
-#: ../src/utils/pactl.c:367
-#: ../src/utils/pactl.c:374
-#: ../src/utils/pactl.c:418
-#: ../src/utils/pactl.c:419
-#: ../src/utils/pactl.c:425
-#: ../src/utils/pactl.c:468
-#: ../src/utils/pactl.c:469
-#: ../src/utils/pactl.c:473
+#: ../src/utils/pactl.c:246 ../src/utils/pactl.c:289 ../src/utils/pactl.c:322
+#: ../src/utils/pactl.c:366 ../src/utils/pactl.c:367 ../src/utils/pactl.c:374
+#: ../src/utils/pactl.c:418 ../src/utils/pactl.c:419 ../src/utils/pactl.c:425
+#: ../src/utils/pactl.c:468 ../src/utils/pactl.c:469 ../src/utils/pactl.c:473
 msgid "n/a"
 msgstr "n/a"
 
@@ -1722,8 +1798,7 @@ msgstr "destino"
 msgid "source"
 msgstr "fonte"
 
-#: ../src/utils/pactl.c:511
-#: ../src/utils/pactl.c:521
+#: ../src/utils/pactl.c:511 ../src/utils/pactl.c:521
 #, c-format
 msgid "Failure: %s\n"
 msgstr "Falha: %s\n"
@@ -1757,8 +1832,10 @@ msgid ""
 "  -h, --help                            Show this help\n"
 "      --version                         Show version\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
 msgstr ""
 "%s [options] stat\n"
 "%s [options] list\n"
@@ -1777,7 +1854,8 @@ msgstr ""
 "      --version                        Mostra a versão\n"
 "\n"
 "  -s, --server=SERVER                   O nome do servidor a ser conectado\n"
-"  -n, --client-name=NAME                Como chamar este cliente no servidor \n"
+"  -n, --client-name=NAME                Como chamar este cliente no "
+"servidor \n"
 
 #: ../src/utils/pactl.c:729
 #, c-format
@@ -1813,7 +1891,8 @@ msgstr "Você deve especificar um nome da amostra para ser removida\n"
 #: ../src/utils/pactl.c:822
 #, c-format
 msgid "You have to specify a sink input index and a sink\n"
-msgstr "Você tem que especificar a entrada para o destino (sink) e um destino(sink)\n"
+msgstr ""
+"Você tem que especificar a entrada para o destino (sink) e um destino(sink)\n"
 
 #: ../src/utils/pactl.c:831
 #, c-format
@@ -1832,13 +1911,21 @@ msgstr "Você deve especificar um índice de um módulo\n"
 
 #: ../src/utils/pactl.c:875
 #, c-format
-msgid "You may not specify more than one sink. You have to specify at least one boolean value.\n"
-msgstr "Você não pode especificar mais de um destino. Pelo menos um valor booleano deve ser especificado.\n"
+msgid ""
+"You may not specify more than one sink. You have to specify at least one "
+"boolean value.\n"
+msgstr ""
+"Você não pode especificar mais de um destino. Pelo menos um valor booleano "
+"deve ser especificado.\n"
 
 #: ../src/utils/pactl.c:888
 #, c-format
-msgid "You may not specify more than one source. You have to specify at least one boolean value.\n"
-msgstr "Você não pode especificar mais de uma fonte. Pelo menos um valor booleano deve ser especificado.\n"
+msgid ""
+"You may not specify more than one source. You have to specify at least one "
+"boolean value.\n"
+msgstr ""
+"Você não pode especificar mais de uma fonte. Pelo menos um valor booleano "
+"deve ser especificado.\n"
 
 #: ../src/utils/pactl.c:904
 #, c-format
@@ -1852,14 +1939,17 @@ msgid ""
 "\n"
 " -d    Show current PulseAudio data attached to X11 display (default)\n"
 " -e    Export local PulseAudio data to X11 display\n"
-" -i    Import PulseAudio data from X11 display to local environment variables and cookie file.\n"
+" -i    Import PulseAudio data from X11 display to local environment "
+"variables and cookie file.\n"
 " -r    Remove PulseAudio data from X11 display\n"
 msgstr ""
 "%s [-D display] [-S server] [-O sink] [-I source] [-c file]  [-d|-e|-i|-r]\n"
 "\n"
-" -d    Mostra os dados atuais do PulseAudio associados ao display X11 (padrão)\n"
+" -d    Mostra os dados atuais do PulseAudio associados ao display X11 "
+"(padrão)\n"
 " -e    Exporta os dados locais do PulseAudio para um display X11 \n"
-" -i     Importa os dados do PulseAudio de um display X11 para as variáveis de ambiente locais e para o arquivo de cookie.\n"
+" -i     Importa os dados do PulseAudio de um display X11 para as variáveis "
+"de ambiente locais e para o arquivo de cookie.\n"
 " -r    Remove os dados do PulseAudio do display X11\n"
 
 #: ../src/utils/pax11publish.c:94
@@ -1945,14 +2035,12 @@ msgstr "Daemon não responde."
 msgid "select(): %s"
 msgstr "select(): %s"
 
-#: ../src/utils/pacmd.c:124
-#: ../src/utils/pacmd.c:140
+#: ../src/utils/pacmd.c:124 ../src/utils/pacmd.c:140
 #, c-format
 msgid "read(): %s"
 msgstr "read(): %s"
 
-#: ../src/utils/pacmd.c:153
-#: ../src/utils/pacmd.c:167
+#: ../src/utils/pacmd.c:153 ../src/utils/pacmd.c:167
 #, c-format
 msgid "write(): %s"
 msgstr "write(): %s"
@@ -1982,11 +2070,15 @@ msgid ""
 "\n"
 "  -v, --verbose                         Enable verbose operation\n"
 "\n"
-"  -s, --server=SERVER                   The name of the server to connect to\n"
+"  -s, --server=SERVER                   The name of the server to connect "
+"to\n"
 "  -d, --device=DEVICE                   The name of the sink to connect to\n"
-"  -n, --client-name=NAME                How to call this client on the server\n"
-"      --stream-name=NAME                How to call this stream on the server\n"
-"      --volume=VOLUME                   Specify the initial (linear) volume in range 0...65536\n"
+"  -n, --client-name=NAME                How to call this client on the "
+"server\n"
+"      --stream-name=NAME                How to call this stream on the "
+"server\n"
+"      --volume=VOLUME                   Specify the initial (linear) volume "
+"in range 0...65536\n"
 "      --channel-map=CHANNELMAP          Set the channel map to the use\n"
 msgstr ""
 "%s [options] [FILE]\n"
@@ -1998,9 +2090,11 @@ msgstr ""
 "\n"
 "  -s, --server=SERVER                   O nome do servidor a ser conectado\n"
 "  -d, --device=DEVICE                   O nome do destino a ser conectado\n"
-"  -n, --client-name=NAME                Como chamar este cliente no servidor\n"
+"  -n, --client-name=NAME                Como chamar este cliente no "
+"servidor\n"
 "      --stream-name=NAME                Como chamar este fluxo no servidor\n"
-"      --volume=VOLUME                   Especifica o volume inicial (linear) no intervalo 0...65536\n"
+"      --volume=VOLUME                   Especifica o volume inicial (linear) "
+"no intervalo 0...65536\n"
 "      --channel-map=CHANNELMAP          Define o mapa do canal para uso\n"
 
 #: ../src/utils/paplay.c:255
@@ -2034,11 +2128,26 @@ msgstr "O mapa dos canais não coincide com o arquivo.\n"
 msgid "Using sample spec '%s'\n"
 msgstr "Usando a especificação da amostragem '%s'\n"
 
-#: ../src/pulsecore/lock-autospawn.c:126
-#: ../src/pulsecore/lock-autospawn.c:207
+#: ../src/pulsecore/lock-autospawn.c:126 ../src/pulsecore/lock-autospawn.c:207
 msgid "Cannot access autospawn lock."
 msgstr "Não foi possível acessar a trava de autogeração."
 
+#~ msgid ""
+#~ "' and PolicyKit refuse to grant us priviliges. Dropping SUID again.\n"
+#~ "For enabling real-time scheduling please acquire the appropriate "
+#~ "PolicyKit priviliges, or become a member of '"
+#~ msgstr ""
+#~ "' e o PolicyKit recusa-nos a garantia de privilégios. Retirando o SUID "
+#~ "outra vez.\n"
+#~ " Para habilitar o escalonamento em tempo real, por favo, adquira os "
+#~ "privilégios adequados pelo PolicyKit, ou torne-se membro do'"
+
+#~ msgid ""
+#~ "', or increase the RLIMIT_NICE/RLIMIT_RTPRIO resource limits for this "
+#~ "user."
+#~ msgstr ""
+#~ "', ou eleve o RLIMIT_NICE/RLIMIT_RTPRIO dos limites do recurso para este "
+#~ "usuário."
+
 #~ msgid "socketpair(): %s"
 #~ msgstr "socketpair(): %s"
-
diff --git a/po/sv.po b/po/sv.po
index 772e155..ecab9bc 100644
--- a/po/sv.po
+++ b/po/sv.po
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: pulseaudio\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-10-07 21:03+0200\n"
+"POT-Creation-Date: 2009-01-08 19:36+0100\n"
 "PO-Revision-Date: 2008-09-05 18:24+0100\n"
 "Last-Translator: Daniel Nylander <po at danielnylander.se>\n"
 "Language-Team: Swedish <tp-sv at listor.tp-sv.se>\n"
@@ -15,12 +15,17 @@ msgstr ""
 "Content-Type: text/plain; charset=utf-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: ../src/daemon/ltdl-bind-now.c:177 ../src/daemon/ltdl-bind-now.c:197
-msgid "Failed to add bind-now-loader."
+#: ../src/daemon/ltdl-bind-now.c:124
+msgid "Failed to find original lt_dlopen loader."
 msgstr ""
 
-#: ../src/daemon/ltdl-bind-now.c:184
-msgid "Failed to find original dlopen loader."
+#: ../src/daemon/ltdl-bind-now.c:129
+#, fuzzy
+msgid "Failed to allocate new dl loader."
+msgstr "Misslyckades med att öppna ljudfil.\n"
+
+#: ../src/daemon/ltdl-bind-now.c:142
+msgid "Failed to add bind-now-loader."
 msgstr ""
 
 #: ../src/daemon/polkit.c:55
@@ -148,77 +153,77 @@ msgstr "setrlimit(%s, (%u, %u)) misslyckades: %s"
 msgid "Failed to parse command line."
 msgstr ""
 
-#: ../src/daemon/main.c:441
+#: ../src/daemon/main.c:447
 #, c-format
 msgid "We're in the group '%s', allowing high-priority scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:448
+#: ../src/daemon/main.c:454
 #, c-format
 msgid "We're in the group '%s', allowing real-time scheduling."
 msgstr ""
 
-#: ../src/daemon/main.c:456
+#: ../src/daemon/main.c:462
 msgid "PolicyKit grants us acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:459
+#: ../src/daemon/main.c:465
 msgid "PolicyKit refuses acquire-high-priority privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:464
+#: ../src/daemon/main.c:470
 msgid "PolicyKit grants us acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:467
+#: ../src/daemon/main.c:473
 msgid "PolicyKit refuses acquire-real-time privilege."
 msgstr ""
 
-#: ../src/daemon/main.c:479
+#: ../src/daemon/main.c:502
 msgid ""
-"Called SUID root and real-time/high-priority scheduling was requested in the "
-"configuration. However, we lack the necessary priviliges:\n"
+"Called SUID root and real-time and/or high-priority scheduling was requested "
+"in the configuration. However, we lack the necessary privileges:\n"
 "We are not in group '"
 msgstr ""
 
-#: ../src/daemon/main.c:497
+#: ../src/daemon/main.c:526
 msgid ""
 "High-priority scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:522
+#: ../src/daemon/main.c:555
 msgid "Successfully increased RLIMIT_RTPRIO"
 msgstr ""
 
-#: ../src/daemon/main.c:525
+#: ../src/daemon/main.c:558
 #, c-format
 msgid "RLIMIT_RTPRIO failed: %s"
 msgstr "RLIMIT_RTPRIO misslyckades: %s"
 
-#: ../src/daemon/main.c:532
+#: ../src/daemon/main.c:565
 msgid "Giving up CAP_NICE"
 msgstr ""
 
-#: ../src/daemon/main.c:539
+#: ../src/daemon/main.c:572
 msgid ""
 "Real-time scheduling enabled in configuration but not allowed by policy."
 msgstr ""
 
-#: ../src/daemon/main.c:597
+#: ../src/daemon/main.c:633
 msgid "Daemon not running"
 msgstr ""
 
-#: ../src/daemon/main.c:599
+#: ../src/daemon/main.c:635
 #, c-format
 msgid "Daemon running as PID %u"
 msgstr ""
 
-#: ../src/daemon/main.c:609
+#: ../src/daemon/main.c:645
 #, c-format
 msgid "Failed to kill daemon: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:627
+#: ../src/daemon/main.c:663
 msgid ""
 "This program is not intended to be run as root (unless --system is "
 "specified)."
@@ -226,171 +231,172 @@ msgstr ""
 "Detta program är inte tänkt att köras som root (såvida inte --system har "
 "angivits)."
 
-#: ../src/daemon/main.c:629
-msgid "Root priviliges required."
+#: ../src/daemon/main.c:665
+#, fuzzy
+msgid "Root privileges required."
 msgstr "Root-behörighet krävs."
 
-#: ../src/daemon/main.c:634
+#: ../src/daemon/main.c:670
 msgid "--start not supported for system instances."
 msgstr "--start stöds inte för systeminstanser."
 
-#: ../src/daemon/main.c:639
+#: ../src/daemon/main.c:675
 msgid "Running in system mode, but --disallow-exit not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:642
+#: ../src/daemon/main.c:678
 msgid "Running in system mode, but --disallow-module-loading not set!"
 msgstr ""
 
-#: ../src/daemon/main.c:645
+#: ../src/daemon/main.c:681
 msgid "Running in system mode, forcibly disabling SHM mode!"
 msgstr ""
 
-#: ../src/daemon/main.c:650
+#: ../src/daemon/main.c:686
 msgid "Running in system mode, forcibly disabling exit idle time!"
 msgstr ""
 
-#: ../src/daemon/main.c:677
+#: ../src/daemon/main.c:713
 msgid "Failed to acquire stdio."
 msgstr ""
 
-#: ../src/daemon/main.c:683
+#: ../src/daemon/main.c:719
 #, c-format
 msgid "pipe failed: %s"
 msgstr "pipe misslyckades: %s"
 
-#: ../src/daemon/main.c:688
+#: ../src/daemon/main.c:724
 #, c-format
 msgid "fork() failed: %s"
 msgstr "fork() misslyckades: %s"
 
-#: ../src/daemon/main.c:702
+#: ../src/daemon/main.c:738
 #, c-format
 msgid "read() failed: %s"
 msgstr "read() misslyckades: %s"
 
-#: ../src/daemon/main.c:708
+#: ../src/daemon/main.c:744
 msgid "Daemon startup failed."
 msgstr ""
 
-#: ../src/daemon/main.c:710
+#: ../src/daemon/main.c:746
 msgid "Daemon startup successful."
 msgstr ""
 
-#: ../src/daemon/main.c:780
+#: ../src/daemon/main.c:816
 #, c-format
 msgid "This is PulseAudio %s"
 msgstr "Detta är PulseAudio %s"
 
-#: ../src/daemon/main.c:781
+#: ../src/daemon/main.c:817
 #, c-format
 msgid "Compilation host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:782
+#: ../src/daemon/main.c:818
 #, c-format
 msgid "Compilation CFLAGS: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:785
+#: ../src/daemon/main.c:821
 #, c-format
 msgid "Running on host: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:788
+#: ../src/daemon/main.c:824
 #, c-format
 msgid "Page size is %lu bytes"
 msgstr ""
 
-#: ../src/daemon/main.c:791
+#: ../src/daemon/main.c:827
 msgid "Compiled with Valgrind support: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:793
+#: ../src/daemon/main.c:829
 msgid "Compiled with Valgrind support: no"
 msgstr ""
 
-#: ../src/daemon/main.c:796
+#: ../src/daemon/main.c:832
 #, c-format
 msgid "Running in valgrind mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:799
+#: ../src/daemon/main.c:835
 msgid "Optimized build: yes"
 msgstr ""
 
-#: ../src/daemon/main.c:801
+#: ../src/daemon/main.c:837
 msgid "Optimized build: no"
 msgstr ""
 
-#: ../src/daemon/main.c:805
+#: ../src/daemon/main.c:841
 msgid "Failed to get machine ID"
 msgstr ""
 
-#: ../src/daemon/main.c:808
+#: ../src/daemon/main.c:844
 #, c-format
 msgid "Machine ID is %s."
 msgstr ""
 
-#: ../src/daemon/main.c:813
+#: ../src/daemon/main.c:849
 #, c-format
 msgid "Using runtime directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:818
+#: ../src/daemon/main.c:854
 #, c-format
 msgid "Using state directory %s."
 msgstr ""
 
-#: ../src/daemon/main.c:821
+#: ../src/daemon/main.c:857
 #, c-format
 msgid "Running in system mode: %s"
 msgstr ""
 
-#: ../src/daemon/main.c:836
+#: ../src/daemon/main.c:872
 msgid "pa_pid_file_create() failed."
 msgstr "pa_pid_file_create() misslyckades."
 
-#: ../src/daemon/main.c:848
+#: ../src/daemon/main.c:884
 msgid "Fresh high-resolution timers available! Bon appetit!"
 msgstr ""
 
-#: ../src/daemon/main.c:850
+#: ../src/daemon/main.c:886
 msgid ""
 "Dude, your kernel stinks! The chef's recommendation today is Linux with high-"
 "resolution timers enabled!"
 msgstr ""
 
-#: ../src/daemon/main.c:860
+#: ../src/daemon/main.c:896
 msgid "pa_core_new() failed."
 msgstr "pa_core_new() misslyckades."
 
-#: ../src/daemon/main.c:921
+#: ../src/daemon/main.c:957
 msgid "Failed to initialize daemon."
 msgstr ""
 
-#: ../src/daemon/main.c:926
+#: ../src/daemon/main.c:962
 msgid "Daemon startup without any loaded modules, refusing to work."
 msgstr ""
 
-#: ../src/daemon/main.c:931
+#: ../src/daemon/main.c:967
 #, c-format
 msgid "Default sink name (%s) does not exist in name register."
 msgstr ""
 
-#: ../src/daemon/main.c:944
+#: ../src/daemon/main.c:980
 msgid "Daemon startup complete."
 msgstr ""
 
-#: ../src/daemon/main.c:950
+#: ../src/daemon/main.c:986
 msgid "Daemon shutdown initiated."
 msgstr ""
 
-#: ../src/daemon/main.c:971
+#: ../src/daemon/main.c:1007
 msgid "Daemon terminated."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:117
+#: ../src/daemon/cmdline.c:123
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -406,7 +412,8 @@ msgid ""
 "      --start                           Start the daemon if it is not "
 "running\n"
 "  -k  --kill                            Kill a running daemon\n"
-"      --check                           Check for a running daemon\n"
+"      --check                           Check for a running daemon (only "
+"returns exit code)\n"
 "\n"
 "OPTIONS:\n"
 "      --system[=BOOL]                   Run as system-wide instance\n"
@@ -436,6 +443,10 @@ msgid ""
 "      --log-level[=LEVEL]               Increase or set verbosity level\n"
 "  -v                                    Increase the verbosity level\n"
 "      --log-target={auto,syslog,stderr} Specify the log target\n"
+"      --log-meta[=BOOL]                 Include code location in log "
+"messages\n"
+"      --log-time[=BOOL]                 Include timestamps in log messages\n"
+"      --log-backtrace=FRAMES            Include a backtrace in log messages\n"
 "  -p, --dl-search-path=PATH             Set the search path for dynamic "
 "shared\n"
 "                                        objects (plugins)\n"
@@ -459,58 +470,68 @@ msgid ""
 "  -n                                    Don't load default script file\n"
 msgstr ""
 
-#: ../src/daemon/cmdline.c:245
+#: ../src/daemon/cmdline.c:254
 msgid "--daemonize expects boolean argument"
 msgstr "--daemonize förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:252
+#: ../src/daemon/cmdline.c:261
 msgid "--fail expects boolean argument"
 msgstr "--fail förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:262
+#: ../src/daemon/cmdline.c:271
 msgid ""
 "--log-level expects log level argument (either numeric in range 0..4 or one "
 "of debug, info, notice, warn, error)."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:274
+#: ../src/daemon/cmdline.c:283
 msgid "--high-priority expects boolean argument"
 msgstr "--high-priority förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:281
+#: ../src/daemon/cmdline.c:290
 msgid "--realtime expects boolean argument"
 msgstr "--realtime förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:288
+#: ../src/daemon/cmdline.c:297
 msgid "--disallow-module-loading expects boolean argument"
 msgstr "--disallow-module-loading förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:295
+#: ../src/daemon/cmdline.c:304
 msgid "--disallow-exit boolean argument"
 msgstr "--disallow-exit booleskt argument"
 
-#: ../src/daemon/cmdline.c:302
+#: ../src/daemon/cmdline.c:311
 msgid "--use-pid-file expects boolean argument"
 msgstr "--use-pid-file förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:319
+#: ../src/daemon/cmdline.c:328
 msgid "Invalid log target: use either 'syslog', 'stderr' or 'auto'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:338
+#: ../src/daemon/cmdline.c:335
+#, fuzzy
+msgid "--log-time boolean argument"
+msgstr "--disallow-exit booleskt argument"
+
+#: ../src/daemon/cmdline.c:342
+#, fuzzy
+msgid "--log-meta boolean argument"
+msgstr "--disallow-exit booleskt argument"
+
+#: ../src/daemon/cmdline.c:365
 #, c-format
 msgid "Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/cmdline.c:345
+#: ../src/daemon/cmdline.c:372
 msgid "--system expects boolean argument"
 msgstr "--system förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:352
+#: ../src/daemon/cmdline.c:379
 msgid "--no-cpu-limit expects boolean argument"
 msgstr "--no-cpu-limit förväntar sig ett booleskt argument"
 
-#: ../src/daemon/cmdline.c:359
+#: ../src/daemon/cmdline.c:386
 msgid "--disable-shm expects boolean argument"
 msgstr "--disable-shm förväntar sig ett booleskt argument"
 
@@ -554,73 +575,74 @@ msgstr ""
 msgid "Path: %s\n"
 msgstr "Sökväg: %s\n"
 
-#: ../src/daemon/daemon-conf.c:205
+#: ../src/daemon/daemon-conf.c:208
 #, c-format
 msgid "[%s:%u] Invalid log target '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:221
+#: ../src/daemon/daemon-conf.c:224
 #, c-format
 msgid "[%s:%u] Invalid log level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:237
+#: ../src/daemon/daemon-conf.c:240
 #, c-format
 msgid "[%s:%u] Invalid resample method '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:260
+#: ../src/daemon/daemon-conf.c:263
 #, c-format
 msgid "[%s:%u] Invalid rlimit '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:267
+#: ../src/daemon/daemon-conf.c:270
 #, c-format
 msgid "[%s:%u] rlimit not supported on this platform."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:283
+#: ../src/daemon/daemon-conf.c:286
 #, c-format
 msgid "[%s:%u] Invalid sample format '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:301
+#: ../src/daemon/daemon-conf.c:304
 #, c-format
 msgid "[%s:%u] Invalid sample rate '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:319
+#: ../src/daemon/daemon-conf.c:322
 #, c-format
 msgid "[%s:%u] Invalid sample channels '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:337
+#: ../src/daemon/daemon-conf.c:340
 #, c-format
 msgid "[%s:%u] Invalid number of fragments '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:355
+#: ../src/daemon/daemon-conf.c:358
 #, c-format
 msgid "[%s:%u] Invalid fragment size '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:373
+#: ../src/daemon/daemon-conf.c:376
 #, c-format
 msgid "[%s:%u] Invalid nice level '%s'."
 msgstr ""
 
-#: ../src/daemon/daemon-conf.c:570
+#: ../src/daemon/daemon-conf.c:554
 #, c-format
 msgid "Failed to open configuration file: %s"
 msgstr "Misslyckades med att öppna konfigurationsfil: %s"
 
-#: ../src/daemon/daemon-conf.c:644
+#: ../src/daemon/daemon-conf.c:628
 #, c-format
 msgid "### Read from configuration file: %s ###\n"
 msgstr ""
 
 #: ../src/daemon/caps.c:63
-msgid "Dropping root priviliges."
+#, fuzzy
+msgid "Dropping root privileges."
 msgstr "Släpper root-behörighet."
 
 #: ../src/daemon/caps.c:103
@@ -957,177 +979,177 @@ msgstr "waitpid(): %s"
 msgid "Received message for unknown extension '%s'"
 msgstr ""
 
-#: ../src/utils/pacat.c:93
+#: ../src/utils/pacat.c:94
 #, c-format
 msgid "pa_stream_write() failed: %s\n"
 msgstr "pa_stream_write() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:132
+#: ../src/utils/pacat.c:133
 #, c-format
 msgid "pa_stream_peek() failed: %s\n"
 msgstr "pa_stream_peek() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:141
+#: ../src/utils/pacat.c:142
 #, c-format
 msgid "Buffer overrun, dropping incoming data\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:143
+#: ../src/utils/pacat.c:144
 #, c-format
 msgid "pa_stream_drop() failed: %s\n"
 msgstr "pa_stream_drop() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:169
+#: ../src/utils/pacat.c:170
 #, c-format
 msgid "Stream successfully created.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:172
+#: ../src/utils/pacat.c:173
 #, c-format
 msgid "pa_stream_get_buffer_attr() failed: %s\n"
 msgstr "pa_stream_get_buffer_attr() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:176
+#: ../src/utils/pacat.c:177
 #, c-format
 msgid "Buffer metrics: maxlength=%u, tlength=%u, prebuf=%u, minreq=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:179
+#: ../src/utils/pacat.c:180
 #, c-format
 msgid "Buffer metrics: maxlength=%u, fragsize=%u\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:183
+#: ../src/utils/pacat.c:184
 #, c-format
 msgid "Using sample spec '%s', channel map '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:187
+#: ../src/utils/pacat.c:188
 #, c-format
 msgid "Connected to device %s (%u, %ssuspended).\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:197
+#: ../src/utils/pacat.c:198
 #, c-format
 msgid "Stream error: %s\n"
 msgstr "Strömfel: %s\n"
 
-#: ../src/utils/pacat.c:207
+#: ../src/utils/pacat.c:208
 #, c-format
 msgid "Stream device suspended.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:209
+#: ../src/utils/pacat.c:210
 #, c-format
 msgid "Stream device resumed.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:217
+#: ../src/utils/pacat.c:218
 #, c-format
 msgid "Stream underrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:224
+#: ../src/utils/pacat.c:225
 #, c-format
 msgid "Stream overrun.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:231
+#: ../src/utils/pacat.c:232
 #, c-format
 msgid "Stream started.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 #, c-format
 msgid "Stream moved to device %s (%u, %ssuspended).%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:238
+#: ../src/utils/pacat.c:239
 msgid "not "
 msgstr "inte "
 
-#: ../src/utils/pacat.c:259
+#: ../src/utils/pacat.c:260
 #, c-format
 msgid "Connection established.%s \n"
 msgstr ""
 
-#: ../src/utils/pacat.c:262
+#: ../src/utils/pacat.c:263
 #, c-format
 msgid "pa_stream_new() failed: %s\n"
 msgstr "pa_stream_new() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:287
+#: ../src/utils/pacat.c:288
 #, c-format
 msgid "pa_stream_connect_playback() failed: %s\n"
 msgstr "pa_stream_connect_playback() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:293
+#: ../src/utils/pacat.c:294
 #, c-format
 msgid "pa_stream_connect_record() failed: %s\n"
 msgstr "pa_stream_connect_record() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:307 ../src/utils/pasuspender.c:159
+#: ../src/utils/pacat.c:308 ../src/utils/pasuspender.c:159
 #: ../src/utils/pactl.c:666 ../src/utils/paplay.c:183
 #, c-format
 msgid "Connection failure: %s\n"
 msgstr "Anslutningsfel: %s\n"
 
-#: ../src/utils/pacat.c:328 ../src/utils/paplay.c:75
+#: ../src/utils/pacat.c:329 ../src/utils/paplay.c:75
 #, c-format
 msgid "Failed to drain stream: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:333 ../src/utils/paplay.c:80
+#: ../src/utils/pacat.c:334 ../src/utils/paplay.c:80
 #, c-format
 msgid "Playback stream drained.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:343 ../src/utils/paplay.c:92
+#: ../src/utils/pacat.c:344 ../src/utils/paplay.c:92
 #, c-format
 msgid "Draining connection to server.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:369
+#: ../src/utils/pacat.c:370
 #, c-format
 msgid "Got EOF.\n"
 msgstr "Fick filslut.\n"
 
-#: ../src/utils/pacat.c:375
+#: ../src/utils/pacat.c:376
 #, c-format
 msgid "pa_stream_drain(): %s\n"
 msgstr "pa_stream_drain(): %s\n"
 
-#: ../src/utils/pacat.c:385
+#: ../src/utils/pacat.c:386
 #, c-format
 msgid "read() failed: %s\n"
 msgstr "read() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:417
+#: ../src/utils/pacat.c:418
 #, c-format
 msgid "write() failed: %s\n"
 msgstr "write() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:438
+#: ../src/utils/pacat.c:439
 #, c-format
 msgid "Got signal, exiting.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:452
+#: ../src/utils/pacat.c:453
 #, c-format
 msgid "Failed to get latency: %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:457
+#: ../src/utils/pacat.c:458
 #, c-format
 msgid "Time: %0.3f sec; Latency: %0.0f usec.  \r"
 msgstr "Tid: %0.3f sec; Latens: %0.0f ms  \r"
 
-#: ../src/utils/pacat.c:477
+#: ../src/utils/pacat.c:478
 #, c-format
 msgid "pa_stream_update_timing_info() failed: %s\n"
 msgstr "pa_stream_update_timing_info() misslyckades: %s\n"
 
-#: ../src/utils/pacat.c:490
+#: ../src/utils/pacat.c:491
 #, c-format
 msgid ""
 "%s [options]\n"
@@ -1180,7 +1202,7 @@ msgid ""
 "per request in bytes.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:591
+#: ../src/utils/pacat.c:592
 #, c-format
 msgid ""
 "pacat %s\n"
@@ -1188,87 +1210,87 @@ msgid ""
 "Linked with libpulse %s\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:647
+#: ../src/utils/pacat.c:649
 #, c-format
 msgid "Invalid channel map '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:676
+#: ../src/utils/pacat.c:678
 #, c-format
 msgid "Invalid latency specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:683
+#: ../src/utils/pacat.c:685
 #, c-format
 msgid "Invalid process time specification '%s'\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:694
+#: ../src/utils/pacat.c:696
 #, c-format
 msgid "Invalid sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:699
+#: ../src/utils/pacat.c:701
 #, c-format
 msgid "Channel map doesn't match sample specification\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 #, c-format
 msgid "Opening a %s stream with sample specification '%s'.\n"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "recording"
 msgstr ""
 
-#: ../src/utils/pacat.c:706
+#: ../src/utils/pacat.c:708
 msgid "playback"
 msgstr ""
 
-#: ../src/utils/pacat.c:714
+#: ../src/utils/pacat.c:716
 #, c-format
 msgid "open(): %s\n"
 msgstr "open(): %s\n"
 
-#: ../src/utils/pacat.c:719
+#: ../src/utils/pacat.c:721
 #, c-format
 msgid "dup2(): %s\n"
 msgstr "dup2(): %s\n"
 
-#: ../src/utils/pacat.c:729
+#: ../src/utils/pacat.c:731
 #, c-format
 msgid "Too many arguments.\n"
 msgstr "För många argument.\n"
 
-#: ../src/utils/pacat.c:742 ../src/utils/pasuspender.c:280
+#: ../src/utils/pacat.c:744 ../src/utils/pasuspender.c:280
 #: ../src/utils/pactl.c:909 ../src/utils/paplay.c:381
 #, c-format
 msgid "pa_mainloop_new() failed.\n"
 msgstr "pa_mainloop_new() misslyckades.\n"
 
-#: ../src/utils/pacat.c:763
+#: ../src/utils/pacat.c:765
 #, c-format
 msgid "io_new() failed.\n"
 msgstr "io_new() misslyckades.\n"
 
-#: ../src/utils/pacat.c:769 ../src/utils/pasuspender.c:293
+#: ../src/utils/pacat.c:771 ../src/utils/pasuspender.c:293
 #: ../src/utils/pactl.c:923 ../src/utils/paplay.c:396
 #, c-format
 msgid "pa_context_new() failed.\n"
 msgstr "pa_context_new() misslyckades.\n"
 
-#: ../src/utils/pacat.c:777
+#: ../src/utils/pacat.c:779
 #, fuzzy, c-format
 msgid "pa_context_connect() failed: %s"
 msgstr "pa_context_new() misslyckades.\n"
 
-#: ../src/utils/pacat.c:788
+#: ../src/utils/pacat.c:790
 #, c-format
 msgid "time_new() failed.\n"
 msgstr "time_new() misslyckades.\n"
 
-#: ../src/utils/pacat.c:795 ../src/utils/pasuspender.c:301
+#: ../src/utils/pacat.c:797 ../src/utils/pasuspender.c:301
 #: ../src/utils/pactl.c:931 ../src/utils/paplay.c:407
 #, c-format
 msgid "pa_mainloop_run() failed.\n"

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list