[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.16-test4-82-g8dd0d87

Lennart Poettering gitmailer-noreply at 0pointer.de
Sat Aug 15 15:45:35 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  de4968cdded8d78fe2e59b4487a21937b843c570 (commit)

- Log -----------------------------------------------------------------
8dd0d87 core: add to FIXMEs
4c29ba9 modules: add various checks to avoid selecting objects that are not linked or in another unclear state
2a39663 bluetooth: move installation of mq's earlier to avoid context asserts to be triggered
-----------------------------------------------------------------------

Summary of changes:
 src/modules/bluetooth/module-bluetooth-device.c |    4 +-
 src/modules/module-intended-roles.c             |   54 +++++++++++++++++++---
 src/modules/module-rescue-streams.c             |    6 +++
 src/modules/module-stream-restore.c             |   18 ++++++++
 src/pulsecore/namereg.c                         |   30 +++++++++---
 src/pulsecore/sink-input.h                      |    1 +
 src/pulsecore/sink.c                            |    1 +
 7 files changed, 96 insertions(+), 18 deletions(-)

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

commit 2a39663ab61614982c52e244bde596dcc1a08f37
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 16 00:43:22 2009 +0200

    bluetooth: move installation of mq's earlier to avoid context asserts to be triggered

diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index 5f119c7..d6321fc 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -1262,11 +1262,11 @@ static void thread_func(void *userdata) {
     if (u->core->realtime_scheduling)
         pa_make_realtime(u->core->realtime_priority);
 
+    pa_thread_mq_install(&u->thread_mq);
+
     if (start_stream_fd(u) < 0)
         goto fail;
 
-    pa_thread_mq_install(&u->thread_mq);
-
     for (;;) {
         struct pollfd *pollfd;
         int ret;

commit 4c29ba9c332dd682ced5ed668aede16aa5861128
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 16 00:45:23 2009 +0200

    modules: add various checks to avoid selecting objects that are not linked or in another unclear state

diff --git a/src/modules/module-intended-roles.c b/src/modules/module-intended-roles.c
index c697209..b9924df 100644
--- a/src/modules/module-intended-roles.c
+++ b/src/modules/module-intended-roles.c
@@ -127,6 +127,9 @@ static pa_hook_result_t sink_input_new_hook_callback(pa_core *c, pa_sink_input_n
         if (s == def)
             continue;
 
+        if (!PA_SINK_IS_LINKED(pa_sink_get_state(s)))
+            continue;
+
         if (role_match(s->proplist, role)) {
             new_data->sink = s;
             new_data->save_sink = FALSE;
@@ -173,6 +176,9 @@ static pa_hook_result_t source_output_new_hook_callback(pa_core *c, pa_source_ou
         if (s == def)
             continue;
 
+        if (!PA_SOURCE_IS_LINKED(pa_source_get_state(s)))
+            continue;
+
         if (role_match(s->proplist, role)) {
             new_data->source = s;
             new_data->save_source = FALSE;
@@ -201,6 +207,17 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
         if (si->save_sink)
             continue;
 
+        /* Skip this if it is already in the process of being moved
+         * anyway */
+        if (!si->sink)
+            continue;
+
+        /* It might happen that a stream and a sink are set up at the
+           same time, in which case we want to make sure we don't
+           interfere with that */
+        if (!PA_SINK_INPUT_IS_LINKED(pa_sink_input_get_state(si)))
+            continue;
+
         if (!(role = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_ROLE)))
             continue;
 
@@ -237,6 +254,17 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
         if (so->direct_on_input)
             continue;
 
+        /* Skip this if it is already in the process of being moved
+         * anyway */
+        if (!so->source)
+            continue;
+
+        /* It might happen that a stream and a source are set up at the
+           same time, in which case we want to make sure we don't
+           interfere with that */
+        if (!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(so)))
+            continue;
+
         if (!(role = pa_proplist_gets(so->proplist, PA_PROP_MEDIA_ROLE)))
             continue;
 
@@ -275,24 +303,28 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, str
         uint32_t jdx;
         pa_sink *d;
 
+        if (!si->sink)
+            continue;
+
         if (!(role = pa_proplist_gets(si->proplist, PA_PROP_MEDIA_ROLE)))
             continue;
 
         /* Would the default sink fit? If so, let's use it */
-        if (def != sink && role_match(def->proplist, role)) {
-            pa_sink_input_move_to(si, def, FALSE);
-            continue;
-        }
+        if (def != sink && role_match(def->proplist, role))
+            if (pa_sink_input_move_to(si, def, FALSE) >= 0)
+                continue;
 
         /* Try to find some other fitting sink */
         PA_IDXSET_FOREACH(d, c->sinks, jdx) {
             if (d == def || d == sink)
                 continue;
 
-            if (role_match(d->proplist, role)) {
-                pa_sink_input_move_to(si, d, FALSE);
-                break;
-            }
+            if (!PA_SINK_IS_LINKED(pa_sink_get_state(d)))
+                continue;
+
+            if (role_match(d->proplist, role))
+                if (pa_sink_input_move_to(si, d, FALSE) >= 0)
+                    break;
         }
     }
 
@@ -325,6 +357,9 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
         if (so->direct_on_input)
             continue;
 
+        if (!so->source)
+            continue;
+
         if (!(role = pa_proplist_gets(so->proplist, PA_PROP_MEDIA_ROLE)))
             continue;
 
@@ -339,6 +374,9 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
             if (d == def || d == source)
                 continue;
 
+            if (!PA_SOURCE_IS_LINKED(pa_source_get_state(d)))
+                continue;
+
             if (role_match(d->proplist, role) && !source->monitor_of == !d->monitor_of) {
                 pa_source_output_move_to(so, d, FALSE);
                 break;
diff --git a/src/modules/module-rescue-streams.c b/src/modules/module-rescue-streams.c
index 82f693f..722d84b 100644
--- a/src/modules/module-rescue-streams.c
+++ b/src/modules/module-rescue-streams.c
@@ -71,6 +71,9 @@ static pa_sink* find_evacuation_sink(pa_core *c, pa_sink_input *i, pa_sink *skip
         if (target == skip)
             continue;
 
+        if (!PA_SINK_IS_LINKED(pa_sink_get_state(target)))
+            continue;
+
         if (pa_sink_input_may_move_to(i, target))
             return target;
     }
@@ -159,6 +162,9 @@ static pa_source* find_evacuation_source(pa_core *c, pa_source_output *o, pa_sou
         if (!target->monitor_of != !skip->monitor_of)
             continue;
 
+        if (!PA_SOURCE_IS_LINKED(pa_source_get_state(target)))
+            continue;
+
         if (pa_source_output_may_move_to(o, target))
             return target;
     }
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 727a527..e560bd2 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -540,6 +540,11 @@ static pa_hook_result_t sink_put_hook_callback(pa_core *c, pa_sink *sink, struct
         if (si->save_sink)
             continue;
 
+        /* Skip this if it is already in the process of being moved
+         * anyway */
+        if (!si->sink)
+            continue;
+
         /* It might happen that a stream and a sink are set up at the
            same time, in which case we want to make sure we don't
            interfere with that */
@@ -584,6 +589,10 @@ static pa_hook_result_t source_put_hook_callback(pa_core *c, pa_source *source,
         if (so->direct_on_input)
             continue;
 
+        /* Skip this if it is already in the process of being moved anyway */
+        if (!so->source)
+            continue;
+
         /* It might happen that a stream and a sink are set up at the
            same time, in which case we want to make sure we don't
            interfere with that */
@@ -623,6 +632,9 @@ static pa_hook_result_t sink_unlink_hook_callback(pa_core *c, pa_sink *sink, str
         char *name;
         struct entry *e;
 
+        if (!si->sink)
+            continue;
+
         if (!(name = get_name(si->proplist, "sink-input")))
             continue;
 
@@ -663,6 +675,12 @@ static pa_hook_result_t source_unlink_hook_callback(pa_core *c, pa_source *sourc
         char *name;
         struct entry *e;
 
+        if (so->direct_on_input)
+            continue;
+
+        if (!so->source)
+            continue;
+
         if (!(name = get_name(so->proplist, "source-output")))
             continue;
 
diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c
index 9df2f58..e26923d 100644
--- a/src/pulsecore/namereg.c
+++ b/src/pulsecore/namereg.c
@@ -223,6 +223,9 @@ void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type) {
 pa_sink* pa_namereg_set_default_sink(pa_core*c, pa_sink *s) {
     pa_assert(c);
 
+    if (s && !PA_SINK_IS_LINKED(pa_sink_get_state(s)))
+        return NULL;
+
     if (c->default_sink != s) {
         c->default_sink = s;
         pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SERVER|PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
@@ -234,6 +237,9 @@ pa_sink* pa_namereg_set_default_sink(pa_core*c, pa_sink *s) {
 pa_source* pa_namereg_set_default_source(pa_core*c, pa_source *s) {
     pa_assert(c);
 
+    if (s && !PA_SOURCE_IS_LINKED(pa_source_get_state(s)))
+        return NULL;
+
     if (c->default_source != s) {
         c->default_source = s;
         pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SERVER|PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
@@ -244,14 +250,19 @@ pa_source* pa_namereg_set_default_source(pa_core*c, pa_source *s) {
 
 pa_sink *pa_namereg_get_default_sink(pa_core *c) {
     pa_sink *s;
+    uint32_t idx;
 
     pa_assert(c);
 
-    if (c->default_sink)
+    if (c->default_sink && PA_SINK_IS_LINKED(pa_sink_get_state(c->default_sink)))
         return c->default_sink;
 
-    if ((s = pa_idxset_first(c->sinks, NULL)))
-        return pa_namereg_set_default_sink(c, s);
+    /* FIXME: the selection here should be based priority values on
+     * the sinks */
+
+    PA_IDXSET_FOREACH(s, c->sinks, idx)
+        if (PA_SINK_IS_LINKED(pa_sink_get_state(s)))
+            return pa_namereg_set_default_sink(c, s);
 
     return NULL;
 }
@@ -262,15 +273,18 @@ pa_source *pa_namereg_get_default_source(pa_core *c) {
 
     pa_assert(c);
 
-    if (c->default_source)
+    if (c->default_source && PA_SOURCE_IS_LINKED(pa_source_get_state(c->default_source)))
         return c->default_source;
 
-    for (s = PA_SOURCE(pa_idxset_first(c->sources, &idx)); s; s = PA_SOURCE(pa_idxset_next(c->sources, &idx)))
-        if (!s->monitor_of)
+    /* First, try to find one that isn't a monitor */
+    PA_IDXSET_FOREACH(s, c->sources, idx)
+        if (!s->monitor_of && PA_SOURCE_IS_LINKED(pa_source_get_state(s)))
             return pa_namereg_set_default_source(c, s);
 
-    if ((s = pa_idxset_first(c->sources, NULL)))
-        return pa_namereg_set_default_source(c, s);
+    /* Then, fallback to a monitor */
+    PA_IDXSET_FOREACH(s, c->sources, idx)
+        if (PA_SOURCE_IS_LINKED(pa_source_get_state(s)))
+            return pa_namereg_set_default_source(c, s);
 
     return NULL;
 }

commit 8dd0d871a7dd2d97c63ec8e38e1b408637d1b639
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sun Aug 16 00:45:56 2009 +0200

    core: add to FIXMEs

diff --git a/src/pulsecore/sink-input.h b/src/pulsecore/sink-input.h
index c182083..b5502c4 100644
--- a/src/pulsecore/sink-input.h
+++ b/src/pulsecore/sink-input.h
@@ -42,6 +42,7 @@ typedef enum pa_sink_input_state {
     PA_SINK_INPUT_RUNNING,      /*< The stream is alive and kicking */
     PA_SINK_INPUT_CORKED,       /*< The stream was corked on user request */
     PA_SINK_INPUT_UNLINKED      /*< The stream is dead */
+    /* FIXME: we need a state for MOVING here */
 } pa_sink_input_state_t;
 
 static inline pa_bool_t PA_SINK_INPUT_IS_LINKED(pa_sink_input_state_t x) {
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index c79aa79..717584f 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -307,6 +307,7 @@ pa_sink* pa_sink_new(
     s->thread_info.max_latency = ABSOLUTE_MAX_LATENCY;
     s->thread_info.fixed_latency = flags & PA_SINK_DYNAMIC_LATENCY ? 0 : DEFAULT_FIXED_LATENCY;
 
+    /* FIXME: This should probably be moved to pa_sink_put() */
     pa_assert_se(pa_idxset_put(core->sinks, s, &s->index) >= 0);
 
     if (s->card)

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list