mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-12 13:30:10 -05:00
add new switch --disallow-exit
This commit is contained in:
parent
f1d2bf8408
commit
756fac8d04
11 changed files with 87 additions and 52 deletions
|
|
@ -188,7 +188,9 @@ static int pa_cli_command_exit(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b
|
|||
pa_assert(buf);
|
||||
pa_assert(fail);
|
||||
|
||||
c->mainloop->quit(c->mainloop, 0);
|
||||
if (pa_core_exit(c, FALSE, 0) < 0)
|
||||
pa_strbuf_puts(buf, "Not allowed to terminate daemon.\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ pa_client *pa_client_new(pa_core *core, const char *driver, const char *name) {
|
|||
pa_log_info("Created %u \"%s\"", c->index, pa_strnull(name));
|
||||
pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_NEW, c->index);
|
||||
|
||||
pa_core_check_quit(core);
|
||||
pa_core_check_idle(core);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
@ -78,7 +78,7 @@ void pa_client_free(pa_client *c) {
|
|||
pa_xfree(c->driver);
|
||||
pa_xfree(c);
|
||||
|
||||
pa_core_check_quit(core);
|
||||
pa_core_check_idle(core);
|
||||
}
|
||||
|
||||
void pa_client_kill(pa_client *c) {
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
|
|||
c->mempool = pool;
|
||||
pa_silence_cache_init(&c->silence_cache);
|
||||
|
||||
c->quit_event = NULL;
|
||||
c->exit_event = NULL;
|
||||
|
||||
c->exit_idle_time = -1;
|
||||
c->module_idle_time = 20;
|
||||
|
|
@ -134,6 +134,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
|
|||
c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3;
|
||||
|
||||
c->disallow_module_loading = FALSE;
|
||||
c->disallow_exit = FALSE;
|
||||
c->realtime_scheduling = FALSE;
|
||||
c->realtime_priority = 5;
|
||||
c->disable_remixing = FALSE;
|
||||
|
|
@ -149,7 +150,7 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
|
|||
pa_check_signal_is_blocked(SIGPIPE);
|
||||
#endif
|
||||
|
||||
pa_core_check_quit(c);
|
||||
pa_core_check_idle(c);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
|
@ -182,8 +183,8 @@ static void core_free(pa_object *o) {
|
|||
pa_autoload_free(c);
|
||||
pa_subscription_free_all(c);
|
||||
|
||||
if (c->quit_event)
|
||||
c->mainloop->time_free(c->quit_event);
|
||||
if (c->exit_event)
|
||||
c->mainloop->time_free(c->exit_event);
|
||||
|
||||
pa_xfree(c->default_source_name);
|
||||
pa_xfree(c->default_sink_name);
|
||||
|
|
@ -199,17 +200,17 @@ static void core_free(pa_object *o) {
|
|||
pa_xfree(c);
|
||||
}
|
||||
|
||||
static void quit_callback(pa_mainloop_api*m, pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
|
||||
static void exit_callback(pa_mainloop_api*m, pa_time_event *e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
|
||||
pa_core *c = userdata;
|
||||
pa_assert(c->quit_event == e);
|
||||
pa_assert(c->exit_event == e);
|
||||
|
||||
m->quit(m, 0);
|
||||
pa_core_exit(c, TRUE, 0);
|
||||
}
|
||||
|
||||
void pa_core_check_quit(pa_core *c) {
|
||||
void pa_core_check_idle(pa_core *c) {
|
||||
pa_assert(c);
|
||||
|
||||
if (!c->quit_event &&
|
||||
if (!c->exit_event &&
|
||||
c->exit_idle_time >= 0 &&
|
||||
pa_idxset_size(c->clients) == 0) {
|
||||
|
||||
|
|
@ -217,10 +218,20 @@ void pa_core_check_quit(pa_core *c) {
|
|||
pa_gettimeofday(&tv);
|
||||
tv.tv_sec+= c->exit_idle_time;
|
||||
|
||||
c->quit_event = c->mainloop->time_new(c->mainloop, &tv, quit_callback, c);
|
||||
c->exit_event = c->mainloop->time_new(c->mainloop, &tv, exit_callback, c);
|
||||
|
||||
} else if (c->quit_event && pa_idxset_size(c->clients) > 0) {
|
||||
c->mainloop->time_free(c->quit_event);
|
||||
c->quit_event = NULL;
|
||||
} else if (c->exit_event && pa_idxset_size(c->clients) > 0) {
|
||||
c->mainloop->time_free(c->exit_event);
|
||||
c->exit_event = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int pa_core_exit(pa_core *c, pa_bool_t force, int retval) {
|
||||
pa_assert(c);
|
||||
|
||||
if (c->disallow_exit && !force)
|
||||
return -1;
|
||||
|
||||
c->mainloop->quit(c->mainloop, retval);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,11 +115,12 @@ struct pa_core {
|
|||
|
||||
int exit_idle_time, module_idle_time, scache_idle_time;
|
||||
|
||||
pa_time_event *quit_event;
|
||||
pa_time_event *exit_event;
|
||||
|
||||
pa_time_event *scache_auto_unload_event;
|
||||
|
||||
pa_bool_t disallow_module_loading:1;
|
||||
pa_bool_t disallow_exit:1;
|
||||
pa_bool_t running_as_daemon:1;
|
||||
pa_bool_t realtime_scheduling:1;
|
||||
pa_bool_t disable_remixing:1;
|
||||
|
|
@ -142,6 +143,8 @@ enum {
|
|||
pa_core* pa_core_new(pa_mainloop_api *m, int shared);
|
||||
|
||||
/* Check whether noone is connected to this core */
|
||||
void pa_core_check_quit(pa_core *c);
|
||||
void pa_core_check_idle(pa_core *c);
|
||||
|
||||
int pa_core_exit(pa_core *c, pa_bool_t force, int retval);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1955,6 +1955,7 @@ static void command_create_record_stream(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_
|
|||
|
||||
static void command_exit(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
|
||||
pa_native_connection *c = PA_NATIVE_CONNECTION(userdata);
|
||||
int ret;
|
||||
|
||||
pa_native_connection_assert_ref(c);
|
||||
pa_assert(t);
|
||||
|
|
@ -1965,8 +1966,9 @@ static void command_exit(PA_GCC_UNUSED pa_pdispatch *pd, PA_GCC_UNUSED uint32_t
|
|||
}
|
||||
|
||||
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
|
||||
ret = pa_core_exit(c->protocol->core, FALSE, 0);
|
||||
CHECK_VALIDITY(c->pstream, ret >= 0, tag, PA_ERR_ACCESS);
|
||||
|
||||
c->protocol->core->mainloop->quit(c->protocol->core->mainloop, 0);
|
||||
pa_pstream_send_simple_ack(c->pstream, tag); /* nonsense */
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue