diff options
Diffstat (limited to 'src/utils/pasuspender.c')
-rw-r--r-- | src/utils/pasuspender.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/utils/pasuspender.c b/src/utils/pasuspender.c index ad86b943..5b4885db 100644 --- a/src/utils/pasuspender.c +++ b/src/utils/pasuspender.c @@ -1,5 +1,3 @@ -/* $Id$ */ - /*** This file is part of PulseAudio. @@ -81,26 +79,26 @@ static void drain(void) { } static void start_child(void) { - + if ((child_pid = fork()) < 0) { - + fprintf(stderr, "fork(): %s\n", strerror(errno)); quit(1); - + } else if (child_pid == 0) { /* Child */ - + #ifdef __linux__ prctl(PR_SET_PDEATHSIG, SIGTERM, 0, 0, 0); #endif - + if (execvp(child_argv[0], child_argv) < 0) fprintf(stderr, "execvp(): %s\n", strerror(errno)); - + _exit(1); - + } else { - + /* parent */ dead = 0; } @@ -110,7 +108,7 @@ static void suspend_complete(pa_context *c, int success, void *userdata) { static int n = 0; n++; - + if (!success) { fprintf(stderr, "Failure to suspend: %s\n", pa_strerror(pa_context_errno(c))); quit(1); @@ -138,7 +136,7 @@ static void resume_complete(pa_context *c, int success, void *userdata) { static void context_state_callback(pa_context *c, void *userdata) { pa_assert(c); - + switch (pa_context_get_state(c)) { case PA_CONTEXT_CONNECTING: case PA_CONTEXT_AUTHORIZING: @@ -149,11 +147,13 @@ static void context_state_callback(pa_context *c, void *userdata) { if (pa_context_is_local(c)) { pa_operation_unref(pa_context_suspend_sink_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL)); pa_operation_unref(pa_context_suspend_source_by_index(c, PA_INVALID_INDEX, 1, suspend_complete, NULL)); - } else + } else { + fprintf(stderr, "WARNING: Sound server is not local, not suspending.\n"); start_child(); - + } + break; - + case PA_CONTEXT_TERMINATED: quit(0); break; @@ -184,14 +184,14 @@ static void sigint_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, voi static void sigchld_callback(pa_mainloop_api *m, pa_signal_event *e, int sig, void *userdata) { int status = 0; pid_t p; - + p = waitpid(-1, &status, WNOHANG); if (p != child_pid) return; dead = 1; - + if (WIFEXITED(status)) child_ret = WEXITSTATUS(status); else if (WIFSIGNALED(status)) { |