[pulseaudio-commits] 3 commits - src/pulsecore

Tanu Kaskinen tanuk at kemper.freedesktop.org
Wed Apr 10 06:33:41 PDT 2013


 src/pulsecore/core.h   |    2 ++
 src/pulsecore/sink.c   |   42 ++++++++++++++++++++++++++++++++++--------
 src/pulsecore/source.c |   28 +++++++++++++++++++++++++---
 3 files changed, 61 insertions(+), 11 deletions(-)

New commits:
commit 4096989ad6d9c6c36c90fe109a471946289ec931
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Thu Mar 28 17:30:16 2013 +0200

    sink, source: Send notifications when flags change
    
    The hooks aren't currently used, but for example, the D-Bus protocol
    could use them if it implemented flag change signals.

diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index 533ba9e..a8cff5c 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -74,6 +74,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SINK_STATE_CHANGED,
     PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
     PA_CORE_HOOK_SINK_PORT_CHANGED,
+    PA_CORE_HOOK_SINK_FLAGS_CHANGED,
     PA_CORE_HOOK_SOURCE_NEW,
     PA_CORE_HOOK_SOURCE_FIXATE,
     PA_CORE_HOOK_SOURCE_PUT,
@@ -82,6 +83,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SOURCE_STATE_CHANGED,
     PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
     PA_CORE_HOOK_SOURCE_PORT_CHANGED,
