static int pa_cli_command_autoload_list(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail, int *verbose);
static int pa_cli_command_autoload_add(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail, int *verbose);
static int pa_cli_command_autoload_remove(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail, int *verbose);
+static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail, int *verbose);
static const struct command commands[] = {
{ "exit", pa_cli_command_exit, "Terminate the daemon", 1 },
{ "autoload_source_add", pa_cli_command_autoload_add, "Add autoload entry for a source (args: source, name, arguments)", 4},
{ "autoload_sink_remove", pa_cli_command_autoload_remove, "Remove autoload entry for a sink (args: sink)", 2},
{ "autoload_source_remove", pa_cli_command_autoload_remove, "Remove autoload entry for a source (args: source)", 2},
+ { "dump", pa_cli_command_dump, "Dump daemon configuration", 1},
{ NULL, NULL, NULL, 0 }
};
return 0;
}
+static int pa_cli_command_dump(struct pa_core *c, struct pa_tokenizer *t, struct pa_strbuf *buf, int *fail, int *verbose) {
+ struct pa_module *m;
+ struct pa_sink *s;
+ int nl;
+ const char *p;
+ uint32_t index;
+ char txt[256];
+ time_t now;
+ void *i;
+ struct pa_autoload_entry *a;
+
+ assert(c && t);
+
+ time(&now);
+
+ pa_strbuf_printf(buf, "### Configuration dump generated at %s\n", ctime_r(&now, txt));
+
+
+ for (m = pa_idxset_first(c->modules, &index); m; m = pa_idxset_next(c->modules, &index)) {
+ if (m->auto_unload)
+ continue;
+
+ pa_strbuf_printf(buf, "load %s", m->name);
+
+ if (m->argument)
+ pa_strbuf_printf(buf, " %s", m->argument);
+
+ pa_strbuf_puts(buf, "\n");
+ }
+
+ nl = 0;
+
+ for (s = pa_idxset_first(c->sinks, &index); s; s = pa_idxset_next(c->sinks, &index)) {
+ if (s->volume == PA_VOLUME_NORM)
+ continue;
+
+ if (s->owner && s->owner->auto_unload)
+ continue;
+
+ if (!nl) {
+ pa_strbuf_puts(buf, "\n");
+ nl = 1;
+ }
+
+ pa_strbuf_printf(buf, "sink_volume %s 0x%03x\n", s->name, s->volume);
+ }
+
+
+ if (c->autoload_hashmap) {
+ nl = 0;
+
+ i = NULL;
+ while ((a = pa_hashmap_iterate(c->autoload_hashmap, &i))) {
+
+ if (!nl) {
+ pa_strbuf_puts(buf, "\n");
+ nl = 1;
+ }
+
+ pa_strbuf_printf(buf, "autoload_%s_add %s %s", a->type == PA_NAMEREG_SINK ? "sink" : "source", a->name, a->module);
+
+ if (a->argument)
+ pa_strbuf_printf(buf, " %s", a->argument);
+
+ pa_strbuf_puts(buf, "\n");
+ }
+ }
+
+ nl = 0;
+
+ if ((p = pa_namereg_get_default_sink_name(c))) {
+ if (!nl) {
+ pa_strbuf_puts(buf, "\n");
+ nl = 1;
+ }
+ pa_strbuf_printf(buf, "sink_default %s\n", p);
+ }
+
+ if ((p = pa_namereg_get_default_source_name(c))) {
+ if (!nl) {
+ pa_strbuf_puts(buf, "\n");
+ nl = 1;
+ }
+ pa_strbuf_printf(buf, "source_default %s\n", p);
+ }
+
+ pa_strbuf_puts(buf, "\n### EOF\n");
+
+ return 0;
+}
+
+
int pa_cli_command_execute_line(struct pa_core *c, const char *s, struct pa_strbuf *buf, int *fail, int *verbose) {
const char *cs;
# Load audio drivers automatically on access
-#autoload_sink_add output module-oss device="/dev/adsp" sink_name=output source_name=input
-#autoload_source_add input module-oss device="/dev/adsp" sink_name=output source_name=input
+#autoload_sink_add output module-oss device="/dev/dsp" sink_name=output source_name=input
+#autoload_source_add input module-oss device="/dev/dsp" sink_name=output source_name=input
#autoload_sink_add output module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#autoload_source_add input module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#autoload_sink_add output module-alsa-sink sink_name=output
#autoload_source_add input module-alsa-source source_name=input
# Load several protocols
-#load module-esound-protocol-tcp
+load module-esound-protocol-tcp
#load module-simple-protocol-tcp
load module-native-protocol-unix
#load module-cli-protocol-unix
load module-cli
# Make some devices default
-#isink_default output
-#source_default input
+sink_default output
+source_default input
.nofail
scache_load /usr/share/sounds/KDE_Notify.wav x11-bell
# Load X11 bell module
-#load module-x11-bell sample=x11-bell sink=output
+load module-x11-bell sample=x11-bell sink=output
#load module-pipe-source
#load module-pipe-sink
return 1;
}
-int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void)) {
+int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void), void (*prefork)(void), void (*postfork)(void)) {
pid_t pid;
- int status;
+ int status, r;
int fds[2] = { -1, -1} ;
struct pa_iochannel *io;
goto fail;
}
+ if (prefork)
+ prefork();
+
if ((pid = fork()) < 0) {
pa_log(__FILE__": fork() failed: %s\n", strerror(errno));
pa_context_fail(c, PA_ERROR_INTERNAL);
+
+ if (postfork)
+ postfork();
+
goto fail;
} else if (!pid) {
char t[64];
}
/* Parent */
- if (waitpid(pid, &status, 0) < 0) {
+
+ r = waitpid(pid, &status, 0);
+
+ if (postfork)
+ postfork();
+
+ if (r < 0) {
pa_log(__FILE__": waitpid() failed: %s\n", strerror(errno));
pa_context_fail(c, PA_ERROR_INTERNAL);
goto fail;
/** Connect the context to a server. If the default server is local
* but not accessible, spawn a new daemon. If atfork is not NULL it is
* run after the fork() in the child process. It may be used to close
- * file descriptors or to do any other cleanups. Make sure that
- * SIGCHLD is handled when calling this function. The function will
- * waitpid() on the daemon's PID. \since 0.4 */
-int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void));
+ * file descriptors or to do any other cleanups. (It is not safe to
+ * close all file descriptors unconditionally, since a UNIX socket is
+ * passed to the new process.) if prefork is not NULL it is run just
+ * before forking in the parent process. Use this to block SIGCHLD
+ * handling if required. If postfork is not NULL it is run just after
+ * forking in the parent process. Use this to unblock SIGCHLD if
+ * required. The function will waitpid() on the daemon's PID, but
+ * will not block or ignore SIGCHLD signals, since this cannot be done
+ * in a thread compatible way. \since 0.4 */
+int pa_context_connect_spawn(struct pa_context *c, void (*atfork)(void), void (*prefork)(void), void (*postfork)(void));
/** Terminate the context connection immediately */
void pa_context_disconnect(struct pa_context *c);