mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
* add new argument 'exit_on_eof' to module-cli and make use of it if "-C" is passed to the daemon
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1026 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
5e1127a234
commit
bd432f0590
4 changed files with 51 additions and 14 deletions
|
|
@ -193,7 +193,9 @@ once.</p>
|
||||||
<p>For an explanation of the simple command line language used by this
|
<p>For an explanation of the simple command line language used by this
|
||||||
module see <a href="cli.html"><tt>cli.html</tt></a>.
|
module see <a href="cli.html"><tt>cli.html</tt></a>.
|
||||||
|
|
||||||
<p>This module doesn't accept any arguments.</p>
|
<table>
|
||||||
|
<tr><td><tt>exit_on_eof=</tt></td><td>Accepts a binary numerical argument specifying whether the daemon shuld exit after an EOF was recieved from STDIN (default: 0)</td></tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
<a name="module-cli-protocol-unix"/>
|
<a name="module-cli-protocol-unix"/>
|
||||||
<a name="module-cli-protocol-tcp"/>
|
<a name="module-cli-protocol-tcp"/>
|
||||||
|
|
|
||||||
1
doc/todo
1
doc/todo
|
|
@ -35,7 +35,6 @@ Post 0.9.0:
|
||||||
- check if using prctl(PR_GET_NAME) makes sense in pa_get_binary_name()
|
- check if using prctl(PR_GET_NAME) makes sense in pa_get_binary_name()
|
||||||
- gconf module + frontend
|
- gconf module + frontend
|
||||||
- hooks for creating sink inputs
|
- hooks for creating sink inputs
|
||||||
- module-cli argument exit-on-eof
|
|
||||||
|
|
||||||
Long term:
|
Long term:
|
||||||
- pass meta info for hearing impaired
|
- pass meta info for hearing impaired
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ int pa_cmdline_parse(pa_daemon_conf *conf, int argc, char *const argv [], int *d
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'C':
|
case 'C':
|
||||||
pa_strbuf_puts(buf, "load-module module-cli\n");
|
pa_strbuf_puts(buf, "load-module module-cli exit_on_eof=1\n");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_DAEMONIZE:
|
case ARG_DAEMONIZE:
|
||||||
|
|
|
||||||
|
|
@ -32,38 +32,64 @@
|
||||||
#include <polypcore/cli.h>
|
#include <polypcore/cli.h>
|
||||||
#include <polypcore/sioman.h>
|
#include <polypcore/sioman.h>
|
||||||
#include <polypcore/log.h>
|
#include <polypcore/log.h>
|
||||||
|
#include <polypcore/modargs.h>
|
||||||
|
|
||||||
#include "module-cli-symdef.h"
|
#include "module-cli-symdef.h"
|
||||||
|
|
||||||
PA_MODULE_AUTHOR("Lennart Poettering")
|
PA_MODULE_AUTHOR("Lennart Poettering")
|
||||||
PA_MODULE_DESCRIPTION("Command line interface")
|
PA_MODULE_DESCRIPTION("Command line interface")
|
||||||
PA_MODULE_VERSION(PACKAGE_VERSION)
|
PA_MODULE_VERSION(PACKAGE_VERSION)
|
||||||
PA_MODULE_USAGE("No arguments")
|
PA_MODULE_USAGE("exit_on_eof=<exit daemon after EOF?>")
|
||||||
|
|
||||||
static void eof_cb(pa_cli*c, void *userdata) {
|
static const char* const valid_modargs[] = {
|
||||||
|
"exit_on_eof",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static void eof_and_unload_cb(pa_cli*c, void *userdata) {
|
||||||
pa_module *m = userdata;
|
pa_module *m = userdata;
|
||||||
assert(c && m);
|
|
||||||
|
assert(c);
|
||||||
|
assert(m);
|
||||||
|
|
||||||
pa_module_unload_request(m);
|
pa_module_unload_request(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void eof_and_exit_cb(pa_cli*c, void *userdata) {
|
||||||
|
pa_module *m = userdata;
|
||||||
|
|
||||||
|
assert(c);
|
||||||
|
assert(m);
|
||||||
|
|
||||||
|
m->core->mainloop->quit(m->core->mainloop, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int pa__init(pa_core *c, pa_module*m) {
|
int pa__init(pa_core *c, pa_module*m) {
|
||||||
pa_iochannel *io;
|
pa_iochannel *io;
|
||||||
assert(c && m);
|
pa_modargs *ma;
|
||||||
|
int exit_on_eof = 0;
|
||||||
|
|
||||||
|
assert(c);
|
||||||
|
assert(m);
|
||||||
|
|
||||||
if (c->running_as_daemon) {
|
if (c->running_as_daemon) {
|
||||||
pa_log_info(__FILE__": Running as daemon so won't load this module.");
|
pa_log_info(__FILE__": Running as daemon, refusing to load this module.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->argument) {
|
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
|
||||||
pa_log(__FILE__": module doesn't accept arguments.");
|
pa_log(__FILE__": failed to parse module arguments.");
|
||||||
return -1;
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pa_modargs_get_value_boolean(ma, "exit_on_eof", &exit_on_eof) < 0) {
|
||||||
|
pa_log(__FILE__": exit_on_eof= expects boolean argument.");
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pa_stdio_acquire() < 0) {
|
if (pa_stdio_acquire() < 0) {
|
||||||
pa_log(__FILE__": STDIN/STDUSE already in use.");
|
pa_log(__FILE__": STDIN/STDUSE already in use.");
|
||||||
return -1;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
||||||
|
|
@ -73,13 +99,23 @@ int pa__init(pa_core *c, pa_module*m) {
|
||||||
m->userdata = pa_cli_new(c, io, m);
|
m->userdata = pa_cli_new(c, io, m);
|
||||||
assert(m->userdata);
|
assert(m->userdata);
|
||||||
|
|
||||||
pa_cli_set_eof_callback(m->userdata, eof_cb, m);
|
pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m);
|
||||||
|
|
||||||
|
pa_modargs_free(ma);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
|
||||||
|
if (ma)
|
||||||
|
pa_modargs_free(ma);
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pa__done(pa_core *c, pa_module*m) {
|
void pa__done(pa_core *c, pa_module*m) {
|
||||||
assert(c && m);
|
assert(c);
|
||||||
|
assert(m);
|
||||||
|
|
||||||
if (c->running_as_daemon == 0) {
|
if (c->running_as_daemon == 0) {
|
||||||
pa_cli_free(m->userdata);
|
pa_cli_free(m->userdata);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue