[PATCH 1/6] cli: Change interface of pa_cli_xxx() functions to take a pa_cli* as first argument, not pa_core

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



so the pa_cli_* function can have and pass around there own state

drop libcli.la (it becomes part of pulsecore)

Signed-off-by: Peter Meerwald <pmeerw at pmeerw.net>
---
 src/Makefile.am             |  10 +-
 src/daemon/main.c           |   7 +-
 src/pulsecore/cli-command.c | 477 ++++++++++++++++++++++----------------------
 src/pulsecore/cli-command.h |  11 +-
 src/pulsecore/cli.c         |  36 ++--
 src/pulsecore/cli.h         |  17 ++
 6 files changed, 285 insertions(+), 273 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 6de6e96..f102ec2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -869,6 +869,7 @@ libpulsecore_ at PA_MAJORMINOR@_la_SOURCES = \
 		pulsecore/auth-cookie.c pulsecore/auth-cookie.h \
 		pulsecore/cli-command.c pulsecore/cli-command.h \
 		pulsecore/cli-text.c pulsecore/cli-text.h \
+		pulsecore/cli.c pulsecore/cli.h \
 		pulsecore/client.c pulsecore/client.h \
 		pulsecore/card.c pulsecore/card.h \
 		pulsecore/core-scache.c pulsecore/core-scache.h \
@@ -980,7 +981,6 @@ libpulsecore_foreign_la_CFLAGS = $(AM_CFLAGS) $(FOREIGN_CFLAGS)
 ### the head, and not the other way!
 
 modlibexec_LTLIBRARIES = \
-		libcli.la \
 		libprotocol-cli.la \
 		libprotocol-simple.la \
 		libprotocol-http.la \
@@ -1010,13 +1010,9 @@ libprotocol_simple_la_SOURCES = pulsecore/protocol-simple.c pulsecore/protocol-s
 libprotocol_simple_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
 libprotocol_simple_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR@.la libpulsecommon- at PA_MAJORMINOR@.la libpulse.la
 
-libcli_la_SOURCES = pulsecore/cli.c pulsecore/cli.h
-libcli_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
-libcli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR@.la libpulsecommon- at PA_MAJORMINOR@.la libpulse.la
-
 libprotocol_cli_la_SOURCES = pulsecore/protocol-cli.c pulsecore/protocol-cli.h
 libprotocol_cli_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
-libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR@.la libpulsecommon- at PA_MAJORMINOR@.la libpulse.la libcli.la
+libprotocol_cli_la_LIBADD = $(AM_LIBADD) libpulsecore- at PA_MAJORMINOR@.la libpulsecommon- at PA_MAJORMINOR@.la libpulse.la
 
 libprotocol_http_la_SOURCES = pulsecore/protocol-http.c pulsecore/protocol-http.h pulsecore/mime-type.c pulsecore/mime-type.h
 libprotocol_http_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version
@@ -1472,7 +1468,7 @@ module_simple_protocol_unix_la_LIBADD = $(MODULE_LIBADD) libprotocol-simple.la
 
 module_cli_la_SOURCES = modules/module-cli.c
 module_cli_la_LDFLAGS = $(MODULE_LDFLAGS)
-module_cli_la_LIBADD = $(MODULE_LIBADD) libcli.la
+module_cli_la_LIBADD = $(MODULE_LIBADD)
 
 module_cli_protocol_tcp_la_SOURCES = modules/module-protocol-stub.c
 module_cli_protocol_tcp_la_CFLAGS = -DUSE_TCP_SOCKETS -DUSE_PROTOCOL_CLI $(AM_CFLAGS)
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 5b4e005..1e163db 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -80,6 +80,7 @@
 #include <pulsecore/core-util.h>
 #include <pulsecore/sioman.h>
 #include <pulsecore/cli-text.h>
+#include <pulsecore/cli.h>
 #include <pulsecore/pid.h>
 #include <pulsecore/random.h>
 #include <pulsecore/macro.h>
