]> code.delx.au - pulseaudio/blob - src/module-protocol-stub.c
some fixes
[pulseaudio] / src / module-protocol-stub.c
1 #include <assert.h>
2 #include <arpa/inet.h>
3
4 #include "module.h"
5 #include "socket-server.h"
6
7 #ifdef USE_PROTOCOL_SIMPLE
8 #include "protocol-simple.h"
9 #define protocol_free protocol_simple_free
10 #define IPV4_PORT 4711
11 #define UNIX_SOCKET "/tmp/polypaudio_simple"
12 #else
13 #ifdef USE_PROTOCOL_CLI
14 #include "protocol-cli.h"
15 #define protocol_new protocol_cli_new
16 #define protocol_free protocol_cli_free
17 #define IPV4_PORT 4712
18 #define UNIX_SOCKET "/tmp/polypaudio_cli"
19 #else
20 #ifdef USE_PROTOCOL_NATIVE
21 #include "protocol-native.h"
22 #define protocol_new protocol_native_new
23 #define protocol_free protocol_native_free
24 #define IPV4_PORT 4713
25 #define UNIX_SOCKET "/tmp/polypaudio_native"
26 #else
27 #error "Broken build system"
28 #endif
29 #endif
30 #endif
31
32 int module_init(struct core *c, struct module*m) {
33 struct socket_server *s;
34 assert(c && m);
35
36 #ifdef USE_TCP_SOCKETS
37 if (!(s = socket_server_new_ipv4(c->mainloop, INADDR_LOOPBACK, IPV4_PORT)))
38 return -1;
39 #else
40 if (!(s = socket_server_new_unix(c->mainloop, UNIX_SOCKET)))
41 return -1;
42 #endif
43
44 #ifdef USE_PROTOCOL_SIMPLE
45 m->userdata = protocol_simple_new(c, s, PROTOCOL_SIMPLE_PLAYBACK);
46 #else
47 m->userdata = protocol_new(c, s);
48 #endif
49
50 assert(m->userdata);
51 return 0;
52 }
53
54 void module_done(struct core *c, struct module*m) {
55 assert(c && m);
56
57 protocol_free(m->userdata);
58 }