+    PA_CORE_HOOK_SOURCE_FLAGS_CHANGED,
     PA_CORE_HOOK_SINK_INPUT_NEW,
     PA_CORE_HOOK_SINK_INPUT_FIXATE,
     PA_CORE_HOOK_SINK_INPUT_PUT,
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index f5d4dbc..9b4b066 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -784,6 +784,9 @@ void pa_sink_update_flags(pa_sink *s, pa_sink_flags_t mask, pa_sink_flags_t valu
         pa_log_debug("Sink %s: DYNAMIC_LATENCY flag %s.",
                      s->name, (s->flags & PA_SINK_DYNAMIC_LATENCY) ? "enabled" : "disabled");
 
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_FLAGS_CHANGED], s);
+
     if (s->monitor_source)
         pa_source_update_flags(s->monitor_source,
                                ((mask & PA_SINK_LATENCY) ? PA_SOURCE_LATENCY : 0) |
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 6724c4b..c6aa5e3 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -710,6 +710,9 @@ void pa_source_update_flags(pa_source *s, pa_source_flags_t mask, pa_source_flag
         pa_log_debug("Source %s: DYNAMIC_LATENCY flag %s.",
                      s->name, (s->flags & PA_SOURCE_DYNAMIC_LATENCY) ? "enabled" : "disabled");
 
+    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+    pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_FLAGS_CHANGED], s);
+
     PA_IDXSET_FOREACH(output, s->outputs, idx) {
         if (output->destination_source)
             pa_source_update_flags(output->destination_source, mask, value);

commit ed51769a5932898e2d59b4fb326039fe7fd52c4c
Author: Tanu Kaskinen <tanu.kaskinen at jollamobile.com>
Date:   Thu Mar 28 17:30:15 2013 +0200

    sink, source: Really set the fixed latency in set_fixed_latency_within_thread(), always.
    
    The old assumption seemed to be that if a sink or source has the
    DYNAMIC_LATENCY flag set, it can never change, so the fixed latency
    will always be zero. This assumption doesn't hold with filter sinks
    and sources that are moved around.
    
    This fixes a crash with two module-virtual-sink instances on top of
    each other, when the bottom one is moved from a sink without dynamic
    latency to a sink with dynamic latency. What happened was that first
    the bottom virtual sink "updated" (due to this bug nothing was
    actually updated) its fixed latency to match the master sink (zero
    fixed latency), and then the top virtual sink updated its fixed
    latency to match the master sink. The master sink was the bottom
    virtual sink, whose fixed latency should have been set to zero, but it
    was not, so the pa_sink_set_fixed_latency_within_thread() failed in
    the assertion "latency == 0".

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 2320359..f5d4dbc 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -3268,6 +3268,11 @@ void pa_sink_set_fixed_latency_within_thread(pa_sink *s, pa_usec_t latency) {
 
     if (s->flags & PA_SINK_DYNAMIC_LATENCY) {
         pa_assert(latency == 0);
+        s->thread_info.fixed_latency = 0;
+
+        if (s->monitor_source)
+            pa_source_set_fixed_latency_within_thread(s->monitor_source, 0);
+
         return;
     }
 
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index fb2e14b..6724c4b 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -2528,6 +2528,8 @@ void pa_source_set_fixed_latency_within_thread(pa_source *s, pa_usec_t latency)
 
     if (s->flags & PA_SOURCE_DYNAMIC_LATENCY) {
         pa_assert(latency == 0);
+        s->thread_info.fixed_latency = 0;
+
         return;
     }
 

commit 6745b1f97020fca84f6a55a87da8bb38f5b270ac
Author: Tanu Kaskinen <tanuk at iki.fi>
Date:   Thu Mar 28 17:30:14 2013 +0200

    sink, source: Propagate flag changes to filters
    
    An example: let's say that there's an alsa sink and two filter sinks
    on top of each other:
    
            alsa-sink <- filter1 <- filter2
    
    With the old code, if filter1 gets moved to another sink, and the
    new sink doesn't have the LATENCY and DYNAMIC_LATENCY flags set
    (unlike alsa-sink), filter1's flags are updated fine in the moving()
    callback, but filter2 is not notified at all about the flag changes.
    With this patch, the flag changes are propagated to filter2 too.

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index d2d6c97..2320359 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -761,22 +761,40 @@ void pa_sink_set_asyncmsgq(pa_sink *s, pa_asyncmsgq *q) {
 
 /* Called from main context, and not while the IO thread is active, please */
 void pa_sink_update_flags(pa_sink *s, pa_sink_flags_t mask, pa_sink_flags_t value) {
+    pa_sink_flags_t old_flags;
+    pa_sink_input *input;
+    uint32_t idx;
+
     pa_sink_assert_ref(s);
     pa_assert_ctl_context();
 
-    if (mask == 0)
-        return;
-
     /* For now, allow only a minimal set of flags to be changed. */
     pa_assert((mask & ~(PA_SINK_DYNAMIC_LATENCY|PA_SINK_LATENCY)) == 0);
 
+    old_flags = s->flags;
     s->flags = (s->flags & ~mask) | (value & mask);
 
-    pa_source_update_flags(s->monitor_source,
-                           ((mask & PA_SINK_LATENCY) ? PA_SOURCE_LATENCY : 0) |
-                           ((mask & PA_SINK_DYNAMIC_LATENCY) ? PA_SOURCE_DYNAMIC_LATENCY : 0),
-                           ((value & PA_SINK_LATENCY) ? PA_SOURCE_LATENCY : 0) |
-                           ((value & PA_SINK_DYNAMIC_LATENCY) ? PA_SOURCE_DYNAMIC_LATENCY : 0));
+    if (s->flags == old_flags)
+        return;
+
+    if ((s->flags & PA_SINK_LATENCY) != (old_flags & PA_SINK_LATENCY))
+        pa_log_debug("Sink %s: LATENCY flag %s.", s->name, (s->flags & PA_SINK_LATENCY) ? "enabled" : "disabled");
+
+    if ((s->flags & PA_SINK_DYNAMIC_LATENCY) != (old_flags & PA_SINK_DYNAMIC_LATENCY))
+        pa_log_debug("Sink %s: DYNAMIC_LATENCY flag %s.",
+                     s->name, (s->flags & PA_SINK_DYNAMIC_LATENCY) ? "enabled" : "disabled");
+
+    if (s->monitor_source)
+        pa_source_update_flags(s->monitor_source,
+                               ((mask & PA_SINK_LATENCY) ? PA_SOURCE_LATENCY : 0) |
+                               ((mask & PA_SINK_DYNAMIC_LATENCY) ? PA_SOURCE_DYNAMIC_LATENCY : 0),
+                               ((value & PA_SINK_LATENCY) ? PA_SOURCE_LATENCY : 0) |
+                               ((value & PA_SINK_DYNAMIC_LATENCY) ? PA_SOURCE_DYNAMIC_LATENCY : 0));
+
+    PA_IDXSET_FOREACH(input, s->inputs, idx) {
+        if (input->origin_sink)
+            pa_sink_update_flags(input->origin_sink, mask, value);
+    }
 }
 
 /* Called from IO context, or before _put() from main context */
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 4e4cd67..fb2e14b 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -687,16 +687,33 @@ void pa_source_set_asyncmsgq(pa_source *s, pa_asyncmsgq *q) {
 
 /* Called from main context, and not while the IO thread is active, please */
 void pa_source_update_flags(pa_source *s, pa_source_flags_t mask, pa_source_flags_t value) {
+    pa_source_flags_t old_flags;
+    pa_source_output *output;
+    uint32_t idx;
+
     pa_source_assert_ref(s);
     pa_assert_ctl_context();
 
-    if (mask == 0)
-        return;
-
     /* For now, allow only a minimal set of flags to be changed. */
     pa_assert((mask & ~(PA_SOURCE_DYNAMIC_LATENCY|PA_SOURCE_LATENCY)) == 0);
 
+    old_flags = s->flags;
     s->flags = (s->flags & ~mask) | (value & mask);
+
+    if (s->flags == old_flags)
+        return;
+
+    if ((s->flags & PA_SOURCE_LATENCY) != (old_flags & PA_SOURCE_LATENCY))
+        pa_log_debug("Source %s: LATENCY flag %s.", s->name, (s->flags & PA_SOURCE_LATENCY) ? "enabled" : "disabled");
+
+    if ((s->flags & PA_SOURCE_DYNAMIC_LATENCY) != (old_flags & PA_SOURCE_DYNAMIC_LATENCY))
+        pa_log_debug("Source %s: DYNAMIC_LATENCY flag %s.",
+                     s->name, (s->flags & PA_SOURCE_DYNAMIC_LATENCY) ? "enabled" : "disabled");
+
+    PA_IDXSET_FOREACH(output, s->outputs, idx) {
+        if (output->destination_source)
+            pa_source_update_flags(output->destination_source, mask, value);
+    }
 }
 
 /* Called from IO context, or before _put() from main context */



More information about the pulseaudio-commits mailing list