[pulseaudio-commits] 4 commits - configure.ac src/modules src/pulsecore

Arun Raghavan arun at kemper.freedesktop.org
Fri Nov 16 10:01:35 PST 2012


 configure.ac                                    |    2 +-
 src/modules/alsa/alsa-sink.c                    |   14 ++++++++++----
 src/modules/bluetooth/module-bluetooth-device.c |    2 +-
 src/modules/jack/module-jack-sink.c             |    5 ++---
 src/modules/macosx/module-coreaudio-device.c    |    9 ++++++---
 src/modules/module-combine-sink.c               |    5 ++---
 src/modules/module-esound-sink.c                |    5 ++---
 src/modules/module-null-sink.c                  |   22 +++++++++-------------
 src/modules/module-pipe-sink.c                  |    7 +++----
 src/modules/module-solaris.c                    |   13 ++++++++-----
 src/modules/module-tunnel.c                     |    5 ++---
 src/modules/module-waveout.c                    |   11 +++++++----
 src/modules/oss/module-oss.c                    |    5 ++---
 src/modules/raop/module-raop-sink.c             |    5 ++---
 src/modules/xen/module-xenpv-sink.c             |    7 +++----
 src/pulsecore/sink-input.c                      |   11 ++---------
 src/pulsecore/sink.c                            |    9 +++------
 src/pulsecore/source-output.c                   |   11 ++---------
 src/pulsecore/source.c                          |    3 +++
 19 files changed, 70 insertions(+), 81 deletions(-)

New commits:
commit 87e89ac4eb4227e6b50a8dd4afa9da519ec861f8
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Fri Nov 16 23:13:26 2012 +0530

    build-sys: Bump BlueZ dependency to 4.99
    
    Since the old UNIX fd IPC mechanism was removed and we rely on the D-Bus
    based API, this is the oldest version that is known to reliably work.

