Add default-monitor-time-sec
[platform/upstream/pulseaudio.git] / src / pulsecore / module.h
1 #ifndef foomodulehfoo
2 #define foomodulehfoo
3
4 /***
5   This file is part of PulseAudio.
6
7   Copyright 2004-2006 Lennart Poettering
8
9   PulseAudio is free software; you can redistribute it and/or modify
10   it under the terms of the GNU Lesser General Public License as published
11   by the Free Software Foundation; either version 2.1 of the License,
12   or (at your option) any later version.
13
14   PulseAudio is distributed in the hope that it will be useful, but
15   WITHOUT ANY WARRANTY; without even the implied warranty of
16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17   General Public License for more details.
18
19   You should have received a copy of the GNU Lesser General Public License
20   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
21 ***/
22
23 #include <inttypes.h>
24 #include <ltdl.h>
25
26 typedef struct pa_module pa_module;
27
28 #include <pulse/proplist.h>
29 #include <pulsecore/dynarray.h>
30
31 #include <pulsecore/core.h>
32
33 enum {
34   PA_MODULE_ERR_UNSPECIFIED = 1,
35   PA_MODULE_ERR_SKIP = 2
36 };
37
38 struct pa_module {
39     pa_core *core;
40     char *name, *argument;
41     uint32_t index;
42
43     lt_dlhandle dl;
44
45     int (*init)(pa_module*m);
46     void (*done)(pa_module*m);
47     int (*get_n_used)(pa_module *m);
48
49     void *userdata;
50
51     bool load_once:1;
52     bool unload_requested:1;
53
54     pa_proplist *proplist;
55     pa_dynarray *hooks;
56 };
57
58 bool pa_module_exists(const char *name);
59
60 int pa_module_load(pa_module** m, pa_core *c, const char *name, const char *argument);
61
62 void pa_module_unload(pa_module *m, bool force);
63 void pa_module_unload_by_index(pa_core *c, uint32_t idx, bool force);
64
65 void pa_module_unload_request(pa_module *m, bool force);
66 void pa_module_unload_request_by_index(pa_core *c, uint32_t idx, bool force);
67
68 void pa_module_unload_all(pa_core *c);
69
70 int pa_module_get_n_used(pa_module*m);
71
72 void pa_module_update_proplist(pa_module *m, pa_update_mode_t mode, pa_proplist *p);
73
74 void pa_module_hook_connect(pa_module *m, pa_hook *hook, pa_hook_priority_t prio, pa_hook_cb_t cb, void *data);
75
76 #define PA_MODULE_AUTHOR(s)                                     \
77     const char *pa__get_author(void) { return s; }              \
78     struct __stupid_useless_struct_to_allow_trailing_semicolon
79
80 #define PA_MODULE_DESCRIPTION(s)                                \
81     const char *pa__get_description(void) { return s; }         \
82     struct __stupid_useless_struct_to_allow_trailing_semicolon
83
84 #define PA_MODULE_USAGE(s)                                      \
85     const char *pa__get_usage(void) { return s; }               \
86     struct __stupid_useless_struct_to_allow_trailing_semicolon
87
88 #define PA_MODULE_VERSION(s)                                    \
89     const char * pa__get_version(void) { return s; }            \
90     struct __stupid_useless_struct_to_allow_trailing_semicolon
91
92 #define PA_MODULE_DEPRECATED(s)                                 \
93     const char * pa__get_deprecated(void) { return s; }         \
94     struct __stupid_useless_struct_to_allow_trailing_semicolon
95
96 #define PA_MODULE_LOAD_ONCE(b)                                  \
97     bool pa__load_once(void) { return b; }                 \
98     struct __stupid_useless_struct_to_allow_trailing_semicolon
99
100 /* Check if we're defining a module (usually defined via compiler flags) */
101 #ifdef PA_MODULE_NAME
102
103 /* Jump through some double-indirection hoops to get PA_MODULE_NAME substituted before the concatenation */
104 #define _MACRO_CONCAT1(a, b) a ## b
105 #define _MACRO_CONCAT(a, b) _MACRO_CONCAT1(a, b)
106
107 #define pa__init _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__init)
108 #define pa__done _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__done)
109 #define pa__get_author _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_author)
110 #define pa__get_description _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_description)
111 #define pa__get_usage _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_usage)
112 #define pa__get_version _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_version)
113 #define pa__get_deprecated _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_deprecated)
114 #define pa__load_once _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__load_once)
115 #define pa__get_n_used _MACRO_CONCAT(PA_MODULE_NAME, _LTX_pa__get_n_used)
116
117 int pa__init(pa_module*m);
118 void pa__done(pa_module*m);
119 int pa__get_n_used(pa_module*m);
120
121 const char* pa__get_author(void);
122 const char* pa__get_description(void);
123 const char* pa__get_usage(void);
124 const char* pa__get_version(void);
125 const char* pa__get_deprecated(void);
126 bool pa__load_once(void);
127 #endif /* PA_MODULE_NAME */
128
129 #endif