[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-test3-44-g656fc66

Lennart Poettering gitmailer-noreply at 0pointer.de
Tue Mar 3 20:33:25 PST 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  d09287d211164a93bcbb66839998fc64bad746ce (commit)

- Log -----------------------------------------------------------------
656fc66... never try to suspend monitor sources, suspend the sinks they belong to instead
ec1c923... print error code when suspend/resume fails
0dd8a33... handle negative error codes
341f44f... fix handling of _suspend_all(), return first failure error code
ecbc320... make suspend state of monitor source follow the suspend state of the sink it belongs to
bffa8be... Don't allow suspending of monitor sources.
-----------------------------------------------------------------------

Summary of changes:
 src/modules/module-suspend-on-idle.c |   63 +++++++++++++++++++++++++++-------
 src/pulse/error.c                    |    5 ++-
 src/pulsecore/cli-command.c          |   25 +++++++------
 src/pulsecore/sink.c                 |   11 +++++-
 src/pulsecore/source.c               |   32 ++++++++++++++++-
 src/pulsecore/source.h               |    2 +
 6 files changed, 109 insertions(+), 29 deletions(-)

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

commit bffa8be8cd208fbc4d3cd44c34be47e9e47b086f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 4 05:25:41 2009 +0100

    Don't allow suspending of monitor sources.
    
    Closes #499

diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 5277716..f946366 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -424,6 +424,9 @@ int pa_source_suspend(pa_source *s, pa_bool_t suspend) {
     pa_source_assert_ref(s);
     pa_assert(PA_SOURCE_IS_LINKED(s->state));
 
+    if (s->monitor_of)
+        return -PA_ERR_NOTSUPPORTED;
+
     if (suspend)
         return source_set_state(s, PA_SOURCE_SUSPENDED);
     else

commit ecbc320a4c219b40795e0462de6f37d610003c88
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 4 05:27:14 2009 +0100

    make suspend state of monitor source follow the suspend state of the sink it belongs to

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index 1133403..ed68dd8 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -326,6 +326,9 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
                 pa_sink_input_kill(i);
             else if (i->suspend)
                 i->suspend(i, state == PA_SINK_SUSPENDED);
+
+        if (s->monitor_source)
+            pa_source_sync_suspend(s->monitor_source);
     }
 
     return 0;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index f946366..476cb55 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -434,6 +434,24 @@ int pa_source_suspend(pa_source *s, pa_bool_t suspend) {
 }
 
 /* Called from main context */
+int pa_source_sync_suspend(pa_source *s) {
+    pa_sink_state_t state;
+
+    pa_source_assert_ref(s);
+    pa_assert(PA_SOURCE_IS_LINKED(s->state));
+    pa_assert(s->monitor_of);
+
+    state = pa_sink_get_state(s->monitor_of);
+
+    if (state == PA_SINK_SUSPENDED)
+        return source_set_state(s, PA_SOURCE_SUSPENDED);
+
+    pa_assert(PA_SINK_IS_OPENED(state));
+
+    return source_set_state(s, pa_source_used_by(s) ? PA_SOURCE_RUNNING : PA_SOURCE_IDLE);
+}
+
+/* Called from main context */
 pa_queue *pa_source_move_all_start(pa_source *s) {
     pa_queue *q;
     pa_source_output *o, *n;
diff --git a/src/pulsecore/source.h b/src/pulsecore/source.h
index 2aac25f..26471de 100644
--- a/src/pulsecore/source.h
+++ b/src/pulsecore/source.h
@@ -212,6 +212,8 @@ void pa_source_attach(pa_source *s);
 
 void pa_source_set_soft_volume(pa_source *s, const pa_cvolume *volume);
 
+int pa_source_sync_suspend(pa_source *s);
+
 /*** May be called by everyone, from main context */
 
 /* The returned value is supposed to be in the time domain of the sound card! */

commit 341f44fa24dfff910c34e0cd8c4819e88231cff6
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 4 05:27:49 2009 +0100

    fix handling of _suspend_all(), return first failure error code

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index ed68dd8..667ae76 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1605,8 +1605,12 @@ int pa_sink_suspend_all(pa_core *c, pa_bool_t suspend) {
 
     pa_core_assert_ref(c);
 
-    for (sink = PA_SINK(pa_idxset_first(c->sinks, &idx)); sink; sink = PA_SINK(pa_idxset_next(c->sinks, &idx)))
-        ret -= pa_sink_suspend(sink, suspend) < 0;
+    for (sink = PA_SINK(pa_idxset_first(c->sinks, &idx)); sink; sink = PA_SINK(pa_idxset_next(c->sinks, &idx))) {
+        int r;
+
+        if ((r = pa_sink_suspend(sink, suspend)) < 0)
+            ret = r;
+    }
 
     return ret;
 }
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 476cb55..cc6dfc4 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -955,8 +955,15 @@ int pa_source_suspend_all(pa_core *c, pa_bool_t suspend) {
 
     pa_core_assert_ref(c);
 
-    for (source = PA_SOURCE(pa_idxset_first(c->sources, &idx)); source; source = PA_SOURCE(pa_idxset_next(c->sources, &idx)))
-        ret -= pa_source_suspend(source, suspend) < 0;
+    for (source = PA_SOURCE(pa_idxset_first(c->sources, &idx)); source; source = PA_SOURCE(pa_idxset_next(c->sources, &idx))) {
+        int r;
+
+        if (source->monitor_of)
+            continue;
+
+        if ((r = pa_source_suspend(source, suspend)) < 0)
+            ret = r;
+    }
 
     return ret;
 }

commit 0dd8a3306f552c5f9d5fa69635df617ecf503b2f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 4 05:29:09 2009 +0100

    handle negative error codes

diff --git a/src/pulse/error.c b/src/pulse/error.c
index 3f2e70e..9551d98 100644
--- a/src/pulse/error.c
+++ b/src/pulse/error.c
@@ -68,7 +68,10 @@ const char*pa_strerror(int error) {
 
     pa_init_i18n();
 
-    if (error < 0 || error >= PA_ERR_MAX)
+    if (error < 0)
+        error = -error;
+
+    if (error >= PA_ERR_MAX)
         return NULL;
 
     return _(errortab[error]);

commit ec1c92347da686de0a4d8cd0886488a320e3d59f
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 4 05:30:28 2009 +0100

    print error code when suspend/resume fails

diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index 334d05d..b5f7e7f 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -32,6 +32,7 @@
 #include <ltdl.h>
 
 #include <pulse/xmalloc.h>
+#include <pulse/error.h>
 
 #include <pulsecore/module.h>
 #include <pulsecore/sink.h>
@@ -1236,7 +1237,7 @@ static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_str
 static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
     const char *n, *m;
     pa_sink *sink;
-    int suspend;
+    int suspend, r;
 
     pa_core_assert_ref(c);
     pa_assert(t);
@@ -1263,14 +1264,16 @@ static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *b
         return -1;
     }
 
-    pa_sink_suspend(sink, suspend);
+    if ((r = pa_sink_suspend(sink, suspend)) < 0)
+        pa_strbuf_printf(buf, "Failed to resume/suspend sink: %s\n", pa_strerror(r));
+
     return 0;
 }
 
 static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
     const char *n, *m;
     pa_source *source;
-    int suspend;
+    int suspend, r;
 
     pa_core_assert_ref(c);
     pa_assert(t);
@@ -1297,14 +1300,15 @@ static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    pa_source_suspend(source, suspend);
+    if ((r = pa_source_suspend(source, suspend)) < 0)
+        pa_strbuf_printf(buf, "Failed to resume/suspend source: %s\n", pa_strerror(r));
+
     return 0;
 }
 
 static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) {
     const char *m;
-    int suspend;
-    int ret;
+    int suspend, r;
 
     pa_core_assert_ref(c);
     pa_assert(t);
@@ -1321,12 +1325,11 @@ static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, p
         return -1;
     }
 
