[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test5-55-ga7246bd

Lennart Poettering gitmailer-noreply at 0pointer.de
Tue Mar 24 13:45:15 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  bcbfd5b9835ca2e7d00cd3f2ca090bcfea182451 (commit)

- Log -----------------------------------------------------------------
a7246bd bluetooth: fix #NOKIA, correctly unlink sink/src
5b523d0 fix bad memory access when destroying m-b-d
c64d8cb Allow calling pa_{sink|source}_update_proplist() without an actual proprlist
50695d9 minimal reordering
2f9a784 set request/rewind sizes only via accessor functions
aa92ff4 simplify latency range by not allowing stored 'wildcard' ranges anymore
e6be948 only decrease timer slack, never increase
-----------------------------------------------------------------------

Summary of changes:
 src/modules/alsa/alsa-sink.c                      |    4 +-
 src/modules/alsa/alsa-source.c                    |    2 +-
 src/modules/bluetooth/module-bluetooth-device.c   |    4 +-
 src/modules/bluetooth/module-bluetooth-discover.c |   43 +++++++++----
 src/modules/module-combine.c                      |    2 +-
 src/modules/module-ladspa-sink.c                  |    8 +-
 src/modules/module-null-sink.c                    |    9 ++-
 src/modules/module-remap-sink.c                   |    8 +-
 src/modules/module-solaris.c                      |    4 +-
 src/modules/oss/module-oss.c                      |    2 +-
 src/pulse/stream.c                                |    2 +-
 src/pulsecore/rtclock.c                           |   16 +++--
 src/pulsecore/sink.c                              |   70 ++++++++++++++++-----
 src/pulsecore/sink.h                              |   10 ++-
 src/pulsecore/source.c                            |   26 +++++---
 src/pulsecore/source.h                            |    2 +-
 16 files changed, 140 insertions(+), 72 deletions(-)

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

commit e6be9481dcf1d9c675aa8881b473189c6c50081d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Mar 24 20:59:54 2009 +0100

    only decrease timer slack, never increase

diff --git a/src/pulsecore/rtclock.c b/src/pulsecore/rtclock.c
index 56ab2ef..65c826a 100644
--- a/src/pulsecore/rtclock.c
+++ b/src/pulsecore/rtclock.c
@@ -95,6 +95,8 @@ pa_bool_t pa_rtclock_hrtimer(void) {
 #endif
 }
 
+#define TIMER_SLACK_NS (int) ((500 * PA_NSEC_PER_USEC))
+
 void pa_rtclock_hrtimer_enable(void) {
 #ifdef PR_SET_TIMERSLACK
     int slack_ns;
@@ -104,15 +106,17 @@ void pa_rtclock_hrtimer_enable(void) {
         return;
     }
 
-    pa_log_debug("Timer slack set to %i us.", slack_ns/1000);
+    pa_log_debug("Timer slack is set to %i us.", (int) (slack_ns/PA_NSEC_PER_USEC));
 
-    slack_ns = 500000000;
+    if (slack_ns > TIMER_SLACK_NS) {
+        slack_ns = TIMER_SLACK_NS;
 
-    pa_log_debug("Setting timer slack to %i us.", slack_ns/1000);
+        pa_log_debug("Setting timer slack to %i us.", (int) (slack_ns/PA_NSEC_PER_USEC));
 
-    if (prctl(PR_SET_TIMERSLACK, slack_ns, 0, 0, 0) < 0) {
-        pa_log_warn("PR_SET_TIMERSLACK failed: %s", pa_cstrerror(errno));
-        return;
+        if (prctl(PR_SET_TIMERSLACK, slack_ns, 0, 0, 0) < 0) {
+            pa_log_warn("PR_SET_TIMERSLACK failed: %s", pa_cstrerror(errno));
+            return;
+        }
     }
 
 #endif

commit aa92ff408c6a5fb6a4bd452aef1105eb70da9d0d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Mar 24 21:06:57 2009 +0100

    simplify latency range by not allowing stored 'wildcard' ranges anymore

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 7bf16c3..a770f0f 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -240,7 +240,7 @@ static void adjust_after_underrun(struct userdata *u) {
         pa_log_notice("Increasing minimal latency to %0.2f ms",
                       (double) new_min_latency / PA_USEC_PER_MSEC);
 
-        pa_sink_update_latency_range(u->sink, new_min_latency, u->sink->thread_info.max_latency);
+        pa_sink_set_latency_range_within_thread(u->sink, new_min_latency, u->sink->thread_info.max_latency);
         return;
     }
 
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index f4acad8..7c09c00 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -238,7 +238,7 @@ static void adjust_after_overrun(struct userdata *u) {
         pa_log_notice("Increasing minimal latency to %0.2f ms",
                       (double) new_min_latency / PA_USEC_PER_MSEC);
 
-        pa_source_update_latency_range(u->source, new_min_latency, u->source->thread_info.max_latency);
+        pa_source_set_latency_range_within_thread(u->source, new_min_latency, u->source->thread_info.max_latency);
         return;
     }
 
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 33562b1..54a4e6c 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -290,7 +290,7 @@ static void sink_input_update_sink_latency_range_cb(pa_sink_input *i) {
     if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
         return;
 
-    pa_sink_update_latency_range(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
+    pa_sink_set_latency_range_within_thread(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
 }
 
 /* Called from I/O thread context */
@@ -322,7 +322,7 @@ static void sink_input_attach_cb(pa_sink_input *i) {
     pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
     pa_sink_attach_within_thread(u->sink);
 
-    pa_sink_update_latency_range(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
+    pa_sink_set_latency_range_within_thread(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
 }
 
 /* Called from main context */
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 31824bc..7ab81b6 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -205,7 +205,7 @@ static void sink_input_update_sink_latency_range_cb(pa_sink_input *i) {
     if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
         return;
 
-    pa_sink_update_latency_range(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
+    pa_sink_set_latency_range_within_thread(u->sink, i->sink->thread_info.min_latency, i->sink->thread_info.max_latency);
 }
 
 /* Called from I/O thread context */
@@ -237,7 +237,7 @@ static void sink_input_attach_cb(pa_sink_input *i) {
     pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
     pa_sink_attach_within_thread(u->sink);
 
-    pa_sink_update_latency_range(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
+    pa_sink_set_latency_range_within_thread(u->sink, u->master->thread_info.min_latency, u->master->thread_info.max_latency);
 }
 
 /* Called from main context */
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 147926a..7c43a8e 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -48,7 +48,9 @@
 
 #define MAX_MIX_CHANNELS 32
 #define MIX_BUFFER_LENGTH (PA_PAGE_SIZE)
+#define ABSOLUTE_MIN_LATENCY (500)
 #define DEFAULT_MIN_LATENCY (4*PA_USEC_PER_MSEC)
+#define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC)
 
 static PA_DEFINE_CHECK_TYPE(pa_sink, pa_msgobject);
 
@@ -231,7 +233,7 @@ pa_sink* pa_sink_new(
     s->thread_info.requested_latency_valid = FALSE;
     s->thread_info.requested_latency = 0;
     s->thread_info.min_latency = DEFAULT_MIN_LATENCY;
-    s->thread_info.max_latency = 0;
+    s->thread_info.max_latency = DEFAULT_MIN_LATENCY;
 
     pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
 
@@ -343,8 +345,7 @@ void pa_sink_put(pa_sink* s) {
     /* The following fields must be initialized properly when calling _put() */
     pa_assert(s->asyncmsgq);
     pa_assert(s->rtpoll);
-    pa_assert(!s->thread_info.min_latency || !s->thread_info.max_latency ||
-              s->thread_info.min_latency <= s->thread_info.max_latency);
+    pa_assert(s->thread_info.min_latency <= s->thread_info.max_latency);
 
     if (!(s->flags & PA_SINK_HW_VOLUME_CTRL)) {
         s->flags |= PA_SINK_DECIBEL_VOLUME;
@@ -1591,7 +1592,7 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
         case PA_SINK_MESSAGE_SET_LATENCY_RANGE: {
             pa_usec_t *r = userdata;
 
-            pa_sink_update_latency_range(s, r[0], r[1]);
+            pa_sink_set_latency_range_within_thread(s, r[0], r[1]);
 
             return 0;
         }
@@ -1738,10 +1739,10 @@ pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s) {
         result = monitor_latency;
 
     if (result != (pa_usec_t) -1) {
-        if (s->thread_info.max_latency > 0 && result > s->thread_info.max_latency)
+        if (result > s->thread_info.max_latency)
             result = s->thread_info.max_latency;
 
-        if (s->thread_info.min_latency > 0 && result < s->thread_info.min_latency)
+        if (result < s->thread_info.min_latency)
             result = s->thread_info.min_latency;
     }
 
@@ -1835,11 +1836,16 @@ void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_
     if (min_latency == (pa_usec_t) -1)
         min_latency = DEFAULT_MIN_LATENCY;
 
+    if (min_latency < ABSOLUTE_MIN_LATENCY)
+        min_latency = ABSOLUTE_MIN_LATENCY;
+
     if (max_latency == (pa_usec_t) -1)
         max_latency = min_latency;
 
-    pa_assert(!min_latency || !max_latency ||
-              min_latency <= max_latency);
+    if (max_latency > ABSOLUTE_MAX_LATENCY || max_latency <= 0)
+        max_latency = ABSOLUTE_MAX_LATENCY;
+
+    pa_assert(min_latency <= max_latency);
 
     if (PA_SINK_IS_LINKED(s->state)) {
         pa_usec_t r[2];
@@ -1879,14 +1885,15 @@ void pa_sink_get_latency_range(pa_sink *s, pa_usec_t *min_latency, pa_usec_t *ma
 }
 
 /* Called from IO thread */
-void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency) {
+void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency) {
     pa_sink_input *i;
     void *state = NULL;
 
     pa_sink_assert_ref(s);
 
-    pa_assert(!min_latency || !max_latency ||
-              min_latency <= max_latency);
+    pa_assert(min_latency >= ABSOLUTE_MIN_LATENCY);
+    pa_assert(max_latency <= ABSOLUTE_MAX_LATENCY);
+    pa_assert(min_latency <= max_latency);
 
     s->thread_info.min_latency = min_latency;
     s->thread_info.max_latency = max_latency;
@@ -1897,7 +1904,7 @@ void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t m
 
     pa_sink_invalidate_requested_latency(s);
 
-    pa_source_update_latency_range(s->monitor_source, min_latency, max_latency);
+    pa_source_set_latency_range_within_thread(s->monitor_source, min_latency, max_latency);
 }
 
 /* Called from main context */
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 448f280..260b272 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -283,7 +283,7 @@ pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s);
 void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind);
 void pa_sink_set_max_request(pa_sink *s, size_t max_request);
 
-void pa_sink_update_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
+void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
 
 /*** To be called exclusively by sink input drivers, from IO context */
 
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index ac1ef1e..4a5bbad 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -41,7 +41,9 @@
 
 #include "source.h"
 
+#define ABSOLUTE_MIN_LATENCY (500)
 #define DEFAULT_MIN_LATENCY (4*PA_USEC_PER_MSEC)
+#define ABSOLUTE_MAX_LATENCY (10*PA_USEC_PER_SEC)
 
 static PA_DEFINE_CHECK_TYPE(pa_source, pa_msgobject);
 
@@ -219,7 +221,7 @@ pa_source* pa_source_new(
     s->thread_info.requested_latency_valid = FALSE;
     s->thread_info.requested_latency = 0;
     s->thread_info.min_latency = DEFAULT_MIN_LATENCY;
-    s->thread_info.max_latency = 0;
+    s->thread_info.max_latency = DEFAULT_MIN_LATENCY;
 
     pa_assert_se(pa_idxset_put(core->sources, s, &s->index) >= 0);
 
@@ -936,7 +938,7 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
         case PA_SOURCE_MESSAGE_SET_LATENCY_RANGE: {
             pa_usec_t *r = userdata;
 
-            pa_source_update_latency_range(s, r[0], r[1]);
+            pa_source_set_latency_range_within_thread(s, r[0], r[1]);
 
             return 0;
         }
@@ -1130,11 +1132,16 @@ void pa_source_set_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t
     if (min_latency == (pa_usec_t) -1)
         min_latency = DEFAULT_MIN_LATENCY;
 
+    if (min_latency < ABSOLUTE_MIN_LATENCY)
+        min_latency = ABSOLUTE_MIN_LATENCY;
+
     if (max_latency == (pa_usec_t) -1)
         max_latency = min_latency;
 
-    pa_assert(!min_latency || !max_latency ||
-              min_latency <= max_latency);
+    if (max_latency > ABSOLUTE_MAX_LATENCY || max_latency <= 0)
+        max_latency = ABSOLUTE_MAX_LATENCY;
+
+    pa_assert(min_latency <= max_latency);
 
     if (PA_SOURCE_IS_LINKED(s->state)) {
         pa_usec_t r[2];
@@ -1170,14 +1177,15 @@ void pa_source_get_latency_range(pa_source *s, pa_usec_t *min_latency, pa_usec_t
 }
 
 /* Called from IO thread */
-void pa_source_update_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
+void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency) {
     pa_source_output *o;
     void *state = NULL;
 
     pa_source_assert_ref(s);
 
-    pa_assert(!min_latency || !max_latency ||
-              min_latency <= max_latency);
+    pa_assert(min_latency >= ABSOLUTE_MIN_LATENCY);
+    pa_assert(max_latency <= ABSOLUTE_MAX_LATENCY);
+    pa_assert(min_latency <= max_latency);
 
     s->thread_info.min_latency = min_latency;
     s->thread_info.max_latency = max_latency;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 68bf2f0..862e1aa 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -260,7 +260,7 @@ void pa_source_detach_within_thread(pa_source *s);
 pa_usec_t pa_source_get_requested_latency_within_thread(pa_source *s);
 
 void pa_source_set_max_rewind(pa_source *s, size_t max_rewind);
-void pa_source_update_latency_range(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency);
+void pa_source_set_latency_range_within_thread(pa_source *s, pa_usec_t min_latency, pa_usec_t max_latency);
 
 /*** To be called exclusively by source output drivers, from IO context */
 

commit 2f9a784167cca67a07d750455bc8006f9077a235
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Mar 24 21:13:41 2009 +0100

    set request/rewind sizes only via accessor functions

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index a770f0f..bcca57d 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -756,7 +756,7 @@ static int update_sw_params(struct userdata *u) {
         return err;
     }
 
-    pa_sink_set_max_request(u->sink, u->hwbuf_size - u->hwbuf_unused);
+    pa_sink_set_max_request_within_thread(u->sink, u->hwbuf_size - u->hwbuf_unused);
 
     return 0;
 }
diff --git a/src/modules/module-combine.c b/src/modules/module-combine.c
index 4b2d6f9..f72223d 100644
--- a/src/modules/module-combine.c
+++ b/src/modules/module-combine.c
@@ -649,7 +649,7 @@ static void update_max_request(struct userdata *u) {
     if (max_request <= 0)
         max_request = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
 
-    pa_sink_set_max_request(u->sink, max_request);
+    pa_sink_set_max_request_within_thread(u->sink, max_request);
 }
 
 /* Called from thread context of the io thread */
diff --git a/src/modules/module-ladspa-sink.c b/src/modules/module-ladspa-sink.c
index 54a4e6c..81546ff 100644
--- a/src/modules/module-ladspa-sink.c
+++ b/src/modules/module-ladspa-sink.c
@@ -264,7 +264,7 @@ static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) {
         return;
 
     pa_memblockq_set_maxrewind(u->memblockq, nbytes);
-    pa_sink_set_max_rewind(u->sink, nbytes);
+    pa_sink_set_max_rewind_within_thread(u->sink, nbytes);
 }
 
 /* Called from I/O thread context */
@@ -277,7 +277,7 @@ static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes) {
     if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
         return;
 
-    pa_sink_set_max_request(u->sink, nbytes);
+    pa_sink_set_max_request_within_thread(u->sink, nbytes);
 }
 
 /* Called from I/O thread context */
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c
index 183d4b2..c8edd0c 100644
--- a/src/modules/module-null-sink.c
+++ b/src/modules/module-null-sink.c
@@ -253,6 +253,7 @@ int pa__init(pa_module*m) {
     pa_channel_map map;
     pa_modargs *ma = NULL;
     pa_sink_new_data data;
+    size_t nbytes;
 
     pa_assert(m);
 
@@ -299,11 +300,11 @@ int pa__init(pa_module*m) {
     pa_sink_set_rtpoll(u->sink, u->rtpoll);
 
     pa_sink_set_latency_range(u->sink, (pa_usec_t) -1, MAX_LATENCY_USEC);
-    u->block_usec = u->sink->thread_info.max_latency;
 
-    u->sink->thread_info.max_rewind =
-        u->sink->thread_info.max_request =
-        pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
+    u->block_usec = u->sink->thread_info.max_latency;
+    nbytes = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec);
+    pa_sink_set_max_rewind(u->sink, nbytes);
+    pa_sink_set_max_request(u->sink, nbytes);
 
     if (!(u->thread = pa_thread_new(thread_func, u))) {
         pa_log("Failed to create thread.");
diff --git a/src/modules/module-remap-sink.c b/src/modules/module-remap-sink.c
index 7ab81b6..8c43a72 100644
--- a/src/modules/module-remap-sink.c
+++ b/src/modules/module-remap-sink.c
@@ -179,7 +179,7 @@ static void sink_input_update_max_rewind_cb(pa_sink_input *i, size_t nbytes) {
     if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
         return;
 
-    pa_sink_set_max_rewind(u->sink, nbytes);
+    pa_sink_set_max_rewind_within_thread(u->sink, nbytes);
 }
 
 /* Called from I/O thread context */
@@ -192,7 +192,7 @@ static void sink_input_update_max_request_cb(pa_sink_input *i, size_t nbytes) {
     if (!u->sink || !PA_SINK_IS_LINKED(u->sink->thread_info.state))
         return;
 
-    pa_sink_set_max_request(u->sink, nbytes);
+    pa_sink_set_max_request_within_thread(u->sink, nbytes);
 }
 
 /* Called from I/O thread context */
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 995b3c6..e7dfc05 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -653,7 +653,7 @@ static void thread_func(void *userdata) {
                             u->buffer_size = u->buffer_size * 18 / 25;
                             u->buffer_size -= u->buffer_size % u->frame_size;
                             u->buffer_size = PA_MAX(u->buffer_size, (int32_t)MIN_BUFFER_SIZE);
-                            pa_sink_set_max_request(u->sink, u->buffer_size);
+                            pa_sink_set_max_request_within_thread(u->sink, u->buffer_size);
                             pa_log("EAGAIN. Buffer size is now %u bytes (%llu buffered)", u->buffer_size, buffered_bytes);
                             break;
                         default:
@@ -946,7 +946,7 @@ int pa__init(pa_module *m) {
         u->sink->set_mute = sink_set_mute;
         u->sink->refresh_volume = u->sink->refresh_muted = TRUE;
 
-        u->sink->thread_info.max_request = u->buffer_size;
+        pa_sink_set_max_request(u->sink, u->buffer_size);
         u->min_request = pa_usec_to_bytes(PA_USEC_PER_SEC / MAX_RENDER_HZ, &ss);
     } else
         u->sink = NULL;
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 7bce8d0..f67f47e 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -1388,7 +1388,7 @@ int pa__init(pa_module*m) {
         pa_sink_set_rtpoll(u->sink, u->rtpoll);
         u->sink->refresh_volume = TRUE;
 
-        u->sink->thread_info.max_request = u->out_hwbuf_size;
+        pa_sink_set_max_request(u->sink, u->out_hwbuf_size);
 
         if (use_mmap)
             u->out_mmap_memblocks = pa_xnew0(pa_memblock*, u->out_nfrags);
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 7c43a8e..308a4e5 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1616,6 +1616,16 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
             *((size_t*) userdata) = s->thread_info.max_request;
             return 0;
 
+        case PA_SINK_MESSAGE_SET_MAX_REWIND:
+
+            pa_sink_set_max_rewind_within_thread(s, (size_t) offset);
+            return 0;
+
+        case PA_SINK_MESSAGE_SET_MAX_REQUEST:
+
+            pa_sink_set_max_request_within_thread(s, (size_t) offset);
+            return 0;
+
         case PA_SINK_MESSAGE_GET_LATENCY:
         case PA_SINK_MESSAGE_MAX:
             ;
@@ -1767,7 +1777,7 @@ pa_usec_t pa_sink_get_requested_latency(pa_sink *s) {
 }
 
 /* Called from IO as well as the main thread -- the latter only before the IO thread started up */
-void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) {
+void pa_sink_set_max_rewind_within_thread(pa_sink *s, size_t max_rewind) {
     pa_sink_input *i;
     void *state = NULL;
 
@@ -1787,8 +1797,18 @@ void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) {
         pa_source_set_max_rewind(s->monitor_source, s->thread_info.max_rewind);
 }
 
+/* Called from main thread */
+void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind) {
+    pa_sink_assert_ref(s);
+
+    if (PA_SINK_IS_LINKED(s->state))
+        pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_MAX_REWIND, NULL, max_rewind, NULL) == 0);
+    else
+        pa_sink_set_max_rewind_within_thread(s, max_rewind);
+}
+
 /* Called from IO as well as the main thread -- the latter only before the IO thread started up */
-void pa_sink_set_max_request(pa_sink *s, size_t max_request) {
+void pa_sink_set_max_request_within_thread(pa_sink *s, size_t max_request) {
     void *state = NULL;
 
     pa_sink_assert_ref(s);
@@ -1806,6 +1826,16 @@ void pa_sink_set_max_request(pa_sink *s, size_t max_request) {
     }
 }
 
+/* Called from main thread */
+void pa_sink_set_max_request(pa_sink *s, size_t max_request) {
+    pa_sink_assert_ref(s);
+
+    if (PA_SINK_IS_LINKED(s->state))
+        pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_MAX_REQUEST, NULL, max_request, NULL) == 0);
+    else
+        pa_sink_set_max_request_within_thread(s, max_request);
+}
+
 /* Called from IO thread */
 void pa_sink_invalidate_requested_latency(pa_sink *s) {
     pa_sink_input *i;
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 260b272..f3f2542 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -172,6 +172,8 @@ typedef enum pa_sink_message {
     PA_SINK_MESSAGE_GET_LATENCY_RANGE,
     PA_SINK_MESSAGE_GET_MAX_REWIND,
     PA_SINK_MESSAGE_GET_MAX_REQUEST,
+    PA_SINK_MESSAGE_SET_MAX_REWIND,
+    PA_SINK_MESSAGE_SET_MAX_REQUEST,
     PA_SINK_MESSAGE_MAX
 } pa_sink_message_t;
 
@@ -217,6 +219,8 @@ void pa_sink_unlink(pa_sink* s);
 void pa_sink_set_description(pa_sink *s, const char *description);
 void pa_sink_set_asyncmsgq(pa_sink *s, pa_asyncmsgq *q);
 void pa_sink_set_rtpoll(pa_sink *s, pa_rtpoll *p);
+void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind);
+void pa_sink_set_max_request(pa_sink *s, size_t max_request);
 
 void pa_sink_set_latency_range(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
 
@@ -280,8 +284,8 @@ void pa_sink_detach_within_thread(pa_sink *s);
 
 pa_usec_t pa_sink_get_requested_latency_within_thread(pa_sink *s);
 
-void pa_sink_set_max_rewind(pa_sink *s, size_t max_rewind);
-void pa_sink_set_max_request(pa_sink *s, size_t max_request);
+void pa_sink_set_max_rewind_within_thread(pa_sink *s, size_t max_rewind);
+void pa_sink_set_max_request_within_thread(pa_sink *s, size_t max_request);
 
 void pa_sink_set_latency_range_within_thread(pa_sink *s, pa_usec_t min_latency, pa_usec_t max_latency);
 

commit 50695d95d11baf621dde1fa71db03ff422bbef6e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Mar 24 21:14:08 2009 +0100

    minimal reordering

diff --git a/src/pulse/stream.c b/src/pulse/stream.c
index a7fccc8..48e3b08 100644
--- a/src/pulse/stream.c
+++ b/src/pulse/stream.c
@@ -138,13 +138,13 @@ pa_stream *pa_stream_new_with_proplist(
     s->device_index = PA_INVALID_INDEX;
     s->device_name = NULL;
     s->suspended = FALSE;
+    s->corked = FALSE;
 
     pa_memchunk_reset(&s->peek_memchunk);
     s->peek_data = NULL;
 
     s->record_memblockq = NULL;
 
-    s->corked = FALSE;
 
     memset(&s->timing_info, 0, sizeof(s->timing_info));
     s->timing_info_valid = FALSE;

commit c64d8cbcc7eefa2e805db415f99b507c5a065195
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Mar 24 21:17:55 2009 +0100

    Allow calling pa_{sink|source}_update_proplist() without an actual proprlist

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 308a4e5..a3bf03a 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1202,11 +1202,10 @@ void pa_sink_mute_changed(pa_sink *s, pa_bool_t new_muted) {
 
 /* Called from main thread */
 pa_bool_t pa_sink_update_proplist(pa_sink *s, pa_update_mode_t mode, pa_proplist *p) {
-
     pa_sink_assert_ref(s);
-    pa_assert(p);
 
-    pa_proplist_update(s->proplist, mode, p);
+    if (p)
+        pa_proplist_update(s->proplist, mode, p);
 
     if (PA_SINK_IS_LINKED(s->state)) {
         pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_PROPLIST_CHANGED], s);
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 4a5bbad..da3ae79 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -744,9 +744,9 @@ void pa_source_mute_changed(pa_source *s, pa_bool_t new_muted) {
 /* Called from main thread */
 pa_bool_t pa_source_update_proplist(pa_source *s, pa_update_mode_t mode, pa_proplist *p) {
     pa_source_assert_ref(s);
-    pa_assert(p);
 
-    pa_proplist_update(s->proplist, mode, p);
+    if (p)
+        pa_proplist_update(s->proplist, mode, p);
 
     if (PA_SOURCE_IS_LINKED(s->state)) {
         pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED], s);

commit 5b523d097cb975a28b616098844de49d8431bfbf
Author: Lennart Poettering <lennart at poettering.net>
Date:   Tue Mar 24 21:42:33 2009 +0100

    fix bad memory access when destroying m-b-d

diff --git a/src/modules/bluetooth/module-bluetooth-discover.c b/src/modules/bluetooth/module-bluetooth-discover.c
index 4805e5f..da0fe93 100644
--- a/src/modules/bluetooth/module-bluetooth-discover.c
+++ b/src/modules/bluetooth/module-bluetooth-discover.c
@@ -69,23 +69,24 @@ struct userdata {
     pa_hashmap *hashmap;
 };
 
+struct module_info {
+    char *path;
+    uint32_t module;
+};
+
 static pa_hook_result_t load_module_for_device(pa_bluetooth_discovery *y, const pa_bluetooth_device *d, struct userdata *u) {
-    uint32_t midx;
+    struct module_info *mi;
 
     pa_assert(u);
     pa_assert(d);
 
-
-    if (!(midx = PA_PTR_TO_UINT(pa_hashmap_get(u->hashmap, d->path))))
-        midx = PA_INVALID_INDEX;
-    else
-        midx--;
+    mi = pa_hashmap_get(u->hashmap, d->path);
 
     if (!d->dead &&
         d->device_connected > 0 &&
         (d->audio_sink_connected > 0 || d->headset_connected > 0)) {
 
-        if (midx == PA_INVALID_INDEX) {
+        if (!mi) {
             pa_module *m = NULL;
             char *args;
 
@@ -110,22 +111,28 @@ static pa_hook_result_t load_module_for_device(pa_bluetooth_discovery *y, const
             m = pa_module_load(u->module->core, "module-bluetooth-device", args);
             pa_xfree(args);
 
-            if (m)
-                pa_hashmap_put(u->hashmap, d->path, PA_UINT_TO_PTR((uint32_t) (m->index+1)));
-            else
+            if (m) {
+                mi = pa_xnew(struct module_info, 1);
+                mi->module = m->index;
+                mi->path = pa_xstrdup(d->path);
+
+                pa_hashmap_put(u->hashmap, mi->path, mi);
+            } else
                 pa_log_debug("Failed to load module for device %s", d->path);
         }
 
     } else {
 
-        if (midx != PA_INVALID_INDEX) {
+        if (mi) {
 
             /* Hmm, disconnection? Then let's unload our module */
 
             pa_log_debug("Unloading module for %s", d->path);
-            pa_module_unload_request_by_index(u->core, midx, TRUE);
+            pa_module_unload_request_by_index(u->core, mi->module, TRUE);
 
-            pa_hashmap_remove(u->hashmap, d->path);
+            pa_hashmap_remove(u->hashmap, mi->path);
+            pa_xfree(mi->path);
+            pa_xfree(mi);
         }
     }
 
@@ -189,8 +196,16 @@ void pa__done(pa_module* m) {
     if (u->discovery)
         pa_bluetooth_discovery_unref(u->discovery);
 
-    if (u->hashmap)
+    if (u->hashmap) {
+        struct module_info *mi;
+
+        while ((mi = pa_hashmap_steal_first(u->hashmap))) {
+            pa_xfree(mi->path);
+            pa_xfree(mi);
+        }
+
         pa_hashmap_free(u->hashmap, NULL, NULL);
+    }
 
     if (u->modargs)
         pa_modargs_free(u->modargs);

commit a7246bd635ab5eb9f708937383d7c3ebf5c1345c
Author: Marc-André Lureau <marc-andre.lureau at nokia.com>
Date:   Tue Mar 24 16:28:12 2009 +0200

    bluetooth: fix #NOKIA, correctly unlink sink/src

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index dbc7ab1..2500fb0 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1718,16 +1718,16 @@ static int card_set_profile(pa_card *c, pa_card_profile *new_profile) {
         inputs = pa_sink_move_all_start(u->sink);
 #ifdef NOKIA
         if (!USE_SCO_OVER_PCM(u))
-            pa_sink_unlink(u->sink);
 #endif
+            pa_sink_unlink(u->sink);
     }
 
     if (u->source) {
         outputs = pa_source_move_all_start(u->source);
 #ifdef NOKIA
         if (!USE_SCO_OVER_PCM(u))
-            pa_source_unlink(u->source);
 #endif
+            pa_source_unlink(u->source);
     }
 
     stop_thread(u);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list