[pulseaudio-discuss] [PATCH 3/4] core: no rewinding on volume change if the sink does not support it.

oku at iki.fi oku at iki.fi
Fri Apr 8 07:18:14 PDT 2011


From: Jyri Sarha <jyri.sarha at nokia.com>

No volume is applied to a stream before pa_sink_render or some
it's siblings is called. Because of this there is no use to
rewind on volume change if the sink does not support it. It is
just a waste of CPU.
---
 src/pulsecore/sink-input.c |    6 ++++--
 src/pulsecore/sink.c       |    3 ++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c
index 46f26f9..28d083d 100644
--- a/src/pulsecore/sink-input.c
+++ b/src/pulsecore/sink-input.c
@@ -1648,14 +1648,16 @@ int pa_sink_input_process_msg(pa_msgobject *o, int code, void *userdata, int64_t
         case PA_SINK_INPUT_MESSAGE_SET_SOFT_VOLUME:
             if (!pa_cvolume_equal(&i->thread_info.soft_volume, &i->soft_volume)) {
                 i->thread_info.soft_volume = i->soft_volume;
-                pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
+                if (i->sink && i->sink->thread_info.max_rewind > 0)
+                    pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
             }
             return 0;
 
         case PA_SINK_INPUT_MESSAGE_SET_SOFT_MUTE:
             if (i->thread_info.muted != i->muted) {
                 i->thread_info.muted = i->muted;
-                pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
+                if (i->sink && i->sink->thread_info.max_rewind > 0)
+                    pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
             }
             return 0;
 
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 839b7d4..ebe4c7b 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -2060,7 +2060,8 @@ static void sync_input_volumes_within_thread(pa_sink *s) {
             continue;
 
         i->thread_info.soft_volume = i->soft_volume;
-        pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
+        if (s->thread_info.max_rewind > 0)
+            pa_sink_input_request_rewind(i, 0, TRUE, FALSE, FALSE);
     }
 }
 
-- 
1.7.1




More information about the pulseaudio-discuss mailing list