pulsecore/memchunk.c pulsecore/memchunk.h \
pulsecore/modargs.c pulsecore/modargs.h \
pulsecore/modinfo.c pulsecore/modinfo.h \
+ pulsecore/ltdl-helper.c pulsecore/ltdl-helper.h \
pulsecore/module.c pulsecore/module.h \
pulsecore/namereg.c pulsecore/namereg.h \
pulsecore/pid.c pulsecore/pid.h \
BUILT_SOURCES += $(SYMDEF_FILES)
$(SYMDEF_FILES): modules/module-defs.h.m4
- -mkdir modules
- -mkdir modules/gconf
- -mkdir modules/rtp
+ $(mkdir_p) modules modules/gconf modules/rtp
$(M4) -Dfname="$@" $< > $@
# Simple protocol
#include <config.h>
#endif
-#include <assert.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <fcntl.h>
+#include <dirent.h>
#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
static int fill_buf(struct userdata *u) {
ssize_t r;
- assert(u);
+ pa_assert(u);
if (u->buf_fill >= BUF_MAX) {
pa_log("read buffer overflow");
static int read_byte(struct userdata *u) {
int ret;
- assert(u);
+ pa_assert(u);
if (u->buf_fill < 1)
if (fill_buf(u) < 0)
return -1;
ret = u->buf[0];
- assert(u->buf_fill > 0);
+ pa_assert(u->buf_fill > 0);
u->buf_fill--;
memmove(u->buf, u->buf+1, u->buf_fill);
return ret;
}
static char *read_string(struct userdata *u) {
- assert(u);
+ pa_assert(u);
for (;;) {
char *e;
}
static void unload_one_module(struct userdata *u, struct module_info*m, unsigned i) {
- assert(u);
- assert(m);
- assert(i < m->n_items);
+ pa_assert(u);
+ pa_assert(m);
+ pa_assert(i < m->n_items);
if (m->items[i].index == PA_INVALID_INDEX)
return;
static void unload_all_modules(struct userdata *u, struct module_info*m) {
unsigned i;
- assert(u);
- assert(m);
+ pa_assert(u);
+ pa_assert(m);
for (i = 0; i < m->n_items; i++)
unload_one_module(u, m, i);
pa_module *mod;
- assert(u);
- assert(m);
- assert(name);
- assert(args);
+ pa_assert(u);
+ pa_assert(m);
+ pa_assert(name);
+ pa_assert(args);
if (!is_new) {
if (m->items[i].index != PA_INVALID_INDEX &&
struct module_info *m = p;
struct userdata *u = userdata;
- assert(m);
- assert(u);
+ pa_assert(m);
+ pa_assert(u);
unload_all_modules(u, m);
pa_xfree(m->name);
return pipe_fds[0];
} else {
+#ifdef __linux__
+ DIR* d;
+#endif
int max_fd, i;
-
/* child */
close(pipe_fds[0]);
close(2);
open("/dev/null", O_WRONLY);
- max_fd = 1024;
+#ifdef __linux__
+
+ if ((d = opendir("/proc/self/fd/"))) {
+
+ struct dirent *de;
+
+ while ((de = readdir(d))) {
+ char *e;
+ int fd;
+
+ errno = 0;
+ fd = strtol(de->d_name, &e, 10);
+ pa_assert(errno == 0 && *e == 0);
+ if (fd >= 3)
+ close(fd);
+ }
+
+ closedir(d);
+ } else {
+
+#endif
+
+ max_fd = 1024;
+
#ifdef HAVE_SYS_RESOURCE_H
- {
- struct rlimit r;
- if (getrlimit(RLIMIT_NOFILE, &r) == 0)
- max_fd = r.rlim_max;
+ {
+ struct rlimit r;
+ if (getrlimit(RLIMIT_NOFILE, &r) == 0)
+ max_fd = r.rlim_max;
+ }
+#endif
+
+ for (i = 3; i < max_fd; i++)
+ close(i);
+#
+#ifdef __linux__
}
#endif
- for (i = 3; i < max_fd; i++)
- close(i);
-
#ifdef PR_SET_PDEATHSIG
/* On Linux we can use PR_SET_PDEATHSIG to have the helper
process killed when the daemon dies abnormally. On non-Linux
return -1;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct userdata *u;
int r;
u = pa_xnew(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
u->module_infos = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
if ((u->fd = start_client(PA_GCONF_HELPER, &u->pid)) < 0)
goto fail;
- u->io_event = c->mainloop->io_new(
- c->mainloop,
+ u->io_event = m->core->mainloop->io_new(
+ m->core->mainloop,
u->fd,
PA_IO_EVENT_INPUT,
io_event_cb,
return 0;
fail:
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- assert(c);
- assert(m);
+ pa_assert(m);
if (!(u = m->userdata))
return;
if (u->io_event)
- c->mainloop->io_free(u->io_event);
+ m->core->mainloop->io_free(u->io_event);
if (u->fd >= 0)
close(u->fd);
pa_log_debug("Thread shutting down");
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
int namereg_fail;
int use_mmap = 1, b;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
goto fail;
}
- ss = c->default_sample_spec;
+ ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) {
pa_log("Failed to parse sample specification and channel map");
goto fail;
}
u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
u->use_mmap = use_mmap;
namereg_fail = 0;
}
- u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map);
+ u->sink = pa_sink_new(m->core, __FILE__, name, namereg_fail, &ss, &map);
pa_xfree(name_buf);
if (!u->sink) {
u->mixer_fdl = pa_alsa_fdlist_new();
- if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, c->mainloop) < 0) {
+ if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, m->core->mainloop) < 0) {
pa_log("failed to initialise file descriptor monitoring");
goto fail;
}
fail:
if (u)
- pa__done(c, m);
+ pa__done(m);
goto finish;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
pa_log_debug("Thread shutting down");
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
int namereg_fail;
int use_mmap = 1, b;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
goto fail;
}
- ss = c->default_sample_spec;
+ ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) {
pa_log("Failed to parse sample specification");
goto fail;
}
u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
u->use_mmap = use_mmap;
namereg_fail = 0;
}
- u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map);
+ u->source = pa_source_new(m->core, __FILE__, name, namereg_fail, &ss, &map);
pa_xfree(name_buf);
if (!u->source) {
u->mixer_fdl = pa_alsa_fdlist_new();
- if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, c->mainloop) < 0) {
+ if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, m->core->mainloop) < 0) {
pa_log("failed to initialise file descriptor monitoring");
goto fail;
}
fail:
if (u)
- pa__done(c, m);
+ pa__done(m);
goto finish;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
m->core->mainloop->quit(m->core->mainloop, 0);
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_iochannel *io;
pa_modargs *ma;
int exit_on_eof = 0;
- assert(c);
assert(m);
- if (c->running_as_daemon) {
+ if (m->core->running_as_daemon) {
pa_log_info("Running as daemon, refusing to load this module.");
return 0;
}
goto fail;
}
- io = pa_iochannel_new(c->mainloop, STDIN_FILENO, STDOUT_FILENO);
- assert(io);
+ io = pa_iochannel_new(m->core->mainloop, STDIN_FILENO, STDOUT_FILENO);
pa_iochannel_set_noclose(io, 1);
- m->userdata = pa_cli_new(c, io, m);
- assert(m->userdata);
+ m->userdata = pa_cli_new(m->core, io, m);
pa_cli_set_eof_callback(m->userdata, exit_on_eof ? eof_and_exit_cb : eof_and_unload_cb, m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
- assert(c);
+void pa__done(pa_module*m) {
assert(m);
- if (c->running_as_daemon == 0) {
+ if (m->core->running_as_daemon == 0) {
pa_cli_free(m->userdata);
pa_stdio_release();
}
gen_symbol(pa__get_usage)
gen_symbol(pa__get_version)
-int pa__init(struct pa_core *c, struct pa_module*m);
-void pa__done(struct pa_core *c, struct pa_module*m);
+int pa__init(pa_module*m);
+void pa__done(pa_module*m);
const char* pa__get_author(void);
const char* pa__get_description(void);
PA_MODULE_VERSION(PACKAGE_VERSION)
PA_MODULE_USAGE("just-one=<boolean>")
+static const char* const valid_modargs[] = {
+ "just-one",
+ NULL
+};
+
#ifdef HAVE_ALSA
static int detect_alsa(pa_core *c, int just_one) {
}
#endif
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
int just_one = 0, n = 0;
pa_modargs *ma;
- static const char* const valid_modargs[] = {
- "just-one",
- NULL
- };
-
- assert(c);
- assert(m);
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
}
#if HAVE_ALSA
- if ((n = detect_alsa(c, just_one)) <= 0)
+ if ((n = detect_alsa(m->core, just_one)) <= 0)
#endif
#if HAVE_OSS
- if ((n = detect_oss(c, just_one)) <= 0)
+ if ((n = detect_oss(m->core, just_one)) <= 0)
#endif
#if HAVE_SOLARIS
- if ((n = detect_solaris(c, just_one)) <= 0)
+ if ((n = detect_solaris(m->core, just_one)) <= 0)
#endif
#if OS_IS_WIN32
- if ((n = detect_waveout(c, just_one)) <= 0)
+ if ((n = detect_waveout(m->core, just_one)) <= 0)
#endif
{
pa_log_warn("failed to detect any sound hardware.");
return -1;
}
-
-
-void pa__done(PA_GCC_UNUSED pa_core *c, PA_GCC_UNUSED pa_module*m) {
- /* NOP */
-}
-
#endif
#include <unistd.h>
-#include <assert.h>
#include <string.h>
#include <errno.h>
NULL,
};
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1, fd = -1;
char x = 1;
- assert(c && m);
+
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs)) ||
pa_modargs_get_value_s32(ma, "fd", &fd) < 0 ||
fd < 0) {
+
pa_log("Failed to parse module arguments");
goto finish;
}
if (pa_loop_write(fd, &x, sizeof(x), NULL) != sizeof(x))
- pa_log("WARNING: write(%u, 1, 1) failed: %s", fd, pa_cstrerror(errno));
+ pa_log_warn("WARNING: write(%u, 1, 1) failed: %s", fd, pa_cstrerror(errno));
close(fd);
return ret;
}
-
-void pa__done(pa_core *c, pa_module*m) {
- assert(c && m);
-}
-
-
#endif
#include <unistd.h>
-#include <assert.h>
#include <string.h>
#include <errno.h>
#include <signal.h>
NULL,
};
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
uint32_t pid = 0;
- assert(c && m);
+
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs)) ||
pa_modargs_get_value_u32(ma, "pid", &pid) < 0 ||
}
if (kill(pid, SIGUSR1) < 0)
- pa_log("WARNING: kill(%u) failed: %s", pid, pa_cstrerror(errno));
+ pa_log_warn("WARNING: kill(%u) failed: %s", pid, pa_cstrerror(errno));
pa_module_unload_request(m);
return ret;
}
-
-void pa__done(pa_core *c, pa_module*m) {
- assert(c && m);
-}
-
-
#include <pulsecore/core-util.h>
#include <pulsecore/namereg.h>
#include <pulsecore/core-scache.h>
+#include <pulsecore/modargs.h>
#include <hal/libhal.h>
PA_MODULE_AUTHOR("Shahms King")
PA_MODULE_DESCRIPTION("Detect available audio hardware and load matching drivers")
PA_MODULE_VERSION(PACKAGE_VERSION)
+#if defined(HAVE_ALSA) && defined(HAVE_OSS)
+PA_MODULE_USAGE("api=<alsa or oss>")
+#elif defined(HAVE_ALSA)
+PA_MODULE_USAGE("api=<alsa>")
+#elif defined(HAVE_OSS)
+PA_MODULE_USAGE("api=<oss>")
+#endif
struct device {
uint32_t index;
#define CAPABILITY_ALSA "alsa"
#define CAPABILITY_OSS "oss"
+static const char* const valid_modargs[] = {
+ "api",
+ NULL
+};
+
static void hal_device_free(struct device* d) {
pa_assert(d);
return NULL;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
DBusError error;
pa_dbus_connection *conn;
struct userdata *u = NULL;
LibHalContext *hal_context = NULL;
int n = 0;
+ pa_modargs *ma;
+ const char *api;
- pa_assert(c);
pa_assert(m);
dbus_error_init(&error);
-
- if (!(conn = pa_dbus_bus_get(c, DBUS_BUS_SYSTEM, &error)) || dbus_error_is_set(&error)) {
+
+ if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
+ pa_log("Failed to parse module arguments");
+ goto fail;
+ }
+
+ if ((api = pa_modargs_get_value(ma, "api", NULL))) {
+ int good = 0;
+
+#ifdef HAVE_ALSA
+ if (strcmp(api, CAPABILITY_ALSA) == 0) {
+ good = 1;
+ api = CAPABILITY_ALSA;
+ }
+#endif
+#ifdef HAVE_OSS
+ if (strcmp(api, CAPABILITY_OSS) == 0) {
+ good = 1;
+ api = CAPABILITY_OSS;
+ }
+#endif
+
+ if (!good) {
+ pa_log_error("Invalid API specification.");
+ goto fail;
+ }
+ }
+
+ if (!(conn = pa_dbus_bus_get(m->core, DBUS_BUS_SYSTEM, &error)) || dbus_error_is_set(&error)) {
if (conn)
pa_dbus_connection_unref(conn);
pa_log_error("Unable to contact DBUS system bus: %s: %s", error.name, error.message);
goto fail;
}
- if (!(hal_context = hal_context_new(c, pa_dbus_connection_get(conn)))) {
+ if (!(hal_context = hal_context_new(m->core, pa_dbus_connection_get(conn)))) {
/* pa_hal_context_new() logs appropriate errors */
pa_dbus_connection_unref(conn);
goto fail;
}
u = pa_xnew(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->context = hal_context;
u->connection = conn;
u->devices = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
- u->capability = NULL;
+ u->capability = api;
m->userdata = u;
#ifdef HAVE_ALSA
pa_log_info("Loaded %i modules.", n);
+ pa_modargs_free(ma);
+
return 0;
fail:
+ if (ma)
+ pa_modargs_free(ma);
+
dbus_error_free(&error);
- pa__done(c, m);
+ pa__done(m);
+
return -1;
}
-void pa__done(PA_GCC_UNUSED pa_core *c, pa_module *m) {
+void pa__done(pa_module *m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GCC_UNUSED int fd, pa_io_event_flags_t events, void*userdata) {
struct userdata *u = userdata;
char *name = NULL, *code = NULL;
- assert(io);
- assert(u);
+
+ pa_assert(io);
+ pa_assert(u);
if (events & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) {
- pa_log("lost connection to LIRC daemon.");
+ pa_log("Lost connection to LIRC daemon.");
goto fail;
}
c = pa_xstrdup(code);
c[strcspn(c, "\n\r")] = 0;
- pa_log_debug("raw IR code '%s'", c);
+ pa_log_debug("Raw IR code '%s'", c);
pa_xfree(c);
while (lirc_code2char(u->config, code, &name) == 0 && name) {
MUTE_TOGGLE
} volchange = INVALID;
- pa_log_info("translated IR code '%s'", name);
+ pa_log_info("Translated IR code '%s'", name);
if (strcasecmp(name, "volume-up") == 0)
volchange = UP;
volchange = RESET;
if (volchange == INVALID)
- pa_log_warn("recieved unknown IR code '%s'", name);
+ pa_log_warn("Recieved unknown IR code '%s'", name);
else {
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
- pa_log("failed to get sink '%s'", u->sink_name);
+ pa_log("Failed to get sink '%s'", u->sink_name);
else {
int i;
pa_cvolume cv = *pa_sink_get_volume(s);
pa_module_unload_request(u->module);
- free(code);
+ pa_xfree(code);
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
- assert(c && m);
+
+ pa_assert(m);
if (lirc_in_use) {
pa_log("module-lirc may no be loaded twice.");
goto fail;
}
- m->userdata = u = pa_xmalloc(sizeof(struct userdata));
+ m->userdata = u = pa_xnew(struct userdata, 1);
u->module = m;
u->io = NULL;
u->config = NULL;
goto fail;
}
- u->io = c->mainloop->io_new(c->mainloop, u->lirc_fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
+ u->io = m->core->mainloop->io_new(m->core->mainloop, u->lirc_fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
lirc_in_use = 1;
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- assert(c);
- assert(m);
+ pa_assert(m);
if (!(u = m->userdata))
return;
#endif
#include <unistd.h>
-#include <assert.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
struct rule *end = NULL;
char *fn = NULL;
+ pa_assert(u);
+
f = filename ?
fopen(fn = pa_xstrdup(filename), "r") :
pa_open_config_file(DEFAULT_MATCH_TABLE_FILE, DEFAULT_MATCH_TABLE_FILE_USER, NULL, &fn, "r");
goto finish;
}
- rule = pa_xmalloc(sizeof(struct rule));
+ rule = pa_xnew(struct rule, 1);
rule->regex = regex;
rule->volume = volume;
rule->next = NULL;
struct userdata *u = userdata;
pa_sink_input *si;
struct rule *r;
- assert(c && u);
+
+ pa_assert(c);
+ pa_assert(u);
if (t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW))
return;
}
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
- assert(c && m);
+
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
goto fail;
}
- u = pa_xmalloc(sizeof(struct userdata));
+ u = pa_xnew(struct userdata, 1);
u->rules = NULL;
u->subscription = NULL;
m->userdata = u;
if (load_rules(u, pa_modargs_get_value(ma, "table", NULL)) < 0)
goto fail;
- u->subscription = pa_subscription_new(c, PA_SUBSCRIPTION_MASK_SINK_INPUT, callback, u);
+ u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK_INPUT, callback, u);
pa_modargs_free(ma);
return 0;
fail:
- pa__done(c, m);
+ pa__done(m);
if (ma)
pa_modargs_free(ma);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata* u;
struct rule *r, *n;
- assert(c && m);
+
+ pa_assert(m);
if (!(u = m->userdata))
return;
#endif
#include <stdio.h>
-#include <assert.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
static void io_callback(pa_mainloop_api *io, PA_GCC_UNUSED pa_io_event *e, PA_GCC_UNUSED int fd, pa_io_event_flags_t events, void*userdata) {
struct userdata *u = userdata;
- assert(io);
- assert(u);
+
+ pa_assert(io);
+ pa_assert(u);
if (events & (PA_IO_EVENT_HANGUP|PA_IO_EVENT_ERROR)) {
- pa_log("lost connection to evdev device.");
+ pa_log("Lost connection to evdev device.");
goto fail;
}
struct input_event ev;
if (pa_loop_read(u->fd, &ev, sizeof(ev), &u->fd_type) <= 0) {
- pa_log("failed to read from event device: %s", pa_cstrerror(errno));
+ pa_log("Failed to read from event device: %s", pa_cstrerror(errno));
goto fail;
}
if (ev.type == EV_KEY && (ev.value == 1 || ev.value == 2)) {
enum { INVALID, UP, DOWN, MUTE_TOGGLE } volchange = INVALID;
- pa_log_debug("key code=%u, value=%u", ev.code, ev.value);
+ pa_log_debug("Key code=%u, value=%u", ev.code, ev.value);
switch (ev.code) {
case KEY_VOLUMEDOWN: volchange = DOWN; break;
pa_sink *s;
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK, 1)))
- pa_log("failed to get sink '%s'", u->sink_name);
+ pa_log("Failed to get sink '%s'", u->sink_name);
else {
int i;
pa_cvolume cv = *pa_sink_get_volume(s);
#define test_bit(bit, array) (array[bit/8] & (1<<(bit%8)))
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
+
pa_modargs *ma = NULL;
struct userdata *u;
int version;
struct _input_id input_id;
char name[256];
uint8_t evtype_bitmask[EV_MAX/8 + 1];
- assert(c && m);
+
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
goto fail;
}
- m->userdata = u = pa_xmalloc(sizeof(struct userdata));
+ m->userdata = u = pa_xnew(struct userdata,1);
u->module = m;
u->io = NULL;
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
}
if (!test_bit(EV_KEY, evtype_bitmask)) {
- pa_log("device has no keys.");
+ pa_log("Device has no keys.");
goto fail;
}
- u->io = c->mainloop->io_new(c->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
+ u->io = m->core->mainloop->io_new(m->core->mainloop, u->fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
pa_modargs_free(ma);
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- assert(c);
- assert(m);
+
+ pa_assert(m);
if (!(u = m->userdata))
return;
#endif
#include <stdio.h>
-#include <assert.h>
#include <unistd.h>
#include <pulsecore/module.h>
+#include <pulsecore/macro.h>
#include <pulsecore/iochannel.h>
#include <pulsecore/modargs.h>
#include <pulsecore/protocol-native.h>
NULL,
};
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_iochannel *io;
pa_modargs *ma;
int fd, r = -1;
- assert(c && m);
+
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
- pa_log("failed to parse module arguments.");
+ pa_log("Failed to parse module arguments.");
goto finish;
}
if (pa_modargs_get_value_s32(ma, "fd", &fd) < 0) {
- pa_log("invalid file descriptor.");
+ pa_log("Invalid file descriptor.");
goto finish;
}
- io = pa_iochannel_new(c->mainloop, fd, fd);
+ io = pa_iochannel_new(m->core->mainloop, fd, fd);
- if (!(m->userdata = pa_protocol_native_new_iochannel(c, io, m, ma))) {
+ if (!(m->userdata = pa_protocol_native_new_iochannel(m->core, io, m, ma))) {
pa_iochannel_free(io);
goto finish;
}
return r;
}
-void pa__done(pa_core *c, pa_module*m) {
- assert(c && m);
+void pa__done(pa_module*m) {
+ pa_assert(m);
pa_protocol_native_free(m->userdata);
}
pa_log_debug("Thread shutting down");
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct userdata *u = NULL;
pa_sample_spec ss;
pa_channel_map map;
pa_modargs *ma = NULL;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
goto fail;
}
- ss = c->default_sample_spec;
+ ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
pa_log("Invalid sample format specification or channel map");
goto fail;
}
u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
pa_assert_se(u->asyncmsgq = pa_asyncmsgq_new(0));
- if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
+ if (!(u->sink = pa_sink_new(m->core, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
pa_log("Failed to create sink.");
goto fail;
}
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
pa_log_debug("Thread shutting down");
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct audio_buf_info info;
struct userdata *u = NULL;
const char *name;
int namereg_fail;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
mode = (playback && record) ? O_RDWR : (playback ? O_WRONLY : (record ? O_RDONLY : 0));
- ss = c->default_sample_spec;
+ ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_OSS) < 0) {
pa_log("Failed to parse sample specification or channel map");
goto fail;
pa_assert(frag_size > 0);
u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
u->fd = fd;
namereg_fail = 0;
}
- u->source = pa_source_new(c, __FILE__, name, namereg_fail, &ss, &map);
+ u->source = pa_source_new(m->core, __FILE__, name, namereg_fail, &ss, &map);
pa_xfree(name_buf);
if (!u->source) {
pa_log("Failed to create source object");
namereg_fail = 0;
}
- u->sink = pa_sink_new(c, __FILE__, name, namereg_fail, &ss, &map);
+ u->sink = pa_sink_new(m->core, __FILE__, name, namereg_fail, &ss, &map);
pa_xfree(name_buf);
if (!u->sink) {
pa_log("Failed to create sink object");
fail:
if (u)
- pa__done(c, m);
+ pa__done(m);
else if (fd >= 0)
close(fd);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
pa_log_debug("Thread shutting down");
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct userdata *u;
struct stat st;
pa_sample_spec ss;
pa_modargs *ma;
char *t;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
goto fail;
}
- ss = c->default_sample_spec;
+ ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
pa_log("Invalid sample format specification or channel map");
goto fail;
}
u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
pa_memchunk_reset(&u->memchunk);
goto fail;
}
- if (!(u->sink = pa_sink_new(c, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
+ if (!(u->sink = pa_sink_new(m->core, __FILE__, pa_modargs_get_value(ma, "sink_name", DEFAULT_SINK_NAME), 0, &ss, &map))) {
pa_log("Failed to create sink.");
goto fail;
}
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
pa_log_debug("Thread shutting down");
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct userdata *u;
struct stat st;
pa_sample_spec ss;
pa_modargs *ma;
char *t;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
goto fail;
}
- ss = c->default_sample_spec;
+ ss = m->core->default_sample_spec;
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_DEFAULT) < 0) {
pa_log("invalid sample format specification or channel map");
goto fail;
}
u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
m->userdata = u;
pa_memchunk_reset(&u->memchunk);
goto fail;
}
- if (!(u->source = pa_source_new(c, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) {
+ if (!(u->source = pa_source_new(m->core, __FILE__, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss, &map))) {
pa_log("Failed to create source.");
goto fail;
}
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
#include <string.h>
#include <errno.h>
#include <stdio.h>
-#include <assert.h>
#include <unistd.h>
#include <limits.h>
#include <netinet/in.h>
#endif
-#include "../pulsecore/winsock.h"
-
#include <pulse/xmalloc.h>
+#include <pulsecore/winsock.h>
#include <pulsecore/core-error.h>
#include <pulsecore/module.h>
#include <pulsecore/socket-server.h>
#endif
};
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
int ret = -1;
-
struct userdata *u = NULL;
#if defined(USE_TCP_SOCKETS)
#endif
#endif
- assert(c && m);
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
listen_on = pa_modargs_get_value(ma, "listen", NULL);
if (listen_on) {
- s_ipv6 = pa_socket_server_new_ipv6_string(c->mainloop, listen_on, port, TCPWRAP_SERVICE);
- s_ipv4 = pa_socket_server_new_ipv4_string(c->mainloop, listen_on, port, TCPWRAP_SERVICE);
+ s_ipv6 = pa_socket_server_new_ipv6_string(m->core->mainloop, listen_on, port, TCPWRAP_SERVICE);
+ s_ipv4 = pa_socket_server_new_ipv4_string(m->core->mainloop, listen_on, port, TCPWRAP_SERVICE);
} else {
- s_ipv6 = pa_socket_server_new_ipv6_any(c->mainloop, port, TCPWRAP_SERVICE);
- s_ipv4 = pa_socket_server_new_ipv4_any(c->mainloop, port, TCPWRAP_SERVICE);
+ s_ipv6 = pa_socket_server_new_ipv6_any(m->core->mainloop, port, TCPWRAP_SERVICE);
+ s_ipv4 = pa_socket_server_new_ipv4_any(m->core->mainloop, port, TCPWRAP_SERVICE);
}
if (!s_ipv4 && !s_ipv6)
goto fail;
if (s_ipv4)
- if (!(u->protocol_ipv4 = protocol_new(c, s_ipv4, m, ma)))
+ if (!(u->protocol_ipv4 = protocol_new(m->core, s_ipv4, m, ma)))
pa_socket_server_unref(s_ipv4);
if (s_ipv6)
- if (!(u->protocol_ipv6 = protocol_new(c, s_ipv6, m, ma)))
+ if (!(u->protocol_ipv6 = protocol_new(m->core, s_ipv6, m, ma)))
pa_socket_server_unref(s_ipv6);
if (!u->protocol_ipv4 && !u->protocol_ipv6)
/* This socket doesn't reside in our own runtime dir but in
* /tmp/.esd/, hence we have to create the dir first */
- if (pa_make_secure_parent_dir(u->socket_path, c->is_system_instance ? 0755 : 0700, (uid_t)-1, (gid_t)-1) < 0) {
+ if (pa_make_secure_parent_dir(u->socket_path, m->core->is_system_instance ? 0755 : 0700, (uid_t)-1, (gid_t)-1) < 0) {
pa_log("Failed to create socket directory '%s': %s\n", u->socket_path, pa_cstrerror(errno));
goto fail;
}
if (r)
pa_log("Removed stale UNIX socket '%s'.", tmp);
- if (!(s = pa_socket_server_new_unix(c->mainloop, tmp)))
+ if (!(s = pa_socket_server_new_unix(m->core->mainloop, tmp)))
goto fail;
- if (!(u->protocol_unix = protocol_new(c, s, m, ma)))
+ if (!(u->protocol_unix = protocol_new(m->core, s, m, ma)))
goto fail;
#endif
goto finish;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- assert(c);
- assert(m);
+ pa_assert(m);
u = m->userdata;
}
#endif
-
pa_xfree(u->socket_path);
#endif
return PA_HOOK_OK;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
}
m->userdata = u = pa_xnew(struct userdata, 1);
- u->sink_slot = pa_hook_connect(&c->hook_sink_disconnect, (pa_hook_cb_t) sink_hook_callback, NULL);
- u->source_slot = pa_hook_connect(&c->hook_source_disconnect, (pa_hook_cb_t) source_hook_callback, NULL);
+ u->sink_slot = pa_hook_connect(&m->core->hook_sink_disconnect, (pa_hook_cb_t) sink_hook_callback, NULL);
+ u->source_slot = pa_hook_connect(&m->core->hook_source_disconnect, (pa_hook_cb_t) source_hook_callback, NULL);
pa_modargs_free(ma);
return 0;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!m->userdata)
f[i] = (float) sin((double) i/l*M_PI*2*freq)/2;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
pa_sink *sink;
}
m->userdata = u = pa_xnew0(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->module = m;
u->sink_input = NULL;
u->memblock = NULL;
u->peek_index = 0;
- if (!(sink = pa_namereg_get(c, pa_modargs_get_value(ma, "sink", NULL), PA_NAMEREG_SINK, 1))) {
+ if (!(sink = pa_namereg_get(m->core, pa_modargs_get_value(ma, "sink", NULL), PA_NAMEREG_SINK, 1))) {
pa_log("No such sink.");
goto fail;
}
goto fail;
}
- u->memblock = pa_memblock_new(c->mempool, pa_bytes_per_second(&ss));
+ u->memblock = pa_memblock_new(m->core->mempool, pa_bytes_per_second(&ss));
p = pa_memblock_acquire(u->memblock);
calc_sine(p, pa_memblock_get_length(u->memblock), frequency);
pa_memblock_release(u->memblock);
pa_sink_input_new_data_set_sample_spec(&data, &ss);
data.module = m;
- if (!(u->sink_input = pa_sink_input_new(c, &data, 0)))
+ if (!(u->sink_input = pa_sink_input_new(m->core, &data, 0)))
goto fail;
u->sink_input->peek = sink_input_peek_cb;
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- pa_assert(c);
pa_assert(m);
if (!(u = m->userdata))
return PA_HOOK_OK;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
uint32_t timeout = 5;
pa_sink *sink;
pa_source *source;
- assert(c);
- assert(m);
+ pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments.");
}
m->userdata = u = pa_xnew(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->timeout = timeout;
u->device_infos = pa_hashmap_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func);
- for (sink = pa_idxset_first(c->sinks, &idx); sink; sink = pa_idxset_next(c->sinks, &idx))
- device_new_hook_cb(c, PA_OBJECT(sink), u);
+ for (sink = pa_idxset_first(m->core->sinks, &idx); sink; sink = pa_idxset_next(m->core->sinks, &idx))
+ device_new_hook_cb(m->core, PA_OBJECT(sink), u);
- for (source = pa_idxset_first(c->sources, &idx); source; source = pa_idxset_next(c->sources, &idx))
- device_new_hook_cb(c, PA_OBJECT(source), u);
+ for (source = pa_idxset_first(m->core->sources, &idx); source; source = pa_idxset_next(m->core->sources, &idx))
+ device_new_hook_cb(m->core, PA_OBJECT(source), u);
- u->sink_new_slot = pa_hook_connect(&c->hook_sink_new_post, (pa_hook_cb_t) device_new_hook_cb, u);
- u->source_new_slot = pa_hook_connect(&c->hook_source_new_post, (pa_hook_cb_t) device_new_hook_cb, u);
- u->sink_disconnect_slot = pa_hook_connect(&c->hook_sink_disconnect_post, (pa_hook_cb_t) device_disconnect_hook_cb, u);
- u->source_disconnect_slot = pa_hook_connect(&c->hook_source_disconnect_post, (pa_hook_cb_t) device_disconnect_hook_cb, u);
+ u->sink_new_slot = pa_hook_connect(&m->core->hook_sink_new_post, (pa_hook_cb_t) device_new_hook_cb, u);
+ u->source_new_slot = pa_hook_connect(&m->core->hook_source_new_post, (pa_hook_cb_t) device_new_hook_cb, u);
+ u->sink_disconnect_slot = pa_hook_connect(&m->core->hook_sink_disconnect_post, (pa_hook_cb_t) device_disconnect_hook_cb, u);
+ u->source_disconnect_slot = pa_hook_connect(&m->core->hook_source_disconnect_post, (pa_hook_cb_t) device_disconnect_hook_cb, u);
- u->sink_input_new_slot = pa_hook_connect(&c->hook_sink_input_new_post, (pa_hook_cb_t) sink_input_new_hook_cb, u);
- u->source_output_new_slot = pa_hook_connect(&c->hook_source_output_new_post, (pa_hook_cb_t) source_output_new_hook_cb, u);
- u->sink_input_disconnect_slot = pa_hook_connect(&c->hook_sink_input_disconnect_post, (pa_hook_cb_t) sink_input_disconnect_hook_cb, u);
- u->source_output_disconnect_slot = pa_hook_connect(&c->hook_source_output_disconnect_post, (pa_hook_cb_t) source_output_disconnect_hook_cb, u);
+ u->sink_input_new_slot = pa_hook_connect(&m->core->hook_sink_input_new_post, (pa_hook_cb_t) sink_input_new_hook_cb, u);
+ u->source_output_new_slot = pa_hook_connect(&m->core->hook_source_output_new_post, (pa_hook_cb_t) source_output_new_hook_cb, u);
+ u->sink_input_disconnect_slot = pa_hook_connect(&m->core->hook_sink_input_disconnect_post, (pa_hook_cb_t) sink_input_disconnect_hook_cb, u);
+ u->source_output_disconnect_slot = pa_hook_connect(&m->core->hook_source_output_disconnect_post, (pa_hook_cb_t) source_output_disconnect_hook_cb, u);
pa_modargs_free(ma);
return 0;
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
struct device_info *d;
- assert(c);
- assert(m);
+ pa_assert(m);
if (!m->userdata)
return;
return PA_HOOK_OK;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
- assert(c);
assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
if (load_rules(u) < 0)
goto fail;
- u->subscription = pa_subscription_new(c, PA_SUBSCRIPTION_MASK_SINK_INPUT|PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, subscribe_callback, u);
- u->sink_input_hook_slot = pa_hook_connect(&c->hook_sink_input_new, (pa_hook_cb_t) sink_input_hook_callback, u);
- u->source_output_hook_slot = pa_hook_connect(&c->hook_source_output_new, (pa_hook_cb_t) source_output_hook_callback, u);
+ u->subscription = pa_subscription_new(m->core, PA_SUBSCRIPTION_MASK_SINK_INPUT|PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, subscribe_callback, u);
+ u->sink_input_hook_slot = pa_hook_connect(&m->core->hook_sink_input_new, (pa_hook_cb_t) sink_input_hook_callback, u);
+ u->source_output_hook_slot = pa_hook_connect(&m->core->hook_source_output_new, (pa_hook_cb_t) source_output_hook_callback, u);
pa_modargs_free(ma);
return 0;
fail:
- pa__done(c, m);
-
+ pa__done(m);
if (ma)
pa_modargs_free(ma);
pa_xfree(r);
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata* u;
- assert(c);
assert(m);
if (!(u = m->userdata))
return 1;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct userdata *u = NULL;
pa_modargs *ma = NULL;
int major, minor;
unsigned int auto_ctrls, auto_values;
- pa_assert(c);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
}
m->userdata = u = pa_xnew(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->scache_item = pa_xstrdup(pa_modargs_get_value(ma, "sample", "x11-bell"));
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
u->x11_client = NULL;
- if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
+ if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;
major = XkbMajorVersion;
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata *u;
- assert(c);
- assert(m);
+ pa_assert(m);
if (!m->userdata)
return;
#endif
#include <stdio.h>
-#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
};
static int load_key(struct userdata *u, const char*fn) {
- assert(u);
+ pa_assert(u);
u->auth_cookie_in_property = 0;
if (pa_authkey_load_auto(fn, u->auth_cookie, sizeof(u->auth_cookie)) < 0)
return -1;
- pa_log_debug("loading cookie from disk.");
+ pa_log_debug("Loading cookie from disk.");
if (pa_authkey_prop_put(u->core, PA_NATIVE_COOKIE_PROPERTY_NAME, u->auth_cookie, sizeof(u->auth_cookie)) >= 0)
u->auth_cookie_in_property = 1;
return 0;
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
struct userdata *u;
pa_modargs *ma = NULL;
char hn[256], un[128];
char *s;
pa_strlist *l;
+ pa_assert(m);
+
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("failed to parse module arguments");
goto fail;
}
m->userdata = u = pa_xmalloc(sizeof(struct userdata));
- u->core = c;
+ u->core = m->core;
u->id = NULL;
u->auth_cookie_in_property = 0;
if (load_key(u, pa_modargs_get_value(ma, "cookie", NULL)) < 0)
goto fail;
- if (!(u->x11_wrapper = pa_x11_wrapper_get(c, pa_modargs_get_value(ma, "display", NULL))))
+ if (!(u->x11_wrapper = pa_x11_wrapper_get(m->core, pa_modargs_get_value(ma, "display", NULL))))
goto fail;
- if (!(l = pa_property_get(c, PA_NATIVE_SERVER_PROPERTY_NAME)))
+ if (!(l = pa_property_get(m->core, PA_NATIVE_SERVER_PROPERTY_NAME)))
goto fail;
s = pa_strlist_tostring(l);
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata*u;
- assert(c && m);
+
+ pa_assert(m);
if (!(u = m->userdata))
return;
pa_x11_wrapper_unref(u->x11_wrapper);
if (u->auth_cookie_in_property)
- pa_authkey_prop_unref(c, PA_NATIVE_COOKIE_PROPERTY_NAME);
+ pa_authkey_prop_unref(m->core, PA_NATIVE_COOKIE_PROPERTY_NAME);
pa_xfree(u->id);
pa_xfree(u);
PA_MODULE_DESCRIPTION("X11 session management")
PA_MODULE_VERSION(PACKAGE_VERSION)
-struct userdata {
- pa_core *core;
- SmcConn sm_conn;
-};
+static int ice_in_use = 0;
static const char* const valid_modargs[] = {
NULL
};
static void die_cb(SmcConn connection, SmPointer client_data){
- pa_core *c = client_data;
+ pa_core *c = PA_CORE(client_data);
pa_log_debug("Got die message from XSM. Exiting...");
c->mainloop->io_free(*watch_data);
}
-int pa__init(pa_core *c, pa_module*m) {
- struct userdata *u = NULL;
+int pa__init(pa_module*m) {
+
pa_modargs *ma = NULL;
char t[256], *vendor, *client_id;
SmcCallbacks callbacks;
SmProp prop_program, prop_user;
SmProp *prop_list[2];
SmPropValue val_program, val_user;
+ SmcConn connection;
- pa_assert(c);
pa_assert(m);
+ if (ice_in_use) {
+ pa_log("module-x11-xsmp may no be loaded twice.");
+ return -1;
+ }
+
+ IceAddConnectionWatch(new_ice_connection, m->core);
+ ice_in_use = 1;
+
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
goto fail;
pa_log("X11 session manager not running.");
goto fail;
}
-
- m->userdata = u = pa_xnew(struct userdata, 1);
- u->core = c;
- u->sm_conn = NULL;
-
- IceAddConnectionWatch(new_ice_connection, c);
memset(&callbacks, 0, sizeof(callbacks));
callbacks.die.callback = die_cb;
- callbacks.die.client_data = c;
-
+ callbacks.die.client_data = m->core;
callbacks.save_yourself.callback = save_yourself_cb;
+ callbacks.save_yourself.client_data = m->core;
callbacks.save_complete.callback = save_complete_cb;
+ callbacks.save_complete.client_data = m->core;
callbacks.shutdown_cancelled.callback = shutdown_cancelled_cb;
+ callbacks.shutdown_cancelled.client_data = m->core;
- if (!(u->sm_conn = SmcOpenConnection(
- NULL, u,
+ if (!(m->userdata = connection = SmcOpenConnection(
+ NULL, m->core,
SmProtoMajor, SmProtoMinor,
SmcSaveYourselfProcMask | SmcDieProcMask | SmcSaveCompleteProcMask | SmcShutdownCancelledProcMask,
&callbacks, NULL, &client_id,
prop_user.vals = &val_user;
prop_list[1] = &prop_user;
- SmcSetProperties(u->sm_conn, PA_ELEMENTSOF(prop_list), prop_list);
+ SmcSetProperties(connection, PA_ELEMENTSOF(prop_list), prop_list);
- pa_log_info("Connected to session manager '%s' as '%s'.", vendor = SmcVendor(u->sm_conn), client_id);
+ pa_log_info("Connected to session manager '%s' as '%s'.", vendor = SmcVendor(connection), client_id);
free(vendor);
free(client_id);
if (ma)
pa_modargs_free(ma);
- pa__done(c, m);
+ pa__done(m);
return -1;
}
-void pa__done(pa_core *c, pa_module*m) {
- struct userdata *u;
-
- assert(c);
- assert(m);
-
- if (!m->userdata)
- return;
-
- u = m->userdata;
+void pa__done(pa_module*m) {
+ pa_assert(m);
- if (u->sm_conn)
- SmcCloseConnection(u->sm_conn, 0, NULL);
+ if (m->userdata)
+ SmcCloseConnection(m->userdata, 0, NULL);
- IceRemoveConnectionWatch(new_ice_connection, c);
-
- pa_xfree(u);
+ if (ice_in_use) {
+ IceRemoveConnectionWatch(new_ice_connection, m->core);
+ ice_in_use = 0;
+ }
}
};
static void get_service_data(struct userdata *u, struct service *s, pa_sample_spec *ret_ss, char **ret_description) {
- assert(u && s && s->loaded.valid && ret_ss && ret_description);
+ pa_assert(u && s && s->loaded.valid && ret_ss && ret_description);
if (s->loaded.type == PA_NAMEREG_SINK) {
pa_sink *sink = pa_idxset_get_by_index(u->core->sinks, s->loaded.index);
- assert(sink);
+ pa_assert(sink);
*ret_ss = sink->sample_spec;
*ret_description = sink->description;
} else if (s->loaded.type == PA_NAMEREG_SOURCE) {
pa_source *source = pa_idxset_get_by_index(u->core->sources, s->loaded.index);
- assert(source);
+ pa_assert(source);
*ret_ss = source->sample_spec;
*ret_description = source->description;
} else
- assert(0);
+ pa_assert(0);
}
static AvahiStringList* txt_record_server_data(pa_core *c, AvahiStringList *l) {
char s[128];
- assert(c);
+ pa_assert(c);
l = avahi_string_list_add_pair(l, "server-version", PACKAGE_NAME" "PACKAGE_VERSION);
l = avahi_string_list_add_pair(l, "user-name", pa_get_user_name(s, sizeof(s)));
int r = -1;
AvahiStringList *txt = NULL;
- assert(u);
- assert(s);
+ pa_assert(u);
+ pa_assert(s);
if (!u->client || avahi_client_get_state(u->client) != AVAHI_CLIENT_S_RUNNING)
return 0;
static int publish_sink(struct userdata *u, pa_sink *s) {
struct service *svc;
int ret;
- assert(u && s);
+ pa_assert(u && s);
svc = get_service(u, s->name, s->description);
if (svc->loaded.valid)
struct service *svc;
int ret;
- assert(u && s);
+ pa_assert(u && s);
svc = get_service(u, s->name, s->description);
if (svc->loaded.valid)
struct service *svc;
int ret;
- assert(u && s);
+ pa_assert(u && s);
svc = get_service(u, s->name, NULL);
if (svc->autoload.valid)
static int remove_sink(struct userdata *u, uint32_t idx) {
struct service *svc;
- assert(u && idx != PA_INVALID_INDEX);
+ pa_assert(u && idx != PA_INVALID_INDEX);
if (!(svc = pa_dynarray_get(u->sink_dynarray, idx)))
return 0;
static int remove_source(struct userdata *u, uint32_t idx) {
struct service *svc;
- assert(u && idx != PA_INVALID_INDEX);
+ pa_assert(u && idx != PA_INVALID_INDEX);
if (!(svc = pa_dynarray_get(u->source_dynarray, idx)))
return 0;
static int remove_autoload(struct userdata *u, uint32_t idx) {
struct service *svc;
- assert(u && idx != PA_INVALID_INDEX);
+ pa_assert(u && idx != PA_INVALID_INDEX);
if (!(svc = pa_dynarray_get(u->autoload_dynarray, idx)))
return 0;
static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
struct userdata *u = userdata;
- assert(u && c);
+ pa_assert(u && c);
switch (t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK)
case PA_SUBSCRIPTION_EVENT_SINK: {
static void main_entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, void *userdata) {
struct userdata *u = userdata;
- assert(u);
+ pa_assert(u);
if (state == AVAHI_ENTRY_GROUP_COLLISION) {
char *t;
int r = -1;
uint32_t idx;
- assert(u);
+ pa_assert(u);
pa_log_debug("Publishing services in Zeroconf");
void *state = NULL;
struct service *s;
- assert(u);
+ pa_assert(u);
pa_log_debug("Unpublishing services in Zeroconf");
static void client_callback(AvahiClient *c, AvahiClientState state, void *userdata) {
struct userdata *u = userdata;
- assert(c);
+ pa_assert(c);
u->client = c;
}
}
-int pa__init(pa_core *c, pa_module*m) {
+int pa__init(pa_module*m) {
+
struct userdata *u;
uint32_t port = PA_NATIVE_DEFAULT_PORT;
pa_modargs *ma = NULL;
goto fail;
}
- if (pa_modargs_get_value_u32(ma, "port", &port) < 0 || port == 0 || port >= 0xFFFF) {
+ if (pa_modargs_get_value_u32(ma, "port", &port) < 0 || port <= 0 || port > 0xFFFF) {
pa_log("invalid port specified.");
goto fail;
}
m->userdata = u = pa_xnew(struct userdata, 1);
- u->core = c;
+ u->core = m->core;
u->port = (uint16_t) port;
- u->avahi_poll = pa_avahi_poll_new(c->mainloop);
+ u->avahi_poll = pa_avahi_poll_new(m->core->mainloop);
u->services = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
u->sink_dynarray = pa_dynarray_new();
u->source_dynarray = pa_dynarray_new();
u->autoload_dynarray = pa_dynarray_new();
- u->subscription = pa_subscription_new(c,
+ u->subscription = pa_subscription_new(m->core,
PA_SUBSCRIPTION_MASK_SINK|
PA_SUBSCRIPTION_MASK_SOURCE|
PA_SUBSCRIPTION_MASK_AUTOLOAD, subscribe_callback, u);
return 0;
fail:
- pa__done(c, m);
+ pa__done(m);
if (ma)
pa_modargs_free(ma);
struct service *s = p;
struct userdata *u = userdata;
- assert(s);
- assert(u);
+ pa_assert(s);
+ pa_assert(u);
if (s->entry_group)
avahi_entry_group_free(s->entry_group);
pa_xfree(s);
}
-void pa__done(pa_core *c, pa_module*m) {
+void pa__done(pa_module*m) {
struct userdata*u;
- assert(c && m);
+ pa_assert(m);
if (!(u = m->userdata))
return;
--- /dev/null
+/* $Id$ */
+
+/***
+ This file is part of PulseAudio.
+
+ Copyright 2004-2006 Lennart Poettering
+ Copyright 2006 Pierre Ossman <ossman@cendio.se> 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 <config.h>
+#endif
+
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <pulse/xmalloc.h>
+#include <pulse/util.h>
+
+#include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
+
+#include "ltdl-helper.h"
+
+pa_void_func_t pa_load_sym(lt_dlhandle handle, const char *module, const char *symbol) {
+ char *sn, *c;
+ pa_void_func_t f;
+
+ pa_assert(handle);
+ pa_assert(module);
+ pa_assert(symbol);
+
+ if ((f = ((pa_void_func_t) (long) lt_dlsym(handle, symbol))))
+ return f;
+
+ /* As the .la files might have been cleansed from the system, we should
+ * try with the ltdl prefix as well. */
+
+ sn = pa_sprintf_malloc("%s_LTX_%s", module, symbol);
+
+ for (c = sn; *c; c++)
+ if (!isalnum(*c))
+ *c = '_';
+
+ f = (pa_void_func_t) (long) lt_dlsym(handle, sn);
+ pa_xfree(sn);
+
+ return f;
+}
--- /dev/null
+#ifndef foopulsecoreltdlhelperhfoo
+#define foopulsecoreltdlhelperhfoo
+
+/* $Id$ */
+
+/***
+ 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 <ltdl.h>
+
+typedef void (*pa_void_func_t)(void);
+
+pa_void_func_t pa_load_sym(lt_dlhandle handle, const char*module, const char *symbol);
+
+#endif
+
#endif
#include <ltdl.h>
-#include <assert.h>
#include <pulse/xmalloc.h>
#include <pulsecore/core-util.h>
#include <pulsecore/log.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/ltdl-helper.h>
#include "modinfo.h"
#define PA_SYMBOL_USAGE "pa__get_usage"
#define PA_SYMBOL_VERSION "pa__get_version"
-/* lt_dlsym() violates ISO C, so confide the breakage into this function to
- * avoid warnings. */
-typedef void (*fnptr)(void);
-static inline fnptr lt_dlsym_fn(lt_dlhandle handle, const char *symbol) {
- return (fnptr) (long) lt_dlsym(handle, symbol);
-}
-
-pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl) {
+pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl, const char *module_name) {
pa_modinfo *i;
const char* (*func)(void);
- assert(dl);
+
+ pa_assert(dl);
i = pa_xnew0(pa_modinfo, 1);
- if ((func = (const char* (*)(void)) lt_dlsym_fn(dl, PA_SYMBOL_AUTHOR)))
+ if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_AUTHOR)))
i->author = pa_xstrdup(func());
- if ((func = (const char* (*)(void)) lt_dlsym_fn(dl, PA_SYMBOL_DESCRIPTION)))
+ if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_DESCRIPTION)))
i->description = pa_xstrdup(func());
- if ((func = (const char* (*)(void)) lt_dlsym_fn(dl, PA_SYMBOL_USAGE)))
+ if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_USAGE)))
i->usage = pa_xstrdup(func());
- if ((func = (const char* (*)(void)) lt_dlsym_fn(dl, PA_SYMBOL_VERSION)))
+ if ((func = (const char* (*)(void)) pa_load_sym(dl, module_name, PA_SYMBOL_VERSION)))
i->version = pa_xstrdup(func());
return i;
pa_modinfo *pa_modinfo_get_by_name(const char *name) {
lt_dlhandle dl;
pa_modinfo *i;
- assert(name);
+
+ pa_assert(name);
if (!(dl = lt_dlopenext(name))) {
pa_log("Failed to open module \"%s\": %s", name, lt_dlerror());
return NULL;
}
- i = pa_modinfo_get_by_handle(dl);
+ i = pa_modinfo_get_by_handle(dl, name);
lt_dlclose(dl);
return i;
void pa_modinfo_free(pa_modinfo *i) {
assert(i);
+
pa_xfree(i->author);
pa_xfree(i->description);
pa_xfree(i->usage);
} pa_modinfo;
/* Read meta data from an libtool handle */
-pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl);
+pa_modinfo *pa_modinfo_get_by_handle(lt_dlhandle dl, const char *module_name);
/* Read meta data from a module file */
pa_modinfo *pa_modinfo_get_by_name(const char *name);
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
-#include <assert.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <pulsecore/core-subscribe.h>
#include <pulsecore/log.h>
#include <pulsecore/core-util.h>
+#include <pulsecore/macro.h>
+#include <pulsecore/ltdl-helper.h>
#include "module.h"
#define UNLOAD_POLL_TIME 2
-/* lt_dlsym() violates ISO C, so confide the breakage into this function to
- * avoid warnings. */
-typedef void (*fnptr)(void);
-static inline fnptr lt_dlsym_fn(lt_dlhandle handle, const char *symbol) {
- return (fnptr) (long) lt_dlsym(handle, symbol);
-}
-
static void timeout_callback(pa_mainloop_api *m, pa_time_event*e, PA_GCC_UNUSED const struct timeval *tv, void *userdata) {
- pa_core *c = userdata;
+ pa_core *c = PA_CORE(userdata);
struct timeval ntv;
- assert(c && c->mainloop == m && c->module_auto_unload_event == e);
+
+ 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);
- ntv.tv_sec += UNLOAD_POLL_TIME;
+ pa_timeval_add(&ntv, UNLOAD_POLL_TIME*1000000);
m->time_restart(e, &ntv);
}
-static inline fnptr load_sym(lt_dlhandle handle, const char *module, const char *symbol) {
- char *buffer, *ch;
- size_t buflen;
- fnptr res;
-
- res = lt_dlsym_fn(handle, symbol);
- if (res)
- return res;
-
- /* As the .la files might have been cleansed from the system, we should
- * try with the ltdl prefix as well. */
-
- buflen = strlen(symbol) + strlen(module) + strlen("_LTX_") + 1;
- buffer = pa_xmalloc(buflen);
- assert(buffer);
-
- strcpy(buffer, module);
-
- for (ch = buffer;*ch != '\0';ch++) {
- if (!isalnum(*ch))
- *ch = '_';
- }
-
- strcat(buffer, "_LTX_");
- strcat(buffer, symbol);
-
- res = lt_dlsym_fn(handle, buffer);
-
- pa_xfree(buffer);
-
- return res;
-}
-
pa_module* pa_module_load(pa_core *c, const char *name, const char *argument) {
pa_module *m = NULL;
- int r;
- assert(c && name);
+ pa_assert(c);
+ pa_assert(name);
if (c->disallow_module_loading)
goto fail;
- m = pa_xmalloc(sizeof(pa_module));
-
+ m = pa_xnew(pa_module, 1);
m->name = pa_xstrdup(name);
m->argument = pa_xstrdup(argument);
goto fail;
}
- if (!(m->init = (int (*)(pa_core *_c, pa_module*_m)) load_sym(m->dl, name, PA_SYMBOL_INIT))) {
+ if (!(m->init = (int (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_INIT))) {
pa_log("Failed to load module \"%s\": symbol \""PA_SYMBOL_INIT"\" not found.", name);
goto fail;
}
- if (!(m->done = (void (*)(pa_core *_c, pa_module*_m)) load_sym(m->dl, name, PA_SYMBOL_DONE))) {
- pa_log("Failed to load module \"%s\": symbol \""PA_SYMBOL_DONE"\" not found.", name);
- goto fail;
- }
-
+ m->done = (void (*)(pa_module*_m)) pa_load_sym(m->dl, name, PA_SYMBOL_DONE);
m->userdata = NULL;
m->core = c;
m->n_used = -1;
m->auto_unload = 0;
m->unload_requested = 0;
- assert(m->init);
- if (m->init(c, m) < 0) {
+ if (m->init(m) < 0) {
pa_log_error("Failed to load module \"%s\" (argument: \"%s\"): initialization failed.", name, argument ? argument : "");
goto fail;
}
if (!c->module_auto_unload_event) {
struct timeval ntv;
pa_gettimeofday(&ntv);
- ntv.tv_sec += UNLOAD_POLL_TIME;
+ pa_timeval_add(&ntv, UNLOAD_POLL_TIME*1000000);
c->module_auto_unload_event = c->mainloop->time_new(c->mainloop, &ntv, timeout_callback, c);
}
- assert(c->module_auto_unload_event);
- assert(c->modules);
- r = pa_idxset_put(c->modules, m, &m->index);
- assert(r >= 0 && m->index != PA_IDXSET_INVALID);
+ pa_assert_se(pa_idxset_put(c->modules, m, &m->index) >= 0);
+ pa_assert(m->index != PA_IDXSET_INVALID);
pa_log_info("Loaded \"%s\" (index: #%u; argument: \"%s\").", m->name, m->index, m->argument ? m->argument : "");
}
static void pa_module_free(pa_module *m) {
- assert(m && m->done && m->core);
+ pa_assert(m);
+ pa_assert(m->core);
if (m->core->disallow_module_loading)
return;
pa_log_info("Unloading \"%s\" (index: #%u).", m->name, m->index);
- m->done(m->core, m);
+ if (m->done)
+ m->done(m);
lt_dlclose(m->dl);
}
void pa_module_unload(pa_core *c, pa_module *m) {
- assert(c && m);
+ pa_assert(c && m);
- assert(c->modules);
+ pa_assert(c->modules);
if (!(m = pa_idxset_remove_by_data(c->modules, m, NULL)))
return;
void pa_module_unload_by_index(pa_core *c, uint32_t idx) {
pa_module *m;
- assert(c && idx != PA_IDXSET_INVALID);
+ pa_assert(c);
+ pa_assert(idx != PA_IDXSET_INVALID);
- assert(c->modules);
if (!(m = pa_idxset_remove_by_index(c->modules, idx)))
return;
static void free_callback(void *p, PA_GCC_UNUSED void *userdata) {
pa_module *m = p;
- assert(m);
+ pa_assert(m);
pa_module_free(m);
}
void pa_module_unload_all(pa_core *c) {
pa_module *m;
- assert(c);
+
+ pa_assert(c);
if (!c->modules)
return;
static int unused_callback(void *p, PA_GCC_UNUSED uint32_t idx, int *del, void *userdata) {
pa_module *m = p;
time_t *now = userdata;
- assert(p && del && now);
+
+ pa_assert(m);
+ pa_assert(del);
+ pa_assert(now);
if (m->n_used == 0 && m->auto_unload && m->last_used_time+m->core->module_idle_time <= *now) {
pa_module_free(m);
void pa_module_unload_unused(pa_core *c) {
time_t now;
- assert(c);
+ pa_assert(c);
if (!c->modules)
return;
static int unload_callback(void *p, PA_GCC_UNUSED uint32_t idx, int *del, PA_GCC_UNUSED void *userdata) {
pa_module *m = p;
- assert(m);
+ pa_assert(m);
if (m->unload_requested) {
pa_module_free(m);
}
static void defer_cb(pa_mainloop_api*api, pa_defer_event *e, void *userdata) {
- pa_core *core = userdata;
+ pa_core *core = PA_CORE(userdata);
+
+ pa_core_assert_ref(core);
api->defer_enable(e, 0);
if (!core->modules)
return;
pa_idxset_foreach(core->modules, unload_callback, NULL);
-
}
void pa_module_unload_request(pa_module *m) {
- assert(m);
+ pa_assert(m);
m->unload_requested = 1;
}
void pa_module_set_used(pa_module*m, int used) {
- assert(m);
+ pa_assert(m);
if (m->n_used != used)
pa_subscription_post(m->core, PA_SUBSCRIPTION_EVENT_MODULE|PA_SUBSCRIPTION_EVENT_CHANGE, m->index);
- if (m->n_used != used && used == 0)
+ if (used == 0 && m->n_used > 0)
time(&m->last_used_time);
m->n_used = used;
}
pa_modinfo *pa_module_get_info(pa_module *m) {
- assert(m);
+ pa_assert(m);
- return pa_modinfo_get_by_handle(m->dl);
+ return pa_modinfo_get_by_handle(m->dl, m->name);
}
lt_dlhandle dl;
- int (*init)(pa_core *c, pa_module*m);
- void (*done)(pa_core *c, pa_module*m);
+ int (*init)(pa_module*m);
+ void (*done)(pa_module*m);
void *userdata;
void pa_module_set_used(pa_module*m, int used);
-#define PA_MODULE_AUTHOR(s) const char * pa__get_author(void) { return s; }
-#define PA_MODULE_DESCRIPTION(s) const char * pa__get_description(void) { return s; }
-#define PA_MODULE_USAGE(s) const char * pa__get_usage(void) { return s; }
+#define PA_MODULE_AUTHOR(s) const char *pa__get_author(void) { return s; }
+#define PA_MODULE_DESCRIPTION(s) const char *pa__get_description(void) { return s; }
+#define PA_MODULE_USAGE(s) const char *pa__get_usage(void) { return s; }
#define PA_MODULE_VERSION(s) const char * pa__get_version(void) { return s; }
pa_modinfo *pa_module_get_info(pa_module *m);