From ec1c92347da686de0a4d8cd0886488a320e3d59f Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 4 Mar 2009 05:30:28 +0100 Subject: print error code when suspend/resume fails --- src/pulsecore/cli-command.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 334d05d1..b5f7e7f5 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -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; } -- cgit