-    ret = - (pa_sink_suspend_all(c, suspend) < 0);
-    if (pa_source_suspend_all(c, suspend) < 0)
-        ret = -1;
+    if ((r = pa_sink_suspend_all(c, suspend)) < 0)
+        pa_strbuf_printf(buf, "Failed to resume/suspend all sinks: %s\n", pa_strerror(r));
 
-    if (ret < 0)
-        pa_strbuf_puts(buf, "Failed to resume/suspend all sinks/sources.\n");
+    if ((r = pa_source_suspend_all(c, suspend)) < 0)
+        pa_strbuf_printf(buf, "Failed to resume/suspend all sources: %s\n", pa_strerror(r));
 
     return 0;
 }

commit 656fc6660fac6ad4524fd2b679cbd35c69033d3b
Author: Lennart Poettering <lennart at poettering.net>
Date:   Wed Mar 4 05:31:53 2009 +0100

    never try to suspend monitor sources, suspend the sinks they belong to instead

diff --git a/src/modules/module-suspend-on-idle.c b/src/modules/module-suspend-on-idle.c
index 945fd09..7e17f8f 100644
--- a/src/modules/module-suspend-on-idle.c
+++ b/src/modules/module-suspend-on-idle.c
@@ -149,7 +149,12 @@ static pa_hook_result_t source_output_fixate_hook_cb(pa_core *c, pa_source_outpu
     pa_assert(data);
     pa_assert(u);
 
-    if ((d = pa_hashmap_get(u->device_infos, data->source)))
+    if (data->source->monitor_of)
+        d = pa_hashmap_get(u->device_infos, data->source->monitor_of);
+    else
+        d = pa_hashmap_get(u->device_infos, data->source);
+
+    if (d)
         resume(d);
 
     return PA_HOOK_OK;
@@ -173,6 +178,8 @@ static pa_hook_result_t sink_input_unlink_hook_cb(pa_core *c, pa_sink_input *s,
 }
 
 static pa_hook_result_t source_output_unlink_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
+    struct device_info *d = NULL;
+
     pa_assert(c);
     pa_source_output_assert_ref(s);
     pa_assert(u);
@@ -180,12 +187,17 @@ static pa_hook_result_t source_output_unlink_hook_cb(pa_core *c, pa_source_outpu
     if (!s->source)
         return PA_HOOK_OK;
 
-    if (pa_source_check_suspend(s->source) <= 0) {
-        struct device_info *d;
-        if ((d = pa_hashmap_get(u->device_infos, s->source)))
-            restart(d);
+    if (s->source->monitor_of) {
+        if (pa_sink_check_suspend(s->source->monitor_of) <= 0)
+            d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
+    } else {
+        if (pa_source_check_suspend(s->source) <= 0)
+            d = pa_hashmap_get(u->device_infos, s->source);
     }
 
+    if (d)
+        restart(d);
+
     return PA_HOOK_OK;
 }
 
@@ -217,15 +229,22 @@ static pa_hook_result_t sink_input_move_finish_hook_cb(pa_core *c, pa_sink_input
 }
 
 static pa_hook_result_t source_output_move_start_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
-    struct device_info *d;
+    struct device_info *d = NULL;
 
     pa_assert(c);
     pa_source_output_assert_ref(s);
     pa_assert(u);
 
-    if (pa_source_check_suspend(s->source) <= 1)
-        if ((d = pa_hashmap_get(u->device_infos, s->source)))
-            restart(d);
+    if (s->source->monitor_of) {
+        if (pa_sink_check_suspend(s->source->monitor_of) <= 1)
+            d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
+    } else {
+        if (pa_source_check_suspend(s->source) <= 1)
+            d = pa_hashmap_get(u->device_infos, s->source);
+    }
+
+    if (d)
+        restart(d);
 
     return PA_HOOK_OK;
 }
@@ -237,7 +256,12 @@ static pa_hook_result_t source_output_move_finish_hook_cb(pa_core *c, pa_source_
     pa_source_output_assert_ref(s);
     pa_assert(u);
 
-    if ((d = pa_hashmap_get(u->device_infos, s->source)))
+    if (s->source->monitor_of)
+        d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
+    else
+        d = pa_hashmap_get(u->device_infos, s->source);
+
+    if (d)
         resume(d);
 
     return PA_HOOK_OK;
@@ -259,16 +283,25 @@ static pa_hook_result_t sink_input_state_changed_hook_cb(pa_core *c, pa_sink_inp
 }
 
 static pa_hook_result_t source_output_state_changed_hook_cb(pa_core *c, pa_source_output *s, struct userdata *u) {
-    struct device_info *d;
     pa_source_output_state_t state;
+
     pa_assert(c);
     pa_source_output_assert_ref(s);
     pa_assert(u);
 
     state = pa_source_output_get_state(s);
-    if (state == PA_SOURCE_OUTPUT_RUNNING)
-        if ((d = pa_hashmap_get(u->device_infos, s->source)))
+
+    if (state == PA_SOURCE_OUTPUT_RUNNING) {
+        struct device_info *d;
+
+        if (s->source->monitor_of)
+            d = pa_hashmap_get(u->device_infos, s->source->monitor_of);
+        else
+            d = pa_hashmap_get(u->device_infos, s->source);
+
+        if (d)
             resume(d);
+    }
 
     return PA_HOOK_OK;
 }
@@ -285,6 +318,10 @@ static pa_hook_result_t device_new_hook_cb(pa_core *c, pa_object *o, struct user
     source = pa_source_isinstance(o) ? PA_SOURCE(o) : NULL;
     sink = pa_sink_isinstance(o) ? PA_SINK(o) : NULL;
 
+    /* Never suspend monitors */
+    if (source && source->monitor_of)
+        return PA_HOOK_OK;
+
     pa_assert(source || sink);
 
     d = pa_xnew(struct device_info, 1);

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list