Add policy in pulseaudio-system.conf to allow new interface
[platform/upstream/pulseaudio.git] / src / modules / module-combine.c
1 /***
2   This file is part of PulseAudio.
3
4   Copyright 2009 Lennart Poettering
5   Copyright 2011 Colin Guthrie
6
7   PulseAudio is free software; you can redistribute it and/or modify
8   it under the terms of the GNU Lesser General Public License as published
9   by the Free Software Foundation; either version 2.1 of the License,
10   or (at your option) any later version.
11
12   PulseAudio is distributed in the hope that it will be useful, but
13   WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   General Public License for more details.
16
17   You should have received a copy of the GNU Lesser General Public License
18   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
19 ***/
20
21 #ifdef HAVE_CONFIG_H
22 #include <config.h>
23 #endif
24
25 #include <pulse/xmalloc.h>
26
27 #include <pulsecore/module.h>
28 #include <pulsecore/log.h>
29
30 PA_MODULE_AUTHOR("Colin Guthrie");
31 PA_MODULE_DESCRIPTION("Compatibility module (module-combine rename)");
32 PA_MODULE_VERSION(PACKAGE_VERSION);
33 PA_MODULE_LOAD_ONCE(false);
34 PA_MODULE_DEPRECATED("Please use module-combine-sink instead of module-combine!");
35
36 struct userdata {
37     uint32_t module_index;
38 };
39
40 int pa__init(pa_module*m) {
41     struct userdata *u;
42     pa_module *module;
43
44     pa_assert(m);
45     pa_assert_se(m->userdata = u = pa_xnew0(struct userdata, 1));
46
47     pa_log_warn("We will now load module-combine-sink. Please make sure to remove module-combine from your configuration.");
48
49     pa_module_load(&module, m->core, "module-combine-sink", m->argument);
50     u->module_index = module ? module->index : PA_INVALID_INDEX;
51
52     return module ? 0 : -1;
53 }
54
55 void pa__done(pa_module*m) {
56     struct userdata *u;
57
58     pa_assert(m);
59     pa_assert(m->userdata);
60
61     u = m->userdata;
62
63     if (u && PA_INVALID_INDEX != u->module_index)
64         pa_module_unload_by_index(m->core, u->module_index, true);
65
66     pa_xfree(u);
67 }