diff --git a/configure.ac b/configure.ac
index 99aafda..4590a55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1004,7 +1004,7 @@ AC_ARG_ENABLE([bluez],
     AS_HELP_STRING([--disable-bluez],[Disable optional BlueZ support]))
 
 AS_IF([test "x$enable_bluez" != "xno"],
-    [PKG_CHECK_MODULES(BLUEZ, [ bluez >= 3.0 ], HAVE_BLUEZ=1, HAVE_BLUEZ=0)],
+    [PKG_CHECK_MODULES(BLUEZ, [ bluez >= 4.99 ], HAVE_BLUEZ=1, HAVE_BLUEZ=0)],
     HAVE_BLUEZ=0)
 AS_IF([test "x$enable_bluez" != "xno"],
     [PKG_CHECK_MODULES(SBC, [ sbc >= 1.0 ], HAVE_BLUEZ=1, HAVE_BLUEZ=0)],

commit e5953fb0ddf8c4a84c815f72755261e7dadbf00e
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Fri Nov 16 23:09:15 2012 +0530

    modules: Micro-optimisation for rewind_requested paths
    
    Since some devices can be chatty with regards to how often they return
    from poll(), this adds a PA_UNLIKELY() to all the the rewind_requested
    checks in our sink modules to make the general case (no rewind was
    requested) the fast path.

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 8c2efa4..8a9d39f 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1081,7 +1081,7 @@ static void thread_func(void *userdata) {
 
         if (u->sink && PA_SINK_IS_LINKED(u->sink->thread_info.state)) {
 
-            if (u->sink->thread_info.rewind_requested)
+            if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
                 pa_sink_process_rewind(u->sink, 0);
 
             if (pollfd) {
diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index 028c86f..1e34abd 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -229,7 +229,7 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
index 6d36a6a..ea88ebd 100644
--- a/src/modules/macosx/module-coreaudio-device.c
+++ b/src/modules/macosx/module-coreaudio-device.c
@@ -665,7 +665,7 @@ static void thread_func(void *userdata) {
         int ret;
 
         PA_LLIST_FOREACH(ca_sink, u->sinks) {
-            if (ca_sink->pa_sink->thread_info.rewind_requested)
+            if (PA_UNLIKELY(ca_sink->pa_sink->thread_info.rewind_requested))
                 pa_sink_process_rewind(ca_sink->pa_sink, 0);
         }
 
diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c
index b778019..488f69f 100644
--- a/src/modules/module-combine-sink.c
+++ b/src/modules/module-combine-sink.c
@@ -305,7 +305,7 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         /* If no outputs are connected, render some data and drop it immediately. */
diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c
index 54fed65..40ef5bc 100644
--- a/src/modules/module-esound-sink.c
+++ b/src/modules/module-esound-sink.c
@@ -213,7 +213,7 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         if (u->rtpoll_item) {
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c
index d6ea43f..10bc67f 100644
--- a/src/modules/module-null-sink.c
+++ b/src/modules/module-null-sink.c
@@ -213,7 +213,7 @@ static void thread_func(void *userdata) {
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
             now = pa_rtclock_now();
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             process_rewind(u, now);
 
         /* Render some data and drop it immediately */
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index 1fcea17..54dceb4 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -180,7 +180,7 @@ static void thread_func(void *userdata) {
 
         pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         /* Render some data and write it to the fifo */
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index aaf7189..753c1a1 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -628,7 +628,7 @@ static void thread_func(void *userdata) {
     for (;;) {
         /* Render some data and write it to the dsp */
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             process_rewind(u);
 
         if (u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c
index d02bb6b..39c2ab4 100644
--- a/src/modules/module-waveout.c
+++ b/src/modules/module-waveout.c
@@ -256,7 +256,7 @@ static void thread_func(void *userdata) {
         pa_bool_t need_timer = FALSE;
 
         if (u->sink) {
-            if (u->sink->thread_info.rewind_requested)
+            if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
                 pa_sink_process_rewind(u->sink, 0);
 
             if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 3d79412..c4746ca 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -891,7 +891,7 @@ static void thread_func(void *userdata) {
 
 /*        pa_log("loop");    */
 
-        if (u->sink && u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink && u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         /* Render some data and write it to the dsp */
diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c
index 2952216..1816fee 100644
--- a/src/modules/raop/module-raop-sink.c
+++ b/src/modules/raop/module-raop-sink.c
@@ -327,7 +327,7 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         if (u->rtpoll_item) {
diff --git a/src/modules/xen/module-xenpv-sink.c b/src/modules/xen/module-xenpv-sink.c
index a5756e5..6f82ff4 100644
--- a/src/modules/xen/module-xenpv-sink.c
+++ b/src/modules/xen/module-xenpv-sink.c
@@ -338,7 +338,7 @@ static void thread_func(void *userdata) {
 
         pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
-        if (u->sink->thread_info.rewind_requested)
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
             pa_sink_process_rewind(u->sink, 0);
 
         /* Render some data and write it to the fifo */

commit 29f064aa3d3a83e275361aad3f9e7efdc84b8ad0
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Thu Aug 30 16:50:13 2012 +0300

    sink: Process rewind requests also when suspended.
    
    When a rewind is requested on a sink input, the request parameters are
    stored in the pa_sink_input struct. The parameters are reset during
    rewind processing, and if the sink decides to ignore the rewind
    request due to being suspended, stale parameters are left in
    pa_sink_input. It's particularly problematic if the rewrite_bytes
    parameter is left at -1, because that will prevent all future rewind
    processing on that sink input. So, in order to avoid stale parameters,
    every rewind request needs to be processed, even if the sink is
    suspended.
    
    Reported-by: Uoti Urpala

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index eab70ef..ee82ec7 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -1608,6 +1608,11 @@ static int process_rewind(struct userdata *u) {
     size_t rewind_nbytes, unused_nbytes, limit_nbytes;
     pa_assert(u);
 
+    if (!PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
+        pa_sink_process_rewind(u->sink, 0);
+        return 0;
+    }
+
     /* Figure out how much we shall rewind and reset the counter */
     rewind_nbytes = u->sink->thread_info.rewind_nbytes;
 
@@ -1687,16 +1692,17 @@ static void thread_func(void *userdata) {
         pa_log_debug("Loop");
 #endif
 
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested)) {
+            if (process_rewind(u) < 0)
+                goto fail;
+        }
+
         /* Render some data and write it to the dsp */
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
             int work_done;
             pa_usec_t sleep_usec = 0;
             pa_bool_t on_timeout = pa_rtpoll_timer_elapsed(u->rtpoll);
 
-            if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
-                if (process_rewind(u) < 0)
-                        goto fail;
-
             if (u->use_mmap)
                 work_done = mmap_write(u, &sleep_usec, revents & POLLOUT, on_timeout);
             else
diff --git a/src/modules/jack/module-jack-sink.c b/src/modules/jack/module-jack-sink.c
index f18ff6e..028c86f 100644
--- a/src/modules/jack/module-jack-sink.c
+++ b/src/modules/jack/module-jack-sink.c
@@ -229,9 +229,8 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
+        if (u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
             goto fail;
diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
index 6d39158..6d36a6a 100644
--- a/src/modules/macosx/module-coreaudio-device.c
+++ b/src/modules/macosx/module-coreaudio-device.c
@@ -280,9 +280,6 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                 pa_assert(sink);
 
                 if (PA_SINK_IS_OPENED(sink->pa_sink->thread_info.state)) {
-                    if (sink->pa_sink->thread_info.rewind_requested)
-                        pa_sink_process_rewind(sink->pa_sink, 0);
-
                     audio_chunk.memblock = pa_memblock_new_fixed(u->module->core->mempool, buf->mData, buf->mDataByteSize, FALSE);
                     audio_chunk.length = buf->mDataByteSize;
                     audio_chunk.index = 0;
@@ -664,8 +661,14 @@ static void thread_func(void *userdata) {
     pa_thread_mq_install(&u->thread_mq);
 
     for (;;) {
+        coreaudio_sink *ca_sink;
         int ret;
 
+        PA_LLIST_FOREACH(ca_sink, u->sinks) {
+            if (ca_sink->pa_sink->thread_info.rewind_requested)
+                pa_sink_process_rewind(ca_sink->pa_sink, 0);
+        }
+
         ret = pa_rtpoll_run(u->rtpoll, TRUE);
 
         if (ret < 0)
diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c
index 1afdc12..b778019 100644
--- a/src/modules/module-combine-sink.c
+++ b/src/modules/module-combine-sink.c
@@ -305,9 +305,8 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
+        if (u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
 
         /* If no outputs are connected, render some data and drop it immediately. */
         if (u->sink->thread_info.state == PA_SINK_RUNNING && !u->thread_info.active_outputs) {
diff --git a/src/modules/module-esound-sink.c b/src/modules/module-esound-sink.c
index 0838716..54fed65 100644
--- a/src/modules/module-esound-sink.c
+++ b/src/modules/module-esound-sink.c
@@ -213,9 +213,8 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
+        if (u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
 
         if (u->rtpoll_item) {
             struct pollfd *pollfd;
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c
index f40546a..d6ea43f 100644
--- a/src/modules/module-null-sink.c
+++ b/src/modules/module-null-sink.c
@@ -136,11 +136,11 @@ static void process_rewind(struct userdata *u, pa_usec_t now) {
 
     pa_assert(u);
 
-    /* Figure out how much we shall rewind and reset the counter */
     rewind_nbytes = u->sink->thread_info.rewind_nbytes;
-    u->sink->thread_info.rewind_nbytes = 0;
 
-    pa_assert(rewind_nbytes > 0);
+    if (!PA_SINK_IS_OPENED(u->sink->thread_info.state) || rewind_nbytes <= 0)
+        goto do_nothing;
+
     pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes);
 
     if (u->timestamp <= now)
@@ -207,21 +207,17 @@ static void thread_func(void *userdata) {
     u->timestamp = pa_rtclock_now();
 
     for (;;) {
+        pa_usec_t now = 0;
         int ret;
 
-        /* Render some data and drop it immediately */
-        if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
-            pa_usec_t now;
-
+        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
             now = pa_rtclock_now();
 
-            if (u->sink->thread_info.rewind_requested) {
-                if (u->sink->thread_info.rewind_nbytes > 0)
-                    process_rewind(u, now);
-                else
-                    pa_sink_process_rewind(u->sink, 0);
-            }
+        if (u->sink->thread_info.rewind_requested)
+            process_rewind(u, now);
 
+        /* Render some data and drop it immediately */
+        if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
             if (u->timestamp <= now)
                 process_render(u, now);
 
diff --git a/src/modules/module-pipe-sink.c b/src/modules/module-pipe-sink.c
index ef18fad..1fcea17 100644
--- a/src/modules/module-pipe-sink.c
+++ b/src/modules/module-pipe-sink.c
@@ -180,12 +180,11 @@ static void thread_func(void *userdata) {
 
         pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
+        if (u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
+
         /* Render some data and write it to the fifo */
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
-
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
-
             if (pollfd->revents) {
                 if (process_render(u) < 0)
                     goto fail;
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 5081ceb..aaf7189 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -587,9 +587,12 @@ static void process_rewind(struct userdata *u) {
 
     pa_assert(u);
 
-    /* Figure out how much we shall rewind and reset the counter */
+    if (!PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
+        pa_sink_process_rewind(u->sink, 0);
+        return;
+    }
+
     rewind_nbytes = u->sink->thread_info.rewind_nbytes;
-    u->sink->thread_info.rewind_nbytes = 0;
 
     if (rewind_nbytes > 0) {
         pa_log_debug("Requested to rewind %lu bytes.", (unsigned long) rewind_nbytes);
@@ -625,13 +628,13 @@ static void thread_func(void *userdata) {
     for (;;) {
         /* Render some data and write it to the dsp */
 
+        if (u->sink->thread_info.rewind_requested)
+            process_rewind(u);
+
         if (u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
             pa_usec_t xtime0, ysleep_interval, xsleep_interval;
             uint64_t buffered_bytes;
 
-            if (u->sink->thread_info.rewind_requested)
-                process_rewind(u);
-
             err = ioctl(u->fd, AUDIO_GETINFO, &info);
             if (err < 0) {
                 pa_log("AUDIO_GETINFO ioctl failed: %s", pa_cstrerror(errno));
diff --git a/src/modules/module-tunnel.c b/src/modules/module-tunnel.c
index 4675a62..66b9617 100644
--- a/src/modules/module-tunnel.c
+++ b/src/modules/module-tunnel.c
@@ -698,9 +698,8 @@ static void thread_func(void *userdata) {
         int ret;
 
 #ifdef TUNNEL_SINK
-        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
-            if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
-                pa_sink_process_rewind(u->sink, 0);
+        if (PA_UNLIKELY(u->sink->thread_info.rewind_requested))
+            pa_sink_process_rewind(u->sink, 0);
 #endif
 
         if ((ret = pa_rtpoll_run(u->rtpoll, TRUE)) < 0)
diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c
index 53efce9..d02bb6b 100644
--- a/src/modules/module-waveout.c
+++ b/src/modules/module-waveout.c
@@ -255,13 +255,16 @@ static void thread_func(void *userdata) {
         int ret;
         pa_bool_t need_timer = FALSE;
 
-        if (u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
+        if (u->sink) {
             if (u->sink->thread_info.rewind_requested)
                 pa_sink_process_rewind(u->sink, 0);
 
-            do_write(u);
-            need_timer = TRUE;
+            if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
+                do_write(u);
+                need_timer = TRUE;
+            }
         }
+
         if (u->source && PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
             do_read(u);
             need_timer = TRUE;
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 6f0f271..3d79412 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -891,9 +891,8 @@ static void thread_func(void *userdata) {
 
 /*        pa_log("loop");    */
 
-        if (u->sink && PA_SINK_IS_OPENED(u->sink->thread_info.state))
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
+        if (u->sink && u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
 
         /* Render some data and write it to the dsp */
 
diff --git a/src/modules/raop/module-raop-sink.c b/src/modules/raop/module-raop-sink.c
index 2cb7a95..2952216 100644
--- a/src/modules/raop/module-raop-sink.c
+++ b/src/modules/raop/module-raop-sink.c
@@ -327,9 +327,8 @@ static void thread_func(void *userdata) {
     for (;;) {
         int ret;
 
-        if (PA_SINK_IS_OPENED(u->sink->thread_info.state))
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
+        if (u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
 
         if (u->rtpoll_item) {
             struct pollfd *pollfd;
diff --git a/src/modules/xen/module-xenpv-sink.c b/src/modules/xen/module-xenpv-sink.c
index 34e5fc4..a5756e5 100644
--- a/src/modules/xen/module-xenpv-sink.c
+++ b/src/modules/xen/module-xenpv-sink.c
@@ -338,12 +338,11 @@ static void thread_func(void *userdata) {
 
         pollfd = pa_rtpoll_item_get_pollfd(u->rtpoll_item, NULL);
 
+        if (u->sink->thread_info.rewind_requested)
+            pa_sink_process_rewind(u->sink, 0);
+
         /* Render some data and write it to the fifo */
         if (PA_SINK_IS_OPENED(u->sink->thread_info.state)) {
-
-            if (u->sink->thread_info.rewind_requested)
-                pa_sink_process_rewind(u->sink, 0);
-
             if (pollfd->revents) {
                 if (process_render(u) < 0)
                     goto fail;
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 1ccceb4..4512470 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -938,9 +938,6 @@ void pa_sink_process_rewind(pa_sink *s, size_t nbytes) {
     s->thread_info.rewind_nbytes = 0;
     s->thread_info.rewind_requested = FALSE;
 
-    if (s->thread_info.state == PA_SINK_SUSPENDED)
-        return;
-
     if (nbytes > 0) {
         pa_log_debug("Processing rewind...");
         if (s->flags & PA_SINK_DEFERRED_VOLUME)
@@ -2929,9 +2926,6 @@ void pa_sink_request_rewind(pa_sink*s, size_t nbytes) {
     pa_sink_assert_io_context(s);
     pa_assert(PA_SINK_IS_LINKED(s->thread_info.state));
 
-    if (s->thread_info.state == PA_SINK_SUSPENDED)
-        return;
-
     if (nbytes == (size_t) -1)
         nbytes = s->thread_info.max_rewind;
 

commit cd1102cce01e47645ed03ddf46a0a8b80d65fc9e
Author: Arun Raghavan <arun.raghavan at collabora.co.uk>
Date:   Thu Nov 15 15:51:52 2012 +0530

    sink, source: Prevent unnecessary rate update attempts
    
    We don't need to try a rate update if the desired sample rate is the
    same as the one the sink or source is already using.

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 7a7575a..a5edd21 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -371,10 +371,7 @@ int pa_sink_input_new(
 
         pa_log_info("Trying to change sample rate");
         if (pa_sink_update_rate(data->sink, data->sample_spec.rate, pa_sink_input_new_data_is_passthrough(data)) == TRUE)
-            pa_log_info("Rate changed to %u Hz",
-                        data->sink->sample_spec.rate);
-        else
-            pa_log_info("Resampling enabled to %u Hz", data->sink->sample_spec.rate);
+            pa_log_info("Rate changed to %u Hz", data->sink->sample_spec.rate);
     }
 
     /* Due to the fixing of the sample spec the volume might not match anymore */
@@ -1662,11 +1659,7 @@ int pa_sink_input_finish_move(pa_sink_input *i, pa_sink *dest, pa_bool_t save) {
 
         pa_log_info("Trying to change sample rate");
         if (pa_sink_update_rate(dest, i->sample_spec.rate, pa_sink_input_is_passthrough(i)) == TRUE)
-            pa_log_info("Rate changed to %u Hz",
-                        dest->sample_spec.rate);
-        else
-            pa_log_info("Resampling enabled to %u Hz",
-                        dest->sample_spec.rate);
+            pa_log_info("Rate changed to %u Hz", dest->sample_spec.rate);
     }
 
     if (i->moving)
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 9958be6..1ccceb4 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1392,6 +1392,9 @@ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
             desired_rate = rate; /* use stream sampling rate, discard default/alternate settings */
         }
 
+        if (desired_rate == s->sample_spec.rate)
+            return FALSE;
+
         if (!passthrough && pa_sink_used_by(s) > 0)
             return FALSE;
 
diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c
index 1297ec7..85045e7 100644
--- a/src/pulsecore/source-output.c
+++ b/src/pulsecore/source-output.c
@@ -350,10 +350,7 @@ int pa_source_output_new(
 
         pa_log_info("Trying to change sample rate");
         if (pa_source_update_rate(data->source, data->sample_spec.rate, pa_source_output_new_data_is_passthrough(data)) == TRUE)
-            pa_log_info("Rate changed to %u Hz",
-                        data->source->sample_spec.rate);
-        else
-            pa_log_info("Resampling enabled to %u Hz", data->source->sample_spec.rate);
+            pa_log_info("Rate changed to %u Hz", data->source->sample_spec.rate);
     }
 
     if (data->resample_method == PA_RESAMPLER_INVALID)
@@ -1425,11 +1422,7 @@ int pa_source_output_finish_move(pa_source_output *o, pa_source *dest, pa_bool_t
 
         pa_log_info("Trying to change sample rate");
         if (pa_source_update_rate(dest, o->sample_spec.rate, pa_source_output_is_passthrough(o)) == TRUE)
-            pa_log_info("Rate changed to %u Hz",
-                        dest->sample_spec.rate);
-        else
-            pa_log_info("Resampling enabled to %u Hz",
-                        dest->sample_spec.rate);
+            pa_log_info("Rate changed to %u Hz", dest->sample_spec.rate);
     }
 
     if (o->moving)
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 7af86f5..e9c3669 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -1000,6 +1000,9 @@ pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrou
             desired_rate = rate; /* use stream sampling rate, discard default/alternate settings */
         }
 
+        if (desired_rate == s->sample_spec.rate)
+            return FALSE;
+
         if (!passthrough && pa_source_used_by(s) > 0)
             return FALSE;
 



More information about the pulseaudio-commits mailing list