[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.11-189-gbf403fe

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Sep 3 10:52:01 PDT 2008


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

The master branch has been updated
      from  82ea8dde8abc51165a781c69bc3b38034d62d969 (commit)

- Log -----------------------------------------------------------------
bf403fe... introduce macros for all flags so that clients can check for them with #ifdef
cbd8e60... use PA_STREAM_EARLY_REQUESTS for OSS streams
79009d2... command_get_info() segv in some conditions
c402de7... reindent comments a bit
40b66a0... Implement "early requests" mode.
99d5ec6... Rework pa_machine_id() a bit
5f93113... fix misuse of return value
2c2b271... use gcc malloc attribute macros for internal functions, too
5467cc3... drop -Winline from build cflags
4348faf... don't include leagacy definition PA_STREAM_NOT_MONOTONOUS in docs
f6e187f... prefix  internally used inline function with _
70b820d... add gcc malloc related function attributes where appropriate
e015879... add malloc related gcc attribute macros
-----------------------------------------------------------------------

Summary of changes:
 PROTOCOL                        |   13 +-
 configure.ac                    |    2 +-
 src/pulse/channelmap.h          |   29 +-
 src/pulse/def.h                 |  765 ++++++++++++++++++++++-----------------
 src/pulse/gccmacro.h            |   20 +
 src/pulse/introspect.h          |    2 +-
 src/pulse/proplist.h            |   16 +-
 src/pulse/sample.h              |   67 +++-
 src/pulse/stream.c              |   18 +-
 src/pulse/xmalloc.c             |    2 +-
 src/pulse/xmalloc.h             |   32 +-
 src/pulsecore/core-util.c       |   37 ++-
 src/pulsecore/protocol-native.c |  174 +++++++--
 src/tests/parec-simple.c        |    6 +-
 src/utils/padsp.c               |    2 +-
 15 files changed, 745 insertions(+), 440 deletions(-)

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

commit e015879bb86662703850b7bcd13b46649f1628b8
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 1 19:13:37 2008 +0200

    add malloc related gcc attribute macros

diff --git a/src/pulse/gccmacro.h b/src/pulse/gccmacro.h
index e406203..0533b10 100644
--- a/src/pulse/gccmacro.h
+++ b/src/pulse/gccmacro.h
@@ -93,4 +93,24 @@
 #endif
 #endif
 
+#ifndef PA_GCC_ALLOC_SIZE
+#if defined(__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
+#define PA_GCC_ALLOC_SIZE(x) __attribute__ ((__alloc_size__(x)))
+#define PA_GCC_ALLOC_SIZE2(x,y) __attribute__ ((__alloc_size__(x,y)))
+#else
+/** Macro for usage of GCC's alloc_size attribute */
+#define PA_GCC_ALLOC_SIZE(x)
+#define PA_GCC_ALLOC_SIZE2(x,y)
+#endif
+#endif
+
+#ifndef PA_GCC_MALLOC
+#ifdef __GNUCC__
+#define PA_GCC_MALLOC __attribute__ ((malloc))
+#else
+/** Macro for usage of GCC's malloc attribute */
+#define PA_GCC_MALLOC
+#endif
+#endif
+
 #endif

commit 70b820d875480dcd5ba4fb7faf74dbdbec775fe1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 1 19:15:07 2008 +0200

    add gcc malloc related function attributes where appropriate

diff --git a/src/pulse/xmalloc.h b/src/pulse/xmalloc.h
index c453138..b963ba6 100644
--- a/src/pulse/xmalloc.h
+++ b/src/pulse/xmalloc.h
@@ -26,7 +26,9 @@
 #include <stdlib.h>
 #include <limits.h>
 #include <assert.h>
+
 #include <pulse/cdecl.h>
+#include <pulse/gccmacro.h>
 
 /** \file
  * Memory allocation functions.
@@ -35,25 +37,25 @@
 PA_C_DECL_BEGIN
 
 /** Allocate the specified number of bytes, just like malloc() does. However, in case of OOM, terminate */
-void* pa_xmalloc(size_t l);
+void* pa_xmalloc(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1);
 
 /** Same as pa_xmalloc(), but initialize allocated memory to 0 */
-void *pa_xmalloc0(size_t l);
+void *pa_xmalloc0(size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(1);
 
 /**  The combination of pa_xmalloc() and realloc() */
-void *pa_xrealloc(void *ptr, size_t size);
+void *pa_xrealloc(void *ptr, size_t size) PA_GCC_ALLOC_SIZE(2);
 
 /** Free allocated memory */
 void pa_xfree(void *p);
 
 /** Duplicate the specified string, allocating memory with pa_xmalloc() */
-char *pa_xstrdup(const char *s);
+char *pa_xstrdup(const char *s) PA_GCC_MALLOC;
 
 /** Duplicate the specified string, but truncate after l characters */
-char *pa_xstrndup(const char *s, size_t l);
+char *pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC;
 
 /** Duplicate the specified memory block */
-void* pa_xmemdup(const void *p, size_t l);
+void* pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2);
 
 /** Internal helper for pa_xnew() */
 static inline void* pa_xnew_internal(unsigned n, size_t k) {

commit f6e187f0a5299ea95a2b39c181eb27fb7bd80a7b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 1 19:16:12 2008 +0200

    prefix  internally used inline function with _

diff --git a/src/pulse/xmalloc.h b/src/pulse/xmalloc.h
index b963ba6..7a408d3 100644
--- a/src/pulse/xmalloc.h
+++ b/src/pulse/xmalloc.h
@@ -58,31 +58,31 @@ char *pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC;
 void* pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2);
 
 /** Internal helper for pa_xnew() */
-static inline void* pa_xnew_internal(unsigned n, size_t k) {
+static inline void* _pa_xnew_internal(unsigned n, size_t k) {
     assert(n < INT_MAX/k);
     return pa_xmalloc(n*k);
 }
 
 /** Allocate n new structures of the specified type. */
-#define pa_xnew(type, n) ((type*) pa_xnew_internal((n), sizeof(type)))
+#define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type)))
 
 /** Internal helper for pa_xnew0() */
-static inline void* pa_xnew0_internal(unsigned n, size_t k) {
+static inline void* _pa_xnew0_internal(unsigned n, size_t k) {
     assert(n < INT_MAX/k);
     return pa_xmalloc0(n*k);
 }
 
 /** Same as pa_xnew() but set the memory to zero */
-#define pa_xnew0(type, n) ((type*) pa_xnew0_internal((n), sizeof(type)))
+#define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type)))
 
 /** Internal helper for pa_xnew0() */
-static inline void* pa_xnewdup_internal(const void *p, unsigned n, size_t k) {
+static inline void* _pa_xnewdup_internal(const void *p, unsigned n, size_t k) {
     assert(n < INT_MAX/k);
     return pa_xmemdup(p, n*k);
 }
 
 /** Same as pa_xnew() but set the memory to zero */
-#define pa_xnewdup(type, p, n) ((type*) pa_xnewdup_internal((p), (n), sizeof(type)))
+#define pa_xnewdup(type, p, n) ((type*) _pa_xnewdup_internal((p), (n), sizeof(type)))
 
 PA_C_DECL_END
 

commit 4348fafcc87dbdca859037f45e19d0bbfcb62a03
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 1 19:17:14 2008 +0200

    don't include leagacy definition PA_STREAM_NOT_MONOTONOUS in docs

diff --git a/src/pulse/def.h b/src/pulse/def.h
index aa07d1c..53bea3b 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -240,10 +240,13 @@ typedef enum pa_stream_flags {
                                       * accordingly. See pa_buffer_attr \since 0.9.11 */
 } pa_stream_flags_t;
 
+/** \cond fulldocs */
 
 /** English is an evil language */
 #define PA_STREAM_NOT_MONOTONOUS PA_STREAM_NOT_MONOTONIC
 
+/** \endcond */
+
 /** Playback and record buffer metrics */
 typedef struct pa_buffer_attr {
     uint32_t maxlength;      /**< Maximum length of the

commit 5467cc390d303028dc448a2f16df9d99b29f61a1
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 1 21:42:27 2008 +0200

    drop -Winline from build cflags

diff --git a/configure.ac b/configure.ac
index c35eca0..4a560b1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -99,7 +99,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 -Winline -Wno-unused-parameter -ffast-math"
+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"
 
 for flag in $DESIRED_FLAGS ; do
   CC_CHECK_CFLAGS([$flag], [CFLAGS="$CFLAGS $flag"])

commit 2c2b2717eb0e8d1831b498043e6995b477747e89
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Sep 1 21:44:00 2008 +0200

    use gcc malloc attribute macros for internal functions, too

diff --git a/src/pulse/xmalloc.c b/src/pulse/xmalloc.c
index 71a6847..c570e40 100644
--- a/src/pulse/xmalloc.c
+++ b/src/pulse/xmalloc.c
@@ -46,7 +46,7 @@
 
 static void oom(void) PA_GCC_NORETURN;
 
-/** called in case of an OOM situation. Prints an error message and
+/* called in case of an OOM situation. Prints an error message and
  * exits */
 static void oom(void) {
     static const char e[] = "Not enough memory\n";
diff --git a/src/pulse/xmalloc.h b/src/pulse/xmalloc.h
index 7a408d3..b264358 100644
--- a/src/pulse/xmalloc.h
+++ b/src/pulse/xmalloc.h
@@ -58,7 +58,9 @@ char *pa_xstrndup(const char *s, size_t l) PA_GCC_MALLOC;
 void* pa_xmemdup(const void *p, size_t l) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE(2);
 
 /** Internal helper for pa_xnew() */
-static inline void* _pa_xnew_internal(unsigned n, size_t k) {
+static void* _pa_xnew_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2);
+
+static inline void* _pa_xnew_internal(size_t n, size_t k) {
     assert(n < INT_MAX/k);
     return pa_xmalloc(n*k);
 }
@@ -67,7 +69,9 @@ static inline void* _pa_xnew_internal(unsigned n, size_t k) {
 #define pa_xnew(type, n) ((type*) _pa_xnew_internal((n), sizeof(type)))
 
 /** Internal helper for pa_xnew0() */
-static inline void* _pa_xnew0_internal(unsigned n, size_t k) {
+static void* _pa_xnew0_internal(size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(1,2);
+
+static inline void* _pa_xnew0_internal(size_t n, size_t k) {
     assert(n < INT_MAX/k);
     return pa_xmalloc0(n*k);
 }
@@ -76,7 +80,9 @@ static inline void* _pa_xnew0_internal(unsigned n, size_t k) {
 #define pa_xnew0(type, n) ((type*) _pa_xnew0_internal((n), sizeof(type)))
 
 /** Internal helper for pa_xnew0() */
-static inline void* _pa_xnewdup_internal(const void *p, unsigned n, size_t k) {
+static void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) PA_GCC_MALLOC PA_GCC_ALLOC_SIZE2(2,3);
+
+static inline void* _pa_xnewdup_internal(const void *p, size_t n, size_t k) {
     assert(n < INT_MAX/k);
     return pa_xmemdup(p, n*k);
 }

commit 5f931138d2445691e7e97d237e1db183d0dabfb7
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 3 18:29:49 2008 +0200

    fix misuse of return value

diff --git a/src/tests/parec-simple.c b/src/tests/parec-simple.c
index 0312005..c9d3bef 100644
--- a/src/tests/parec-simple.c
+++ b/src/tests/parec-simple.c
@@ -72,7 +72,6 @@ int main(int argc, char*argv[]) {
 
     for (;;) {
         uint8_t buf[BUFSIZE];
-        ssize_t r;
 
         /* Record some data ... */
         if (pa_simple_read(s, buf, sizeof(buf), &error) < 0) {
@@ -80,11 +79,8 @@ int main(int argc, char*argv[]) {
             goto finish;
         }
 
-        if (r == 0)
-            break;
-
         /* And write it to STDOUT */
-        if ((r = loop_write(STDOUT_FILENO, buf, sizeof(buf))) <= 0) {
+        if (loop_write(STDOUT_FILENO, buf, sizeof(buf)) != sizeof(buf)) {
             fprintf(stderr, __FILE__": write() failed: %s\n", strerror(errno));
             goto finish;
         }

commit 99d5ec6c93c14a2b5892d9342e20c145d7915ae4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 3 18:30:27 2008 +0200

    Rework pa_machine_id() a bit
    
    Guarantee this function never fails, use POSIX gethostid as last resort. Add
    comments.

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index c78e8fd..ad00f4f 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2391,18 +2391,29 @@ char *pa_machine_id(void) {
     FILE *f;
     size_t l;
 
+    /* The returned value is supposed be some kind of ascii identifier
+     * that is unique and stable across reboots. */
+
+    /* First we try the D-Bus UUID, which is the best option we have,
+     * since it fits perfectly our needs and is not as volatile as the
+     * hostname which might be set from dhcp. */
+
     if ((f = fopen(PA_MACHINE_ID, "r"))) {
         char ln[34] = "", *r;
 
         r = fgets(ln, sizeof(ln)-1, f);
         fclose(f);
 
-        if (r)
-            return pa_xstrdup(pa_strip_nl(ln));
+        pa_strip_nl(ln);
+
+        if (ln[0])
+            return pa_xstrdup(ln);
     }
 
-    l = 100;
+    /* The we fall back to the host name. It supposed to be somewhat
+     * unique, at least in a network, but may change. */
 
+    l = 100;
     for (;;) {
         char *c;
 
@@ -2410,17 +2421,18 @@ char *pa_machine_id(void) {
 
         if (!pa_get_host_name(c, l)) {
 
-            if (errno == EINVAL || errno == ENAMETOOLONG) {
+            if (errno != EINVAL && errno != ENAMETOOLONG)
+                break;
+
+        } else if (strlen(c) < l-1) {
+
+            if (*c == 0) {
                 pa_xfree(c);
-                l *= 2;
-                continue;
+                break;
             }
 
-            return NULL;
-        }
-
-        if (strlen(c) < l-1)
             return c;
+        }
 
         /* Hmm, the hostname is as long the space we offered the
          * function, we cannot know if it fully fit in, so let's play
@@ -2429,4 +2441,9 @@ char *pa_machine_id(void) {
         pa_xfree(c);
         l *= 2;
     }
+
+    /* If no hostname was set we use the POSIX hostid. It's usually
+     * the IPv4 address.  Mit not be that stable. */
+    return pa_sprintf_malloc("%08lx", (unsigned long) gethostid);
+
 }

commit 40b66a0be9579fff095cba77f3ea29c390d966f2
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 3 18:31:46 2008 +0200

    Implement "early requests" mode.
    
    PA_STREAM_EARLY_REQUESTS is a new flag that will modify buffering metric
    selection behaviour a bit. This code is good for broken ALSA/OSS clients that
    ignore 'readability' on the fds in question and schedule audio via usleep()
    instead.

diff --git a/PROTOCOL b/PROTOCOL
index 581eeef..1e2a832 100644
--- a/PROTOCOL
+++ b/PROTOCOL
@@ -126,7 +126,7 @@ New field for PA_COMMAND_CREATE_PLAYBACK_STREAM at the end:
 Buffer attributes for PA_COMMAND_CREATE_PLAYBACK_STREAM and
 PA_COMMAND_CREATE_RECORD_STREAM may now be 0 for default values.
 
-New filed for PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR,
+New field for PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR,
 PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR at the end:
 
   adjust_latency (bool)
@@ -141,6 +141,15 @@ new message:
 
   PA_COMMAND_EXTENSION
 
-PA_COMMAND_CREATE_RECORD_STREAM, PA_COMMAND_CREATE_PLAYBACK_STREAM:
+PA_COMMAND_CREATE_PLAYBACK_STREAM:
 
   bool volume_set at the end
+
+PA_COMMAND_CREATE_RECORD_STREAM, PA_COMMAND_CREATE_PLAYBACK_STREAM:
+
+  bool early_requests at the end
+
+New field for PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR,
+PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR at the end:
+
+  early_requests (bool)
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 53bea3b..02da9f7 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -96,148 +96,124 @@ typedef enum pa_stream_direction {
 
 /** Some special flags for stream connections. */
 typedef enum pa_stream_flags {
-    PA_STREAM_START_CORKED = 1,       /**< Create the stream corked, requiring an explicit pa_stream_cork() call to uncork it. */
-    PA_STREAM_INTERPOLATE_TIMING = 2, /**< Interpolate the latency for
-                                       * this stream. When enabled,
-                                       * pa_stream_get_latency() and
-                                       * pa_stream_get_time() will try
-                                       * to estimate the current
-                                       * record/playback time based on
-                                       * the local time that passed
-                                       * since the last timing info
-                                       * update.  Using this option
-                                       * has the advantage of not
-                                       * requiring a whole roundtrip
-                                       * when the current
-                                       * playback/recording time is
-                                       * needed. Consider using this
-                                       * option when requesting
-                                       * latency information
-                                       * frequently. This is
-                                       * especially useful on long
-                                       * latency network
-                                       * connections. It makes a lot
-                                       * of sense to combine this
-                                       * option with
-                                       * PA_STREAM_AUTO_TIMING_UPDATE. */
-    PA_STREAM_NOT_MONOTONIC = 4,    /**< Don't force the time to
-                                      * increase monotonically. If
-                                      * this option is enabled,
-                                      * pa_stream_get_time() will not
-                                      * necessarily return always
-                                      * monotonically increasing time
-                                      * values on each call. This may
-                                      * confuse applications which
-                                      * cannot deal with time going
-                                      * 'backwards', but has the
-                                      * advantage that bad transport
-                                      * latency estimations that
-                                      * caused the time to to jump
-                                      * ahead can be corrected
-                                      * quickly, without the need to
-                                      * wait. (Please note that this
-                                      * flag was named
-                                      * PA_STREAM_NOT_MONOTONOUS in
-                                      * releases prior to 0.9.11. The
-                                      * old name is still defined too,
-                                      * for compatibility reasons. */
-    PA_STREAM_AUTO_TIMING_UPDATE = 8, /**< If set timing update requests
-                                       * are issued periodically
-                                       * automatically. Combined with
-                                       * PA_STREAM_INTERPOLATE_TIMING
-                                       * you will be able to query the
-                                       * current time and latency with
-                                       * pa_stream_get_time() and
-                                       * pa_stream_get_latency() at
-                                       * all times without a packet
-                                       * round trip.*/
-    PA_STREAM_NO_REMAP_CHANNELS = 16, /**< Don't remap channels by
-                                       * their name, instead map them
-                                       * simply by their
-                                       * index. Implies
-                                       * PA_STREAM_NO_REMIX_CHANNELS. Only
-                                       * supported when the server is
-                                       * at least PA 0.9.8. It is
-                                       * ignored on older
-                                       * servers.\since 0.9.8 */
-    PA_STREAM_NO_REMIX_CHANNELS = 32, /**< When remapping channels by
-                                       * name, don't upmix or downmix
-                                       * them to related
-                                       * channels. Copy them into
-                                       * matching channels of the
-                                       * device 1:1. Only supported
-                                       * when the server is at least
-                                       * PA 0.9.8. It is ignored on
-                                       * older servers. \since
-                                       * 0.9.8 */
-    PA_STREAM_FIX_FORMAT = 64, /**< Use the sample format of the
-                                * sink/device this stream is being
-                                * connected to, and possibly ignore
-                                * the format the sample spec contains
-                                * -- but you still have to pass a
-                                * valid value in it as a hint to
-                                * PulseAudio what would suit your
-                                * stream best. If this is used you
-                                * should query the used sample format
-                                * after creating the stream by using
-                                * pa_stream_get_sample_spec(). Also,
-                                * if you specified manual buffer
-                                * metrics it is recommended to update
-                                * them with
-                                * pa_stream_set_buffer_attr() to
-                                * compensate for the changed frame
-                                * sizes. Only supported when the
-                                * server is at least PA 0.9.8. It is
-                                * ignored on older servers. \since
-                                * 0.9.8 */
-
-    PA_STREAM_FIX_RATE = 128, /**< Use the sample rate of the sink,
-                               * and possibly ignore the rate the
-                               * sample spec contains. Usage similar
-                               * to PA_STREAM_FIX_FORMAT.Only
-                               * supported when the server is at least
-                               * PA 0.9.8. It is ignored on older
-                               * servers. \since 0.9.8 */
-
-    PA_STREAM_FIX_CHANNELS = 256, /**< Use the number of channels and
-                               * the channel map of the sink, and
-                               * possibly ignore the number of
-                               * channels and the map the sample spec
-                               * and the passed channel map
-                               * contains. Usage similar to
-                               * PA_STREAM_FIX_FORMAT. Only supported
-                               * when the server is at least PA
-                               * 0.9.8. It is ignored on older
-                               * servers. \since 0.9.8 */
-    PA_STREAM_DONT_MOVE = 512, /**< Don't allow moving of this stream to
-                              * another sink/device. Useful if you use
-                              * any of the PA_STREAM_FIX_ flags and
-                              * want to make sure that resampling
-                              * never takes place -- which might
-                              * happen if the stream is moved to
-                              * another sink/source whith a different
-                              * sample spec/channel map. Only
-                              * supported when the server is at least
-                              * PA 0.9.8. It is ignored on older
-                              * servers. \since 0.9.8 */
-    PA_STREAM_VARIABLE_RATE = 1024, /**< Allow dynamic changing of the
-                                     * sampling rate during playback
-                                     * with
-                                     * pa_stream_update_sample_rate(). Only
-                                     * supported when the server is at
-                                     * least PA 0.9.8. It is ignored
-                                     * on older servers. \since
-                                     * 0.9.8 */
-    PA_STREAM_PEAK_DETECT = 2048, /**< Find peaks instead of
-                                   * resampling. \since 0.9.11 */
-
-    PA_STREAM_START_MUTED = 4096,  /**< Create in muted state. \since 0.9.11 */
-
-    PA_STREAM_ADJUST_LATENCY = 8192, /**< Try to adjust the latency of
-                                      * the sink/source based on the
-                                      * requested buffer metrics and
-                                      * adjust buffer metrics
-                                      * accordingly. See pa_buffer_attr \since 0.9.11 */
+
+    PA_STREAM_START_CORKED = 0x0001U,
+    /**< Create the stream corked, requiring an explicit
+     * pa_stream_cork() call to uncork it. */
+
+    PA_STREAM_INTERPOLATE_TIMING = 0x0002U,
+    /**< Interpolate the latency for this stream. When enabled,
+     * pa_stream_get_latency() and pa_stream_get_time() will try to
+     * estimate the current record/playback time based on the local
+     * time that passed since the last timing info update.  Using this
+     * option has the advantage of not requiring a whole roundtrip
+     * when the current playback/recording time is needed. Consider
+     * using this option when requesting latency information
+     * frequently. This is especially useful on long latency network
+     * connections. It makes a lot of sense to combine this option
+     * with PA_STREAM_AUTO_TIMING_UPDATE. */
+
+    PA_STREAM_NOT_MONOTONIC = 0x0004U,
+    /**< Don't force the time to increase monotonically. If this
+     * option is enabled, pa_stream_get_time() will not necessarily
+     * return always monotonically increasing time values on each
+     * call. This may confuse applications which cannot deal with time
+     * going 'backwards', but has the advantage that bad transport
+     * latency estimations that caused the time to to jump ahead can
+     * be corrected quickly, without the need to wait. (Please note
+     * that this flag was named PA_STREAM_NOT_MONOTONOUS in releases
+     * prior to 0.9.11. The old name is still defined too, for
+     * compatibility reasons. */
+
+    PA_STREAM_AUTO_TIMING_UPDATE = 0x0008U,
+    /**< If set timing update requests are issued periodically
+     * automatically. Combined with PA_STREAM_INTERPOLATE_TIMING you
+     * will be able to query the current time and latency with
+     * pa_stream_get_time() and pa_stream_get_latency() at all times
+     * without a packet round trip.*/
+
+    PA_STREAM_NO_REMAP_CHANNELS = 0x0010U,
+    /**< Don't remap channels by their name, instead map them simply
+     * by their index. Implies PA_STREAM_NO_REMIX_CHANNELS. Only
+     * supported when the server is at least PA 0.9.8. It is ignored
+     * on older servers.\since 0.9.8 */
+
+    PA_STREAM_NO_REMIX_CHANNELS = 0x0020U,
+    /**< When remapping channels by name, don't upmix or downmix them
+     * to related channels. Copy them into matching channels of the
+     * device 1:1. Only supported when the server is at least PA
+     * 0.9.8. It is ignored on older servers. \since 0.9.8 */
+
+    PA_STREAM_FIX_FORMAT = 0x0040U,
+    /**< Use the sample format of the sink/device this stream is being
+     * connected to, and possibly ignore the format the sample spec
+     * contains -- but you still have to pass a valid value in it as a
+     * hint to PulseAudio what would suit your stream best. If this is
+     * used you should query the used sample format after creating the
+     * stream by using pa_stream_get_sample_spec(). Also, if you
+     * specified manual buffer metrics it is recommended to update
+     * them with pa_stream_set_buffer_attr() to compensate for the
+     * changed frame sizes. Only supported when the server is at least
+     * PA 0.9.8. It is ignored on older servers. \since 0.9.8 */
+
+    PA_STREAM_FIX_RATE = 0x0080U,
+    /**< Use the sample rate of the sink, and possibly ignore the rate
+     * the sample spec contains. Usage similar to
+     * PA_STREAM_FIX_FORMAT.Only supported when the server is at least
+     * PA 0.9.8. It is ignored on older servers. \since 0.9.8 */
+
+    PA_STREAM_FIX_CHANNELS = 0x0100,
+    /**< Use the number of channels and the channel map of the sink,
+     * and possibly ignore the number of channels and the map the
+     * sample spec and the passed channel map contains. Usage similar
+     * to PA_STREAM_FIX_FORMAT. Only supported when the server is at
+     * least PA 0.9.8. It is ignored on older servers. \since 0.9.8 */
+
+    PA_STREAM_DONT_MOVE = 0x0200U,
+    /**< Don't allow moving of this stream to another
+     * sink/device. Useful if you use any of the PA_STREAM_FIX_ flags
+     * and want to make sure that resampling never takes place --
+     * which might happen if the stream is moved to another
+     * sink/source whith a different sample spec/channel map. Only
+     * supported when the server is at least PA 0.9.8. It is ignored
+     * on older servers. \since 0.9.8 */
+
+    PA_STREAM_VARIABLE_RATE = 0x0400U,
+    /**< Allow dynamic changing of the sampling rate during playback
+     * with pa_stream_update_sample_rate(). Only supported when the
+     * server is at least PA 0.9.8. It is ignored on older
+     * servers. \since 0.9.8 */
+
+    PA_STREAM_PEAK_DETECT = 0x0800U,
+    /**< Find peaks instead of resampling. \since 0.9.11 */
+
+    PA_STREAM_START_MUTED = 0x1000U,
+    /**< Create in muted state. \since 0.9.11 */
+
+    PA_STREAM_ADJUST_LATENCY = 0x2000U,
+    /**< Try to adjust the latency of the sink/source based on the
+     * requested buffer metrics and adjust buffer metrics
+     * accordingly. Also see pa_buffer_attr. This option may not be
+     * specified at the same time as PA_STREAM_EARLY_REQUESTS. \since
+     * 0.9.11 */
+
+    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
+     * a new meaning: instead of just specifying that no requests
+     * asking for less new data than this value will be made to the
+     * client it will also guarantee that requests are generated as
+     * early as this limit is reached. This flag should only be set in
+     * very few situations where compatiblity with a fragment-based
+     * playback model needs to be kept and the client applications
+     * cannot deal with data requests that are delayed to the latest
+     * moment possible. (Usually these are programs that use usleep()
+     * or a similar call in their playback loops instead of sleeping
+     * on the device itself.) Also see pa_buffer_attr. This option may
+     * not be specified at the same time as
+     * PA_STREAM_ADJUST_LATENCY. \since 0.9.12 */
+
 } pa_stream_flags_t;
 
 /** \cond fulldocs */
diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index 6a497b7..d0c7d67 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -886,7 +886,8 @@ static int create_stream(
                                               PA_STREAM_VARIABLE_RATE|
                                               PA_STREAM_PEAK_DETECT|
                                               PA_STREAM_START_MUTED|
-                                              PA_STREAM_ADJUST_LATENCY)), PA_ERR_INVALID);
+                                              PA_STREAM_ADJUST_LATENCY|
+                                              PA_STREAM_EARLY_REQUESTS)), 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);
@@ -899,6 +900,7 @@ static int create_stream(
     PA_CHECK_VALIDITY(s->context, direction == PA_STREAM_RECORD || !(flags & (PA_STREAM_PEAK_DETECT)), PA_ERR_INVALID);
     PA_CHECK_VALIDITY(s->context, !volume || volume->channels == s->sample_spec.channels, PA_ERR_INVALID);
     PA_CHECK_VALIDITY(s->context, !sync_stream || (direction == PA_STREAM_PLAYBACK && sync_stream->direction == PA_STREAM_PLAYBACK), PA_ERR_INVALID);
+    PA_CHECK_VALIDITY(s->context, (flags & (PA_STREAM_ADJUST_LATENCY|PA_STREAM_EARLY_REQUESTS)) != (PA_STREAM_ADJUST_LATENCY|PA_STREAM_EARLY_REQUESTS), PA_ERR_INVALID);
 
     pa_stream_ref(s);
 
@@ -997,13 +999,12 @@ static int create_stream(
             pa_tagstruct_putu32(t, s->direct_on_input);
     }
 
-    if (s->context->version >= 14 &&
-        s->direction == PA_STREAM_PLAYBACK) {
+    if (s->context->version >= 14) {
 
-        pa_tagstruct_put(
-                t,
-                PA_TAG_BOOLEAN, volume_set,
-                PA_TAG_INVALID);
+        if (s->direction == PA_STREAM_PLAYBACK)
+            pa_tagstruct_put_boolean(t, volume_set);
+
+        pa_tagstruct_put_boolean(t, flags & PA_STREAM_EARLY_REQUESTS);
     }
 
     pa_pstream_send_tagstruct(s->context->pstream, t);
@@ -2079,6 +2080,9 @@ pa_operation* pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr
     if (s->context->version >= 13)
         pa_tagstruct_put_boolean(t, !!(s->flags & PA_STREAM_ADJUST_LATENCY));
 
+    if (s->context->version >= 14)
+        pa_tagstruct_put_boolean(t, !!(s->flags & PA_STREAM_EARLY_REQUESTS));
+
     pa_pstream_send_tagstruct(s->context->pstream, t);
     pa_pdispatch_register_reply(s->context->pdispatch, tag, DEFAULT_TIMEOUT, stream_set_buffer_attr_callback, pa_operation_ref(o), (pa_free_cb_t) pa_operation_unref);
 
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 8ceea80..06245d1 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -469,47 +469,95 @@ static int record_stream_process_msg(pa_msgobject *o, int code, void*userdata, i
     return 0;
 }
 
-static void fix_record_buffer_attr_pre(record_stream *s, pa_bool_t adjust_latency, uint32_t *maxlength, uint32_t *fragsize) {
+static void fix_record_buffer_attr_pre(
+        record_stream *s,
+        pa_bool_t adjust_latency,
+        pa_bool_t early_requests,
+        uint32_t *maxlength,
+        uint32_t *fragsize) {
+
+    size_t frame_size;
+    pa_usec_t orig_fragsize_usec, fragsize_usec, source_usec;
+
     pa_assert(s);
     pa_assert(maxlength);
     pa_assert(fragsize);
 
+    frame_size = pa_frame_size(&s->source_output->sample_spec);
+
     if (*maxlength == (uint32_t) -1 || *maxlength > MAX_MEMBLOCKQ_LENGTH)
         *maxlength = MAX_MEMBLOCKQ_LENGTH;
     if (*maxlength <= 0)
-        *maxlength = (uint32_t) pa_frame_size(&s->source_output->sample_spec);
+        *maxlength = (uint32_t) frame_size;
 
     if (*fragsize == (uint32_t) -1)
         *fragsize = (uint32_t) pa_usec_to_bytes(DEFAULT_FRAGSIZE_MSEC*PA_USEC_PER_MSEC, &s->source_output->sample_spec);
     if (*fragsize <= 0)
-        *fragsize = (uint32_t) pa_frame_size(&s->source_output->sample_spec);
+        *fragsize = (uint32_t) frame_size;
+
+    orig_fragsize_usec = fragsize_usec = pa_bytes_to_usec(*fragsize, &s->source_output->sample_spec);
 
-    if (adjust_latency) {
-        pa_usec_t orig_fragsize_usec, fragsize_usec;
+    if (early_requests) {
+
+        /* In early request mode we need to emulate the classic
+         * fragment-based playback model. We do this setting the source
+         * latency to the fragment size. */
+
+        source_usec = fragsize_usec;
+
+    } else if (adjust_latency) {
 
         /* So, the user asked us to adjust the latency according to
          * what the source can provide. Half the latency will be
          * spent on the hw buffer, half of it in the async buffer
          * queue we maintain for each client. */
 
-        orig_fragsize_usec = fragsize_usec = pa_bytes_to_usec(*fragsize, &s->source_output->sample_spec);
+        source_usec = fragsize_usec/2;
+
+    } else {
+
+        /* Ok, the user didn't ask us to adjust the latency, hence we
+         * don't */
 
-        s->source_latency = pa_source_output_set_requested_latency(s->source_output, fragsize_usec/2);
+        source_usec = 0;
+    }
+
+    if (source_usec > 0)
+        s->source_latency = pa_source_output_set_requested_latency(s->source_output, source_usec);
+    else
+        s->source_latency = 0;
+
+    if (early_requests) {
+
+        /* Ok, we didn't necessarily get what we were asking for, so
+         * let's tell the user */
+
+        fragsize_usec = s->source_latency;
+
+    } else if (adjust_latency) {
+
+        /* Now subtract what we actually got */
 
         if (fragsize_usec >= s->source_latency*2)
             fragsize_usec -= s->source_latency;
         else
             fragsize_usec = s->source_latency;
+    }
 
-        if (pa_usec_to_bytes(orig_fragsize_usec, &s->source_output->sample_spec) !=
-            pa_usec_to_bytes(fragsize_usec, &s->source_output->sample_spec))
+    if (pa_usec_to_bytes(orig_fragsize_usec, &s->source_output->sample_spec) !=
+        pa_usec_to_bytes(fragsize_usec, &s->source_output->sample_spec))
 
-            *fragsize = (uint32_t) pa_usec_to_bytes(fragsize_usec, &s->source_output->sample_spec);
-    } else
-        s->source_latency = 0;
+        *fragsize = (uint32_t) pa_usec_to_bytes(fragsize_usec, &s->source_output->sample_spec);
+
+    if (*fragsize <= 0)
+        *fragsize = (uint32_t) frame_size;
 }
 
-static void fix_record_buffer_attr_post(record_stream *s, uint32_t *maxlength, uint32_t *fragsize) {
+static void fix_record_buffer_attr_post(
+        record_stream *s,
+        uint32_t *maxlength,
+        uint32_t *fragsize) {
+
     size_t base;
 
     pa_assert(s);
@@ -541,7 +589,8 @@ static record_stream* record_stream_new(
         pa_source_output_flags_t flags,
         pa_proplist *p,
         pa_bool_t adjust_latency,
-        pa_sink_input *direct_on_input) {
+        pa_sink_input *direct_on_input,
+        pa_bool_t early_requests) {
 
     record_stream *s;
     pa_source_output *source_output;
@@ -587,7 +636,7 @@ static record_stream* record_stream_new(
     s->source_output->suspend = source_output_suspend_cb;
     s->source_output->userdata = s;
 
-    fix_record_buffer_attr_pre(s, adjust_latency, maxlength, fragsize);
+    fix_record_buffer_attr_pre(s, adjust_latency, early_requests, maxlength, fragsize);
 
     s->memblockq = pa_memblockq_new(
             0,
@@ -693,6 +742,8 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
         case PLAYBACK_STREAM_MESSAGE_UNDERFLOW: {
             pa_tagstruct *t;
 
+/*             pa_log("signalling underflow"); */
+
             /* Report that we're empty */
             t = pa_tagstruct_new(NULL, 0);
             pa_tagstruct_putu32(t, PA_COMMAND_UNDERFLOW);
@@ -737,7 +788,15 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
     return 0;
 }
 
-static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_latency, uint32_t *maxlength, uint32_t *tlength, uint32_t* prebuf, uint32_t* minreq) {
+static void fix_playback_buffer_attr_pre(
+        playback_stream *s,
+        pa_bool_t adjust_latency,
+        pa_bool_t early_requests,
+        uint32_t *maxlength,
+        uint32_t *tlength,
+        uint32_t* prebuf,
+        uint32_t* minreq) {
+
     size_t frame_size;
     pa_usec_t orig_tlength_usec, tlength_usec, orig_minreq_usec, minreq_usec, sink_usec;
 
@@ -774,7 +833,17 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
                 (double) tlength_usec / PA_USEC_PER_MSEC,
                 (double) minreq_usec / PA_USEC_PER_MSEC);
 
-    if (adjust_latency) {
+    if (early_requests) {
+
+        /* In early request mode we need to emulate the classic
+         * fragment-based playback model. We do this setting the sink
+         * latency to the fragment size. */
+
+        sink_usec = minreq_usec;
+
+        pa_log_debug("Early requests mode enabled, configuring sink latency to minreq.");
+
+    } else if (adjust_latency) {
 
         /* So, the user asked us to adjust the latency of the stream
          * buffer according to the what the sink can provide. The
@@ -798,6 +867,8 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
         else
             sink_usec = 0;
 
+        pa_log_debug("Adjust latency mode enabled, configuring sink latency to half of overall latency.");
+
     } else {
 
         /* Ok, the user didn't ask us to adjust the latency, but we
@@ -808,11 +879,21 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
             sink_usec = (tlength_usec - minreq_usec*2);
         else
             sink_usec = 0;
+
+        pa_log_debug("Traditional mode enabled, modifying sink usec only for compat with minreq.");
     }
 
     s->sink_latency = pa_sink_input_set_requested_latency(s->sink_input, sink_usec);
 
-    if (adjust_latency) {
+    if (early_requests) {
+
+        /* Ok, we didn't necessarily get what we were asking for, so
+         * let's tell the user */
+
+        minreq_usec = s->sink_latency;
+
+    } else if (adjust_latency) {
+
         /* Ok, we didn't necessarily get what we were asking for, so
          * let's subtract from what we asked for for the remaining
          * buffer space */
@@ -835,7 +916,7 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
         *minreq = (uint32_t) pa_usec_to_bytes(minreq_usec, &s->sink_input->sample_spec);
 
     if (*minreq <= 0) {
-        *minreq += (uint32_t) frame_size;
+        *minreq = (uint32_t) frame_size;
         *tlength += (uint32_t) frame_size*2;
     }
 
@@ -846,7 +927,13 @@ static void fix_playback_buffer_attr_pre(playback_stream *s, pa_bool_t adjust_la
         *prebuf = *tlength;
 }
 
-static void fix_playback_buffer_attr_post(playback_stream *s, uint32_t *maxlength, uint32_t *tlength, uint32_t* prebuf, uint32_t* minreq) {
+static void fix_playback_buffer_attr_post(
+        playback_stream *s,
+        uint32_t *maxlength,
+        uint32_t *tlength,
+        uint32_t* prebuf,
+        uint32_t* minreq) {
+
     pa_assert(s);
     pa_assert(maxlength);
     pa_assert(tlength);
@@ -876,7 +963,8 @@ static playback_stream* playback_stream_new(
         uint32_t *missing,
         pa_sink_input_flags_t flags,
         pa_proplist *p,
-        pa_bool_t adjust_latency) {
+        pa_bool_t adjust_latency,
+        pa_bool_t early_requests) {
 
     playback_stream *s, *ssync;
     pa_sink_input *sink_input;
@@ -957,7 +1045,7 @@ static playback_stream* playback_stream_new(
 
     start_index = ssync ? pa_memblockq_get_read_index(ssync->memblockq) : 0;
 
-    fix_playback_buffer_attr_pre(s, adjust_latency, maxlength, tlength, prebuf, minreq);
+    fix_playback_buffer_attr_pre(s, adjust_latency, early_requests, maxlength, tlength, prebuf, minreq);
     pa_sink_input_get_silence(sink_input, &silence);
 
     s->memblockq = pa_memblockq_new(
@@ -1433,7 +1521,7 @@ static void sink_input_moved_cb(pa_sink_input *i) {
     prebuf = (uint32_t) pa_memblockq_get_prebuf(s->memblockq);
     minreq = (uint32_t) pa_memblockq_get_minreq(s->memblockq);
 
-    fix_playback_buffer_attr_pre(s, TRUE, &maxlength, &tlength, &prebuf, &minreq);
+    fix_playback_buffer_attr_pre(s, TRUE, FALSE, &maxlength, &tlength, &prebuf, &minreq);
     pa_memblockq_set_maxlength(s->memblockq, maxlength);
     pa_memblockq_set_tlength(s->memblockq, tlength);
     pa_memblockq_set_prebuf(s->memblockq, prebuf);
@@ -1532,7 +1620,7 @@ static void source_output_moved_cb(pa_source_output *o) {
     fragsize = (uint32_t) s->fragment_size;
     maxlength = (uint32_t) pa_memblockq_get_length(s->memblockq);
 
-    fix_record_buffer_attr_pre(s, TRUE, &maxlength, &fragsize);
+    fix_record_buffer_attr_pre(s, TRUE, FALSE, &maxlength, &fragsize);
     pa_memblockq_set_maxlength(s->memblockq, maxlength);
     fix_record_buffer_attr_post(s, &maxlength, &fragsize);
 
@@ -1599,7 +1687,8 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         no_move = FALSE,
         variable_rate = FALSE,
         muted = FALSE,
-        adjust_latency = FALSE;
+        adjust_latency = FALSE,
+        early_requests = FALSE;
 
     pa_sink_input_flags_t flags = 0;
     pa_proplist *p;
@@ -1672,7 +1761,8 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
 
     if (c->version >= 14) {
 
-        if (pa_tagstruct_get_boolean(t, &volume_set) < 0) {
+        if (pa_tagstruct_get_boolean(t, &volume_set) < 0 ||
+            pa_tagstruct_get_boolean(t, &early_requests) < 0) {
             protocol_error(c);
             pa_proplist_free(p);
             return;
@@ -1712,7 +1802,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
         (no_move ?  PA_SINK_INPUT_DONT_MOVE : 0) |
         (variable_rate ?  PA_SINK_INPUT_VARIABLE_RATE : 0);
 
-    s = playback_stream_new(c, sink, &ss, &map, &maxlength, &tlength, &prebuf, &minreq, volume_set ? &volume : NULL, muted, syncid, &missing, flags, p, adjust_latency);
+    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);
     pa_proplist_free(p);
 
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
@@ -1832,7 +1922,8 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         no_move = FALSE,
         variable_rate = FALSE,
         adjust_latency = FALSE,
-        peak_detect = FALSE;
+        peak_detect = FALSE,
+        early_requests = FALSE;
     pa_source_output_flags_t flags = 0;
     pa_proplist *p;
     uint32_t direct_on_input_idx = PA_INVALID_INDEX;
@@ -1895,6 +1986,15 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         }
     }
 
+    if (c->version >= 14) {
+
+        if (pa_tagstruct_get_boolean(t, &early_requests) < 0) {
+            protocol_error(c);
+            pa_proplist_free(p);
+            return;
+        }
+    }
+
     if (!pa_tagstruct_eof(t)) {
         protocol_error(c);
         pa_proplist_free(p);
@@ -1937,7 +2037,7 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
         (no_move ?  PA_SOURCE_OUTPUT_DONT_MOVE : 0) |
         (variable_rate ?  PA_SOURCE_OUTPUT_VARIABLE_RATE : 0);
 
-    s = record_stream_new(c, source, &ss, &map, peak_detect, &maxlength, &fragment_size, flags, p, adjust_latency, direct_on_input);
+    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);
 
     CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_INVALID);
@@ -1997,7 +2097,7 @@ static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
     pa_native_connection *c = PA_NATIVE_CONNECTION(userdata);
     const void*cookie;
     pa_tagstruct *reply;
-    pa_bool_t shm_on_remote, do_shm;
+    pa_bool_t shm_on_remote = FALSE, do_shm;
 
     pa_native_connection_assert_ref(c);
     pa_assert(t);
@@ -3174,7 +3274,7 @@ static void command_set_stream_buffer_attr(pa_pdispatch *pd, uint32_t command, u
 
     if (command == PA_COMMAND_SET_PLAYBACK_STREAM_BUFFER_ATTR) {
         playback_stream *s;
-        pa_bool_t adjust_latency = FALSE;
+        pa_bool_t adjust_latency = FALSE, early_requests = FALSE;
 
         s = pa_idxset_get_by_index(c->output_streams, idx);
         CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY);
@@ -3188,12 +3288,13 @@ static void command_set_stream_buffer_attr(pa_pdispatch *pd, uint32_t command, u
                     PA_TAG_U32, &minreq,
                     PA_TAG_INVALID) < 0 ||
             (c->version >= 13 && pa_tagstruct_get_boolean(t, &adjust_latency) < 0) ||
+            (c->version >= 14 && pa_tagstruct_get_boolean(t, &early_requests) < 0) ||
             !pa_tagstruct_eof(t)) {
             protocol_error(c);
             return;
         }
 
-        fix_playback_buffer_attr_pre(s, adjust_latency, &maxlength, &tlength, &prebuf, &minreq);
+        fix_playback_buffer_attr_pre(s, adjust_latency, early_requests, &maxlength, &tlength, &prebuf, &minreq);
         pa_memblockq_set_maxlength(s->memblockq, maxlength);
         pa_memblockq_set_tlength(s->memblockq, tlength);
         pa_memblockq_set_prebuf(s->memblockq, prebuf);
@@ -3211,7 +3312,7 @@ static void command_set_stream_buffer_attr(pa_pdispatch *pd, uint32_t command, u
 
     } else {
         record_stream *s;
-        pa_bool_t adjust_latency = FALSE;
+        pa_bool_t adjust_latency = FALSE, early_requests = FALSE;
         pa_assert(command == PA_COMMAND_SET_RECORD_STREAM_BUFFER_ATTR);
 
         s = pa_idxset_get_by_index(c->record_streams, idx);
@@ -3223,12 +3324,13 @@ static void command_set_stream_buffer_attr(pa_pdispatch *pd, uint32_t command, u
                     PA_TAG_U32, &fragsize,
                     PA_TAG_INVALID) < 0 ||
             (c->version >= 13 && pa_tagstruct_get_boolean(t, &adjust_latency) < 0) ||
+            (c->version >= 14 && pa_tagstruct_get_boolean(t, &early_requests) < 0) ||
             !pa_tagstruct_eof(t)) {
             protocol_error(c);
             return;
         }
 
-        fix_record_buffer_attr_pre(s, adjust_latency, &maxlength, &fragsize);
+        fix_record_buffer_attr_pre(s, adjust_latency, early_requests, &maxlength, &fragsize);
         pa_memblockq_set_maxlength(s->memblockq, maxlength);
         fix_record_buffer_attr_post(s, &maxlength, &fragsize);
 
@@ -3954,6 +4056,8 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
         return;
     }
 
+/*     pa_log("got %lu bytes", (unsigned long) chunk->length); */
+
     if (playback_stream_isinstance(stream)) {
         playback_stream *ps = PLAYBACK_STREAM(stream);
 

commit c402de754583b41ae96409aebce713b0d07e2826
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 3 18:51:46 2008 +0200

    reindent comments a bit

diff --git a/src/pulse/channelmap.h b/src/pulse/channelmap.h
index 7c32b86..f9086d1 100644
--- a/src/pulse/channelmap.h
+++ b/src/pulse/channelmap.h
@@ -142,21 +142,34 @@ typedef enum pa_channel_position {
 
 /** A list of channel mapping definitions for pa_channel_map_init_auto() */
 typedef enum pa_channel_map_def {
-    PA_CHANNEL_MAP_AIFF,   /**< The mapping from RFC3551, which is based on AIFF-C */
-    PA_CHANNEL_MAP_ALSA,   /**< The default mapping used by ALSA */
-    PA_CHANNEL_MAP_AUX,    /**< Only aux channels */
-    PA_CHANNEL_MAP_WAVEEX, /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
-    PA_CHANNEL_MAP_OSS,    /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
+    PA_CHANNEL_MAP_AIFF,
+    /**< The mapping from RFC3551, which is based on AIFF-C */
 
-    PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF /**< The default channel map */
+    PA_CHANNEL_MAP_ALSA,
+    /**< The default mapping used by ALSA */
+
+    PA_CHANNEL_MAP_AUX,
+    /**< Only aux channels */
+
+    PA_CHANNEL_MAP_WAVEEX,
+    /**< Microsoft's WAVEFORMATEXTENSIBLE mapping */
+
+    PA_CHANNEL_MAP_OSS,
+    /**< The default channel mapping used by OSS as defined in the OSS 4.0 API specs */
+
+    PA_CHANNEL_MAP_DEFAULT = PA_CHANNEL_MAP_AIFF
+    /**< The default channel map */
 } pa_channel_map_def_t;
 
 /** A channel map which can be used to attach labels to specific
  * channels of a stream. These values are relevant for conversion and
  * mixing of streams */
 typedef struct pa_channel_map {
-    uint8_t channels; /**< Number of channels */
-    pa_channel_position_t map[PA_CHANNELS_MAX]; /**< Channel labels */
+    uint8_t channels;
+    /**< Number of channels */
+
+    pa_channel_position_t map[PA_CHANNELS_MAX];
+    /**< Channel labels */
 } pa_channel_map;
 
 /** Initialize the specified channel map and return a pointer to it */
diff --git a/src/pulse/def.h b/src/pulse/def.h
index 02da9f7..c71e033 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -57,7 +57,7 @@ static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) {
 
 /** The state of a stream */
 typedef enum pa_stream_state {
-    PA_STREAM_UNCONNECTED, /**< The stream is not yet connected to any sink or source */
+    PA_STREAM_UNCONNECTED,  /**< The stream is not yet connected to any sink or source */
     PA_STREAM_CREATING,     /**< The stream is being created */
     PA_STREAM_READY,        /**< The stream is established, you may pass audio data to it now */
     PA_STREAM_FAILED,       /**< An error occured that made the stream invalid */
@@ -83,7 +83,8 @@ typedef enum pa_operation_state {
 
 /** Some special flags for contexts. */
 typedef enum pa_context_flags {
-    PA_CONTEXT_NOAUTOSPAWN = 1 /**< Disabled autospawning of the PulseAudio daemon if required */
+    PA_CONTEXT_NOAUTOSPAWN = 1
+    /**< Disabled autospawning of the PulseAudio daemon if required */
 } pa_context_flags_t;
 
 /** The direction of a pa_stream object */
@@ -225,87 +226,64 @@ typedef enum pa_stream_flags {
 
 /** Playback and record buffer metrics */
 typedef struct pa_buffer_attr {
-    uint32_t maxlength;      /**< Maximum length of the
-                              * buffer. Setting this to (uint32_t) -1 will
-                              * initialize this to the maximum value
-                              * supported by server, which is
-                              * recommended. */
-    uint32_t tlength;        /**< Playback only: target length of the
-                              * buffer. The server tries to assure
-                              * that at least tlength bytes are always
-                              * available in the per-stream
-                              * server-side playback buffer. It is
-                              * recommended to set this to (uint32_t)
-                              * -1, which will initialize this to a
-                              * value that is deemed sensible by the
-                              * server. However, this value will
-                              * default to something like 2s, i.e. for
-                              * applications that have specific
-                              * latency requirements this value should
-                              * be set to the maximum latency that the
-                              * application can deal with. When
-                              * PA_STREAM_ADJUST_LATENCY is not set
-                              * this value will influence only the
-                              * per-stream playback buffer size. When
-                              * PA_STREAM_ADJUST_LATENCY is set the
-                              * overall latency of the sink plus the
-                              * playback buffer size is configured to
-                              * this value. Set
-                              * PA_STREAM_ADJUST_LATENCY if you are
-                              * interested in adjusting the overall
-                              * latency. Don't set it if you are
-                              * interested in configuring the
-                              * server-sider per-stream playback
-                              * buffer size. */
-    uint32_t prebuf;         /**< Playback only: pre-buffering. The
-                              * server does not start with playback
-                              * before at least prebug bytes are
-                              * available in the buffer. It is
-                              * recommended to set this to (uint32_t)
-                              * -1, which will initialize this to the
-                              * same value as tlength, whatever that
-                              * may be. Initialize to 0 to enable
-                              * manual start/stop control of the
-                              * stream. This means that playback will
-                              * not stop on underrun and playback will
-                              * not start automatically. Instead
-                              * pa_stream_corked() needs to be called
-                              * explicitly. If you set this value to 0
-                              * you should also set
-                              * PA_STREAM_START_CORKED. */
-    uint32_t minreq;         /**< Playback only: minimum request. The
-                              * server does not request less than
-                              * minreq bytes from the client, instead
-                              * waits until the buffer is free enough
-                              * to request more bytes at once. It is
-                              * recommended to set this to (uint32_t)
-                              * -1, which will initialize this to a
-                              * value that is deemed sensible by the
-                              * server. This should be set to a value
-                              * that gives PulseAudio enough time to
-                              * move the data from the per-stream
-                              * playback buffer into the hardware
-                              * playback buffer. */
-    uint32_t fragsize;       /**< Recording only: fragment size. The
-                              * server sends data in blocks of
-                              * fragsize bytes size. Large values
-                              * deminish interactivity with other
-                              * operations on the connection context
-                              * but decrease control overhead. It is
-                              * recommended to set this to (uint32_t)
-                              * -1, which will initialize this to a
-                              * value that is deemed sensible by the
-                              * server. However, this value will
-                              * default to something like 2s, i.e. for
-                              * applications that have specific
-                              * latency requirements this value should
-                              * be set to the maximum latency that the
-                              * application can deal with. If
-                              * PA_STREAM_ADJUST_LATENCY is set the
-                              * overall source latency will be
-                              * adjusted according to this value. If
-                              * it is not set the source latency is
-                              * left unmodified. */
+    uint32_t maxlength;
+    /**< Maximum length of the buffer. Setting this to (uint32_t) -1
+     * will initialize this to the maximum value supported by server,
+     * which is recommended. */
+
+    uint32_t tlength;
+    /**< Playback only: target length of the buffer. The server tries
+     * to assure that at least tlength bytes are always available in
+     * the per-stream server-side playback buffer. It is recommended
+     * to set this to (uint32_t) -1, which will initialize this to a
+     * value that is deemed sensible by the server. However, this
+     * value will default to something like 2s, i.e. for applications
+     * that have specific latency requirements this value should be
+     * set to the maximum latency that the application can deal
+     * with. When PA_STREAM_ADJUST_LATENCY is not set this value will
+     * influence only the per-stream playback buffer size. When
+     * PA_STREAM_ADJUST_LATENCY is set the overall latency of the sink
+     * plus the playback buffer size is configured to this value. Set
+     * PA_STREAM_ADJUST_LATENCY if you are interested in adjusting the
+     * overall latency. Don't set it if you are interested in
+     * configuring the server-sider per-stream playback buffer
+     * size. */
+
+    uint32_t prebuf;
+    /**< Playback only: pre-buffering. The server does not start with
+     * playback before at least prebug bytes are available in the
+     * buffer. It is recommended to set this to (uint32_t) -1, which
+     * will initialize this to the same value as tlength, whatever
+     * that may be. Initialize to 0 to enable manual start/stop
+     * control of the stream. This means that playback will not stop
+     * on underrun and playback will not start automatically. Instead
+     * pa_stream_corked() needs to be called explicitly. If you set
+     * this value to 0 you should also set PA_STREAM_START_CORKED. */
+
+    uint32_t minreq;
+    /**< Playback only: minimum request. The server does not request
+     * less than minreq bytes from the client, instead waits until the
+     * buffer is free enough to request more bytes at once. It is
+     * recommended to set this to (uint32_t) -1, which will initialize
+     * this to a value that is deemed sensible by the server. This
+     * should be set to a value that gives PulseAudio enough time to
+     * move the data from the per-stream playback buffer into the
+     * hardware playback buffer. */
+
+    uint32_t fragsize;
+    /**< Recording only: fragment size. The server sends data in
+     * blocks of fragsize bytes size. Large values deminish
+     * interactivity with other operations on the connection context
+     * but decrease control overhead. It is recommended to set this to
+     * (uint32_t) -1, which will initialize this to a value that is
+     * deemed sensible by the server. However, this value will default
+     * to something like 2s, i.e. for applications that have specific
+     * latency requirements this value should be set to the maximum
+     * latency that the application can deal with. If
+     * PA_STREAM_ADJUST_LATENCY is set the overall source latency will
+     * be adjusted according to this value. If it is not set the
+     * source latency is left unmodified. */
+
 } pa_buffer_attr;
 
 /** Error values as used by pa_context_errno(). Use pa_strerror() to convert these values to human readable strings */
@@ -337,36 +315,84 @@ enum {
 
 /** Subscription event mask, as used by pa_context_subscribe() */
 typedef enum pa_subscription_mask {
-    PA_SUBSCRIPTION_MASK_NULL = 0,               /**< No events */
-    PA_SUBSCRIPTION_MASK_SINK = 1,               /**< Sink events */
-    PA_SUBSCRIPTION_MASK_SOURCE = 2,             /**< Source events */
-    PA_SUBSCRIPTION_MASK_SINK_INPUT = 4,         /**< Sink input events */
-    PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 8,      /**< Source output events */
-    PA_SUBSCRIPTION_MASK_MODULE = 16,            /**< Module events */
-    PA_SUBSCRIPTION_MASK_CLIENT = 32,            /**< Client events */
-    PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 64,      /**< Sample cache events */
-    PA_SUBSCRIPTION_MASK_SERVER = 128,           /**< Other global server changes. */
-    PA_SUBSCRIPTION_MASK_AUTOLOAD = 256,         /**< Autoload table events. */
-    PA_SUBSCRIPTION_MASK_ALL = 511               /**< Catch all events */
+    PA_SUBSCRIPTION_MASK_NULL = 0x0000U,
+    /**< No events */
+
+    PA_SUBSCRIPTION_MASK_SINK = 0x0001U,
+    /**< Sink events */
+
+    PA_SUBSCRIPTION_MASK_SOURCE = 0x0002U,
+    /**< Source events */
+
+    PA_SUBSCRIPTION_MASK_SINK_INPUT = 0x0004U,
+    /**< Sink input events */
+
+    PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT = 0x0008U,
+    /**< Source output events */
+
+    PA_SUBSCRIPTION_MASK_MODULE = 0x0010U,
+    /**< Module events */
+
+    PA_SUBSCRIPTION_MASK_CLIENT = 0x0020U,
+    /**< Client events */
+
+    PA_SUBSCRIPTION_MASK_SAMPLE_CACHE = 0x0040U,
+    /**< Sample cache events */
+
+    PA_SUBSCRIPTION_MASK_SERVER = 0x0080U,
+    /**< Other global server changes. */
+
+    PA_SUBSCRIPTION_MASK_AUTOLOAD = 0x0100U,
+    /**< Autoload table events. */
+
+    PA_SUBSCRIPTION_MASK_ALL = 0x01ffU
+    /**< Catch all events */
 } pa_subscription_mask_t;
 
 /** Subscription event types, as used by pa_context_subscribe() */
 typedef enum pa_subscription_event_type {
-    PA_SUBSCRIPTION_EVENT_SINK = 0,           /**< Event type: Sink */
-    PA_SUBSCRIPTION_EVENT_SOURCE = 1,         /**< Event type: Source */
-    PA_SUBSCRIPTION_EVENT_SINK_INPUT = 2,     /**< Event type: Sink input */
-    PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 3,  /**< Event type: Source output */
-    PA_SUBSCRIPTION_EVENT_MODULE = 4,         /**< Event type: Module */
-    PA_SUBSCRIPTION_EVENT_CLIENT = 5,         /**< Event type: Client */
-    PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 6,   /**< Event type: Sample cache item */
-    PA_SUBSCRIPTION_EVENT_SERVER = 7,         /**< Event type: Global server change, only occuring with PA_SUBSCRIPTION_EVENT_CHANGE. */
-    PA_SUBSCRIPTION_EVENT_AUTOLOAD = 8,       /**< Event type: Autoload table changes. */
-    PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 15, /**< A mask to extract the event type from an event value */
-
-    PA_SUBSCRIPTION_EVENT_NEW = 0,            /**< A new object was created */
-    PA_SUBSCRIPTION_EVENT_CHANGE = 16,        /**< A property of the object was modified */
-    PA_SUBSCRIPTION_EVENT_REMOVE = 32,        /**< An object was removed */
-    PA_SUBSCRIPTION_EVENT_TYPE_MASK = 16+32   /**< A mask to extract the event operation from an event value */
+    PA_SUBSCRIPTION_EVENT_SINK = 0x0000U,
+    /**< Event type: Sink */
+
+    PA_SUBSCRIPTION_EVENT_SOURCE = 0x0001U,
+    /**< Event type: Source */
+
+    PA_SUBSCRIPTION_EVENT_SINK_INPUT = 0x0002U,
+    /**< Event type: Sink input */
+
+    PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT = 0x0003U,
+    /**< Event type: Source output */
+
+    PA_SUBSCRIPTION_EVENT_MODULE = 0x0004U,
+    /**< Event type: Module */
+
+    PA_SUBSCRIPTION_EVENT_CLIENT = 0x0005U,
+    /**< Event type: Client */
+
+    PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE = 0x0006U,
+    /**< Event type: Sample cache item */
+
+    PA_SUBSCRIPTION_EVENT_SERVER = 0x0007U,
+    /**< Event type: Global server change, only occuring with PA_SUBSCRIPTION_EVENT_CHANGE. */
+
+    PA_SUBSCRIPTION_EVENT_AUTOLOAD = 0x0008U,
+    /**< Event type: Autoload table changes. */
+
+    PA_SUBSCRIPTION_EVENT_FACILITY_MASK = 0x000FU,
+    /**< A mask to extract the event type from an event value */
+
+    PA_SUBSCRIPTION_EVENT_NEW = 0x0000U,
+    /**< A new object was created */
+
+    PA_SUBSCRIPTION_EVENT_CHANGE = 0x0010U,
+    /**< A property of the object was modified */
+
+    PA_SUBSCRIPTION_EVENT_REMOVE = 0x0020U,
+    /**< An object was removed */
+
+    PA_SUBSCRIPTION_EVENT_TYPE_MASK = 0x0030U,
+    /**< A mask to extract the event operation from an event value */
+
 } pa_subscription_event_type_t;
 
 /** Return one if an event type t matches an event mask bitfield */
@@ -391,69 +417,71 @@ typedef enum pa_subscription_event_type {
  * note that this structure can be extended as part of evolutionary
  * API updates at any time in any new release.*/
 typedef struct pa_timing_info {
-    struct timeval timestamp; /**< The time when this timing info structure was current */
-    int synchronized_clocks;  /**< Non-zero if the local and the
-                               * remote machine have synchronized
-                               * clocks. If synchronized clocks are
-                               * detected transport_usec becomes much
-                               * more reliable. However, the code that
-                               * detects synchronized clocks is very
-                               * limited und unreliable itself. */
-
-    pa_usec_t sink_usec;      /**< Time in usecs a sample takes to be played on the sink. For playback streams and record streams connected to a monitor source. */
-    pa_usec_t source_usec;    /**< Time in usecs a sample takes from being recorded to being delivered to the application. Only for record streams. */
-    pa_usec_t transport_usec; /**< Estimated time in usecs a sample takes to be transferred to/from the daemon. For both playback and record streams. */
-
-    int playing;              /**< Non-zero when the stream is
-                               * currently not underrun and data is
-                               * being passed on to the device. Only
-                               * for playback streams. This field does
-                               * not say whether the data is actually
-                               * already being played. To determine
-                               * this check whether since_underrun
-                               * (converted to usec) is larger than
-                               * sink_usec.*/
-
-    int write_index_corrupt;  /**< Non-zero if write_index is not
-                               * up-to-date because a local write
-                               * command that corrupted it has been
-                               * issued in the time since this latency
-                               * info was current . Only write
-                               * commands with SEEK_RELATIVE_ON_READ
-                               * and SEEK_RELATIVE_END can corrupt
-                               * write_index. */
-    int64_t write_index;      /**< Current write index into the
-                               * playback buffer in bytes. Think twice before
-                               * using this for seeking purposes: it
-                               * might be out of date a the time you
-                               * want to use it. Consider using
-                               * PA_SEEK_RELATIVE instead.  */
-
-    int read_index_corrupt;   /**< Non-zero if read_index is not
-                               * up-to-date because a local pause or
-                               * flush request that corrupted it has
-                               * been issued in the time since this
-                               * latency info was current. */
-
-    int64_t read_index;       /**< Current read index into the
-                               * playback buffer in bytes. Think twice before
-                               * using this for seeking purposes: it
-                               * might be out of date a the time you
-                               * want to use it. Consider using
-                               * PA_SEEK_RELATIVE_ON_READ
-                               * instead. */
-
-    pa_usec_t configured_sink_usec;   /**< The configured latency for
-                                * the sink. \since 0.9.11 */
-    pa_usec_t configured_source_usec; /**< The configured latency for
-                                * the source. \since 0.9.11 */
-
-    int64_t since_underrun;    /**< Bytes that were handed to the sink
-                                  since the last underrun happened, or
-                                  since playback started again after
-                                  the last underrun. playing will tell
-                                  you which case it is. \since
-                                  0.9.11 */
+    struct timeval timestamp;
+    /**< The time when this timing info structure was current */
+
+    int synchronized_clocks;
+    /**< Non-zero if the local and the remote machine have
+     * synchronized clocks. If synchronized clocks are detected
+     * transport_usec becomes much more reliable. However, the code
+     * that detects synchronized clocks is very limited und unreliable
+     * itself. */
+
+    pa_usec_t sink_usec;
+    /**< Time in usecs a sample takes to be played on the sink. For
+     * playback streams and record streams connected to a monitor
+     * source. */
+
+    pa_usec_t source_usec;
+    /**< Time in usecs a sample takes from being recorded to being
+     * delivered to the application. Only for record streams. */
+
+    pa_usec_t transport_usec;
+    /**< Estimated time in usecs a sample takes to be transferred
+     * to/from the daemon. For both playback and record streams. */
+
+    int playing;
+    /**< Non-zero when the stream is currently not underrun and data
+     * is being passed on to the device. Only for playback
+     * streams. This field does not say whether the data is actually
+     * already being played. To determine this check whether
+     * since_underrun (converted to usec) is larger than sink_usec.*/
+
+    int write_index_corrupt;
+    /**< Non-zero if write_index is not up-to-date because a local
+     * write command that corrupted it has been issued in the time
+     * since this latency info was current . Only write commands with
+     * SEEK_RELATIVE_ON_READ and SEEK_RELATIVE_END can corrupt
+     * write_index. */
+
+    int64_t write_index;
+    /**< Current write index into the playback buffer in bytes. Think
+     * twice before using this for seeking purposes: it might be out
+     * of date a the time you want to use it. Consider using
+     * PA_SEEK_RELATIVE instead. */
+
+    int read_index_corrupt;
+    /**< Non-zero if read_index is not up-to-date because a local
+     * pause or flush request that corrupted it has been issued in the
+     * time since this latency info was current. */
+
+    int64_t read_index;
+    /**< Current read index into the playback buffer in bytes. Think
+     * twice before using this for seeking purposes: it might be out
+     * of date a the time you want to use it. Consider using
+     * PA_SEEK_RELATIVE_ON_READ instead. */
+
+    pa_usec_t configured_sink_usec;
+    /**< The configured latency for the sink. \since 0.9.11 */
+
+    pa_usec_t configured_source_usec;
+    /**< The configured latency for * the source. \since 0.9.11 */
+
+    int64_t since_underrun;
+    /**< Bytes that were handed to the sink since the last underrun
+     * happened, or since playback started again after the last
+     * underrun. playing will tell you which case it is. \since
+     * 0.9.11 */
 
 } pa_timing_info;
 
@@ -465,43 +493,81 @@ typedef struct pa_timing_info {
  * thread compatible way. You might have to do this in
  * prefork/postfork. */
 typedef struct pa_spawn_api {
-    void (*prefork)(void);     /**< Is called just before the fork in the parent process. May be NULL. */
-    void (*postfork)(void);    /**< Is called immediately after the fork in the parent process. May be NULL.*/
-    void (*atfork)(void);      /**< Is called immediately after the
-                                * fork in the child process. May be
-                                * NULL. It is not safe to close all
-                                * file descriptors in this function
-                                * unconditionally, since a UNIX socket
-                                * (created using socketpair()) is
-                                * passed to the new process. */
+    void (*prefork)(void);
+    /**< Is called just before the fork in the parent process. May be
+     * NULL. */
+
+    void (*postfork)(void);
+    /**< Is called immediately after the fork in the parent
+     * process. May be NULL.*/
+
+    void (*atfork)(void);
+    /**< Is called immediately after the fork in the child
+     * process. May be NULL. It is not safe to close all file
+     * descriptors in this function unconditionally, since a UNIX
+     * socket (created using socketpair()) is passed to the new
+     * process. */
 } pa_spawn_api;
 
 /** Seek type for pa_stream_write(). */
 typedef enum pa_seek_mode {
-    PA_SEEK_RELATIVE = 0,           /**< Seek relatively to the write index */
-    PA_SEEK_ABSOLUTE = 1,           /**< Seek relatively to the start of the buffer queue */
-    PA_SEEK_RELATIVE_ON_READ = 2,   /**< Seek relatively to the read index.  */
-    PA_SEEK_RELATIVE_END = 3        /**< Seek relatively to the current end of the buffer queue. */
+    PA_SEEK_RELATIVE = 0,
+    /**< Seek relatively to the write index */
+
+    PA_SEEK_ABSOLUTE = 1,
+    /**< Seek relatively to the start of the buffer queue */
+
+    PA_SEEK_RELATIVE_ON_READ = 2,
+    /**< Seek relatively to the read index.  */
+
+    PA_SEEK_RELATIVE_END = 3
+    /**< Seek relatively to the current end of the buffer queue. */
 } pa_seek_mode_t;
 
 /** Special sink flags. */
 typedef enum pa_sink_flags {
-    PA_SINK_HW_VOLUME_CTRL = 1,   /**< Supports hardware volume control */
-    PA_SINK_LATENCY = 2,          /**< Supports latency querying */
-    PA_SINK_HARDWARE = 4,         /**< Is a hardware sink of some kind, in contrast to "virtual"/software sinks \since 0.9.3 */
-    PA_SINK_NETWORK = 8,          /**< Is a networked sink of some kind. \since 0.9.7 */
-    PA_SINK_HW_MUTE_CTRL = 16,    /**< Supports hardware mute control \since 0.9.11 */
-    PA_SINK_DECIBEL_VOLUME = 32   /**< Volume can be translated to dB with pa_sw_volume_to_dB() \since 0.9.11 */
+    PA_SINK_HW_VOLUME_CTRL = 0x0001U,
+    /**< Supports hardware volume control */
+
+    PA_SINK_LATENCY = 0x0002U,
+    /**< Supports latency querying */
+
+    PA_SINK_HARDWARE = 0x0004U,
+    /**< Is a hardware sink of some kind, in contrast to
+     * "virtual"/software sinks \since 0.9.3 */
+
+    PA_SINK_NETWORK = 0x0008U,
+    /**< Is a networked sink of some kind. \since 0.9.7 */
+
+    PA_SINK_HW_MUTE_CTRL = 0x0010U,
+    /**< Supports hardware mute control \since 0.9.11 */
+
+    PA_SINK_DECIBEL_VOLUME = 0x0020U
+    /**< Volume can be translated to dB with pa_sw_volume_to_dB()
+     * \since 0.9.11 */
 } pa_sink_flags_t;
 
 /** Special source flags.  */
 typedef enum pa_source_flags {
-    PA_SOURCE_HW_VOLUME_CTRL = 1,  /**< Supports hardware volume control */
-    PA_SOURCE_LATENCY = 2,         /**< Supports latency querying */
-    PA_SOURCE_HARDWARE = 4,        /**< Is a hardware source of some kind, in contrast to "virtual"/software source \since 0.9.3 */
-    PA_SOURCE_NETWORK = 8,         /**< Is a networked sink of some kind. \since 0.9.7 */
-    PA_SOURCE_HW_MUTE_CTRL = 16,   /**< Supports hardware mute control \since 0.9.11 */
-    PA_SOURCE_DECIBEL_VOLUME = 32  /**< Volume can be translated to dB with pa_sw_volume_to_dB() \since 0.9.11 */
+    PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
+    /**< Supports hardware volume control */
+
+    PA_SOURCE_LATENCY = 0x0002U,
+    /**< Supports latency querying */
+
+    PA_SOURCE_HARDWARE = 0x0004U,
+    /**< Is a hardware source of some kind, in contrast to
+     * "virtual"/software source \since 0.9.3 */
+
+    PA_SOURCE_NETWORK = 0x0008U,
+    /**< Is a networked sink of some kind. \since 0.9.7 */
+
+    PA_SOURCE_HW_MUTE_CTRL = 0x0010U,
+    /**< Supports hardware mute control \since 0.9.11 */
+
+    PA_SOURCE_DECIBEL_VOLUME = 0x0020U
+    /**< Volume can be translated to dB with pa_sw_volume_to_dB()
+     * \since 0.9.11 */
 } pa_source_flags_t;
 
 /** A generic free() like callback prototype */
diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h
index ca79f5b..087bd9f 100644
--- a/src/pulse/introspect.h
+++ b/src/pulse/introspect.h
@@ -561,7 +561,7 @@ typedef enum pa_autoload_type {
 typedef struct pa_autoload_info {
     uint32_t index;               /**< Index of this autoload entry */
     const char *name;             /**< Name of the sink or source */
-    pa_autoload_type_t type;   /**< Type of the autoload entry */
+    pa_autoload_type_t type;      /**< Type of the autoload entry */
     const char *module;           /**< Module name to load */
     const char *argument;         /**< Argument string for module */
 } pa_autoload_info;
diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h
index 39d5330..c23ef23 100644
--- a/src/pulse/proplist.h
+++ b/src/pulse/proplist.h
@@ -168,9 +168,19 @@ int pa_proplist_get(pa_proplist *p, const char *key, const void **data, size_t *
 
 /** Update mode enum for pa_proplist_update(). \since 0.9.11 */
 typedef enum pa_update_mode {
-    PA_UPDATE_SET,  /*< Replace the entirey property list with the new one. Don't keep any of the old data around */
-    PA_UPDATE_MERGE, /*< Merge new property list into the existing one, not replacing any old entries if they share a common key with the new property list. */
-    PA_UPDATE_REPLACE /*< Merge new property list into the existing one, replacing all old entries that share a common key with  the new property list. */
+    PA_UPDATE_SET,
+    /*< Replace the entirey property list with the new one. Don't keep
+     *  any of the old data around */
+
+    PA_UPDATE_MERGE,
+    /*< Merge new property list into the existing one, not replacing
+     *  any old entries if they share a common key with the new
+     *  property list. */
+
+    PA_UPDATE_REPLACE
+    /*< Merge new property list into the existing one, replacing all
+     *  old entries that share a common key with the new property
+     *  list. */
 } pa_update_mode_t;
 
 /** Merge property list "other" into "p", adhering the merge mode as
diff --git a/src/pulse/sample.h b/src/pulse/sample.h
index 7061272..6bf146c 100644
--- a/src/pulse/sample.h
+++ b/src/pulse/sample.h
@@ -120,17 +120,38 @@ PA_C_DECL_BEGIN
 
 /** Sample format */
 typedef enum pa_sample_format {
-    PA_SAMPLE_U8,              /**< Unsigned 8 Bit PCM */
-    PA_SAMPLE_ALAW,            /**< 8 Bit a-Law */
-    PA_SAMPLE_ULAW,            /**< 8 Bit mu-Law */
-    PA_SAMPLE_S16LE,           /**< Signed 16 Bit PCM, little endian (PC) */
-    PA_SAMPLE_S16BE,           /**< Signed 16 Bit PCM, big endian */
-    PA_SAMPLE_FLOAT32LE,       /**< 32 Bit IEEE floating point, little endian, range -1 to 1 */
-    PA_SAMPLE_FLOAT32BE,       /**< 32 Bit IEEE floating point, big endian, range -1 to 1 */
-    PA_SAMPLE_S32LE,           /**< Signed 32 Bit PCM, little endian (PC) */
-    PA_SAMPLE_S32BE,           /**< Signed 32 Bit PCM, big endian (PC) */
-    PA_SAMPLE_MAX,             /**< Upper limit of valid sample types */
-    PA_SAMPLE_INVALID = -1     /**< An invalid value */
+    PA_SAMPLE_U8,
+    /**< Unsigned 8 Bit PCM */
+
+    PA_SAMPLE_ALAW,
+    /**< 8 Bit a-Law */
+
+    PA_SAMPLE_ULAW,
+    /**< 8 Bit mu-Law */
+
+    PA_SAMPLE_S16LE,
+    /**< Signed 16 Bit PCM, little endian (PC) */
+
+    PA_SAMPLE_S16BE,
+    /**< Signed 16 Bit PCM, big endian */
+
+    PA_SAMPLE_FLOAT32LE,
+    /**< 32 Bit IEEE floating point, little endian, range -1 to 1 */
+
+    PA_SAMPLE_FLOAT32BE,
+    /**< 32 Bit IEEE floating point, big endian, range -1 to 1 */
+
+    PA_SAMPLE_S32LE,
+    /**< Signed 32 Bit PCM, little endian (PC) */
+
+    PA_SAMPLE_S32BE,
+    /**< Signed 32 Bit PCM, big endian (PC) */
+
+    PA_SAMPLE_MAX,
+    /**< Upper limit of valid sample types */
+
+    PA_SAMPLE_INVALID = -1
+    /**< An invalid value */
 } pa_sample_format_t;
 
 #ifdef WORDS_BIGENDIAN
@@ -166,9 +187,14 @@ typedef enum pa_sample_format {
 
 /** A sample format and attribute specification */
 typedef struct pa_sample_spec {
-    pa_sample_format_t format;     /**< The sample format */
-    uint32_t rate;                 /**< The sample rate. (e.g. 44100) */
-    uint8_t channels;              /**< Audio channels. (1 for mono, 2 for stereo, ...) */
+    pa_sample_format_t format;
+    /**< The sample format */
+
+    uint32_t rate;
+    /**< The sample rate. (e.g. 44100) */
+
+    uint8_t channels;
+    /**< Audio channels. (1 for mono, 2 for stereo, ...) */
 } pa_sample_spec;
 
 /** Type for usec specifications (unsigned). Always 64 bit. */

commit 79009d223582277c389ed1bfae792cbfbbc061e7
Author: Marc-André Lureau <marcandre.lureau at gmail.com>
Date:   Mon Sep 1 16:00:08 2008 +0300

    command_get_info() segv in some conditions
    
    Signed-off-by: Lennart Poettering <lennart at poettering.net>

diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 06245d1..6ccee57 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -2791,7 +2791,7 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
     pa_sink_input *si = NULL;
     pa_source_output *so = NULL;
     pa_scache_entry *sce = NULL;
-    const char *name;
+    const char *name = NULL;
     pa_tagstruct *reply;
 
     pa_native_connection_assert_ref(c);

commit cbd8e60f6cae11d3f26c8cd4ce27450e877f259f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 3 19:51:12 2008 +0200

    use PA_STREAM_EARLY_REQUESTS for OSS streams

diff --git a/src/utils/padsp.c b/src/utils/padsp.c
index 2c88c48..f2fdede 100644
--- a/src/utils/padsp.c
+++ b/src/utils/padsp.c
@@ -1003,7 +1003,7 @@ static int create_playback_stream(fd_info *i) {
     attr.prebuf = (uint32_t) i->fragment_size;
     attr.minreq = (uint32_t) i->fragment_size;
 
-    flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE;
+    flags = PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE|PA_STREAM_EARLY_REQUESTS;
     if (i->play_precork) {
         flags |= PA_STREAM_START_CORKED;
         debug(DEBUG_LEVEL_NORMAL, __FILE__": creating stream corked\n");

commit bf403fe0d8bbb159e80b2edddb74c6ea37ec372b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Sep 3 19:51:33 2008 +0200

    introduce macros for all flags so that clients can check for them with #ifdef

diff --git a/src/pulse/def.h b/src/pulse/def.h
index c71e033..66d9aff 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -87,6 +87,11 @@ typedef enum pa_context_flags {
     /**< Disabled autospawning of the PulseAudio daemon if required */
 } pa_context_flags_t;
 
+/** \cond fulldocs */
+/* Allow clients to check with #ifdef for those flags */
+#define PA_CONTEXT_NOAUTOSPAWN PA_CONTEXT_NOAUTOSPAWN
+/** \endcond */
+
 /** The direction of a pa_stream object */
 typedef enum pa_stream_direction {
     PA_STREAM_NODIRECTION,   /**< Invalid direction */
@@ -219,9 +224,26 @@ typedef enum pa_stream_flags {
 
 /** \cond fulldocs */
 
-/** English is an evil language */
+/* English is an evil language */
 #define PA_STREAM_NOT_MONOTONOUS PA_STREAM_NOT_MONOTONIC
 
+/* Allow clients to check with #ifdef for those flags */
+#define PA_STREAM_START_CORKED PA_STREAM_START_CORKED
+#define PA_STREAM_INTERPOLATE_TIMING PA_STREAM_INTERPOLATE_TIMING
+#define PA_STREAM_NOT_MONOTONIC PA_STREAM_NOT_MONOTONIC
+#define PA_STREAM_AUTO_TIMING_UPDATE PA_STREAM_AUTO_TIMING_UPDATE
+#define PA_STREAM_NO_REMAP_CHANNELS PA_STREAM_NO_REMAP_CHANNELS
+#define PA_STREAM_NO_REMIX_CHANNELS PA_STREAM_NO_REMIX_CHANNELS
+#define PA_STREAM_FIX_FORMAT PA_STREAM_FIX_FORMAT
+#define PA_STREAM_FIX_RATE PA_STREAM_FIX_RATE
+#define PA_STREAM_FIX_CHANNELS PA_STREAM_FIX_CHANNELS
+#define PA_STREAM_DONT_MOVE PA_STREAM_DONT_MOVE
+#define PA_STREAM_VARIABLE_RATE PA_STREAM_VARIABLE_RATE
+#define PA_STREAM_PEAK_DETECT PA_STREAM_PEAK_DETECT
+#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
+
 /** \endcond */
 
 /** Playback and record buffer metrics */
@@ -547,6 +569,15 @@ typedef enum pa_sink_flags {
      * \since 0.9.11 */
 } pa_sink_flags_t;
 
+/** \cond fulldocs */
+#define PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL
+#define PA_SINK_LATENCY PA_SINK_LATENCY
+#define PA_SINK_HARDWARE PA_SINK_HARDWARE
+#define PA_SINK_NETWORK PA_SINK_NETWORK
+#define PA_SINK_HW_VOLUME_CTRL PA_SINK_HW_VOLUME_CTRL
+#define PA_SINK_DECIBEL_VOLUME PA_SINK_DECIBEL_VOLUME
+/** \endcond */
+
 /** Special source flags.  */
 typedef enum pa_source_flags {
     PA_SOURCE_HW_VOLUME_CTRL = 0x0001U,
@@ -570,6 +601,15 @@ typedef enum pa_source_flags {
      * \since 0.9.11 */
 } pa_source_flags_t;
 
+/** \cond fulldocs */
+#define PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL
+#define PA_SOURCE_LATENCY PA_SOURCE_LATENCY
+#define PA_SOURCE_HARDWARE PA_SOURCE_HARDWARE
+#define PA_SOURCE_NETWORK PA_SOURCE_NETWORK
+#define PA_SOURCE_HW_VOLUME_CTRL PA_SOURCE_HW_VOLUME_CTRL
+#define PA_SOURCE_DECIBEL_VOLUME PA_SOURCE_DECIBEL_VOLUME
+/** \endcond */
+
 /** A generic free() like callback prototype */
 typedef void (*pa_free_cb_t)(void *p);
 
diff --git a/src/pulse/sample.h b/src/pulse/sample.h
index 6bf146c..3f1b2fc 100644
--- a/src/pulse/sample.h
+++ b/src/pulse/sample.h
@@ -185,6 +185,19 @@ typedef enum pa_sample_format {
 /** A Shortcut for PA_SAMPLE_FLOAT32NE */
 #define PA_SAMPLE_FLOAT32 PA_SAMPLE_FLOAT32NE
 
+/** \cond fulldocs */
+/* Allow clients to check with #ifdef for thse sample formats */
+#define PA_SAMPLE_U8 PA_SAMPLE_U8
+#define PA_SAMPLE_ALAW PA_SAMPLE_ALAW
+#define PA_SAMPLE_ULAW PA_SAMPLE_ULAW
+#define PA_SAMPLE_S16LE PA_SAMPLE_S16LE
+#define PA_SAMPLE_S16BE PA_SAMPLE_S16BE
+#define PA_SAMPLE_FLOAT32LE PA_SAMPLE_FLOAT32LE
+#define PA_SAMPLE_FLOAT32BE PA_SAMPLE_FLOAT32BE
+#define PA_SAMPLE_S32LE PA_SAMPLE_S32LE
+#define PA_SAMPLE_S32BE PA_SAMPLE_S32BE
+/** \endcond */
+
 /** A sample format and attribute specification */
 typedef struct pa_sample_spec {
     pa_sample_format_t format;

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list