mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-02 09:01:46 -05:00
add kill_* and default_* commands to CLI
make module-cli unload itself on EOF clean up stdio usage add sink pointer to monitor sources git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@50 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
e61c2dddb7
commit
722c2c8c87
13 changed files with 300 additions and 96 deletions
|
|
@ -2,27 +2,36 @@
|
|||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "main.h"
|
||||
#include "module.h"
|
||||
#include "iochannel.h"
|
||||
#include "cli.h"
|
||||
#include "sioman.h"
|
||||
|
||||
static void eof_cb(struct pa_cli*c, void *userdata) {
|
||||
struct pa_module *m = userdata;
|
||||
assert(c && m);
|
||||
|
||||
pa_module_unload_request(m->core, m);
|
||||
}
|
||||
|
||||
int module_init(struct pa_core *c, struct pa_module*m) {
|
||||
struct pa_iochannel *io;
|
||||
assert(c && m);
|
||||
|
||||
if (pa_stdin_inuse || pa_stdout_inuse) {
|
||||
if (pa_stdio_acquire() < 0) {
|
||||
fprintf(stderr, "STDIN/STDUSE already used\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pa_stdin_inuse = pa_stdout_inuse = 1;
|
||||
io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO);
|
||||
assert(io);
|
||||
pa_iochannel_set_noclose(io, 1);
|
||||
|
||||
m->userdata = pa_cli_new(c, io);
|
||||
assert(m->userdata);
|
||||
|
||||
pa_cli_set_eof_callback(m->userdata, eof_cb, m);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -30,6 +39,5 @@ void module_done(struct pa_core *c, struct pa_module*m) {
|
|||
assert(c && m);
|
||||
|
||||
pa_cli_free(m->userdata);
|
||||
assert(pa_stdin_inuse && pa_stdout_inuse);
|
||||
pa_stdin_inuse = pa_stdout_inuse = 0;
|
||||
pa_stdio_release();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue