9 #include "socket-server.h"
10 #include "socket-util.h"
13 #ifdef USE_PROTOCOL_SIMPLE
14 #include "protocol-simple.h"
15 #define protocol_free pa_protocol_simple_free
16 #define IPV4_PORT 4711
17 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
18 #define UNIX_SOCKET "/tmp/polypaudio/simple"
20 #ifdef USE_PROTOCOL_CLI
21 #include "protocol-cli.h"
22 #define protocol_new pa_protocol_cli_new
23 #define protocol_free pa_protocol_cli_free
24 #define IPV4_PORT 4712
25 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
26 #define UNIX_SOCKET "/tmp/polypaudio/cli"
28 #ifdef USE_PROTOCOL_NATIVE
29 #include "protocol-native.h"
30 #define protocol_new pa_protocol_native_new
31 #define protocol_free pa_protocol_native_free
32 #define IPV4_PORT 4713
33 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
34 #define UNIX_SOCKET "/tmp/polypaudio/native"
36 #ifdef USE_PROTOCOL_ESOUND
37 #include "protocol-esound.h"
38 #include "esound-spec.h"
39 #define protocol_new pa_protocol_esound_new
40 #define protocol_free pa_protocol_esound_free
41 #define IPV4_PORT ESD_DEFAULT_PORT
42 #define UNIX_SOCKET_DIR ESD_UNIX_SOCKET_DIR
43 #define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
45 #error "Broken build system"
51 int pa_module_init(struct pa_core *c, struct pa_module*m) {
52 struct pa_socket_server *s;
55 #ifdef USE_TCP_SOCKETS
56 if (!(s = pa_socket_server_new_ipv4(c->mainloop, INADDR_ANY, IPV4_PORT)))
59 if (pa_make_secure_dir(UNIX_SOCKET_DIR) < 0) {
60 fprintf(stderr, "Failed to create secure socket directory.\n");
66 if ((r = pa_unix_socket_remove_stale(UNIX_SOCKET)) < 0) {
67 fprintf(stderr, "Failed to remove stale UNIX socket '%s': %s\n", UNIX_SOCKET, strerror(errno));
72 fprintf(stderr, "Removed stale UNIX socket '%s'.", UNIX_SOCKET);
75 if (!(s = pa_socket_server_new_unix(c->mainloop, UNIX_SOCKET))) {
76 rmdir(UNIX_SOCKET_DIR);
81 #ifdef USE_PROTOCOL_SIMPLE
82 m->userdata = pa_protocol_simple_new(c, s, m, PA_PROTOCOL_SIMPLE_PLAYBACK);
84 m->userdata = protocol_new(c, s, m);
88 pa_socket_server_free(s);
95 void pa_module_done(struct pa_core *c, struct pa_module*m) {
98 protocol_free(m->userdata);
100 #ifndef USE_TCP_SOCKETS
101 rmdir(UNIX_SOCKET_DIR);