From e61c2dddb7bc392ab4073d5691870615ada82922 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 3 Jul 2004 23:35:12 +0000 Subject: add pa_ prefix to all identifiers. fix downsampling/resampling add support for U8 samples git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@49 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/cli.c | 250 +++++++++++++++++++++++++++++++------------------------------- 1 file changed, 125 insertions(+), 125 deletions(-) (limited to 'src/cli.c') diff --git a/src/cli.c b/src/cli.c index 10e780cd..659523b1 100644 --- a/src/cli.c +++ b/src/cli.c @@ -15,94 +15,94 @@ #include "strbuf.h" #include "namereg.h" -struct cli { - struct core *core; - struct ioline *line; +struct pa_cli { + struct pa_core *core; + struct pa_ioline *line; - void (*eof_callback)(struct cli *c, void *userdata); + void (*eof_callback)(struct pa_cli *c, void *userdata); void *userdata; - struct client *client; + struct pa_client *client; }; struct command { const char *name; - void (*proc) (struct cli *cli, struct tokenizer*t); + void (*proc) (struct pa_cli *cli, struct pa_tokenizer*t); const char *help; unsigned args; }; -static void line_callback(struct ioline *line, const char *s, void *userdata); - -static void cli_command_exit(struct cli *c, struct tokenizer *t); -static void cli_command_help(struct cli *c, struct tokenizer *t); -static void cli_command_modules(struct cli *c, struct tokenizer *t); -static void cli_command_clients(struct cli *c, struct tokenizer *t); -static void cli_command_sinks(struct cli *c, struct tokenizer *t); -static void cli_command_sources(struct cli *c, struct tokenizer *t); -static void cli_command_sink_inputs(struct cli *c, struct tokenizer *t); -static void cli_command_source_outputs(struct cli *c, struct tokenizer *t); -static void cli_command_stat(struct cli *c, struct tokenizer *t); -static void cli_command_info(struct cli *c, struct tokenizer *t); -static void cli_command_load(struct cli *c, struct tokenizer *t); -static void cli_command_unload(struct cli *c, struct tokenizer *t); -static void cli_command_sink_volume(struct cli *c, struct tokenizer *t); -static void cli_command_sink_input_volume(struct cli *c, struct tokenizer *t); +static void line_callback(struct pa_ioline *line, const char *s, void *userdata); + +static void pa_cli_command_exit(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_help(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_modules(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_clients(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_sinks(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_sources(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_sink_inputs(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_source_outputs(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_stat(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_info(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_load(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_unload(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_sink_volume(struct pa_cli *c, struct pa_tokenizer *t); +static void pa_cli_command_sink_input_volume(struct pa_cli *c, struct pa_tokenizer *t); static const struct command commands[] = { - { "exit", cli_command_exit, "Terminate the daemon", 1 }, - { "help", cli_command_help, "Show this help", 1 }, - { "modules", cli_command_modules, "List loaded modules", 1 }, - { "sinks", cli_command_sinks, "List loaded sinks", 1 }, - { "sources", cli_command_sources, "List loaded sources", 1 }, - { "clients", cli_command_clients, "List loaded clients", 1 }, - { "sink_inputs", cli_command_sink_inputs, "List sink inputs", 1 }, - { "source_outputs", cli_command_source_outputs, "List source outputs", 1 }, - { "stat", cli_command_stat, "Show memory block statistics", 1 }, - { "info", cli_command_info, "Show comprehensive status", 1 }, - { "load", cli_command_load, "Load a module (args: name, arguments)", 3}, - { "unload", cli_command_unload, "Unload a module (args: index)", 2}, - { "sink_volume", cli_command_sink_volume, "Set the volume of a sink (args: sink, volume)", 3}, - { "sink_input_volume", cli_command_sink_input_volume, "Set the volume of a sink input (args: sink input, volume)", 3}, + { "exit", pa_cli_command_exit, "Terminate the daemon", 1 }, + { "help", pa_cli_command_help, "Show this help", 1 }, + { "modules", pa_cli_command_modules, "List loaded modules", 1 }, + { "sinks", pa_cli_command_sinks, "List loaded sinks", 1 }, + { "sources", pa_cli_command_sources, "List loaded sources", 1 }, + { "clients", pa_cli_command_clients, "List loaded clients", 1 }, + { "sink_inputs", pa_cli_command_sink_inputs, "List sink inputs", 1 }, + { "source_outputs", pa_cli_command_source_outputs, "List source outputs", 1 }, + { "stat", pa_cli_command_stat, "Show memory block statistics", 1 }, + { "info", pa_cli_command_info, "Show comprehensive status", 1 }, + { "load", pa_cli_command_load, "Load a module (args: name, arguments)", 3}, + { "unload", pa_cli_command_unload, "Unload a module (args: index)", 2}, + { "sink_volume", pa_cli_command_sink_volume, "Set the volume of a sink (args: sink, volume)", 3}, + { "sink_input_volume", pa_cli_command_sink_input_volume, "Set the volume of a sink input (args: sink input, volume)", 3}, { NULL, NULL, NULL, 0 } }; static const char prompt[] = ">>> "; -struct cli* cli_new(struct core *core, struct iochannel *io) { +struct pa_cli* pa_cli_new(struct pa_core *core, struct pa_iochannel *io) { char cname[256]; - struct cli *c; + struct pa_cli *c; assert(io); - c = malloc(sizeof(struct cli)); + c = malloc(sizeof(struct pa_cli)); assert(c); c->core = core; - c->line = ioline_new(io); + c->line = pa_ioline_new(io); assert(c->line); c->userdata = NULL; c->eof_callback = NULL; - iochannel_peer_to_string(io, cname, sizeof(cname)); - c->client = client_new(core, "CLI", cname); + pa_iochannel_peer_to_string(io, cname, sizeof(cname)); + c->client = pa_client_new(core, "CLI", cname); assert(c->client); - ioline_set_callback(c->line, line_callback, c); - ioline_puts(c->line, "Welcome to polypaudio! Use \"help\" for usage information.\n"); - ioline_puts(c->line, prompt); + pa_ioline_set_callback(c->line, line_callback, c); + pa_ioline_puts(c->line, "Welcome to polypaudio! Use \"help\" for usage information.\n"); + pa_ioline_puts(c->line, prompt); return c; } -void cli_free(struct cli *c) { +void pa_cli_free(struct pa_cli *c) { assert(c); - ioline_free(c->line); - client_free(c->client); + pa_ioline_free(c->line); + pa_client_free(c->client); free(c); } -static void line_callback(struct ioline *line, const char *s, void *userdata) { - struct cli *c = userdata; +static void line_callback(struct pa_ioline *line, const char *s, void *userdata) { + struct pa_cli *c = userdata; const char *cs; const char delimiter[] = " \t\n\r"; assert(line && c); @@ -125,225 +125,225 @@ static void line_callback(struct ioline *line, const char *s, void *userdata) { for (command = commands; command->name; command++) if (strlen(command->name) == l && !strncmp(s, command->name, l)) { - struct tokenizer *t = tokenizer_new(s, command->args); + struct pa_tokenizer *t = pa_tokenizer_new(s, command->args); assert(t); command->proc(c, t); - tokenizer_free(t); + pa_tokenizer_free(t); unknown = 0; break; } if (unknown) - ioline_puts(line, "Unknown command\n"); + pa_ioline_puts(line, "Unknown command\n"); } - ioline_puts(c->line, prompt); + pa_ioline_puts(c->line, prompt); } -void cli_set_eof_callback(struct cli *c, void (*cb)(struct cli*c, void *userdata), void *userdata) { +void pa_cli_set_eof_callback(struct pa_cli *c, void (*cb)(struct pa_cli*c, void *userdata), void *userdata) { assert(c && cb); c->eof_callback = cb; c->userdata = userdata; } -static void cli_command_exit(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_exit(struct pa_cli *c, struct pa_tokenizer *t) { assert(c && c->core && c->core->mainloop && t); c->core->mainloop->quit(c->core->mainloop, 0); } -static void cli_command_help(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_help(struct pa_cli *c, struct pa_tokenizer *t) { const struct command*command; - struct strbuf *strbuf; + struct pa_strbuf *pa_strbuf; char *p; assert(c && t); - strbuf = strbuf_new(); - assert(strbuf); + pa_strbuf = pa_strbuf_new(); + assert(pa_strbuf); - strbuf_puts(strbuf, "Available commands:\n"); + pa_strbuf_puts(pa_strbuf, "Available commands:\n"); for (command = commands; command->name; command++) - strbuf_printf(strbuf, " %-20s %s\n", command->name, command->help); + pa_strbuf_printf(pa_strbuf, " %-20s %s\n", command->name, command->help); - ioline_puts(c->line, p = strbuf_tostring_free(strbuf)); + pa_ioline_puts(c->line, p = pa_strbuf_tostring_free(pa_strbuf)); free(p); } -static void cli_command_modules(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_modules(struct pa_cli *c, struct pa_tokenizer *t) { char *s; assert(c && t); - s = module_list_to_string(c->core); + s = pa_module_list_to_string(c->core); assert(s); - ioline_puts(c->line, s); + pa_ioline_puts(c->line, s); free(s); } -static void cli_command_clients(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_clients(struct pa_cli *c, struct pa_tokenizer *t) { char *s; assert(c && t); - s = client_list_to_string(c->core); + s = pa_client_list_to_string(c->core); assert(s); - ioline_puts(c->line, s); + pa_ioline_puts(c->line, s); free(s); } -static void cli_command_sinks(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_sinks(struct pa_cli *c, struct pa_tokenizer *t) { char *s; assert(c && t); - s = sink_list_to_string(c->core); + s = pa_sink_list_to_string(c->core); assert(s); - ioline_puts(c->line, s); + pa_ioline_puts(c->line, s); free(s); } -static void cli_command_sources(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_sources(struct pa_cli *c, struct pa_tokenizer *t) { char *s; assert(c && t); - s = source_list_to_string(c->core); + s = pa_source_list_to_string(c->core); assert(s); - ioline_puts(c->line, s); + pa_ioline_puts(c->line, s); free(s); } -static void cli_command_sink_inputs(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_sink_inputs(struct pa_cli *c, struct pa_tokenizer *t) { char *s; assert(c && t); - s = sink_input_list_to_string(c->core); + s = pa_sink_input_list_to_string(c->core); assert(s); - ioline_puts(c->line, s); + pa_ioline_puts(c->line, s); free(s); } -static void cli_command_source_outputs(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_source_outputs(struct pa_cli *c, struct pa_tokenizer *t) { char *s; assert(c && t); - s = source_output_list_to_string(c->core); + s = pa_source_output_list_to_string(c->core); assert(s); - ioline_puts(c->line, s); + pa_ioline_puts(c->line, s); free(s); } -static void cli_command_stat(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_stat(struct pa_cli *c, struct pa_tokenizer *t) { char txt[256]; assert(c && t); - snprintf(txt, sizeof(txt), "Memory blocks allocated: %u, total size: %u bytes.\n", memblock_count, memblock_total); - ioline_puts(c->line, txt); + snprintf(txt, sizeof(txt), "Memory blocks allocated: %u, total size: %u bytes.\n", pa_memblock_count, pa_memblock_total); + pa_ioline_puts(c->line, txt); } -static void cli_command_info(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_info(struct pa_cli *c, struct pa_tokenizer *t) { assert(c && t); - cli_command_stat(c, t); - cli_command_modules(c, t); - cli_command_sources(c, t); - cli_command_sinks(c, t); - cli_command_clients(c, t); - cli_command_sink_inputs(c, t); - cli_command_source_outputs(c, t); + pa_cli_command_stat(c, t); + pa_cli_command_modules(c, t); + pa_cli_command_sources(c, t); + pa_cli_command_sinks(c, t); + pa_cli_command_clients(c, t); + pa_cli_command_sink_inputs(c, t); + pa_cli_command_source_outputs(c, t); } -static void cli_command_load(struct cli *c, struct tokenizer *t) { - struct module *m; +static void pa_cli_command_load(struct pa_cli *c, struct pa_tokenizer *t) { + struct pa_module *m; const char *name; char txt[256]; assert(c && t); - if (!(name = tokenizer_get(t, 1))) { - ioline_puts(c->line, "You need to specfiy the module name and optionally arguments.\n"); + if (!(name = pa_tokenizer_get(t, 1))) { + pa_ioline_puts(c->line, "You need to specfiy the module name and optionally arguments.\n"); return; } - if (!(m = module_load(c->core, name, tokenizer_get(t, 2)))) { - ioline_puts(c->line, "Module load failed.\n"); + if (!(m = pa_module_load(c->core, name, pa_tokenizer_get(t, 2)))) { + pa_ioline_puts(c->line, "Module load failed.\n"); return; } snprintf(txt, sizeof(txt), "Module successfully loaded, index: %u.\n", m->index); - ioline_puts(c->line, txt); + pa_ioline_puts(c->line, txt); } -static void cli_command_unload(struct cli *c, struct tokenizer *t) { - struct module *m; +static void pa_cli_command_unload(struct pa_cli *c, struct pa_tokenizer *t) { + struct pa_module *m; uint32_t index; const char *i; char *e; assert(c && t); - if (!(i = tokenizer_get(t, 1))) { - ioline_puts(c->line, "You need to specfiy the module index.\n"); + if (!(i = pa_tokenizer_get(t, 1))) { + pa_ioline_puts(c->line, "You need to specfiy the module index.\n"); return; } index = (uint32_t) strtoul(i, &e, 10); - if (*e || !(m = idxset_get_by_index(c->core->modules, index))) { - ioline_puts(c->line, "Invalid module index.\n"); + if (*e || !(m = pa_idxset_get_by_index(c->core->modules, index))) { + pa_ioline_puts(c->line, "Invalid module index.\n"); return; } - module_unload_request(c->core, m); + pa_module_unload_request(c->core, m); } -static void cli_command_sink_volume(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_sink_volume(struct pa_cli *c, struct pa_tokenizer *t) { const char *n, *v; char *x = NULL; - struct sink *sink; + struct pa_sink *sink; long volume; - if (!(n = tokenizer_get(t, 1))) { - ioline_puts(c->line, "You need to specify a sink either by its name or its index.\n"); + if (!(n = pa_tokenizer_get(t, 1))) { + pa_ioline_puts(c->line, "You need to specify a sink either by its name or its index.\n"); return; } - if (!(v = tokenizer_get(t, 2))) { - ioline_puts(c->line, "You need to specify a volume >= 0. (0 is muted, 0x100 is normal volume)\n"); + if (!(v = pa_tokenizer_get(t, 2))) { + pa_ioline_puts(c->line, "You need to specify a volume >= 0. (0 is muted, 0x100 is normal volume)\n"); return; } volume = strtol(v, &x, 0); if (!x || *x != 0 || volume < 0) { - ioline_puts(c->line, "Failed to parse volume.\n"); + pa_ioline_puts(c->line, "Failed to parse volume.\n"); return; } - if (!(sink = namereg_get(c->core, n, NAMEREG_SINK))) { - ioline_puts(c->line, "No sink found by this name or index.\n"); + if (!(sink = pa_namereg_get(c->core, n, PA_NAMEREG_SINK))) { + pa_ioline_puts(c->line, "No sink found by this name or index.\n"); return; } sink->volume = (uint32_t) volume; } -static void cli_command_sink_input_volume(struct cli *c, struct tokenizer *t) { +static void pa_cli_command_sink_input_volume(struct pa_cli *c, struct pa_tokenizer *t) { const char *n, *v; char *x = NULL; - struct sink_input *si; + struct pa_sink_input *si; long index, volume; - if (!(n = tokenizer_get(t, 1))) { - ioline_puts(c->line, "You need to specify a sink input by its index.\n"); + if (!(n = pa_tokenizer_get(t, 1))) { + pa_ioline_puts(c->line, "You need to specify a sink input by its index.\n"); return; } index = strtol(n, &x, 0); if (!x || *x != 0 || index < 0) { - ioline_puts(c->line, "Failed to parse index.\n"); + pa_ioline_puts(c->line, "Failed to parse index.\n"); return; } - if (!(v = tokenizer_get(t, 2))) { - ioline_puts(c->line, "You need to specify a volume >= 0. (0 is muted, 0x100 is normal volume)\n"); + if (!(v = pa_tokenizer_get(t, 2))) { + pa_ioline_puts(c->line, "You need to specify a volume >= 0. (0 is muted, 0x100 is normal volume)\n"); return; } x = NULL; volume = strtol(v, &x, 0); if (!x || *x != 0 || volume < 0) { - ioline_puts(c->line, "Failed to parse volume.\n"); + pa_ioline_puts(c->line, "Failed to parse volume.\n"); return; } - if (!(si = idxset_get_by_index(c->core->sink_inputs, (uint32_t) index))) { - ioline_puts(c->line, "No sink input found with this index.\n"); + if (!(si = pa_idxset_get_by_index(c->core->sink_inputs, (uint32_t) index))) { + pa_ioline_puts(c->line, "No sink input found with this index.\n"); return; } -- cgit