@@ -1080,17 +1081,19 @@ int main(int argc, char *argv[]) {
 
     if (start_server) {
 #endif
+        pa_cli *cli = pa_cli_dummy_new(c);
         if (conf->load_default_script_file) {
             FILE *f;
 
             if ((f = pa_daemon_conf_open_default_script_file(conf))) {
-                r = pa_cli_command_execute_file_stream(c, f, buf, &conf->fail);
+                r = pa_cli_command_execute_file_stream(cli, f, buf, &conf->fail);
                 fclose(f);
             }
         }
 
         if (r >= 0)
-            r = pa_cli_command_execute(c, conf->script_commands, buf, &conf->fail);
+            r = pa_cli_command_execute(cli, conf->script_commands, buf, &conf->fail);
+        pa_cli_free(cli);
 
         pa_log_error("%s", s = pa_strbuf_tostring_free(buf));
         pa_xfree(s);
diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c
index f937d46..0440543 100644
--- a/src/pulsecore/cli-command.c
+++ b/src/pulsecore/cli-command.c
@@ -63,7 +63,7 @@
 
 struct command {
     const char *name;
-    int (*proc) (pa_core *c, pa_tokenizer*t, pa_strbuf *buf, bool *fail);
+    int (*proc) (pa_cli *c, pa_tokenizer*t, pa_strbuf *buf, bool *fail);
     const char *help;
     unsigned args;
 };
@@ -82,61 +82,61 @@ enum {
 };
 
 /* Prototypes for all available commands */
-static int pa_cli_command_exit(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_help(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_modules(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_clients(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_cards(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sinks(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sources(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_inputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_outputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_describe(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_output_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_input_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_output_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_kill_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_kill_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_scache_play(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_scache_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_scache_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_list_shared_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_vacuum(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_log_target(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_log_level(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_update_sink_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_update_source_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_update_sink_input_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_update_source_output_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_card_profile(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_sink_port(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_source_port(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_port_offset(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
-static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_exit(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_help(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_modules(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_clients(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_cards(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sinks(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sources(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_inputs(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_outputs(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_stat(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_info(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_load(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_unload(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_describe(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_input_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_output_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_input_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_output_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_default(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_default(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_kill_client(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_kill_sink_input(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_kill_source_output(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_scache_play(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_scache_remove(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_scache_list(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_scache_load(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_scache_load_dir(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_play_file(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_dump(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_list_shared_props(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_move_sink_input(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_move_source_output(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_vacuum(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_suspend_sink(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_suspend_source(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_suspend(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_log_target(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_log_level(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_log_meta(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_log_time(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_log_backtrace(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_update_sink_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_update_source_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_update_sink_input_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_update_source_output_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_card_profile(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_sink_port(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_source_port(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_port_offset(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
+static int pa_cli_command_dump_volumes(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail);
 
 /* A method table for all available commands */
 
@@ -214,22 +214,22 @@ static uint32_t parse_index(const char *n) {
     return idx;
 }
 
-static int pa_cli_command_exit(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
-    pa_core_assert_ref(c);
+static int pa_cli_command_exit(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    if (pa_core_exit(c, false, 0) < 0)
+    if (pa_core_exit(c->core, false, 0) < 0)
         pa_strbuf_puts(buf, "Not allowed to terminate daemon.\n");
 
     return 0;
 }
 
-static int pa_cli_command_help(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_help(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const struct command*command;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -242,105 +242,105 @@ static int pa_cli_command_help(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     return 0;
 }
 
-static int pa_cli_command_modules(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_modules(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_module_list_to_string(c));
+    pa_assert_se(s = pa_module_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_clients(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_clients(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_client_list_to_string(c));
+    pa_assert_se(s = pa_client_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_cards(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_cards(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_card_list_to_string(c));
+    pa_assert_se(s = pa_card_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_sinks(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sinks(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_sink_list_to_string(c));
+    pa_assert_se(s = pa_sink_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_sources(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sources(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_source_list_to_string(c));
+    pa_assert_se(s = pa_source_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_sink_inputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_inputs(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_sink_input_list_to_string(c));
+    pa_assert_se(s = pa_sink_input_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_source_outputs(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_outputs(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_source_output_list_to_string(c));
+    pa_assert_se(s = pa_source_output_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
     return 0;
 }
 
-static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_stat(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char ss[PA_SAMPLE_SPEC_SNPRINT_MAX];
     char cm[PA_CHANNEL_MAP_SNPRINT_MAX];
     char bytes[PA_BYTES_SNPRINT_MAX];
@@ -358,12 +358,12 @@ static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
         [PA_MEMBLOCK_IMPORTED] = "IMPORTED",
     };
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    mstat = pa_mempool_get_stat(c->mempool);
+    mstat = pa_mempool_get_stat(c->core->mempool);
 
     pa_strbuf_printf(buf, "Memory blocks currently allocated: %u, size: %s.\n",
                      (unsigned) pa_atomic_load(&mstat->n_allocated),
@@ -382,16 +382,16 @@ static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
                      pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_atomic_load(&mstat->exported_size)));
 
     pa_strbuf_printf(buf, "Total sample cache size: %s.\n",
-                     pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_scache_total_size(c)));
+                     pa_bytes_snprint(bytes, sizeof(bytes), (unsigned) pa_scache_total_size(c->core)));
 
     pa_strbuf_printf(buf, "Default sample spec: %s\n",
-                     pa_sample_spec_snprint(ss, sizeof(ss), &c->default_sample_spec));
+                     pa_sample_spec_snprint(ss, sizeof(ss), &c->core->default_sample_spec));
 
     pa_strbuf_printf(buf, "Default channel map: %s\n",
-                     pa_channel_map_snprint(cm, sizeof(cm), &c->default_channel_map));
+                     pa_channel_map_snprint(cm, sizeof(cm), &c->core->default_channel_map));
 
-    def_sink = pa_namereg_get_default_sink(c);
-    def_source = pa_namereg_get_default_source(c);
+    def_sink = pa_namereg_get_default_sink(c->core);
+    def_source = pa_namereg_get_default_source(c->core);
     pa_strbuf_printf(buf, "Default sink name: %s\n"
                      "Default source name: %s\n",
                      def_sink ? def_sink->name : "none",
@@ -407,8 +407,8 @@ static int pa_cli_command_stat(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     return 0;
 }
 
-static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
-    pa_core_assert_ref(c);
+static int pa_cli_command_info(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -425,20 +425,20 @@ static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     return 0;
 }
 
-static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_load(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *name;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
+    pa_core_assert_ref(c->core);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
-
     if (!(name = pa_tokenizer_get(t, 1))) {
         pa_strbuf_puts(buf, "You need to specify the module name and optionally arguments.\n");
         return -1;
     }
 
-    if (!pa_module_load(c, name,  pa_tokenizer_get(t, 2))) {
+    if (!pa_module_load(c->core, name,  pa_tokenizer_get(t, 2))) {
         pa_strbuf_puts(buf, "Module load failed.\n");
         return -1;
     }
@@ -446,13 +446,13 @@ static int pa_cli_command_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     return 0;
 }
 
-static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_unload(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     pa_module *m;
     uint32_t idx;
     const char *i;
     bool unloaded = false;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -463,7 +463,7 @@ static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bo
     }
 
     if (pa_atou(i, &idx) >= 0) {
-        if (!(m = pa_idxset_get_by_index(c->modules, idx))) {
+        if (!(m = pa_idxset_get_by_index(c->core->modules, idx))) {
             pa_strbuf_puts(buf, "Invalid module index.\n");
             return -1;
         }
@@ -471,7 +471,7 @@ static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bo
         pa_module_unload_request(m, false);
 
     } else {
-        PA_IDXSET_FOREACH(m, c->modules, idx)
+        PA_IDXSET_FOREACH(m, c->core->modules, idx)
             if (pa_streq(i, m->name)) {
                 unloaded = true;
                 pa_module_unload_request(m, false);
@@ -486,11 +486,11 @@ static int pa_cli_command_unload(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bo
     return 0;
 }
 
-static int pa_cli_command_describe(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_describe(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *name;
     pa_modinfo *i;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -527,13 +527,13 @@ static int pa_cli_command_describe(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return 0;
 }
 
-static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *v;
     pa_sink *sink;
     uint32_t volume;
     pa_cvolume cvolume;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -558,7 +558,7 @@ static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, n, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -568,14 +568,14 @@ static int pa_cli_command_sink_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_input_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *v;
     pa_sink_input *si;
     pa_volume_t volume;
     pa_cvolume cvolume;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -605,7 +605,7 @@ static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strb
         return -1;
     }
 
-    if (!(si = pa_idxset_get_by_index(c->sink_inputs, idx))) {
+    if (!(si = pa_idxset_get_by_index(c->core->sink_inputs, idx))) {
         pa_strbuf_puts(buf, "No sink input found with this index.\n");
         return -1;
     }
@@ -620,13 +620,13 @@ static int pa_cli_command_sink_input_volume(pa_core *c, pa_tokenizer *t, pa_strb
     return 0;
 }
 
-static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *v;
     pa_source *source;
     uint32_t volume;
     pa_cvolume cvolume;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -651,7 +651,7 @@ static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *
         return -1;
     }
 
-    if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) {
+    if (!(source = pa_namereg_get(c->core, n, PA_NAMEREG_SOURCE))) {
         pa_strbuf_puts(buf, "No source found by this name or index.\n");
         return -1;
     }
@@ -661,14 +661,14 @@ static int pa_cli_command_source_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *
     return 0;
 }
 
-static int pa_cli_command_source_output_volume(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_output_volume(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *v;
     pa_source_output *so;
     pa_volume_t volume;
     pa_cvolume cvolume;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -698,7 +698,7 @@ static int pa_cli_command_source_output_volume(pa_core *c, pa_tokenizer *t, pa_s
         return -1;
     }
 
-    if (!(so = pa_idxset_get_by_index(c->source_outputs, idx))) {
+    if (!(so = pa_idxset_get_by_index(c->core->source_outputs, idx))) {
         pa_strbuf_puts(buf, "No source output found with this index.\n");
         return -1;
     }
@@ -713,12 +713,12 @@ static int pa_cli_command_source_output_volume(pa_core *c, pa_tokenizer *t, pa_s
     return 0;
 }
 
-static int pa_cli_command_sink_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *m;
     pa_sink *sink;
     int mute;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -738,7 +738,7 @@ static int pa_cli_command_sink_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, n, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -747,12 +747,12 @@ static int pa_cli_command_sink_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return 0;
 }
 
-static int pa_cli_command_source_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *m;
     pa_source *source;
     int mute;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -772,7 +772,7 @@ static int pa_cli_command_source_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
         return -1;
     }
 
-    if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) {
+    if (!(source = pa_namereg_get(c->core, n, PA_NAMEREG_SOURCE))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -781,12 +781,12 @@ static int pa_cli_command_source_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_update_sink_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_update_sink_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *s;
     pa_sink *sink;
     pa_proplist *p;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -801,7 +801,7 @@ static int pa_cli_command_update_sink_proplist(pa_core *c, pa_tokenizer *t, pa_s
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, n, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -818,12 +818,12 @@ static int pa_cli_command_update_sink_proplist(pa_core *c, pa_tokenizer *t, pa_s
     return 0;
 }
 
-static int pa_cli_command_update_source_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_update_source_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *s;
     pa_source *source;
     pa_proplist *p;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -838,7 +838,7 @@ static int pa_cli_command_update_source_proplist(pa_core *c, pa_tokenizer *t, pa
         return -1;
     }
 
-    if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) {
+    if (!(source = pa_namereg_get(c->core, n, PA_NAMEREG_SOURCE))) {
         pa_strbuf_puts(buf, "No source found by this name or index.\n");
         return -1;
     }
@@ -855,13 +855,13 @@ static int pa_cli_command_update_source_proplist(pa_core *c, pa_tokenizer *t, pa
     return 0;
 }
 
-static int pa_cli_command_update_sink_input_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_update_sink_input_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *s;
     pa_sink_input *si;
     uint32_t idx;
     pa_proplist *p;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -881,7 +881,7 @@ static int pa_cli_command_update_sink_input_proplist(pa_core *c, pa_tokenizer *t
         return -1;
     }
 
-    if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) idx))) {
+    if (!(si = pa_idxset_get_by_index(c->core->sink_inputs, (uint32_t) idx))) {
         pa_strbuf_puts(buf, "No sink input found with this index.\n");
         return -1;
     }
@@ -898,13 +898,13 @@ static int pa_cli_command_update_sink_input_proplist(pa_core *c, pa_tokenizer *t
     return 0;
 }
 
-static int pa_cli_command_update_source_output_proplist(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_update_source_output_proplist(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *s;
     pa_source_output *so;
     uint32_t idx;
     pa_proplist *p;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -924,7 +924,7 @@ static int pa_cli_command_update_source_output_proplist(pa_core *c, pa_tokenizer
         return -1;
     }
 
-    if (!(so = pa_idxset_get_by_index(c->source_outputs, (uint32_t) idx))) {
+    if (!(so = pa_idxset_get_by_index(c->core->source_outputs, (uint32_t) idx))) {
         pa_strbuf_puts(buf, "No source output found with this index.\n");
         return -1;
     }
@@ -941,13 +941,13 @@ static int pa_cli_command_update_source_output_proplist(pa_core *c, pa_tokenizer
     return 0;
 }
 
-static int pa_cli_command_sink_input_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_input_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *v;
     pa_sink_input *si;
     uint32_t idx;
     int mute;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -972,7 +972,7 @@ static int pa_cli_command_sink_input_mute(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) idx))) {
+    if (!(si = pa_idxset_get_by_index(c->core->sink_inputs, (uint32_t) idx))) {
         pa_strbuf_puts(buf, "No sink input found with this index.\n");
         return -1;
     }
@@ -981,13 +981,13 @@ static int pa_cli_command_sink_input_mute(pa_core *c, pa_tokenizer *t, pa_strbuf
     return 0;
 }
 
-static int pa_cli_command_source_output_mute(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_output_mute(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *v;
     pa_source_output *so;
     uint32_t idx;
     int mute;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1012,7 +1012,7 @@ static int pa_cli_command_source_output_mute(pa_core *c, pa_tokenizer *t, pa_str
         return -1;
     }
 
-    if (!(so = pa_idxset_get_by_index(c->source_outputs, (uint32_t) idx))) {
+    if (!(so = pa_idxset_get_by_index(c->core->source_outputs, (uint32_t) idx))) {
         pa_strbuf_puts(buf, "No source output found with this index.\n");
         return -1;
     }
@@ -1021,11 +1021,11 @@ static int pa_cli_command_source_output_mute(pa_core *c, pa_tokenizer *t, pa_str
     return 0;
 }
 
-static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_default(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n;
     pa_sink *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1035,19 +1035,19 @@ static int pa_cli_command_sink_default(pa_core *c, pa_tokenizer *t, pa_strbuf *b
         return -1;
     }
 
-    if ((s = pa_namereg_get(c, n, PA_NAMEREG_SINK)))
-        pa_namereg_set_default_sink(c, s);
+    if ((s = pa_namereg_get(c->core, n, PA_NAMEREG_SINK)))
+        pa_namereg_set_default_sink(c->core, s);
     else
         pa_strbuf_printf(buf, "Sink %s does not exist.\n", n);
 
     return 0;
 }
 
-static int pa_cli_command_source_default(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_default(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n;
     pa_source *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1057,19 +1057,19 @@ static int pa_cli_command_source_default(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    if ((s = pa_namereg_get(c, n, PA_NAMEREG_SOURCE)))
-        pa_namereg_set_default_source(c, s);
+    if ((s = pa_namereg_get(c->core, n, PA_NAMEREG_SOURCE)))
+        pa_namereg_set_default_source(c->core, s);
     else
         pa_strbuf_printf(buf, "Source %s does not exist.\n", n);
     return 0;
 }
 
-static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_kill_client(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n;
     pa_client *client;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1084,7 +1084,7 @@ static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
         return -1;
     }
 
-    if (!(client = pa_idxset_get_by_index(c->clients, idx))) {
+    if (!(client = pa_idxset_get_by_index(c->core->clients, idx))) {
         pa_strbuf_puts(buf, "No client found by this index.\n");
         return -1;
     }
@@ -1093,12 +1093,12 @@ static int pa_cli_command_kill_client(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_kill_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_kill_sink_input(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n;
     pa_sink_input *sink_input;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1113,7 +1113,7 @@ static int pa_cli_command_kill_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    if (!(sink_input = pa_idxset_get_by_index(c->sink_inputs, idx))) {
+    if (!(sink_input = pa_idxset_get_by_index(c->core->sink_inputs, idx))) {
         pa_strbuf_puts(buf, "No sink input found by this index.\n");
         return -1;
     }
@@ -1122,12 +1122,12 @@ static int pa_cli_command_kill_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf
     return 0;
 }
 
-static int pa_cli_command_kill_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_kill_source_output(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n;
     pa_source_output *source_output;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1142,7 +1142,7 @@ static int pa_cli_command_kill_source_output(pa_core *c, pa_tokenizer *t, pa_str
         return -1;
     }
 
-    if (!(source_output = pa_idxset_get_by_index(c->source_outputs, idx))) {
+    if (!(source_output = pa_idxset_get_by_index(c->core->source_outputs, idx))) {
         pa_strbuf_puts(buf, "No source output found by this index.\n");
         return -1;
     }
@@ -1151,27 +1151,27 @@ static int pa_cli_command_kill_source_output(pa_core *c, pa_tokenizer *t, pa_str
     return 0;
 }
 
-static int pa_cli_command_scache_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_scache_list(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     char *s;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_assert_se(s = pa_scache_list_to_string(c));
+    pa_assert_se(s = pa_scache_list_to_string(c->core));
     pa_strbuf_puts(buf, s);
     pa_xfree(s);
 
     return 0;
 }
 
-static int pa_cli_command_scache_play(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_scache_play(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *sink_name;
     pa_sink *sink;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1181,12 +1181,12 @@ static int pa_cli_command_scache_play(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, sink_name, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink by that name.\n");
         return -1;
     }
 
-    if (pa_scache_play_item(c, n, sink, PA_VOLUME_NORM, NULL, &idx) < 0) {
+    if (pa_scache_play_item(c->core, n, sink, PA_VOLUME_NORM, NULL, &idx) < 0) {
         pa_strbuf_puts(buf, "Failed to play sample.\n");
         return -1;
     }
@@ -1196,10 +1196,10 @@ static int pa_cli_command_scache_play(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_scache_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_scache_remove(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1209,7 +1209,7 @@ static int pa_cli_command_scache_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *
         return -1;
     }
 
-    if (pa_scache_remove_item(c, n) < 0) {
+    if (pa_scache_remove_item(c->core, n) < 0) {
         pa_strbuf_puts(buf, "Failed to remove sample.\n");
         return -1;
     }
@@ -1217,11 +1217,11 @@ static int pa_cli_command_scache_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *
     return 0;
 }
 
-static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_scache_load(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *fname, *n;
     int r;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1232,9 +1232,9 @@ static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     }
 
     if (strstr(pa_tokenizer_get(t, 0), "lazy"))
-        r = pa_scache_add_file_lazy(c, n, fname, NULL);
+        r = pa_scache_add_file_lazy(c->core, n, fname, NULL);
     else
-        r = pa_scache_add_file(c, n, fname, NULL);
+        r = pa_scache_add_file(c->core, n, fname, NULL);
 
     if (r < 0)
         pa_strbuf_puts(buf, "Failed to load sound file.\n");
@@ -1242,10 +1242,10 @@ static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_scache_load_dir(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *pname;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1255,7 +1255,7 @@ static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    if (pa_scache_add_directory_lazy(c, pname) < 0) {
+    if (pa_scache_add_directory_lazy(c->core, pname) < 0) {
         pa_strbuf_puts(buf, "Failed to load directory.\n");
         return -1;
     }
@@ -1263,11 +1263,11 @@ static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf
     return 0;
 }
 
-static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_play_file(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *fname, *sink_name;
     pa_sink *sink;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1277,7 +1277,7 @@ static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, sink_name, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink by that name.\n");
         return -1;
     }
@@ -1285,34 +1285,34 @@ static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return pa_play_file(sink, fname, NULL);
 }
 
-static int pa_cli_command_list_shared_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
-    pa_core_assert_ref(c);
+static int pa_cli_command_list_shared_props(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_shared_dump(c, buf);
+    pa_shared_dump(c->core, buf);
     return 0;
 }
 
-static int pa_cli_command_vacuum(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
-    pa_core_assert_ref(c);
+static int pa_cli_command_vacuum(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    pa_mempool_vacuum(c->mempool);
+    pa_mempool_vacuum(c->core->mempool);
 
     return 0;
 }
 
-static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_move_sink_input(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *k;
     pa_sink_input *si;
     pa_sink *sink;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1332,12 +1332,12 @@ static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    if (!(si = pa_idxset_get_by_index(c->sink_inputs, (uint32_t) idx))) {
+    if (!(si = pa_idxset_get_by_index(c->core->sink_inputs, (uint32_t) idx))) {
         pa_strbuf_puts(buf, "No sink input found with this index.\n");
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, k, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, k, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -1349,13 +1349,13 @@ static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf
     return 0;
 }
 
-static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_move_source_output(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *k;
     pa_source_output *so;
     pa_source *source;
     uint32_t idx;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1375,12 +1375,12 @@ static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_str
         return -1;
     }
 
-    if (!(so = pa_idxset_get_by_index(c->source_outputs, (uint32_t) idx))) {
+    if (!(so = pa_idxset_get_by_index(c->core->source_outputs, (uint32_t) idx))) {
         pa_strbuf_puts(buf, "No source output found with this index.\n");
         return -1;
     }
 
-    if (!(source = pa_namereg_get(c, k, PA_NAMEREG_SOURCE))) {
+    if (!(source = pa_namereg_get(c->core, k, PA_NAMEREG_SOURCE))) {
         pa_strbuf_puts(buf, "No source found by this name or index.\n");
         return -1;
     }
@@ -1392,12 +1392,12 @@ static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_str
     return 0;
 }
 
-static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_suspend_sink(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *m;
     pa_sink *sink;
     int suspend, r;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1417,7 +1417,7 @@ static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *b
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, n, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -1430,12 +1430,12 @@ static int pa_cli_command_suspend_sink(pa_core *c, pa_tokenizer *t, pa_strbuf *b
     return 0;
 }
 
-static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_suspend_source(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *m;
     pa_source *source;
     int suspend, r;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1455,7 +1455,7 @@ static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf
         return -1;
     }
 
-    if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) {
+    if (!(source = pa_namereg_get(c->core, n, PA_NAMEREG_SOURCE))) {
         pa_strbuf_puts(buf, "No source found by this name or index.\n");
         return -1;
     }
@@ -1468,11 +1468,11 @@ static int pa_cli_command_suspend_source(pa_core *c, pa_tokenizer *t, pa_strbuf
     return 0;
 }
 
-static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_suspend(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *m;
     int suspend, r;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1489,20 +1489,20 @@ static int pa_cli_command_suspend(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, b
 
     pa_log_debug("%s of all sinks and sources requested via CLI.", suspend ? "Suspending" : "Resuming");
 
-    if ((r = pa_sink_suspend_all(c, suspend, PA_SUSPEND_USER)) < 0)
+    if ((r = pa_sink_suspend_all(c->core, suspend, PA_SUSPEND_USER)) < 0)
         pa_strbuf_printf(buf, "Failed to resume/suspend all sinks: %s\n", pa_strerror(r));
 
-    if ((r = pa_source_suspend_all(c, suspend, PA_SUSPEND_USER)) < 0)
+    if ((r = pa_source_suspend_all(c->core, suspend, PA_SUSPEND_USER)) < 0)
         pa_strbuf_printf(buf, "Failed to resume/suspend all sources: %s\n", pa_strerror(r));
 
     return 0;
 }
 
-static int pa_cli_command_log_target(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_log_target(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *m;
     pa_log_target *log_target = NULL;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1535,11 +1535,11 @@ static int pa_cli_command_log_target(pa_core *c, pa_tokenizer *t, pa_strbuf *buf
     return 0;
 }
 
-static int pa_cli_command_log_level(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_log_level(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *m;
     uint32_t level;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1559,11 +1559,11 @@ static int pa_cli_command_log_level(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return 0;
 }
 
-static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_log_meta(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *m;
     int b;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1583,11 +1583,11 @@ static int pa_cli_command_log_meta(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return 0;
 }
 
-static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_log_time(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *m;
     int b;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1607,11 +1607,11 @@ static int pa_cli_command_log_time(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return 0;
 }
 
-static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_log_backtrace(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *m;
     uint32_t nframes;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1631,11 +1631,11 @@ static int pa_cli_command_log_backtrace(pa_core *c, pa_tokenizer *t, pa_strbuf *
     return 0;
 }
 
-static int pa_cli_command_card_profile(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_card_profile(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *p;
     pa_card *card;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1650,7 +1650,7 @@ static int pa_cli_command_card_profile(pa_core *c, pa_tokenizer *t, pa_strbuf *b
         return -1;
     }
 
-    if (!(card = pa_namereg_get(c, n, PA_NAMEREG_CARD))) {
+    if (!(card = pa_namereg_get(c->core, n, PA_NAMEREG_CARD))) {
         pa_strbuf_puts(buf, "No card found by this name or index.\n");
         return -1;
     }
@@ -1663,11 +1663,11 @@ static int pa_cli_command_card_profile(pa_core *c, pa_tokenizer *t, pa_strbuf *b
     return 0;
 }
 
-static int pa_cli_command_sink_port(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_sink_port(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *p;
     pa_sink *sink;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1682,7 +1682,7 @@ static int pa_cli_command_sink_port(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
         return -1;
     }
 
-    if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) {
+    if (!(sink = pa_namereg_get(c->core, n, PA_NAMEREG_SINK))) {
         pa_strbuf_puts(buf, "No sink found by this name or index.\n");
         return -1;
     }
@@ -1695,11 +1695,11 @@ static int pa_cli_command_sink_port(pa_core *c, pa_tokenizer *t, pa_strbuf *buf,
     return 0;
 }
 
-static int pa_cli_command_source_port(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_source_port(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *p;
     pa_source *source;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1714,7 +1714,7 @@ static int pa_cli_command_source_port(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
         return -1;
     }
 
-    if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) {
+    if (!(source = pa_namereg_get(c->core, n, PA_NAMEREG_SOURCE))) {
         pa_strbuf_puts(buf, "No source found by this name or index.\n");
         return -1;
     }
@@ -1727,13 +1727,13 @@ static int pa_cli_command_source_port(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_port_offset(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_port_offset(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     const char *n, *p, *l;
     pa_device_port *port;
     pa_card *card;
     int32_t offset;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1758,7 +1758,7 @@ static int pa_cli_command_port_offset(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
         return -1;
     }
 
-    if (!(card = pa_namereg_get(c, n, PA_NAMEREG_CARD))) {
+    if (!(card = pa_namereg_get(c->core, n, PA_NAMEREG_CARD))) {
         pa_strbuf_puts(buf, "No card found by this name or index.\n");
         return -1;
     }
@@ -1773,7 +1773,7 @@ static int pa_cli_command_port_offset(pa_core *c, pa_tokenizer *t, pa_strbuf *bu
     return 0;
 }
 
-static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_dump(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     pa_module *m;
     pa_sink *sink;
     pa_source *source;
@@ -1785,7 +1785,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     char txt[256];
 #endif
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
@@ -1798,7 +1798,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     pa_strbuf_printf(buf, "### Configuration dump generated at %s\n", ctime(&now));
 #endif
 
-    PA_IDXSET_FOREACH(m, c->modules, idx) {
+    PA_IDXSET_FOREACH(m, c->core->modules, idx) {
 
         pa_strbuf_printf(buf, "load-module %s", m->name);
 
@@ -1809,7 +1809,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     }
 
     nl = false;
-    PA_IDXSET_FOREACH(sink, c->sinks, idx) {
+    PA_IDXSET_FOREACH(sink, c->core->sinks, idx) {
 
         if (!nl) {
             pa_strbuf_puts(buf, "\n");
@@ -1822,7 +1822,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     }
 
     nl = false;
-    PA_IDXSET_FOREACH(source, c->sources, idx) {
+    PA_IDXSET_FOREACH(source, c->core->sources, idx) {
 
         if (!nl) {
             pa_strbuf_puts(buf, "\n");
@@ -1835,7 +1835,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     }
 
     nl = false;
-    PA_IDXSET_FOREACH(card, c->cards, idx) {
+    PA_IDXSET_FOREACH(card, c->core->cards, idx) {
 
         if (!nl) {
             pa_strbuf_puts(buf, "\n");
@@ -1846,7 +1846,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     }
 
     nl = false;
-    if ((sink = pa_namereg_get_default_sink(c))) {
+    if ((sink = pa_namereg_get_default_sink(c->core))) {
         if (!nl) {
             pa_strbuf_puts(buf, "\n");
             nl = true;
@@ -1855,7 +1855,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
         pa_strbuf_printf(buf, "set-default-sink %s\n", sink->name);
     }
 
-    if ((source = pa_namereg_get_default_source(c))) {
+    if ((source = pa_namereg_get_default_source(c->core))) {
         if (!nl)
             pa_strbuf_puts(buf, "\n");
 
@@ -1867,7 +1867,7 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool
     return 0;
 }
 
-static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
+static int pa_cli_command_dump_volumes(pa_cli *c, pa_tokenizer *t, pa_strbuf *buf, bool *fail) {
     pa_sink *s;
     pa_source *so;
     pa_sink_input *i;
@@ -1876,12 +1876,12 @@ static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *b
     char v_str[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
     pa_channel_map *map;
 
-    pa_core_assert_ref(c);
+    pa_assert(c);
     pa_assert(t);
     pa_assert(buf);
     pa_assert(fail);
 
-    PA_IDXSET_FOREACH(s, c->sinks, s_idx) {
+    PA_IDXSET_FOREACH(s, c->core->sinks, s_idx) {
         map = &s->channel_map;
         pa_strbuf_printf(buf, "Sink %d: ", s_idx);
         pa_strbuf_printf(buf,
@@ -1933,7 +1933,7 @@ static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *b
         }
     }
 
-    PA_IDXSET_FOREACH(so, c->sources, s_idx) {
+    PA_IDXSET_FOREACH(so, c->core->sources, s_idx) {
         map = &so->channel_map;
         pa_strbuf_printf(buf, "Source %d: ", s_idx);
         pa_strbuf_printf(buf,
@@ -1988,7 +1988,7 @@ static int pa_cli_command_dump_volumes(pa_core *c, pa_tokenizer *t, pa_strbuf *b
     return 0;
 }
 
-int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *buf, bool *fail, int *ifstate) {
+int pa_cli_command_execute_line_stateful(pa_cli *c, const char *s, pa_strbuf *buf, bool *fail, int *ifstate) {
     const char *cs;
 
     pa_assert(c);
@@ -2186,11 +2186,11 @@ int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *b
     return 0;
 }
 
-int pa_cli_command_execute_line(pa_core *c, const char *s, pa_strbuf *buf, bool *fail) {
+int pa_cli_command_execute_line(pa_cli *c, const char *s, pa_strbuf *buf, bool *fail) {
     return pa_cli_command_execute_line_stateful(c, s, buf, fail, NULL);
 }
 
-int pa_cli_command_execute_file_stream(pa_core *c, FILE *f, pa_strbuf *buf, bool *fail) {
+int pa_cli_command_execute_file_stream(pa_cli *c, FILE *f, pa_strbuf *buf, bool *fail) {
     char line[2048];
     int ifstate = IFSTATE_NONE;
     int ret = -1;
@@ -2213,11 +2213,10 @@ int pa_cli_command_execute_file_stream(pa_core *c, FILE *f, pa_strbuf *buf, bool
     ret = 0;
 
 fail:
-
     return ret;
 }
 
-int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, bool *fail) {
+int pa_cli_command_execute_file(pa_cli *c, const char *fn, pa_strbuf *buf, bool *fail) {
     FILE *f = NULL;
     int ret = -1;
     bool _fail = true;
@@ -2246,7 +2245,7 @@ fail:
     return ret;
 }
 
-int pa_cli_command_execute(pa_core *c, const char *s, pa_strbuf *buf, bool *fail) {
+int pa_cli_command_execute(pa_cli *c, const char *s, pa_strbuf *buf, bool *fail) {
     const char *p;
     int ifstate = IFSTATE_NONE;
     bool _fail = true;
diff --git a/src/pulsecore/cli-command.h b/src/pulsecore/cli-command.h
index a2b35d4..fd0aa4e 100644
--- a/src/pulsecore/cli-command.h
+++ b/src/pulsecore/cli-command.h
@@ -24,23 +24,24 @@
 
 #include <pulsecore/strbuf.h>
 #include <pulsecore/core.h>
+#include <pulsecore/cli.h>
 
 /* Execute a single CLI command. Write the results to the string
  * buffer *buf. If *fail is non-zero the function will return -1 when
  * one or more of the executed commands failed. *fail
  * may be modified by the function call. */
-int pa_cli_command_execute_line(pa_core *c, const char *s, pa_strbuf *buf, bool *fail);
+int pa_cli_command_execute_line(pa_cli *c, const char *s, pa_strbuf *buf, bool *fail);
 
 /* Execute a whole file of CLI commands */
-int pa_cli_command_execute_file(pa_core *c, const char *fn, pa_strbuf *buf, bool *fail);
+int pa_cli_command_execute_file(pa_cli *c, const char *fn, pa_strbuf *buf, bool *fail);
 
 /* Execute a whole file of CLI commands */
-int pa_cli_command_execute_file_stream(pa_core *c, FILE *f, pa_strbuf *buf, bool *fail);
+int pa_cli_command_execute_file_stream(pa_cli *c, FILE *f, pa_strbuf *buf, bool *fail);
 
 /* Split the specified string into lines and run pa_cli_command_execute_line() for each. */
-int pa_cli_command_execute(pa_core *c, const char *s, pa_strbuf *buf, bool *fail);
+int pa_cli_command_execute(pa_cli *c, const char *s, pa_strbuf *buf, bool *fail);
 
 /* Same as pa_cli_command_execute_line() but also take ifstate var. */
-int pa_cli_command_execute_line_stateful(pa_core *c, const char *s, pa_strbuf *buf, bool *fail, int *ifstate);
+int pa_cli_command_execute_line_stateful(pa_cli *c, const char *s, pa_strbuf *buf, bool *fail, int *ifstate);
 
 #endif
diff --git a/src/pulsecore/cli.c b/src/pulsecore/cli.c
index af2f871..4a9dabc 100644
--- a/src/pulsecore/cli.c
+++ b/src/pulsecore/cli.c
@@ -29,7 +29,6 @@
 #include <pulse/xmalloc.h>
 
 #include <pulsecore/core-util.h>
-#include <pulsecore/ioline.h>
 #include <pulsecore/module.h>
 #include <pulsecore/client.h>
 #include <pulsecore/tokenizer.h>
@@ -43,24 +42,16 @@
 
 #define PROMPT ">>> "
 
-struct pa_cli {
-    pa_core *core;
-    pa_ioline *line;
-
-    pa_cli_eof_cb_t eof_callback;
-    void *userdata;
-
-    pa_client *client;
-
-    bool fail, kill_requested;
-    int defer_kill;
-
-    char *last_line;
-};
-
 static void line_callback(pa_ioline *line, const char *s, void *userdata);
 static void client_kill(pa_client *c);
 
+pa_cli* pa_cli_dummy_new(pa_core *core) {
+    pa_cli *c = pa_xnew0(pa_cli, 1);
+    c->core = core;
+
+    return c;
+}
+
 pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m) {
     char cname[256];
     pa_cli *c;
@@ -106,9 +97,14 @@ pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m) {
 void pa_cli_free(pa_cli *c) {
     pa_assert(c);
 
-    pa_ioline_close(c->line);
-    pa_ioline_unref(c->line);
-    pa_client_free(c->client);
+    if (c->line) {
+        pa_ioline_close(c->line);
+        pa_ioline_unref(c->line);
+    }
+
+    if (c->client)
+        pa_client_free(c->client);
+
     pa_xfree(c->last_line);
     pa_xfree(c);
 }
@@ -154,7 +150,7 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
 
     pa_assert_se(buf = pa_strbuf_new());
     c->defer_kill++;
-    pa_cli_command_execute_line(c->core, s, buf, &c->fail);
+    pa_cli_command_execute_line(c, s, buf, &c->fail);
     c->defer_kill--;
     pa_ioline_puts(line, p = pa_strbuf_tostring_free(buf));
     pa_xfree(p);
diff --git a/src/pulsecore/cli.h b/src/pulsecore/cli.h
index ebab6c2..c50e065 100644
--- a/src/pulsecore/cli.h
+++ b/src/pulsecore/cli.h
@@ -25,12 +25,29 @@
 #include <pulsecore/iochannel.h>
 #include <pulsecore/core.h>
 #include <pulsecore/module.h>
+#include <pulsecore/ioline.h>
 
 typedef struct pa_cli pa_cli;
 
 typedef void (*pa_cli_eof_cb_t)(pa_cli *c, void *userdata);
 
+struct pa_cli {
+    pa_core *core;
+    pa_ioline *line;
+
+    pa_cli_eof_cb_t eof_callback;
+    void *userdata;
+
+    pa_client *client;
+
+    bool fail, kill_requested;
+    int defer_kill;
+
+    char *last_line;
+};
+
 /* Create a new command line session on the specified io channel owned by the specified module */
+pa_cli* pa_cli_dummy_new(pa_core *core);
 pa_cli* pa_cli_new(pa_core *core, pa_iochannel *io, pa_module *m);
 void pa_cli_free(pa_cli *cli);
 
-- 
1.8.3.2



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux