* drop redundant pa_core argument from module initialization functions

* make pa__done() implementations optional
* a couple of modernizations
* wrap lt_dlsym() at a single place
* allow passing of an "api" argument to the HAL module, to choose whether OSS devices or ALSA devices should be picked up
* optimize fd closing a little on linux in the forked gconf helper
* save a little memory in the xsmp module


git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1615 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-08-10 14:28:39 +00:00
parent e621071bf1
commit ffa1708070
33 changed files with 532 additions and 444 deletions

View file

@ -29,7 +29,6 @@
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <assert.h>
#include <unistd.h>
#include <limits.h>
@ -43,10 +42,9 @@
#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>
@ -204,10 +202,9 @@ struct userdata {
#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)
@ -224,7 +221,7 @@ int pa__init(pa_core *c, pa_module*m) {
#endif
#endif
assert(c && m);
pa_assert(m);
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
@ -242,22 +239,22 @@ int pa__init(pa_core *c, pa_module*m) {
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)
@ -274,7 +271,7 @@ int pa__init(pa_core *c, pa_module*m) {
/* 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;
}
@ -292,10 +289,10 @@ int pa__init(pa_core *c, pa_module*m) {
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
@ -341,11 +338,10 @@ fail:
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;
@ -366,7 +362,6 @@ void pa__done(pa_core *c, pa_module*m) {
}
#endif
pa_xfree(u->socket_path);
#endif