]>
code.delx.au - pulseaudio/blob - src/module-protocol-stub.c
7 #include "socket-server.h"
10 #ifdef USE_PROTOCOL_SIMPLE
11 #include "protocol-simple.h"
12 #define protocol_free protocol_simple_free
13 #define IPV4_PORT 4711
14 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
15 #define UNIX_SOCKET "/tmp/polypaudio/simple"
17 #ifdef USE_PROTOCOL_CLI
18 #include "protocol-cli.h"
19 #define protocol_new protocol_cli_new
20 #define protocol_free protocol_cli_free
21 #define IPV4_PORT 4712
22 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
23 #define UNIX_SOCKET "/tmp/polypaudio/cli"
25 #ifdef USE_PROTOCOL_NATIVE
26 #include "protocol-native.h"
27 #define protocol_new protocol_native_new
28 #define protocol_free protocol_native_free
29 #define IPV4_PORT 4713
30 #define UNIX_SOCKET_DIR "/tmp/polypaudio"
31 #define UNIX_SOCKET "/tmp/polypaudio/native"
33 #ifdef USE_PROTOCOL_ESOUND
34 #include "protocol-esound.h"
35 #include "esound-spec.h"
36 #define protocol_new protocol_esound_new
37 #define protocol_free protocol_esound_free
38 #define IPV4_PORT ESD_DEFAULT_PORT
39 #define UNIX_SOCKET_DIR ESD_UNIX_SOCKET_DIR
40 #define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
42 #error "Broken build system"
48 int module_init(struct core
*c
, struct module
*m
) {
49 struct socket_server
*s
;
52 #ifdef USE_TCP_SOCKETS
53 if (!(s
= socket_server_new_ipv4(c
->mainloop
, INADDR_LOOPBACK
, IPV4_PORT
)))
56 if (make_secure_dir(UNIX_SOCKET_DIR
) < 0) {
57 fprintf(stderr
, "Failed to create secure socket directory.\n");
61 if (!(s
= socket_server_new_unix(c
->mainloop
, UNIX_SOCKET
))) {
62 rmdir(UNIX_SOCKET_DIR
);
67 #ifdef USE_PROTOCOL_SIMPLE
68 m
->userdata
= protocol_simple_new(c
, s
, PROTOCOL_SIMPLE_PLAYBACK
);
70 m
->userdata
= protocol_new(c
, s
);
77 void module_done(struct core
*c
, struct module
*m
) {
80 protocol_free(m
->userdata
);
82 #ifndef USE_TCP_SOCKETS
83 rmdir(UNIX_SOCKET_DIR
);