[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.13-246-g75119e9

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Jan 14 15:40:15 PST 2009


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

The master branch has been updated
      from  20edd846d073507adcfd30d2eb678f965de37e2d (commit)

- Log -----------------------------------------------------------------
75119e9... add new dont_rewind_render flag to allow quick starts of newly created streams
06de639... don't rely on PA_SINK_RUNNING vs. PA_SINK_IDLE for optimizations since it might not be fully up to date
d1cf0e7... fix a potential format string vulnerability
fd3f5db... document that PA_API_VERSION is only for incompatible API changes
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-combine.c      |    2 +-
 src/modules/module-ladspa-sink.c  |    4 ++--
 src/modules/module-remap-sink.c   |    4 ++--
 src/modules/module-sine.c         |    2 +-
 src/modules/rtp/module-rtp-recv.c |    2 +-
 src/pulse/version.h.in            |    3 ++-
 src/pulsecore/play-memblockq.c    |    2 +-
 src/pulsecore/protocol-esound.c   |    2 +-
 src/pulsecore/protocol-native.c   |    4 ++--
 src/pulsecore/protocol-simple.c   |    2 +-
 src/pulsecore/shared.c            |    2 +-
 src/pulsecore/sink-input.c        |   23 ++++++++++++++++-------
 src/pulsecore/sink-input.h        |    5 +++--
 src/pulsecore/sink.c              |   10 ++++------
 src/pulsecore/sound-file-stream.c |    2 +-
 src/pulsecore/source.c            |    6 ------
 16 files changed, 39 insertions(+), 36 deletions(-)

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

commit fd3f5db63c322f6a01bfd62895add2eac94f61b4
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 15 00:03:33 2009 +0100

    document that PA_API_VERSION is only for incompatible API changes

diff --git a/src/pulse/version.h.in b/src/pulse/version.h.in
index e6226c4..0e37f98 100644
--- a/src/pulse/version.h.in
+++ b/src/pulse/version.h.in
@@ -43,7 +43,8 @@ const char* pa_get_library_version(void);
 
 /** The current API version. Version 6 relates to Polypaudio
  * 0.6. Prior versions (i.e. Polypaudio 0.5.1 and older) have
- * PA_API_VERSION undefined.  */
+ * PA_API_VERSION undefined. Please note that this is only ever
+ * increased on incompatible API changes!  */
 #define PA_API_VERSION @PA_API_VERSION@
 
 /** The current protocol version. Version 8 relates to Polypaudio

commit d1cf0e7845b3944fb676a46b528bea519b41e42b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 15 00:03:56 2009 +0100

    fix a potential format string vulnerability

diff --git a/src/pulsecore/shared.c b/src/pulsecore/shared.c
index 4c1ad80..d6e42dd 100644
--- a/src/pulsecore/shared.c
+++ b/src/pulsecore/shared.c
@@ -115,7 +115,7 @@ void pa_shared_cleanup(pa_core *c) {
         pa_strbuf *s = pa_strbuf_new();
 
         pa_shared_dump(c, s);
-        pa_log_debug(pa_strbuf_tostring(s));
+        pa_log_debug("%s", pa_strbuf_tostring(s));
         pa_strbuf_free(s);
         pa_assert(pa_hashmap_isempty(c->shared));
     }

commit 06de6393d1426110c2b0d20a6bbc2685c2138e25
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 15 00:07:38 2009 +0100

    don't rely on PA_SINK_RUNNING vs. PA_SINK_IDLE for optimizations since it might not be fully up to date

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 48c8f79..3a66238 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -642,7 +642,7 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
 
     pa_assert(length > 0);
 
-    n = s->thread_info.state == PA_SINK_RUNNING ? fill_mix_info(s, &length, info, MAX_MIX_CHANNELS) : 0;
+    n = fill_mix_info(s, &length, info, MAX_MIX_CHANNELS);
 
     if (n == 0) {
 
@@ -685,8 +685,7 @@ void pa_sink_render(pa_sink*s, size_t length, pa_memchunk *result) {
         result->index = 0;
     }
 
-    if (s->thread_info.state == PA_SINK_RUNNING)
-        inputs_drop(s, info, n, result);
+    inputs_drop(s, info, n, result);
 
     pa_sink_unref(s);
 }
@@ -716,7 +715,7 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
 
     pa_assert(length > 0);
 
-    n = s->thread_info.state == PA_SINK_RUNNING ? fill_mix_info(s, &length, info, MAX_MIX_CHANNELS) : 0;
+    n = fill_mix_info(s, &length, info, MAX_MIX_CHANNELS);
 
     if (n == 0) {
         if (target->length > length)
@@ -765,8 +764,7 @@ void pa_sink_render_into(pa_sink*s, pa_memchunk *target) {
         pa_memblock_release(target->memblock);
     }
 
-    if (s->thread_info.state == PA_SINK_RUNNING)
-        inputs_drop(s, info, n, target);
+    inputs_drop(s, info, n, target);
 
     pa_sink_unref(s);
 }
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index e65c5ce..dee6f3d 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -429,9 +429,6 @@ void pa_source_post(pa_source*s, const pa_memchunk *chunk) {
     pa_assert(PA_SOURCE_IS_OPENED(s->thread_info.state));
     pa_assert(chunk);
 
-    if (s->thread_info.state != PA_SOURCE_RUNNING)
-        return;
-
     if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&s->thread_info.soft_volume)) {
         pa_memchunk vchunk = *chunk;
 
@@ -470,9 +467,6 @@ void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *
     pa_assert(o->thread_info.direct_on_input);
     pa_assert(chunk);
 
-    if (s->thread_info.state != PA_SOURCE_RUNNING)
-        return;
-
     if (s->thread_info.soft_muted || !pa_cvolume_is_norm(&s->thread_info.soft_volume)) {
         pa_memchunk vchunk = *chunk;
 

commit 75119e91cdb4f29b0567689d07d00ddc17a98b5c
Author: Lennart Poettering <lennart at poettering.net>
Date:   Thu Jan 15 00:40:06 2009 +0100

    add new dont_rewind_render flag to allow quick starts of newly created streams

diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index d61d127..fa80781 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -504,7 +504,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
      * we are heard right-away. */
     if (PA_SINK_INPUT_IS_LINKED(state) &&
         i->thread_info.state == PA_SINK_INPUT_INIT)
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
 }
 
 /* Called from thread context */
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index a27ed71..4209e99 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -144,7 +144,7 @@ static void sink_request_rewind(pa_sink *s) {
     pa_assert_se(u = s->userdata);
 
     /* Just hand this one over to the master sink */
-    pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes + pa_memblockq_get_length(u->memblockq), TRUE, FALSE);
+    pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes + pa_memblockq_get_length(u->memblockq), TRUE, FALSE, FALSE);
 }
 
 /* Called from I/O thread context */
