summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-07-11 22:20:08 +0000
committerLennart Poettering <lennart@poettering.net>2004-07-11 22:20:08 +0000
commit216591d95e00a0cb771088dad9a752efead55e10 (patch)
tree5758e5a203f2db6cda624efbbd644feefa048704 /src
parenta96ed347a30fdc7494b96542c0ad8a19ef178b25 (diff)
make the protocol plugins make use of modargs
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@62 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src')
-rw-r--r--src/authkey.c11
-rw-r--r--src/authkey.h1
-rw-r--r--src/modargs.c37
-rw-r--r--src/modargs.h3
-rw-r--r--src/module-cli.c7
-rw-r--r--src/module-protocol-stub.c96
-rw-r--r--src/protocol-cli.c2
-rw-r--r--src/protocol-cli.h3
-rw-r--r--src/protocol-esound.c21
-rw-r--r--src/protocol-esound.h3
-rw-r--r--src/protocol-native.c14
-rw-r--r--src/protocol-native.h3
-rw-r--r--src/protocol-simple.c94
-rw-r--r--src/protocol-simple.h9
-rw-r--r--src/socket-util.c39
-rw-r--r--src/socket-util.h3
-rw-r--r--src/todo4
17 files changed, 273 insertions, 77 deletions
diff --git a/src/authkey.c b/src/authkey.c
index cd284fb5..7bf45165 100644
--- a/src/authkey.c
+++ b/src/authkey.c
@@ -106,6 +106,8 @@ int pa_authkey_load_from_home(const char *fn, void *data, size_t length) {
char *home;
char path[PATH_MAX];
+ assert(fn && data && length);
+
if (!(home = getenv("HOME")))
return -2;
@@ -113,3 +115,12 @@ int pa_authkey_load_from_home(const char *fn, void *data, size_t length) {
return pa_authkey_load(path, data, length);
}
+
+int pa_authkey_load_auto(const char *fn, void *data, size_t length) {
+ assert(fn && data && length);
+
+ if (*fn == '/')
+ return pa_authkey_load(fn, data, length);
+ else
+ return pa_authkey_load_from_home(fn, data, length);
+}
diff --git a/src/authkey.h b/src/authkey.h
index cc0fcb28..a0d695a9 100644
--- a/src/authkey.h
+++ b/src/authkey.h
@@ -5,5 +5,6 @@
int pa_authkey_load(const char *path, void *data, size_t len);
int pa_authkey_load_from_home(const char *fn, void *data, size_t length);
+int pa_authkey_load_auto(const char *fn, void *data, size_t length);
#endif
diff --git a/src/modargs.c b/src/modargs.c
index a7b48808..a716a80e 100644
--- a/src/modargs.c
+++ b/src/modargs.c
@@ -7,6 +7,9 @@
#include "modargs.h"
#include "idxset.h"
#include "sample-util.h"
+#include "namereg.h"
+#include "sink.h"
+#include "source.h"
struct pa_modargs;
@@ -220,3 +223,37 @@ int pa_modargs_get_sample_spec(struct pa_modargs *ma, struct pa_sample_spec *rss
return 0;
}
+
+int pa_modargs_get_source_index(struct pa_modargs *ma, struct pa_core *c, uint32_t *index) {
+ const char *t;
+ assert(ma && index);
+
+ if (!(t = pa_modargs_get_value(ma, "source", NULL)))
+ *index = PA_IDXSET_INVALID;
+ else {
+ struct pa_source *source;
+ if (!(source = pa_namereg_get(c, t, PA_NAMEREG_SOURCE)))
+ return -1;
+
+ *index = source->index;
+ }
+
+ return 0;
+}
+
+int pa_modargs_get_sink_index(struct pa_modargs *ma, struct pa_core *c, uint32_t *index) {
+ const char *t;
+ assert(ma && index);
+
+ if (!(t = pa_modargs_get_value(ma, "sink", NULL)))
+ *index = PA_IDXSET_INVALID;
+ else {
+ struct pa_sink *sink;
+ if (!(sink = pa_namereg_get(c, t, PA_NAMEREG_SINK)))
+ return -1;
+
+ *index = sink->index;
+ }
+
+ return 0;
+}
diff --git a/src/modargs.h b/src/modargs.h
index 437dd432..07792ef3 100644
--- a/src/modargs.h
+++ b/src/modargs.h
@@ -3,6 +3,7 @@
#include <inttypes.h>
#include "sample.h"
+#include "core.h"
struct pa_modargs;
@@ -14,5 +15,7 @@ int pa_modargs_get_value_u32(struct pa_modargs *ma, const char *key, uint32_t *v
int pa_modargs_get_sample_spec(struct pa_modargs *ma, struct pa_sample_spec *ss);
+int pa_modargs_get_source_index(struct pa_modargs *ma, struct pa_core *c, uint32_t *index);
+int pa_modargs_get_sink_index(struct pa_modargs *ma, struct pa_core *c, uint32_t *index);
#endif
diff --git a/src/module-cli.c b/src/module-cli.c
index 440c4ba5..135d3588 100644
--- a/src/module-cli.c
+++ b/src/module-cli.c
@@ -18,8 +18,13 @@ int pa_module_init(struct pa_core *c, struct pa_module*m) {
struct pa_iochannel *io;
assert(c && m);
+ if (m->argument) {
+ fprintf(stderr, __FILE__": module doesn't accept arguments.\n");
+ return -1;
+ }
+
if (pa_stdio_acquire() < 0) {
- fprintf(stderr, "STDIN/STDUSE already used\n");
+ fprintf(stderr, __FILE__": STDIN/STDUSE already in use.\n");
return -1;
}
diff --git a/src/module-protocol-stub.c b/src/module-protocol-stub.c
index 0547f7e6..4f82d4e0 100644
--- a/src/module-protocol-stub.c
+++ b/src/module-protocol-stub.c
@@ -9,29 +9,31 @@
#include "socket-server.h"
#include "socket-util.h"
#include "util.h"
+#include "modargs.h"
#ifdef USE_PROTOCOL_SIMPLE
#include "protocol-simple.h"
+ #define protocol_new pa_protocol_simple_new
#define protocol_free pa_protocol_simple_free
#define IPV4_PORT 4711
- #define UNIX_SOCKET_DIR "/tmp/polypaudio"
#define UNIX_SOCKET "/tmp/polypaudio/simple"
+ #define MODULE_ARGUMENTS "rate", "format", "channels", "sink", "source", "playback", "record",
#else
#ifdef USE_PROTOCOL_CLI
#include "protocol-cli.h"
#define protocol_new pa_protocol_cli_new
#define protocol_free pa_protocol_cli_free
#define IPV4_PORT 4712
- #define UNIX_SOCKET_DIR "/tmp/polypaudio"
#define UNIX_SOCKET "/tmp/polypaudio/cli"
+ #define MODULE_ARGUMENTS
#else
#ifdef USE_PROTOCOL_NATIVE
#include "protocol-native.h"
#define protocol_new pa_protocol_native_new
#define protocol_free pa_protocol_native_free
#define IPV4_PORT 4713
- #define UNIX_SOCKET_DIR "/tmp/polypaudio"
#define UNIX_SOCKET "/tmp/polypaudio/native"
+ #define MODULE_ARGUMENTS "public", "cookie",
#else
#ifdef USE_PROTOCOL_ESOUND
#include "protocol-esound.h"
@@ -39,8 +41,8 @@
#define protocol_new pa_protocol_esound_new
#define protocol_free pa_protocol_esound_free
#define IPV4_PORT ESD_DEFAULT_PORT
- #define UNIX_SOCKET_DIR ESD_UNIX_SOCKET_DIR
#define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
+ #define MODULE_ARGUMENTS "sink", "source", "public", "cookie",
#else
#error "Broken build system"
#endif
@@ -48,43 +50,75 @@
#endif
#endif
-int pa_module_init(struct pa_core *c, struct pa_module*m) {
- struct pa_socket_server *s;
- assert(c && m);
+static const char* const valid_modargs[] = {
+ MODULE_ARGUMENTS
+#ifdef USE_TCP_SOCKETS
+ "port",
+ "loopback",
+#else
+ "socket",
+#endif
+ NULL
+};
+struct pa_socket_server *create_socket_server(struct pa_core *c, struct pa_modargs *ma) {
+ struct pa_socket_server *s;
#ifdef USE_TCP_SOCKETS
- if (!(s = pa_socket_server_new_ipv4(c->mainloop, INADDR_ANY, IPV4_PORT)))
- return -1;
+ uint32_t loopback = 0, port = IPV4_PORT;
+
+ if (pa_modargs_get_value_u32(ma, "loopback", &loopback) < 0) {
+ fprintf(stderr, "loopback= expects a numerical argument.\n");
+ return NULL;
+ }
+
+ if (pa_modargs_get_value_u32(ma, "port", &port) < 0) {
+ fprintf(stderr, "port= expects a numerical argument.\n");
+ return NULL;
+ }
+
+ if (!(s = pa_socket_server_new_ipv4(c->mainloop, loopback ? INADDR_LOOPBACK : INADDR_ANY, port)))
+ return NULL;
#else
- if (pa_make_secure_dir(UNIX_SOCKET_DIR) < 0) {
+ int r;
+ const char *p;
+
+ p = pa_modargs_get_value(ma, "socket", UNIX_SOCKET);
+ assert(p);
+
+ if (pa_unix_socket_make_secure_dir(p) < 0) {
fprintf(stderr, "Failed to create secure socket directory.\n");
- return -1;
+ return NULL;
}
- {
- int r;
- if ((r = pa_unix_socket_remove_stale(UNIX_SOCKET)) < 0) {
- fprintf(stderr, "Failed to remove stale UNIX socket '%s': %s\n", UNIX_SOCKET, strerror(errno));
- return -1;
- }
-
- if (r)
- fprintf(stderr, "Removed stale UNIX socket '%s'.", UNIX_SOCKET);
+ if ((r = pa_unix_socket_remove_stale(p)) < 0) {
+ fprintf(stderr, "Failed to remove stale UNIX socket '%s': %s\n", p, strerror(errno));
+ return NULL;
}
- if (!(s = pa_socket_server_new_unix(c->mainloop, UNIX_SOCKET))) {
- rmdir(UNIX_SOCKET_DIR);
+ if (r)
+ fprintf(stderr, "Removed stale UNIX socket '%s'.", p);
+
+ if (!(s = pa_socket_server_new_unix(c->mainloop, p)))
+ return NULL;
+
+#endif
+ return s;
+}
+
+int pa_module_init(struct pa_core *c, struct pa_module*m) {
+ struct pa_socket_server *s;
+ struct pa_modargs *ma;
+ assert(c && m);
+
+ if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
+ fprintf(stderr, "Failed to parse module arguments\n");
return -1;
}
-#endif
-#ifdef USE_PROTOCOL_SIMPLE
- m->userdata = pa_protocol_simple_new(c, s, m, PA_PROTOCOL_SIMPLE_PLAYBACK);
-#else
- m->userdata = protocol_new(c, s, m);
-#endif
+ if (!(s = create_socket_server(c, ma)))
+ return -1;
- if (!m->userdata) {
+ if (!(m->userdata = protocol_new(c, s, m, ma))) {
pa_socket_server_free(s);
return -1;
}
@@ -96,8 +130,4 @@ void pa_module_done(struct pa_core *c, struct pa_module*m) {
assert(c && m);
protocol_free(m->userdata);
-
-#ifndef USE_TCP_SOCKETS
- rmdir(UNIX_SOCKET_DIR);
-#endif
}
diff --git a/src/protocol-cli.c b/src/protocol-cli.c
index 55b4a8a0..0e738321 100644
--- a/src/protocol-cli.c
+++ b/src/protocol-cli.c
@@ -30,7 +30,7 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
pa_idxset_put(p->connections, c, NULL);
}
-struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m) {
+struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
struct pa_protocol_cli* p;
assert(core && server);
diff --git a/src/protocol-cli.h b/src/protocol-cli.h
index c3bb8b4f..f970bb8d 100644
--- a/src/protocol-cli.h
+++ b/src/protocol-cli.h
@@ -4,10 +4,11 @@
#include "core.h"
#include "socket-server.h"
#include "module.h"
+#include "modargs.h"
struct pa_protocol_cli;
-struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m);
+struct pa_protocol_cli* pa_protocol_cli_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
void pa_protocol_cli_free(struct pa_protocol_cli *n);
#endif
diff --git a/src/protocol-esound.c b/src/protocol-esound.c
index 955ab93c..cba72438 100644
--- a/src/protocol-esound.c
+++ b/src/protocol-esound.c
@@ -17,7 +17,7 @@
#include "authkey.h"
-#define COOKIE_FILE ".esd_auth"
+#define DEFAULT_COOKIE_FILE ".esd_auth"
#define PLAYBACK_BUFFER_SECONDS (.5)
#define PLAYBACK_BUFFER_FRAGMENTS (10)
@@ -774,14 +774,24 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
/*** entry points ***/
-struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m) {
+struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
+ uint32_t source_index, sink_index;
struct pa_protocol_esound *p;
- assert(core && server);
+ assert(core && server && ma);
+ if (pa_modargs_get_source_index(ma, core, &source_index) < 0) {
+ fprintf(stderr, __FILE__": source does not exist.\n");
+ return NULL;
+ }
+
+ if (pa_modargs_get_sink_index(ma, core, &sink_index) < 0) {
+ fprintf(stderr, __FILE__": sink does not exist.\n");
+ return NULL;
+ }
p = malloc(sizeof(struct pa_protocol_esound));
assert(p);
- if (pa_authkey_load_from_home(COOKIE_FILE, p->esd_key, sizeof(p->esd_key)) < 0) {
+ if (pa_authkey_load_auto(pa_modargs_get_value(ma, "cookie", DEFAULT_COOKIE_FILE), p->esd_key, sizeof(p->esd_key)) < 0) {
free(p);
return NULL;
}
@@ -793,7 +803,8 @@ struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa
p->core = core;
p->connections = pa_idxset_new(NULL, NULL);
assert(p->connections);
- p->sink_index = p->source_index = PA_IDXSET_INVALID;
+ p->sink_index = sink_index;
+ p->source_index = source_index;
p->n_player = 0;
return p;
diff --git a/src/protocol-esound.h b/src/protocol-esound.h
index 6071699d..8653949d 100644
--- a/src/protocol-esound.h
+++ b/src/protocol-esound.h
@@ -4,10 +4,11 @@
#include "core.h"
#include "socket-server.h"
#include "module.h"
+#include "modargs.h"
struct pa_protocol_esound;
-struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m);
+struct pa_protocol_esound* pa_protocol_esound_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
void pa_protocol_esound_free(struct pa_protocol_esound *p);
#endif
diff --git a/src/protocol-native.c b/src/protocol-native.c
index d6a5f9b2..abd17026 100644
--- a/src/protocol-native.c
+++ b/src/protocol-native.c
@@ -736,20 +736,26 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
/*** module entry points ***/
-struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m) {
+struct pa_protocol_native* pa_protocol_native_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
struct pa_protocol_native *p;
- assert(core && server);
+ uint32_t public;
+ assert(core && server && ma);
+ if (pa_modargs_get_value_u32(ma, "public", &public) < 0) {
+ fprintf(stderr, __FILE__": public= expects numeric argument.\n");
+ return NULL;
+ }
+
p = malloc(sizeof(struct pa_protocol_native));
assert(p);
- if (pa_authkey_load_from_home(PA_NATIVE_COOKIE_FILE, p->auth_cookie, sizeof(p->auth_cookie)) < 0) {
+ if (pa_authkey_load_from_home(pa_modargs_get_value(ma, "cookie", PA_NATIVE_COOKIE_FILE), p->auth_cookie, sizeof(p->auth_cookie)) < 0) {
free(p);
return NULL;
}
p->module = m;
- p->public = 1;
+ p->public = public;
p->server = server;
p->core = core;
p->connections = pa_idxset_new(NULL, NULL);
diff --git a/src/protocol-native.h b/src/protocol-native.h
index 811b4e4a..89cb1634 100644
--- a/src/protocol-native.h
+++ b/src/protocol-native.h
@@ -4,10 +4,11 @@
#include "core.h"
#include "socket-server.h"
#include "module.h"
+#include "modargs.h"
struct pa_protocol_native;
-struct pa_protocol_native* pa_protocol_native_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m);
+struct pa_protocol_native* pa_protocol_native_new(struct pa_core*core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
void pa_protocol_native_free(struct pa_protocol_native *n);
#endif
diff --git a/src/protocol-simple.c b/src/protocol-simple.c
index b57f324a..89207133 100644
--- a/src/protocol-simple.c
+++ b/src/protocol-simple.c
@@ -10,6 +10,7 @@
#include "protocol-simple.h"
#include "client.h"
#include "sample-util.h"
+#include "namereg.h"
struct connection {
struct pa_protocol_simple *protocol;
@@ -31,8 +32,13 @@ struct pa_protocol_simple {
struct pa_core *core;
struct pa_socket_server*server;
struct pa_idxset *connections;
- enum pa_protocol_simple_mode mode;
+ enum {
+ RECORD = 1,
+ PLAYBACK = 2,
+ DUPLEX = 3
+ } mode;
struct pa_sample_spec sample_spec;
+ uint32_t sink_index, source_index;
};
#define PLAYBACK_BUFFER_SECONDS (.5)
@@ -263,14 +269,15 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
c->client->kill = client_kill_cb;
c->client->userdata = c;
- if (p->mode & PA_PROTOCOL_SIMPLE_PLAYBACK) {
+ if (p->mode & PLAYBACK) {
struct pa_sink *sink;
size_t l;
- if (!(sink = pa_sink_get_default(p->core))) {
- fprintf(stderr, "Failed to get default sink.\n");
- goto fail;
- }
+ if (!(sink = pa_idxset_get_by_index(p->core->sinks, p->sink_index)))
+ if (!(sink = pa_sink_get_default(p->core))) {
+ fprintf(stderr, "Failed to get sink.\n");
+ goto fail;
+ }
c->sink_input = pa_sink_input_new(sink, c->client->name, &p->sample_spec);
if (!c->sink_input) {
@@ -293,15 +300,15 @@ static void on_connection(struct pa_socket_server*s, struct pa_iochannel *io, vo
c->playback.fragment_size = l/10;
}
-
- if (p->mode & PA_PROTOCOL_SIMPLE_RECORD) {
+ if (p->mode & RECORD) {
struct pa_source *source;
size_t l;
- if (!(source = pa_source_get_default(p->core))) {
- fprintf(stderr, "Failed to get default source.\n");
- goto fail;
- }
+ if (!(source = pa_idxset_get_by_index(p->core->sources, p->source_index)))
+ if (!(source = pa_source_get_default(p->core))) {
+ fprintf(stderr, "Failed to get source.\n");
+ goto fail;
+ }
c->source_output = pa_source_output_new(source, c->client->name, &p->sample_spec);
if (!c->source_output) {
@@ -334,22 +341,62 @@ fail:
connection_free(c);
}
-struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, enum pa_protocol_simple_mode mode) {
- struct pa_protocol_simple* p;
- assert(core && server && mode <= PA_PROTOCOL_SIMPLE_DUPLEX && mode > 0);
+struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma) {
+ struct pa_protocol_simple* p = NULL;
+ uint32_t enable;
+ assert(core && server && ma);
p = malloc(sizeof(struct pa_protocol_simple));
assert(p);
+ memset(p, 0, sizeof(struct pa_protocol_simple));
+
p->module = m;
p->core = core;
p->server = server;
p->connections = pa_idxset_new(NULL, NULL);
- p->mode = mode;
- p->sample_spec = PA_DEFAULT_SAMPLE_SPEC;
+ if (pa_modargs_get_sample_spec(ma, &p->sample_spec) < 0) {
+ fprintf(stderr, "Failed to parse sample type specification.\n");
+ goto fail;
+ }
+
+ if (pa_modargs_get_source_index(ma, core, &p->source_index) < 0) {
+ fprintf(stderr, __FILE__": source does not exist.\n");
+ goto fail;
+ }
+
+ if (pa_modargs_get_sink_index(ma, core, &p->sink_index) < 0) {
+ fprintf(stderr, __FILE__": sink does not exist.\n");
+ goto fail;
+ }
+
+ enable = 0;
+ if (pa_modargs_get_value_u32(ma, "record", &enable) < 0) {
+ fprintf(stderr, __FILE__": record= expects a numeric argument.\n");
+ goto fail;
+ }
+ p->mode = enable ? RECORD : 0;
+
+ enable = 1;
+ if (pa_modargs_get_value_u32(ma, "playback", &enable) < 0) {
+ fprintf(stderr, __FILE__": playback= expects a numeric argument.\n");
+ goto fail;
+ }
+ p->mode |= enable ? PLAYBACK : 0;
+
+ if ((p->mode & (RECORD|PLAYBACK)) == 0) {
+ fprintf(stderr, __FILE__": neither playback nor recording enabled for protocol.\n");
+ goto fail;
+ }
+
pa_socket_server_set_callback(p->server, on_connection, p);
return p;
+
+fail:
+ if (p)
+ pa_protocol_simple_free(p);
+ return NULL;
}
@@ -357,12 +404,15 @@ void pa_protocol_simple_free(struct pa_protocol_simple *p) {
struct connection *c;
assert(p);
- while((c = pa_idxset_first(p->connections, NULL)))
- connection_free(c);
+ if (p->connections) {
+ while((c = pa_idxset_first(p->connections, NULL)))
+ connection_free(c);
+
+ pa_idxset_free(p->connections, NULL, NULL);
+ }
- pa_idxset_free(p->connections, NULL, NULL);
-
- pa_socket_server_free(p->server);
+ if (p->server)
+ pa_socket_server_free(p->server);
free(p);
}
diff --git a/src/protocol-simple.h b/src/protocol-simple.h
index 6b2a2cd1..62682915 100644
--- a/src/protocol-simple.h
+++ b/src/protocol-simple.h
@@ -4,16 +4,11 @@
#include "socket-server.h"
#include "module.h"
#include "core.h"
+#include "modargs.h"
struct pa_protocol_simple;
-enum pa_protocol_simple_mode {
- PA_PROTOCOL_SIMPLE_RECORD = 1,
- PA_PROTOCOL_SIMPLE_PLAYBACK = 2,
- PA_PROTOCOL_SIMPLE_DUPLEX = 3
-};
-
-struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, enum pa_protocol_simple_mode mode);
+struct pa_protocol_simple* pa_protocol_simple_new(struct pa_core *core, struct pa_socket_server *server, struct pa_module *m, struct pa_modargs *ma);
void pa_protocol_simple_free(struct pa_protocol_simple *n);
#endif
diff --git a/src/socket-util.c b/src/socket-util.c
index f9451af8..f4648da5 100644
--- a/src/socket-util.c
+++ b/src/socket-util.c
@@ -14,6 +14,7 @@
#include <netinet/ip.h>
#include "socket-util.h"
+#include "util.h"
void pa_socket_peer_to_string(int fd, char *c, size_t l) {
struct stat st;
@@ -150,3 +151,41 @@ int pa_unix_socket_remove_stale(const char *fn) {
return 0;
}
+
+int pa_unix_socket_make_secure_dir(const char *fn) {
+ int ret = -1;
+ char *slash, *dir = strdup(fn);
+ assert(dir);
+
+ if (!(slash = strrchr(dir, '/')))
+ goto finish;
+ *slash = 0;
+
+ if (pa_make_secure_dir(dir) < 0)
+ goto finish;
+
+ ret = 0;
+
+finish:
+ free(dir);
+ return ret;
+}
+
+int pa_unix_socket_remove_secure_dir(const char *fn) {
+ int ret = -1;
+ char *slash, *dir = strdup(fn);
+ assert(dir);
+
+ if (!(slash = strrchr(dir, '/')))
+ goto finish;
+ *slash = 0;
+
+ if (rmdir(dir) < 0)
+ goto finish;
+
+ ret = 0;
+
+finish:
+ free(dir);
+ return ret;
+}
diff --git a/src/socket-util.h b/src/socket-util.h
index 1c4dbe35..0133bfc3 100644
--- a/src/socket-util.h
+++ b/src/socket-util.h
@@ -14,4 +14,7 @@ int pa_socket_set_rcvbuf(int fd, size_t l);
int pa_unix_socket_is_stale(const char *fn);
int pa_unix_socket_remove_stale(const char *fn);
+int pa_unix_socket_make_secure_dir(const char *fn);
+int pa_unix_socket_remove_secure_dir(const char *fn);
+
#endif
diff --git a/src/todo b/src/todo
index deab2163..b131ac73 100644
--- a/src/todo
+++ b/src/todo
@@ -1,7 +1,9 @@
- native library/protocol:
more functions (esp. latency)
-- make all modules use modargs.c
+- make all modules use modargs.c:
+ module-oss.c
+ module-oss-mmap.c
- cmdline
- daemonizing