[pulseaudio-discuss] [PATCH] Initialise write_volume

Maarten Bosmans mkbosmans at gmail.com
Mon Aug 15 11:19:40 PDT 2011


The callback should also be reset in reset_calbacks().
The extra check in _volume_change_apply() is needed because when the sink is unlinked the callbacks are reset,
but there still may be pending volume changes.
---
 src/pulsecore/sink.c   |    8 ++++++++
 src/pulsecore/source.c |    8 ++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 6277698..e6e410c 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -174,6 +174,7 @@ static void reset_callbacks(pa_sink *s) {
     s->set_state = NULL;
     s->get_volume = NULL;
     s->set_volume = NULL;
+    s->write_volume = NULL;
     s->get_mute = NULL;
     s->set_mute = NULL;
     s->request_rewind = NULL;
@@ -3350,6 +3351,13 @@ pa_bool_t pa_sink_volume_change_apply(pa_sink *s, pa_usec_t *usec_to_next) {
     pa_bool_t ret = FALSE;
 
     pa_assert(s);
+
+    if (!PA_SINK_IS_LINKED(s->state)) {
+        if (usec_to_next)
+            *usec_to_next = 0;
+        return ret;
+    }
+
     pa_assert(s->write_volume);
 
     while (s->thread_info.volume_changes && now >= s->thread_info.volume_changes->at) {
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 31ce39d..ae9528f 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -144,6 +144,7 @@ static void reset_callbacks(pa_source *s) {
     s->set_state = NULL;
     s->get_volume = NULL;
     s->set_volume = NULL;
+    s->write_volume = NULL;
     s->get_mute = NULL;
     s->set_mute = NULL;
     s->update_requested_latency = NULL;
@@ -2533,6 +2534,13 @@ pa_bool_t pa_source_volume_change_apply(pa_source *s, pa_usec_t *usec_to_next) {
     pa_bool_t ret = FALSE;
 
     pa_assert(s);
+
+    if (!PA_SOURCE_IS_LINKED(s->state)) {
+        if (usec_to_next)
+            *usec_to_next = 0;
+        return ret;
+    }
+
     pa_assert(s->write_volume);
 
     while (s->thread_info.volume_changes && now >= s->thread_info.volume_changes->at) {
-- 
1.7.4.1



More information about the pulseaudio-discuss mailing list