[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test7-36-ge61728e

Lennart Poettering gitmailer-noreply at 0pointer.de
Mon Apr 6 13:15:53 PDT 2009


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

The master branch has been updated
      from  7fc2382a0aaaec70401468940afd266252bda178 (commit)

- Log -----------------------------------------------------------------
e61728e Make sure we don't get stuck when prebuf is too high
ff8d66d extend documentation for pa_stream_cork() a bit
-----------------------------------------------------------------------

Summary of changes:
 src/pulse/stream.h              |   11 +++++++-
 src/pulsecore/memblockq.c       |   52 +++++++++++++++++---------------------
 src/pulsecore/protocol-native.c |    9 ++++--
 3 files changed, 39 insertions(+), 33 deletions(-)

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

commit ff8d66d82ec70c18e477f94a965eef4675222d84
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Apr 6 22:06:50 2009 +0200

    extend documentation for pa_stream_cork() a bit

diff --git a/src/pulse/stream.h b/src/pulse/stream.h
index 8e99a75..8993143 100644
--- a/src/pulse/stream.h
+++ b/src/pulse/stream.h
@@ -519,7 +519,16 @@ void pa_stream_set_event_callback(pa_stream *p, pa_stream_event_cb_t cb, void *u
  * pa_stream_set_moved_callback() as well. \since 0.9.15 */
 void pa_stream_set_buffer_attr_callback(pa_stream *p, pa_stream_notify_cb_t cb, void *userdata);
 
-/** Pause (or resume) playback of this stream temporarily. Available on both playback and recording streams. */
+/** Pause (or resume) playback of this stream temporarily. Available
+ * on both playback and recording streams. If b is 1 the stream is
+ * paused. If b is 0 the stream is resumed. The pause/resume operation
+ * is executed as quickly as possible. If a cork is very quickly
+ * followed by an uncork or the other way round this might not
+ * actually have any effect on the stream that is output. You can use
+ * pa_stream_is_corked() to find out whether the stream is currently
+ * paused or not. Normally a stream will be created in uncorked
+ * state. If you pass PA_STREAM_START_CORKED as flag during connection
+ * of the stream it will be created in corked state. */
 pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, void *userdata);
 
 /** Flush the playback buffer of this stream. Most of the time you're

commit e61728e67a656c0bbd12b13bb4c1777d0e3163f4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Mon Apr 6 22:09:38 2009 +0200

    Make sure we don't get stuck when prebuf is too high
    
    If prebuf is greater than tlength minus minreq we might end up waiting
    for the buffer to fill up further however without ever asking for more
    data from the client since less minreq bytes might be missing.
    
    This fixes bug #440

diff --git a/src/pulsecore/memblockq.c b/src/pulsecore/memblockq.c
index d12d13a..77f9efc 100644
--- a/src/pulsecore/memblockq.c
+++ b/src/pulsecore/memblockq.c
@@ -90,8 +90,8 @@ pa_memblockq* pa_memblockq_new(
 
     pa_memblockq_set_maxlength(bq, maxlength);
     pa_memblockq_set_tlength(bq, tlength);
-    pa_memblockq_set_prebuf(bq, prebuf);
     pa_memblockq_set_minreq(bq, minreq);
+    pa_memblockq_set_prebuf(bq, prebuf);
     pa_memblockq_set_maxrewind(bq, maxrewind);
 
     pa_log_debug("memblockq sanitized: maxlength=%lu, tlength=%lu, base=%lu, prebuf=%lu, minreq=%lu maxrewind=%lu",
@@ -784,16 +784,13 @@ void pa_memblockq_set_maxlength(pa_memblockq *bq, size_t maxlength) {
 
     if (bq->tlength > bq->maxlength)
         pa_memblockq_set_tlength(bq, bq->maxlength);
-
-    if (bq->prebuf > bq->maxlength)
-        pa_memblockq_set_prebuf(bq, bq->maxlength);
 }
 
 void pa_memblockq_set_tlength(pa_memblockq *bq, size_t tlength) {
     size_t old_tlength;
     pa_assert(bq);
 
-    if (tlength <= 0)
+    if (tlength <= 0 || tlength == (size_t) -1)
         tlength = bq->maxlength;
 
     old_tlength = bq->tlength;
@@ -802,49 +799,46 @@ void pa_memblockq_set_tlength(pa_memblockq *bq, size_t tlength) {
     if (bq->tlength > bq->maxlength)
         bq->tlength = bq->maxlength;
 
-    if (bq->prebuf > bq->tlength)
-        pa_memblockq_set_prebuf(bq, bq->tlength);
-
     if (bq->minreq > bq->tlength)
         pa_memblockq_set_minreq(bq, bq->tlength);
 
+    if (bq->prebuf > bq->tlength+bq->base-bq->minreq)
+        pa_memblockq_set_prebuf(bq, bq->tlength+bq->base-bq->minreq);
+
     bq->missing += (int64_t) bq->tlength - (int64_t) old_tlength;
 }
 
+void pa_memblockq_set_minreq(pa_memblockq *bq, size_t minreq) {
+    pa_assert(bq);
+
+    bq->minreq = (minreq/bq->base)*bq->base;
+
+    if (bq->minreq > bq->tlength)
+        bq->minreq = bq->tlength;
+
+    if (bq->minreq < bq->base)
+        bq->minreq = bq->base;
+
+    if (bq->prebuf > bq->tlength+bq->base-bq->minreq)
+        pa_memblockq_set_prebuf(bq, bq->tlength+bq->base-bq->minreq);
+}
+
 void pa_memblockq_set_prebuf(pa_memblockq *bq, size_t prebuf) {
     pa_assert(bq);
 
     if (prebuf == (size_t) -1)
-        prebuf = bq->tlength;
+        prebuf = bq->tlength+bq->base-bq->minreq;
 
     bq->prebuf = ((prebuf+bq->base-1)/bq->base)*bq->base;
 
     if (prebuf > 0 && bq->prebuf < bq->base)
         bq->prebuf = bq->base;
 
-    if (bq->prebuf > bq->tlength)
-        bq->prebuf = bq->tlength;
+    if (bq->prebuf > bq->tlength+bq->base-bq->minreq)
+        bq->prebuf = bq->tlength+bq->base-bq->minreq;
 
     if (bq->prebuf <= 0 || pa_memblockq_get_length(bq) >= bq->prebuf)
         bq->in_prebuf = FALSE;
-
-    if (bq->minreq > bq->prebuf)
-        pa_memblockq_set_minreq(bq, bq->prebuf);
-}
-
-void pa_memblockq_set_minreq(pa_memblockq *bq, size_t minreq) {
-    pa_assert(bq);
-
-    bq->minreq = (minreq/bq->base)*bq->base;
-
-    if (bq->minreq > bq->tlength)
-        bq->minreq = bq->tlength;
-
-    if (bq->minreq > bq->prebuf)
-        bq->minreq = bq->prebuf;
-
-    if (bq->minreq < bq->base)
-        bq->minreq = bq->base;
 }
 
 void pa_memblockq_set_maxrewind(pa_memblockq *bq, size_t maxrewind) {
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 59e5d80..edcd598 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -850,7 +850,7 @@ static int playback_stream_process_msg(pa_msgobject *o, int code, void*userdata,
 
 /* Called from main context */
 static void fix_playback_buffer_attr(playback_stream *s) {
-    size_t frame_size;
+    size_t frame_size, max_prebuf;
     pa_usec_t orig_tlength_usec, tlength_usec, orig_minreq_usec, minreq_usec, sink_usec;
 
     pa_assert(s);
@@ -976,8 +976,11 @@ static void fix_playback_buffer_attr(playback_stream *s) {
     if (s->buffer_attr.tlength <= s->buffer_attr.minreq)
         s->buffer_attr.tlength = s->buffer_attr.minreq*2 + (uint32_t) frame_size;
 
-    if (s->buffer_attr.prebuf == (uint32_t) -1 || s->buffer_attr.prebuf > s->buffer_attr.tlength)
-        s->buffer_attr.prebuf = s->buffer_attr.tlength;
+    max_prebuf = s->buffer_attr.tlength + (uint32_t)frame_size - s->buffer_attr.minreq;
+
+    if (s->buffer_attr.prebuf == (uint32_t) -1 ||
+        s->buffer_attr.prebuf > max_prebuf)
+        s->buffer_attr.prebuf = max_prebuf;
 }
 
 /* Called from main context */

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list