@@ -355,7 +355,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
     if (PA_SINK_INPUT_IS_LINKED(state) &&
         i->thread_info.state == PA_SINK_INPUT_INIT) {
         pa_log_debug("Requesting rewind due to state change.");
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
     }
 }
 
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 976a8ce..ae05f07 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -119,7 +119,7 @@ static void sink_request_rewind(pa_sink *s) {
     pa_sink_assert_ref(s);
     pa_assert_se(u = s->userdata);
 
-    pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes, TRUE, FALSE);
+    pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes, TRUE, FALSE, FALSE);
 }
 
 /* Called from I/O thread context */
@@ -270,7 +270,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
     if (PA_SINK_INPUT_IS_LINKED(state) &&
         i->thread_info.state == PA_SINK_INPUT_INIT) {
         pa_log_debug("Requesting rewind due to state change.");
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
     }
 }
 
diff --git a/src/modules/module-sine.c b/src/modules/module-sine.c
index 3b0dc35..2ea78da 100644
--- a/src/modules/module-sine.c
+++ b/src/modules/module-sine.c
@@ -115,7 +115,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
      * we are heard right-away. */
     if (PA_SINK_INPUT_IS_LINKED(state) &&
         i->thread_info.state == PA_SINK_INPUT_INIT)
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
 }
 
 int pa__init(pa_module*m) {
diff --git a/src/modules/rtp/module-rtp-recv.c b/src/modules/rtp/module-rtp-recv.c
index e35773c..478e0a3 100644
--- a/src/modules/rtp/module-rtp-recv.c
+++ b/src/modules/rtp/module-rtp-recv.c
@@ -313,7 +313,7 @@ static int rtpoll_work_cb(pa_rtpoll_item *i) {
     if (pa_memblockq_is_readable(s->memblockq) &&
         s->sink_input->thread_info.underrun_for > 0) {
         pa_log_debug("Requesting rewind due to end of underrun");
-        pa_sink_input_request_rewind(s->sink_input, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(s->sink_input, 0, FALSE, TRUE, FALSE);
     }
 
     return 1;
diff --git a/src/pulsecore/play-memblockq.c b/src/pulsecore/play-memblockq.c
index 86edfe9..758c0de 100644
--- a/src/pulsecore/play-memblockq.c
+++ b/src/pulsecore/play-memblockq.c
@@ -109,7 +109,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
      * we are heard right-away. */
     if (PA_SINK_INPUT_IS_LINKED(state) &&
         i->thread_info.state == PA_SINK_INPUT_INIT)
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
 }
 
 static int sink_input_pop_cb(pa_sink_input *i, size_t nbytes, pa_memchunk *chunk) {
diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c
index 460119a..2f01482 100644
--- a/src/pulsecore/protocol-esound.c
+++ b/src/pulsecore/protocol-esound.c
@@ -1238,7 +1238,7 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
 
             if (pa_memblockq_is_readable(c->input_memblockq) && c->playback.underrun) {
                 pa_log_debug("Requesting rewind due to end of underrun.");
-                pa_sink_input_request_rewind(c->sink_input, 0, FALSE, TRUE);
+                pa_sink_input_request_rewind(c->sink_input, 0, FALSE, TRUE, FALSE);
             }
 
 /*             pa_log("got data, %u", pa_memblockq_get_length(c->input_memblockq)); */
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 3c1e576..7cce3db 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -1240,7 +1240,7 @@ static void handle_seek(playback_stream *s, int64_t indexw) {
             pa_log_debug("Requesting rewind due to end of underrun.");
             pa_sink_input_request_rewind(s->sink_input,
                                          (size_t) (s->sink_input->thread_info.underrun_for == (size_t) -1 ? 0 : s->sink_input->thread_info.underrun_for),
-                                         FALSE, TRUE);
+                                         FALSE, TRUE, FALSE);
         }
 
     } else {
@@ -1253,7 +1253,7 @@ static void handle_seek(playback_stream *s, int64_t indexw) {
              * let's have it usk us again */
 
             pa_log_debug("Requesting rewind due to rewrite.");
-            pa_sink_input_request_rewind(s->sink_input, (size_t) (indexr - indexw), TRUE, FALSE);
+            pa_sink_input_request_rewind(s->sink_input, (size_t) (indexr - indexw), TRUE, FALSE, FALSE);
         }
     }
 
diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c
index 743bf2e..9c4a538 100644
--- a/src/pulsecore/protocol-simple.c
+++ b/src/pulsecore/protocol-simple.c
@@ -323,7 +323,7 @@ static int sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int
 
             if (pa_memblockq_is_readable(c->input_memblockq) && c->playback.underrun) {
                 pa_log_debug("Requesting rewind due to end of underrun.");
-                pa_sink_input_request_rewind(c->sink_input, 0, FALSE, TRUE);
+                pa_sink_input_request_rewind(c->sink_input, 0, FALSE, TRUE, FALSE);
             }
 
 /*             pa_log("got data, %u", pa_memblockq_get_length(c->input_memblockq)); */
diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 33490cc..f5a1cb8 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -265,6 +265,7 @@ pa_sink_input* pa_sink_input_new(
     i->thread_info.requested_sink_latency = (pa_usec_t) -1;
     i->thread_info.rewrite_nbytes = 0;
     i->thread_info.rewrite_flush = FALSE;
+    i->thread_info.dont_rewind_render = FALSE;
     i->thread_info.underrun_for = (uint64_t) -1;
     i->thread_info.playing_for = 0;
     i->thread_info.direct_outputs = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
@@ -658,7 +659,7 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam
 
     lbq = pa_memblockq_get_length(i->thread_info.render_memblockq);
 
-    if (nbytes > 0) {
+    if (nbytes > 0 && !i->thread_info.dont_rewind_render) {
         pa_log_debug("Have to rewind %lu bytes on render memblockq.", (unsigned long) nbytes);
         pa_memblockq_rewind(i->thread_info.render_memblockq, nbytes);
     }
@@ -714,6 +715,7 @@ void pa_sink_input_process_rewind(pa_sink_input *i, size_t nbytes /* in sink sam
 
     i->thread_info.rewrite_nbytes = 0;
     i->thread_info.rewrite_flush = FALSE;
+    i->thread_info.dont_rewind_render = FALSE;
 }
 
 /* Called from thread context */
@@ -1091,7 +1093,7 @@ void pa_sink_input_set_state_within_thread(pa_sink_input *i, pa_sink_input_state
 
         /* This will tell the implementing sink input driver to rewind
          * so that the unplayed already mixed data is not lost */
-        pa_sink_input_request_rewind(i, 0, TRUE, TRUE);
+        pa_sink_input_request_rewind(i, 0, TRUE, TRUE, FALSE);
 
     } else if (uncorking) {
 
@@ -1102,7 +1104,7 @@ void pa_sink_input_set_state_within_thread(pa_sink_input *i, pa_sink_input_state
 
         /* OK, we're being uncorked. Make sure we're not rewound when
          * the hw buffer is remixed and request a remix. */
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
     }
 }
 
@@ -1115,12 +1117,12 @@ int pa_sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int64_t
 
         case PA_SINK_INPUT_MESSAGE_SET_VOLUME:
             i->thread_info.volume = *((pa_cvolume*) userdata);
-            pa_sink_input_request_rewind(i, 0, TRUE, FALSE);
+            pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
             return 0;
 
         case PA_SINK_INPUT_MESSAGE_SET_MUTE:
             i->thread_info.muted = PA_PTR_TO_UINT(userdata);
-            pa_sink_input_request_rewind(i, 0, TRUE, FALSE);
+            pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
             return 0;
 
         case PA_SINK_INPUT_MESSAGE_GET_LATENCY: {
@@ -1195,7 +1197,7 @@ pa_bool_t pa_sink_input_safe_to_remove(pa_sink_input *i) {
 }
 
 /* Called from IO context */
-void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sample spec */, pa_bool_t rewrite, pa_bool_t flush) {
+void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sample spec */, pa_bool_t rewrite, pa_bool_t flush, pa_bool_t dont_rewind_render) {
     size_t lbq;
 
     /* If 'rewrite' is TRUE the sink is rewound as far as requested
@@ -1206,7 +1208,9 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sam
      * If 'rewrite' is FALSE the sink is rewound as far as requested
      * and possible and the already rendered data is dropped so that
      * in the next iteration we read new data from the
-     * implementor. This implies 'flush' is TRUE. */
+     * implementor. This implies 'flush' is TRUE.  If
+     * dont_rewind_render is TRUE then the render memblockq is not
+     * rewound. */
 
     pa_sink_input_assert_ref(i);
 
@@ -1219,6 +1223,7 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sam
         return;
 
     pa_assert(rewrite || flush);
+    pa_assert(!dont_rewind_render || !rewrite);
 
     /* Calculate how much we can rewind locally without having to
      * touch the sink */
@@ -1253,6 +1258,10 @@ void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes  /* in our sam
         i->thread_info.rewrite_flush ||
         (flush && i->thread_info.rewrite_nbytes != 0);
 
+    i->thread_info.dont_rewind_render =
+        i->thread_info.dont_rewind_render ||
+        dont_rewind_render;
+
     if (nbytes != (size_t) -1) {
 
         /* Transform to sink domain */
diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index 8cfe32b..3d2a8c0 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -179,8 +179,9 @@ struct pa_sink_input {
         /* We maintain a history of resampled audio data here. */
         pa_memblockq *render_memblockq;
 
+        /* 0: rewrite nothing, (size_t) -1: rewrite everything, otherwise how many bytes to rewrite */
         size_t rewrite_nbytes;
-        pa_bool_t rewrite_flush;
+        pa_bool_t rewrite_flush, dont_rewind_render;
         uint64_t underrun_for, playing_for;
 
         pa_sink_input *sync_prev, *sync_next;
@@ -277,7 +278,7 @@ fully -- or at all. If the request for a rewrite was successful, the
 sink driver will call ->rewind() and pass the number of bytes that
 could be rewound in the HW device. This functionality is required for
 implementing the "zero latency" write-through functionality. */
-void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes, pa_bool_t rewrite, pa_bool_t flush);
+void pa_sink_input_request_rewind(pa_sink_input *i, size_t nbytes, pa_bool_t rewrite, pa_bool_t flush, pa_bool_t dont_rewind_render);
 
 void pa_sink_input_cork(pa_sink_input *i, pa_bool_t b);
 
diff --git a/src/pulsecore/sound-file-stream.c b/src/pulsecore/sound-file-stream.c
index c30c16e..b78afca 100644
--- a/src/pulsecore/sound-file-stream.c
+++ b/src/pulsecore/sound-file-stream.c
@@ -133,7 +133,7 @@ static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t s
      * we are heard right-away. */
     if (PA_SINK_INPUT_IS_LINKED(state) &&
         i->thread_info.state == PA_SINK_INPUT_INIT)
-        pa_sink_input_request_rewind(i, 0, FALSE, TRUE);
+        pa_sink_input_request_rewind(i, 0, FALSE, TRUE, TRUE);
 }
 
 /* Called from IO thread context */

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list