9 #include "socket-server.h"
12 #ifdef USE_PROTOCOL_SIMPLE
13 #include "protocol-simple.h"
14 #define protocol_free pa_protocol_simple_free
15 #define IPV4_PORT 4711
16 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
17 #define UNIX_SOCKET "/tmp/polypaudio/simple"
19 #ifdef USE_PROTOCOL_CLI
20 #include "protocol-cli.h"
21 #define protocol_new pa_protocol_cli_new
22 #define protocol_free pa_protocol_cli_free
23 #define IPV4_PORT 4712
24 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
25 #define UNIX_SOCKET "/tmp/polypaudio/cli"
27 #ifdef USE_PROTOCOL_NATIVE
28 #include "protocol-native.h"
29 #define protocol_new pa_protocol_native_new
30 #define protocol_free pa_protocol_native_free
31 #define IPV4_PORT 4713
32 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
33 #define UNIX_SOCKET "/tmp/polypaudio/native"
35 #ifdef USE_PROTOCOL_ESOUND
36 #include "protocol-esound.h"
37 #include "esound-spec.h"
38 #define protocol_new pa_protocol_esound_new
39 #define protocol_free pa_protocol_esound_free
40 #define IPV4_PORT ESD_DEFAULT_PORT
41 #define UNIX_SOCKET_DIR ESD_UNIX_SOCKET_DIR
42 #define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
44 #error "Broken build system"
50 int pa_module_init(struct pa_core *c, struct pa_module*m) {
51 struct pa_socket_server *s;
54 #ifdef USE_TCP_SOCKETS
55 if (!(s = pa_socket_server_new_ipv4(c->mainloop, INADDR_ANY, IPV4_PORT)))
58 if (pa_make_secure_dir(UNIX_SOCKET_DIR) < 0) {
59 fprintf(stderr, "Failed to create secure socket directory.\n");
65 if ((r = pa_unix_socket_remove_stale(UNIX_SOCKET)) < 0) {
66 fprintf(stderr, "Failed to remove stale UNIX socket '%s': %s\n", UNIX_SOCKET, strerror(errno));
71 fprintf(stderr, "Removed stale UNIX socket '%s'.", UNIX_SOCKET);
74 if (!(s = pa_socket_server_new_unix(c->mainloop, UNIX_SOCKET))) {
75 rmdir(UNIX_SOCKET_DIR);
80 #ifdef USE_PROTOCOL_SIMPLE
81 m->userdata = pa_protocol_simple_new(c, s, PA_PROTOCOL_SIMPLE_PLAYBACK);
83 m->userdata = protocol_new(c, s);
87 pa_socket_server_free(s);
94 void pa_module_done(struct pa_core *c, struct pa_module*m) {
97 protocol_free(m->userdata);
99 #ifndef USE_TCP_SOCKETS
100 rmdir(UNIX_SOCKET_DIR);