From 29c7a288177c260cf2b3d8f80e807305b96594ba Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 15 Jan 2009 20:07:13 +0100 Subject: kill autoload stuff as planned --- src/pulsecore/autoload.c | 202 ---------------------------------------- src/pulsecore/autoload.h | 58 ------------ src/pulsecore/cli-command.c | 122 +++--------------------- src/pulsecore/cli-text.c | 47 ++-------- src/pulsecore/cli-text.h | 1 - src/pulsecore/core-scache.c | 12 +-- src/pulsecore/core-scache.h | 2 +- src/pulsecore/core.c | 6 -- src/pulsecore/core.h | 7 +- src/pulsecore/module.c | 58 ------------ src/pulsecore/module.h | 4 - src/pulsecore/namereg.c | 16 +--- src/pulsecore/namereg.h | 2 +- src/pulsecore/native-common.h | 9 +- src/pulsecore/pdispatch.c | 8 +- src/pulsecore/protocol-esound.c | 12 +-- src/pulsecore/protocol-native.c | 185 +++++------------------------------- src/pulsecore/protocol-simple.c | 4 +- src/pulsecore/sink-input.c | 2 +- src/pulsecore/source-output.c | 2 +- 20 files changed, 74 insertions(+), 685 deletions(-) delete mode 100644 src/pulsecore/autoload.c delete mode 100644 src/pulsecore/autoload.h (limited to 'src/pulsecore') diff --git a/src/pulsecore/autoload.c b/src/pulsecore/autoload.c deleted file mode 100644 index 8c84cee5..00000000 --- a/src/pulsecore/autoload.c +++ /dev/null @@ -1,202 +0,0 @@ -/*** - This file is part of PulseAudio. - - Copyright 2004-2006 Lennart Poettering - Copyright 2006 Pierre Ossman for Cendio AB - - PulseAudio is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - PulseAudio is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with PulseAudio; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "autoload.h" - -static void entry_free(pa_autoload_entry *e) { - pa_assert(e); - pa_subscription_post(e->core, PA_SUBSCRIPTION_EVENT_AUTOLOAD|PA_SUBSCRIPTION_EVENT_REMOVE, PA_INVALID_INDEX); - pa_xfree(e->name); - pa_xfree(e->module); - pa_xfree(e->argument); - pa_xfree(e); -} - -static void entry_remove_and_free(pa_autoload_entry *e) { - pa_assert(e); - pa_assert(e->core); - - pa_idxset_remove_by_data(e->core->autoload_idxset, e, NULL); - pa_hashmap_remove(e->core->autoload_hashmap, e->name); - entry_free(e); -} - -static pa_autoload_entry* entry_new(pa_core *c, const char *name) { - pa_autoload_entry *e = NULL; - - pa_core_assert_ref(c); - pa_assert(name); - - if (c->autoload_hashmap && (e = pa_hashmap_get(c->autoload_hashmap, name))) - return NULL; - - e = pa_xnew(pa_autoload_entry, 1); - e->core = c; - e->name = pa_xstrdup(name); - e->module = e->argument = NULL; - e->in_action = 0; - - if (!c->autoload_hashmap) - c->autoload_hashmap = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func); - pa_assert(c->autoload_hashmap); - - pa_hashmap_put(c->autoload_hashmap, e->name, e); - - if (!c->autoload_idxset) - c->autoload_idxset = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); - pa_idxset_put(c->autoload_idxset, e, &e->index); - - pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_AUTOLOAD|PA_SUBSCRIPTION_EVENT_NEW, e->index); - - return e; -} - -int pa_autoload_add(pa_core *c, const char*name, pa_namereg_type_t type, const char*module, const char *argument, uint32_t *idx) { - pa_autoload_entry *e = NULL; - - pa_assert(c); - pa_assert(name); - pa_assert(module); - pa_assert(type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE); - - if (!(e = entry_new(c, name))) - return -1; - - e->module = pa_xstrdup(module); - e->argument = pa_xstrdup(argument); - e->type = type; - - if (idx) - *idx = e->index; - - return 0; -} - -int pa_autoload_remove_by_name(pa_core *c, const char*name, pa_namereg_type_t type) { - pa_autoload_entry *e; - - pa_assert(c); - pa_assert(name); - pa_assert(type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE); - - if (!c->autoload_hashmap || !(e = pa_hashmap_get(c->autoload_hashmap, name)) || e->type != type) - return -1; - - entry_remove_and_free(e); - return 0; -} - -int pa_autoload_remove_by_index(pa_core *c, uint32_t idx) { - pa_autoload_entry *e; - - pa_assert(c); - pa_assert(idx != PA_IDXSET_INVALID); - - if (!c->autoload_idxset || !(e = pa_idxset_get_by_index(c->autoload_idxset, idx))) - return -1; - - entry_remove_and_free(e); - return 0; -} - -void pa_autoload_request(pa_core *c, const char *name, pa_namereg_type_t type) { - pa_autoload_entry *e; - pa_module *m; - - pa_assert(c); - pa_assert(name); - - if (!c->autoload_hashmap || !(e = pa_hashmap_get(c->autoload_hashmap, name)) || (e->type != type)) - return; - - if (e->in_action) - return; - - e->in_action = 1; - - if (type == PA_NAMEREG_SINK || type == PA_NAMEREG_SOURCE) { - if ((m = pa_module_load(c, e->module, e->argument))) - m->auto_unload = 1; - } - - e->in_action = 0; -} - -static void free_func(void *p, void *userdata) { - pa_autoload_entry *e = p; - pa_idxset_remove_by_data(e->core->autoload_idxset, e, NULL); - entry_free(e); -} - -void pa_autoload_free(pa_core *c) { - - if (c->autoload_hashmap) { - pa_hashmap_free(c->autoload_hashmap, free_func, NULL); - c->autoload_hashmap = NULL; - } - - if (c->autoload_idxset) { - pa_idxset_free(c->autoload_idxset, NULL, NULL); - c->autoload_idxset = NULL; - } -} - -const pa_autoload_entry* pa_autoload_get_by_name(pa_core *c, const char*name, pa_namereg_type_t type) { - pa_autoload_entry *e; - - pa_core_assert_ref(c); - pa_assert(name); - - if (!c->autoload_hashmap || !(e = pa_hashmap_get(c->autoload_hashmap, name)) || e->type != type) - return NULL; - - return e; -} - -const pa_autoload_entry* pa_autoload_get_by_index(pa_core *c, uint32_t idx) { - pa_autoload_entry *e; - - pa_core_assert_ref(c); - pa_assert(idx != PA_IDXSET_INVALID); - - if (!c->autoload_idxset || !(e = pa_idxset_get_by_index(c->autoload_idxset, idx))) - return NULL; - - return e; -} diff --git a/src/pulsecore/autoload.h b/src/pulsecore/autoload.h deleted file mode 100644 index 3926351f..00000000 --- a/src/pulsecore/autoload.h +++ /dev/null @@ -1,58 +0,0 @@ -#ifndef fooautoloadhfoo -#define fooautoloadhfoo - -/*** - This file is part of PulseAudio. - - Copyright 2004-2006 Lennart Poettering - - PulseAudio is free software; you can redistribute it and/or modify - it under the terms of the GNU Lesser General Public License as published - by the Free Software Foundation; either version 2 of the License, - or (at your option) any later version. - - PulseAudio is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU Lesser General Public License - along with PulseAudio; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - USA. -***/ - -#include - -/* Using the autoloading facility, modules by be loaded on-demand and - * synchronously. The user may register a "ghost sink" or "ghost - * source". Whenever this sink/source is requested but not available a - * specified module is loaded. */ - -/* An autoload entry, or "ghost" sink/source */ -typedef struct pa_autoload_entry { - pa_core *core; - uint32_t index; - char *name; - pa_namereg_type_t type; /* Type of the autoload entry */ - int in_action; /* The module is currently being loaded */ - char *module, *argument; -} pa_autoload_entry; - -/* Add a new autoload entry of the given time, with the speicified - * sink/source name, module name and argument. Return the entry's - * index in *index */ -int pa_autoload_add(pa_core *c, const char*name, pa_namereg_type_t type, const char*module, const char *argument, uint32_t *idx); - -/* Free all autoload entries */ -void pa_autoload_free(pa_core *c); -int pa_autoload_remove_by_name(pa_core *c, const char*name, pa_namereg_type_t type); -int pa_autoload_remove_by_index(pa_core *c, uint32_t idx); - -/* Request an autoload entry by its name, effectively causing a module to be loaded */ -void pa_autoload_request(pa_core *c, const char *name, pa_namereg_type_t type); - -const pa_autoload_entry* pa_autoload_get_by_name(pa_core *c, const char*name, pa_namereg_type_t type); -const pa_autoload_entry* pa_autoload_get_by_index(pa_core *c, uint32_t idx); - -#endif diff --git a/src/pulsecore/cli-command.c b/src/pulsecore/cli-command.c index 93d6bbe6..8f5d9bdd 100644 --- a/src/pulsecore/cli-command.c +++ b/src/pulsecore/cli-command.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include @@ -107,9 +106,6 @@ static int pa_cli_command_scache_list(pa_core *c, pa_tokenizer *t, pa_strbuf *bu static int pa_cli_command_scache_load(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); static int pa_cli_command_scache_load_dir(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); static int pa_cli_command_play_file(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); -static int pa_cli_command_autoload_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); -static int pa_cli_command_autoload_add(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); -static int pa_cli_command_autoload_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); static int pa_cli_command_list_shared_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail); @@ -168,11 +164,6 @@ static const struct command commands[] = { { "load-sample-lazy", pa_cli_command_scache_load, "Lazily load a sound file into the sample cache (args: name, filename)", 3}, { "load-sample-dir-lazy", pa_cli_command_scache_load_dir, "Lazily load all files in a directory into the sample cache (args: pathname)", 2}, { "play-file", pa_cli_command_play_file, "Play a sound file (args: filename, sink|index)", 3}, - { "list-autoload", pa_cli_command_autoload_list, "List autoload entries", 1}, - { "add-autoload-sink", pa_cli_command_autoload_add, NULL /*"Add autoload entry for a sink (args: sink, module name, arguments)"*/, 4}, - { "add-autoload-source", pa_cli_command_autoload_add, NULL /*"Add autoload entry for a source (args: source, module name, arguments)"*/, 4}, - { "remove-autoload-sink", pa_cli_command_autoload_remove, NULL /*"Remove autoload entry for a sink (args: name)"*/, 2}, - { "remove-autoload-source", pa_cli_command_autoload_remove, NULL /*"Remove autoload entry for a source (args: name)"*/, 2}, { "dump", pa_cli_command_dump, "Dump daemon configuration", 1}, { "shared", pa_cli_command_list_shared_props, NULL, 1}, { "move-sink-input", pa_cli_command_move_sink_input, "Move sink input to another sink (args: index, sink)", 3}, @@ -402,7 +393,6 @@ static int pa_cli_command_info(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b pa_cli_command_sink_inputs(c, t, buf, fail); pa_cli_command_source_outputs(c, t, buf, fail); pa_cli_command_scache_list(c, t, buf, fail); -/* pa_cli_command_autoload_list(c, t, buf, fail); */ return 0; } @@ -519,7 +509,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, 1))) { + if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; } @@ -597,7 +587,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, 1))) { + if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) { pa_strbuf_puts(buf, "No source found by this name or index.\n"); return -1; } @@ -632,7 +622,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, 1))) { + if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; } @@ -666,7 +656,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, 1))) { + if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; } @@ -695,7 +685,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, 1))) { + if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; } @@ -729,7 +719,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, 1))) { + if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) { pa_strbuf_puts(buf, "No source found by this name or index.\n"); return -1; } @@ -1014,7 +1004,7 @@ 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, 1))) { + if (!(sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink by that name.\n"); return -1; } @@ -1110,7 +1100,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, 1))) { + if (!(sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink by that name.\n"); return -1; } @@ -1119,66 +1109,6 @@ 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_autoload_add(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) { - const char *a, *b; - - pa_core_assert_ref(c); - pa_assert(t); - pa_assert(buf); - pa_assert(fail); - - pa_log_warn("Autoload will no longer be implemented by future versions of the PulseAudio server."); - - if (!(a = pa_tokenizer_get(t, 1)) || !(b = pa_tokenizer_get(t, 2))) { - pa_strbuf_puts(buf, "You need to specify a device name, a filename or a module name and optionally module arguments\n"); - return -1; - } - - pa_autoload_add(c, a, strstr(pa_tokenizer_get(t, 0), "sink") ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE, b, pa_tokenizer_get(t, 3), NULL); - - return 0; -} - -static int pa_cli_command_autoload_remove(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) { - const char *name; - - pa_core_assert_ref(c); - pa_assert(t); - pa_assert(buf); - pa_assert(fail); - - pa_log_warn("Autoload will no longer be implemented by future versions of the PulseAudio server."); - - if (!(name = pa_tokenizer_get(t, 1))) { - pa_strbuf_puts(buf, "You need to specify a device name\n"); - return -1; - } - - if (pa_autoload_remove_by_name(c, name, strstr(pa_tokenizer_get(t, 0), "sink") ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE) < 0) { - pa_strbuf_puts(buf, "Failed to remove autload entry\n"); - return -1; - } - - return 0; -} - -static int pa_cli_command_autoload_list(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) { - char *s; - - pa_core_assert_ref(c); - pa_assert(t); - pa_assert(buf); - pa_assert(fail); - - pa_log_warn("Autoload will no longer be implemented by future versions of the PulseAudio server."); - - pa_assert_se(s = pa_autoload_list_to_string(c)); - pa_strbuf_puts(buf, s); - pa_xfree(s); - - return 0; -} - static int pa_cli_command_list_shared_props(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_bool_t *fail) { pa_core_assert_ref(c); pa_assert(t); @@ -1231,7 +1161,7 @@ static int pa_cli_command_move_sink_input(pa_core *c, pa_tokenizer *t, pa_strbuf return -1; } - if (!(sink = pa_namereg_get(c, k, PA_NAMEREG_SINK, 1))) { + if (!(sink = pa_namereg_get(c, k, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; } @@ -1274,7 +1204,7 @@ static int pa_cli_command_move_source_output(pa_core *c, pa_tokenizer *t, pa_str return -1; } - if (!(source = pa_namereg_get(c, k, PA_NAMEREG_SOURCE, 1))) { + if (!(source = pa_namereg_get(c, k, PA_NAMEREG_SOURCE))) { pa_strbuf_puts(buf, "No source found by this name or index.\n"); return -1; } @@ -1311,7 +1241,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, 1))) { + if (!(sink = pa_namereg_get(c, n, PA_NAMEREG_SINK))) { pa_strbuf_puts(buf, "No sink found by this name or index.\n"); return -1; } @@ -1345,7 +1275,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, 1))) { + if (!(source = pa_namereg_get(c, n, PA_NAMEREG_SOURCE))) { pa_strbuf_puts(buf, "No source found by this name or index.\n"); return -1; } @@ -1489,8 +1419,6 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b uint32_t idx; char txt[256]; time_t now; - void *i; - pa_autoload_entry *a; pa_core_assert_ref(c); pa_assert(t); @@ -1506,8 +1434,6 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b #endif for (m = pa_idxset_first(c->modules, &idx); m; m = pa_idxset_next(c->modules, &idx)) { - if (m->auto_unload) - continue; pa_strbuf_printf(buf, "load-module %s", m->name); @@ -1520,8 +1446,6 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b nl = 0; for (sink = pa_idxset_first(c->sinks, &idx); sink; sink = pa_idxset_next(c->sinks, &idx)) { - if (sink->module && sink->module->auto_unload) - continue; if (!nl) { pa_strbuf_puts(buf, "\n"); @@ -1534,8 +1458,6 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b } for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx)) { - if (source->module && source->module->auto_unload) - continue; if (!nl) { pa_strbuf_puts(buf, "\n"); @@ -1548,26 +1470,6 @@ static int pa_cli_command_dump(pa_core *c, pa_tokenizer *t, pa_strbuf *buf, pa_b } - if (c->autoload_hashmap) { - nl = 0; - - i = NULL; - while ((a = pa_hashmap_iterate(c->autoload_hashmap, &i, NULL))) { - - if (!nl) { - pa_strbuf_puts(buf, "\n"); - nl = 1; - } - - pa_strbuf_printf(buf, "add-autoload-%s %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))) { diff --git a/src/pulsecore/cli-text.c b/src/pulsecore/cli-text.c index 5d78ce64..27db56e5 100644 --- a/src/pulsecore/cli-text.c +++ b/src/pulsecore/cli-text.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include @@ -59,9 +58,12 @@ char *pa_module_list_to_string(pa_core *c) { "\tname: <%s>\n" "\targument: <%s>\n" "\tused: %i\n" - "\tauto unload: %s\n", - m->index, m->name, m->argument ? m->argument : "", m->n_used, - pa_yes_no(m->auto_unload)); + "\tload once: %s\n", + m->index, + m->name, + pa_strempty(m->argument), + m->n_used, + pa_yes_no(m->load_once)); } return pa_strbuf_tostring_free(s); @@ -506,45 +508,13 @@ char *pa_scache_list_to_string(pa_core *c) { return pa_strbuf_tostring_free(s); } -char *pa_autoload_list_to_string(pa_core *c) { - pa_strbuf *s; - pa_assert(c); - - s = pa_strbuf_new(); - - pa_strbuf_printf(s, "%u autoload entries available.\n", c->autoload_hashmap ? pa_hashmap_size(c->autoload_hashmap) : 0); - - if (c->autoload_hashmap) { - pa_autoload_entry *e; - void *state = NULL; - - while ((e = pa_hashmap_iterate(c->autoload_hashmap, &state, NULL))) { - pa_strbuf_printf( - s, - " name: <%s>\n" - "\ttype: %s\n" - "\tindex: %u\n" - "\tmodule_name: <%s>\n" - "\targuments: <%s>\n", - e->name, - e->type == PA_NAMEREG_SOURCE ? "source" : "sink", - e->index, - e->module, - e->argument ? e->argument : ""); - - } - } - - return pa_strbuf_tostring_free(s); -} - char *pa_full_status_string(pa_core *c) { pa_strbuf *s; int i; s = pa_strbuf_new(); - for (i = 0; i < 9; i++) { + for (i = 0; i < 8; i++) { char *t = NULL; switch (i) { @@ -572,9 +542,6 @@ char *pa_full_status_string(pa_core *c) { case 7: t = pa_scache_list_to_string(c); break; - case 8: - t = pa_autoload_list_to_string(c); - break; } pa_strbuf_puts(s, t); diff --git a/src/pulsecore/cli-text.h b/src/pulsecore/cli-text.h index 167565e5..aad51648 100644 --- a/src/pulsecore/cli-text.h +++ b/src/pulsecore/cli-text.h @@ -35,7 +35,6 @@ char *pa_card_list_to_string(pa_core *c); char *pa_client_list_to_string(pa_core *c); char *pa_module_list_to_string(pa_core *c); char *pa_scache_list_to_string(pa_core *c); -char *pa_autoload_list_to_string(pa_core *c); char *pa_full_status_string(pa_core *c); diff --git a/src/pulsecore/core-scache.c b/src/pulsecore/core-scache.c index 1d080e11..0f34c9d1 100644 --- a/src/pulsecore/core-scache.c +++ b/src/pulsecore/core-scache.c @@ -98,7 +98,7 @@ static pa_scache_entry* scache_add_item(pa_core *c, const char *name) { pa_assert(c); pa_assert(name); - if ((e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, FALSE))) { + if ((e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE))) { if (e->memchunk.memblock) pa_memblock_unref(e->memchunk.memblock); @@ -273,7 +273,7 @@ int pa_scache_remove_item(pa_core *c, const char *name) { pa_assert(c); pa_assert(name); - if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, 0))) + if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE))) return -1; pa_assert_se(pa_idxset_remove_by_data(c->scache, e, NULL) == e); @@ -313,7 +313,7 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t pa_assert(name); pa_assert(sink); - if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, FALSE))) + if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE))) return -1; if (e->lazy && !e->memchunk.memblock) { @@ -360,13 +360,13 @@ int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t return 0; } -int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_bool_t autoload, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx) { +int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx) { pa_sink *sink; pa_assert(c); pa_assert(name); - if (!(sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK, autoload))) + if (!(sink = pa_namereg_get(c, sink_name, PA_NAMEREG_SINK))) return -1; return pa_scache_play_item(c, name, sink, volume, p, sink_input_idx); @@ -390,7 +390,7 @@ uint32_t pa_scache_get_id_by_name(pa_core *c, const char *name) { pa_assert(c); pa_assert(name); - if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE, FALSE))) + if (!(e = pa_namereg_get(c, name, PA_NAMEREG_SAMPLE))) return PA_IDXSET_INVALID; return e->index; diff --git a/src/pulsecore/core-scache.h b/src/pulsecore/core-scache.h index 80e0fd04..ba65a964 100644 --- a/src/pulsecore/core-scache.h +++ b/src/pulsecore/core-scache.h @@ -56,7 +56,7 @@ int pa_scache_add_directory_lazy(pa_core *c, const char *pathname); int pa_scache_remove_item(pa_core *c, const char *name); int pa_scache_play_item(pa_core *c, const char *name, pa_sink *sink, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx); -int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_bool_t autoload, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx); +int pa_scache_play_item_by_name(pa_core *c, const char *name, const char*sink_name, pa_volume_t volume, pa_proplist *p, uint32_t *sink_input_idx); void pa_scache_free(pa_core *c); const char *pa_scache_get_name_by_id(pa_core *c, uint32_t id); diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c index 20764325..0b78bc40 100644 --- a/src/pulsecore/core.c +++ b/src/pulsecore/core.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -104,8 +103,6 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) { c->modules = NULL; c->namereg = NULL; c->scache = NULL; - c->autoload_idxset = NULL; - c->autoload_hashmap = NULL; c->running_as_daemon = FALSE; c->default_sample_spec.format = PA_SAMPLE_S16NE; @@ -114,7 +111,6 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) { c->default_n_fragments = 4; c->default_fragment_size_msec = 25; - c->module_auto_unload_event = NULL; c->module_defer_unload_event = NULL; c->scache_auto_unload_event = NULL; @@ -129,7 +125,6 @@ pa_core* pa_core_new(pa_mainloop_api *m, pa_bool_t shared, size_t shm_size) { c->exit_event = NULL; c->exit_idle_time = -1; - c->module_idle_time = 20; c->scache_idle_time = 20; c->resample_method = PA_RESAMPLER_SPEEX_FLOAT_BASE + 3; @@ -185,7 +180,6 @@ static void core_free(pa_object *o) { pa_scache_free(c); pa_namereg_free(c); - pa_autoload_free(c); pa_subscription_free_all(c); if (c->exit_event) diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h index 87ea4ab6..9f463d67 100644 --- a/src/pulsecore/core.h +++ b/src/pulsecore/core.h @@ -99,10 +99,10 @@ struct pa_core { pa_mainloop_api *mainloop; /* idxset of all kinds of entities */ - pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache, *autoload_idxset; + pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache; /* Some hashmaps for all sorts of entities */ - pa_hashmap *namereg, *autoload_hashmap, *shared; + pa_hashmap *namereg, *shared; /* The name of the default sink/source */ char *default_source_name, *default_sink_name; @@ -110,7 +110,6 @@ struct pa_core { pa_sample_spec default_sample_spec; unsigned default_n_fragments, default_fragment_size_msec; - pa_time_event *module_auto_unload_event; pa_defer_event *module_defer_unload_event; pa_defer_event *subscription_defer_event; @@ -121,7 +120,7 @@ struct pa_core { pa_mempool *mempool; pa_silence_cache silence_cache; - int exit_idle_time, module_idle_time, scache_idle_time; + int exit_idle_time, scache_idle_time; pa_time_event *exit_event; diff --git a/src/pulsecore/module.c b/src/pulsecore/module.c index 56ed2c5d..b197ba06 100644 --- a/src/pulsecore/module.c +++ b/src/pulsecore/module.c @@ -48,21 +48,6 @@ #define UNLOAD_POLL_TIME 2 -static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, const struct timeval *tv, void *userdata) { - pa_core *c = PA_CORE(userdata); - struct timeval ntv; - - pa_core_assert_ref(c); - pa_assert(c->mainloop == m); - pa_assert(c->module_auto_unload_event == e); - - pa_module_unload_unused(c); - - pa_gettimeofday(&ntv); - pa_timeval_add(&ntv, UNLOAD_POLL_TIME*PA_USEC_PER_SEC); - m->time_restart(e, &ntv); -} - pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { pa_module *m = NULL; pa_bool_t (*load_once)(void); @@ -110,7 +95,6 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { m->userdata = NULL; m->core = c; m->n_used = -1; - m->auto_unload = FALSE; m->unload_requested = FALSE; if (m->init(m) < 0) { @@ -121,13 +105,6 @@ pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) { if (!c->modules) c->modules = pa_idxset_new(NULL, NULL); - if (m->auto_unload && !c->module_auto_unload_event) { - struct timeval ntv; - pa_gettimeofday(&ntv); - pa_timeval_add(&ntv, UNLOAD_POLL_TIME*PA_USEC_PER_SEC); - c->module_auto_unload_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, c); - } - pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0); pa_assert(m->index != PA_IDXSET_INVALID); @@ -212,44 +189,12 @@ void pa_module_unload_all(pa_core *c) { c->modules = NULL; } - if (c->module_auto_unload_event) { - c->mainloop->time_free(c->module_auto_unload_event); - c->module_auto_unload_event = NULL; - } - if (c->module_defer_unload_event) { c->mainloop->defer_free(c->module_defer_unload_event); c->module_defer_unload_event = NULL; } } -void pa_module_unload_unused(pa_core *c) { - void *state = NULL; - time_t now; - pa_module *m; - - pa_assert(c); - - if (!c->modules) - return; - - time(&now); - - while ((m = pa_idxset_iterate(c->modules, &state, NULL))) { - - if (m->n_used > 0) - continue; - - if (!m->auto_unload) - continue; - - if (m->last_used_time + m->core->module_idle_time > now) - continue; - - pa_module_unload(c, m, FALSE); - } -} - static void defer_cb(pa_mainloop_api*api, pa_defer_event *e, void *userdata) { void *state = NULL; pa_core *c = PA_CORE(userdata); @@ -296,9 +241,6 @@ void pa_module_set_used(pa_module*m, int used) { if (m->n_used != used) pa_subscription_post(m->core, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_CHANGE, m->index); - if (used == 0 && m->n_used > 0) - time(&m->last_used_time); - m->n_used = used; } diff --git a/src/pulsecore/module.h b/src/pulsecore/module.h index 661b2dd6..c54169bf 100644 --- a/src/pulsecore/module.h +++ b/src/pulsecore/module.h @@ -44,11 +44,8 @@ struct pa_module { int n_used; - pa_bool_t auto_unload:1; pa_bool_t load_once:1; pa_bool_t unload_requested:1; - - time_t last_used_time; }; pa_module* pa_module_load(pa_core *c, const char *name, const char*argument); @@ -60,7 +57,6 @@ void pa_module_unload_request(pa_module *m, pa_bool_t force); void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, pa_bool_t force); void pa_module_unload_all(pa_core *c); -void pa_module_unload_unused(pa_core *c); void pa_module_set_used(pa_module*m, int used); diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c index c1a434ae..3b9ce886 100644 --- a/src/pulsecore/namereg.c +++ b/src/pulsecore/namereg.c @@ -178,7 +178,7 @@ void pa_namereg_unregister(pa_core *c, const char *name) { pa_xfree(e); } -void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, pa_bool_t autoload) { +void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type) { struct namereg_entry *e; uint32_t idx; pa_assert(c); @@ -202,7 +202,7 @@ void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, pa_bo if (type == PA_NAMEREG_SOURCE) { pa_sink *k; - if ((k = pa_namereg_get(c, NULL, PA_NAMEREG_SINK, autoload))) + if ((k = pa_namereg_get(c, NULL, PA_NAMEREG_SINK))) return k->monitor_source; } } else if (*name == '@') @@ -215,18 +215,8 @@ void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, pa_bo if (e->type == type) return e->data; - if (pa_atou(name, &idx) < 0) { - - if (autoload) { - pa_autoload_request(c, name, type); - - if (c->namereg && (e = pa_hashmap_get(c->namereg, name))) - if (e->type == type) - return e->data; - } - + if (pa_atou(name, &idx) < 0) return NULL; - } if (type == PA_NAMEREG_SINK) return pa_idxset_get_by_index(c->sinks, idx); diff --git a/src/pulsecore/namereg.h b/src/pulsecore/namereg.h index 8ce548a7..4205f2f9 100644 --- a/src/pulsecore/namereg.h +++ b/src/pulsecore/namereg.h @@ -38,7 +38,7 @@ void pa_namereg_free(pa_core *c); const char *pa_namereg_register(pa_core *c, const char *name, pa_namereg_type_t type, void *data, pa_bool_t fail); void pa_namereg_unregister(pa_core *c, const char *name); -void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type, pa_bool_t autoload); +void* pa_namereg_get(pa_core *c, const char *name, pa_namereg_type_t type); int pa_namereg_set_default(pa_core*c, const char *name, pa_namereg_type_t type); const char *pa_namereg_get_default_sink_name(pa_core *c); diff --git a/src/pulsecore/native-common.h b/src/pulsecore/native-common.h index 8138b7a4..11643a72 100644 --- a/src/pulsecore/native-common.h +++ b/src/pulsecore/native-common.h @@ -94,10 +94,11 @@ enum { PA_COMMAND_LOAD_MODULE, PA_COMMAND_UNLOAD_MODULE, - PA_COMMAND_ADD_AUTOLOAD, - PA_COMMAND_REMOVE_AUTOLOAD, - PA_COMMAND_GET_AUTOLOAD_INFO, - PA_COMMAND_GET_AUTOLOAD_INFO_LIST, + /* Obsolete */ + PA_COMMAND_ADD_AUTOLOAD___OBSOLETE, + PA_COMMAND_REMOVE_AUTOLOAD___OBSOLETE, + PA_COMMAND_GET_AUTOLOAD_INFO___OBSOLETE, + PA_COMMAND_GET_AUTOLOAD_INFO_LIST___OBSOLETE, PA_COMMAND_GET_RECORD_LATENCY, PA_COMMAND_CORK_RECORD_STREAM, diff --git a/src/pulsecore/pdispatch.c b/src/pulsecore/pdispatch.c index a5b33d62..305941a3 100644 --- a/src/pulsecore/pdispatch.c +++ b/src/pulsecore/pdispatch.c @@ -110,10 +110,10 @@ static const char *command_names[PA_COMMAND_MAX] = { [PA_COMMAND_LOAD_MODULE] = "LOAD_MODULE", [PA_COMMAND_UNLOAD_MODULE] = "UNLOAD_MODULE", - [PA_COMMAND_ADD_AUTOLOAD] = "ADD_AUTOLOAD", - [PA_COMMAND_REMOVE_AUTOLOAD] = "REMOVE_AUTOLOAD", - [PA_COMMAND_GET_AUTOLOAD_INFO] = "GET_AUTOLOAD_INFO", - [PA_COMMAND_GET_AUTOLOAD_INFO_LIST] = "GET_AUTOLOAD_INFO_LIST", + [PA_COMMAND_ADD_AUTOLOAD___OBSOLETE] = "ADD_AUTOLOAD (obsolete)", + [PA_COMMAND_REMOVE_AUTOLOAD___OBSOLETE] = "REMOVE_AUTOLOAD (obsolete)", + [PA_COMMAND_GET_AUTOLOAD_INFO___OBSOLETE] = "GET_AUTOLOAD_INFO (obsolete)", + [PA_COMMAND_GET_AUTOLOAD_INFO_LIST___OBSOLETE] = "GET_AUTOLOAD_INFO_LIST (obsolete)", [PA_COMMAND_GET_RECORD_LATENCY] = "GET_RECORD_LATENCY", [PA_COMMAND_CORK_RECORD_STREAM] = "CORK_RECORD_STREAM", diff --git a/src/pulsecore/protocol-esound.c b/src/pulsecore/protocol-esound.c index 6524b684..97d10df5 100644 --- a/src/pulsecore/protocol-esound.c +++ b/src/pulsecore/protocol-esound.c @@ -403,7 +403,7 @@ static int esd_proto_stream_play(connection *c, esd_proto_t request, const void CHECK_VALIDITY(pa_sample_spec_valid(&ss), "Invalid sample specification"); if (c->options->default_sink) { - sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK); CHECK_VALIDITY(sink, "No such sink: %s", c->options->default_sink); } @@ -490,7 +490,7 @@ static int esd_proto_stream_record(connection *c, esd_proto_t request, const voi if (request == ESD_PROTO_STREAM_MON) { pa_sink* sink; - if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1))) { + if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) { pa_log("no such sink."); return -1; } @@ -503,7 +503,7 @@ static int esd_proto_stream_record(connection *c, esd_proto_t request, const voi pa_assert(request == ESD_PROTO_STREAM_REC); if (c->options->default_source) { - if (!(source = pa_namereg_get(c->protocol->core, c->options->default_source, PA_NAMEREG_SOURCE, 1))) { + if (!(source = pa_namereg_get(c->protocol->core, c->options->default_source, PA_NAMEREG_SOURCE))) { pa_log("no such source."); return -1; } @@ -569,7 +569,7 @@ static int esd_proto_get_latency(connection *c, esd_proto_t request, const void pa_assert(!data); pa_assert(length == 0); - if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1))) + if (!(sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) latency = 0; else { double usec = (double) pa_sink_get_latency(sink); @@ -590,7 +590,7 @@ static int esd_proto_server_info(connection *c, esd_proto_t request, const void pa_assert(data); pa_assert(length == sizeof(int32_t)); - if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1))) { + if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) { rate = (int32_t) sink->sample_spec.rate; format = format_native2esd(&sink->sample_spec); } @@ -865,7 +865,7 @@ static int esd_proto_sample_free_or_play(connection *c, esd_proto_t request, con if (request == ESD_PROTO_SAMPLE_PLAY) { pa_sink *sink; - if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK, 1))) + if ((sink = pa_namereg_get(c->protocol->core, c->options->default_sink, PA_NAMEREG_SINK))) if (pa_scache_play_item(c->protocol->core, name, sink, PA_VOLUME_NORM, c->client->proplist, NULL) >= 0) ok = (int32_t) idx + 1; } else { diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c index d99e212f..21797527 100644 --- a/src/pulsecore/protocol-native.c +++ b/src/pulsecore/protocol-native.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -248,10 +247,6 @@ static void command_set_stream_name(pa_pdispatch *pd, uint32_t command, uint32_t static void command_kill(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); static void command_load_module(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); static void command_unload_module(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); -static void command_add_autoload(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); -static void command_remove_autoload(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); -static void command_get_autoload_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); -static void command_get_autoload_info_list(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); static void command_cork_record_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); static void command_flush_record_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata); @@ -330,10 +325,11 @@ static const pa_pdispatch_cb_t command_table[PA_COMMAND_MAX] = { [PA_COMMAND_KILL_SOURCE_OUTPUT] = command_kill, [PA_COMMAND_LOAD_MODULE] = command_load_module, [PA_COMMAND_UNLOAD_MODULE] = command_unload_module, - [PA_COMMAND_GET_AUTOLOAD_INFO] = command_get_autoload_info, - [PA_COMMAND_GET_AUTOLOAD_INFO_LIST] = command_get_autoload_info_list, - [PA_COMMAND_ADD_AUTOLOAD] = command_add_autoload, - [PA_COMMAND_REMOVE_AUTOLOAD] = command_remove_autoload, + + [PA_COMMAND_GET_AUTOLOAD_INFO___OBSOLETE] = NULL, + [PA_COMMAND_GET_AUTOLOAD_INFO_LIST___OBSOLETE] = NULL, + [PA_COMMAND_ADD_AUTOLOAD___OBSOLETE] = NULL, + [PA_COMMAND_REMOVE_AUTOLOAD___OBSOLETE] = NULL, [PA_COMMAND_MOVE_SINK_INPUT] = command_move_stream, [PA_COMMAND_MOVE_SOURCE_OUTPUT] = command_move_stream, @@ -1799,7 +1795,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u } else if (sink_name) { - if (!(sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK, 1))) { + if (!(sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK))) { pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY); pa_proplist_free(p); return; @@ -2040,7 +2036,7 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin } else if (source_name) { - if (!(source = pa_namereg_get(c->protocol->core, source_name, PA_NAMEREG_SOURCE, 1))) { + if (!(source = pa_namereg_get(c->protocol->core, source_name, PA_NAMEREG_SOURCE))) { pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY); pa_proplist_free(p); return; @@ -2315,12 +2311,12 @@ static void command_lookup(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ if (command == PA_COMMAND_LOOKUP_SINK) { pa_sink *sink; - if ((sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1))) + if ((sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK))) idx = sink->index; } else { pa_source *source; pa_assert(command == PA_COMMAND_LOOKUP_SOURCE); - if ((source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1))) + if ((source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE))) idx = source->index; } @@ -2575,7 +2571,7 @@ static void command_play_sample(pa_pdispatch *pd, uint32_t command, uint32_t tag if (sink_index != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, sink_index); else - sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK); CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY); @@ -2738,7 +2734,7 @@ static void module_fill_tagstruct(pa_tagstruct *t, pa_module *module) { pa_tagstruct_puts(t, module->name); pa_tagstruct_puts(t, module->argument); pa_tagstruct_putu32(t, (uint32_t) module->n_used); - pa_tagstruct_put_boolean(t, module->auto_unload); + pa_tagstruct_put_boolean(t, FALSE); } static void sink_input_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_sink_input *s) { @@ -2855,12 +2851,12 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p if (idx != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); else - sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK); } else if (command == PA_COMMAND_GET_SOURCE_INFO) { if (idx != PA_INVALID_INDEX) source = pa_idxset_get_by_index(c->protocol->core->sources, idx); else - source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1); + source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE); } else if (command == PA_COMMAND_GET_CLIENT_INFO) client = pa_idxset_get_by_index(c->protocol->core->clients, idx); else if (command == PA_COMMAND_GET_MODULE_INFO) @@ -2874,7 +2870,7 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p if (idx != PA_INVALID_INDEX) sce = pa_idxset_get_by_index(c->protocol->core->scache, idx); else - sce = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SAMPLE, 0); + sce = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SAMPLE); } if (!sink && !source && !client && !module && !si && !so && !sce) { @@ -3078,14 +3074,14 @@ static void command_set_volume( if (idx != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); else - sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK); break; case PA_COMMAND_SET_SOURCE_VOLUME: if (idx != PA_INVALID_INDEX) source = pa_idxset_get_by_index(c->protocol->core->sources, idx); else - source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1); + source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE); break; case PA_COMMAND_SET_SINK_INPUT_VOLUME: @@ -3148,7 +3144,7 @@ static void command_set_mute( if (idx != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); else - sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK); break; @@ -3156,7 +3152,7 @@ static void command_set_mute( if (idx != PA_INVALID_INDEX) source = pa_idxset_get_by_index(c->protocol->core->sources, idx); else - source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1); + source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE); break; @@ -3748,143 +3744,6 @@ static void command_unload_module(pa_pdispatch *pd, uint32_t command, uint32_t t pa_pstream_send_simple_ack(c->pstream, tag); } -static void command_add_autoload(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { - pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); - const char *name, *module, *argument; - uint32_t type; - uint32_t idx; - pa_tagstruct *reply; - - pa_native_connection_assert_ref(c); - pa_assert(t); - - if (pa_tagstruct_gets(t, &name) < 0 || - pa_tagstruct_getu32(t, &type) < 0 || - pa_tagstruct_gets(t, &module) < 0 || - pa_tagstruct_gets(t, &argument) < 0 || - !pa_tagstruct_eof(t)) { - protocol_error(c); - return; - } - - CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS); - CHECK_VALIDITY(c->pstream, name && *name && pa_utf8_valid(name), tag, PA_ERR_INVALID); - CHECK_VALIDITY(c->pstream, type == 0 || type == 1, tag, PA_ERR_INVALID); - CHECK_VALIDITY(c->pstream, module && *module && pa_utf8_valid(module), tag, PA_ERR_INVALID); - CHECK_VALIDITY(c->pstream, !argument || pa_utf8_valid(argument), tag, PA_ERR_INVALID); - - if (pa_autoload_add(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE, module, argument, &idx) < 0) { - pa_pstream_send_error(c->pstream, tag, PA_ERR_EXIST); - return; - } - - reply = reply_new(tag); - pa_tagstruct_putu32(reply, idx); - pa_pstream_send_tagstruct(c->pstream, reply); -} - -static void command_remove_autoload(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { - pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); - const char *name = NULL; - uint32_t type, idx = PA_IDXSET_INVALID; - int r; - - pa_native_connection_assert_ref(c); - pa_assert(t); - - if ((pa_tagstruct_getu32(t, &idx) < 0 && - (pa_tagstruct_gets(t, &name) < 0 || - pa_tagstruct_getu32(t, &type) < 0)) || - !pa_tagstruct_eof(t)) { - protocol_error(c); - return; - } - - CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS); - CHECK_VALIDITY(c->pstream, name || idx != PA_IDXSET_INVALID, tag, PA_ERR_INVALID); - CHECK_VALIDITY(c->pstream, !name || (*name && pa_utf8_valid(name) && (type == 0 || type == 1)), tag, PA_ERR_INVALID); - - if (name) - r = pa_autoload_remove_by_name(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE); - else - r = pa_autoload_remove_by_index(c->protocol->core, idx); - - CHECK_VALIDITY(c->pstream, r >= 0, tag, PA_ERR_NOENTITY); - - pa_pstream_send_simple_ack(c->pstream, tag); -} - -static void autoload_fill_tagstruct(pa_tagstruct *t, const pa_autoload_entry *e) { - pa_assert(t && e); - - pa_tagstruct_putu32(t, e->index); - pa_tagstruct_puts(t, e->name); - pa_tagstruct_putu32(t, e->type == PA_NAMEREG_SINK ? 0U : 1U); - pa_tagstruct_puts(t, e->module); - pa_tagstruct_puts(t, e->argument); -} - -static void command_get_autoload_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { - pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); - const pa_autoload_entry *a = NULL; - uint32_t type, idx; - const char *name; - pa_tagstruct *reply; - - pa_native_connection_assert_ref(c); - pa_assert(t); - - if ((pa_tagstruct_getu32(t, &idx) < 0 && - (pa_tagstruct_gets(t, &name) < 0 || - pa_tagstruct_getu32(t, &type) < 0)) || - !pa_tagstruct_eof(t)) { - protocol_error(c); - return; - } - - CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS); - CHECK_VALIDITY(c->pstream, name || idx != PA_IDXSET_INVALID, tag, PA_ERR_INVALID); - CHECK_VALIDITY(c->pstream, !name || (*name && (type == 0 || type == 1) && pa_utf8_valid(name)), tag, PA_ERR_INVALID); - - if (name) - a = pa_autoload_get_by_name(c->protocol->core, name, type == 0 ? PA_NAMEREG_SINK : PA_NAMEREG_SOURCE); - else - a = pa_autoload_get_by_index(c->protocol->core, idx); - - CHECK_VALIDITY(c->pstream, a, tag, PA_ERR_NOENTITY); - - reply = reply_new(tag); - autoload_fill_tagstruct(reply, a); - pa_pstream_send_tagstruct(c->pstream, reply); -} - -static void command_get_autoload_info_list(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { - pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); - pa_tagstruct *reply; - - pa_native_connection_assert_ref(c); - pa_assert(t); - - if (!pa_tagstruct_eof(t)) { - protocol_error(c); - return; - } - - CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS); - - reply = reply_new(tag); - - if (c->protocol->core->autoload_hashmap) { - pa_autoload_entry *a; - void *state = NULL; - - while ((a = pa_hashmap_iterate(c->protocol->core->autoload_hashmap, &state, NULL))) - autoload_fill_tagstruct(reply, a); - } - - pa_pstream_send_tagstruct(c->pstream, reply); -} - static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) { pa_native_connection *c = PA_NATIVE_CONNECTION(userdata); uint32_t idx = PA_INVALID_INDEX, idx_device = PA_INVALID_INDEX; @@ -3918,7 +3777,7 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag if (idx_device != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx_device); else - sink = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SINK); CHECK_VALIDITY(c->pstream, si && sink, tag, PA_ERR_NOENTITY); @@ -3937,7 +3796,7 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag if (idx_device != PA_INVALID_INDEX) source = pa_idxset_get_by_index(c->protocol->core->sources, idx_device); else - source = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SOURCE, 1); + source = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SOURCE); CHECK_VALIDITY(c->pstream, so && source, tag, PA_ERR_NOENTITY); @@ -3989,7 +3848,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa if (idx != PA_INVALID_INDEX) sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx); else - sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK, 1); + sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK); CHECK_VALIDITY(c->pstream, sink, tag, PA_ERR_NOENTITY); @@ -4017,7 +3876,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa if (idx != PA_INVALID_INDEX) source = pa_idxset_get_by_index(c->protocol->core->sources, idx); else - source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE, 1); + source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE); CHECK_VALIDITY(c->pstream, source, tag, PA_ERR_NOENTITY); diff --git a/src/pulsecore/protocol-simple.c b/src/pulsecore/protocol-simple.c index a754669c..dd8002a3 100644 --- a/src/pulsecore/protocol-simple.c +++ b/src/pulsecore/protocol-simple.c @@ -526,7 +526,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp size_t l; pa_sink *sink; - if (!(sink = pa_namereg_get(c->protocol->core, o->default_sink, PA_NAMEREG_SINK, TRUE))) { + if (!(sink = pa_namereg_get(c->protocol->core, o->default_sink, PA_NAMEREG_SINK))) { pa_log("Failed to get sink."); goto fail; } @@ -578,7 +578,7 @@ void pa_simple_protocol_connect(pa_simple_protocol *p, pa_iochannel *io, pa_simp size_t l; pa_source *source; - if (!(source = pa_namereg_get(c->protocol->core, o->default_source, PA_NAMEREG_SOURCE, TRUE))) { + if (!(source = pa_namereg_get(c->protocol->core, o->default_source, PA_NAMEREG_SOURCE))) { pa_log("Failed to get source."); goto fail; } diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index 185350fa..8cdc9286 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -131,7 +131,7 @@ pa_sink_input* pa_sink_input_new( pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver)); if (!data->sink) - data->sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK, TRUE); + data->sink = pa_namereg_get(core, NULL, PA_NAMEREG_SINK); pa_return_null_if_fail(data->sink); pa_return_null_if_fail(pa_sink_get_state(data->sink) != PA_SINK_UNLINKED); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index b1c65d1c..e04acf90 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -112,7 +112,7 @@ pa_source_output* pa_source_output_new( pa_return_null_if_fail(!data->driver || pa_utf8_valid(data->driver)); if (!data->source) - data->source = pa_namereg_get(core, NULL, PA_NAMEREG_SOURCE, TRUE); + data->source = pa_namereg_get(core, NULL, PA_NAMEREG_SOURCE); pa_return_null_if_fail(data->source); pa_return_null_if_fail(pa_source_get_state(data->source) != PA_SOURCE_UNLINKED); -- cgit