]> code.delx.au - pulseaudio/blob - src/module-protocol-stub.c
rename module-simple-protocol to module-protocol-stub
[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 protcol_simple_free
10 #else
11 #ifdef USE_PROTOCOL_CLI
12 #include "protocol-cli.h"
13 #define protocol_new protocol_cli_new
14 #define protocol_free protocol_cli_free
15 #else
16 #error "Broken build system"
17 #endif
18 #endif
19
20 int module_init(struct core *c, struct module*m) {
21 struct socket_server *s;
22 assert(c && m);
23
24 #ifdef USE_TCP_SOCKETS
25 if (!(s = socket_server_new_ipv4(c->mainloop, INADDR_LOOPBACK, 4712)))
26 return -1;
27 #else
28 if (!(s = socket_server_new_unix(c->mainloop, "/tmp/polypsimple")))
29 return -1;
30 #endif
31
32 #ifdef USE_PROTOCOL_SIMPLE
33 m->userdata = protocol_simple_new(c, s, PROTOCOL_SIMPLE_PLAYBACK);
34 #else
35 m->userdata = protocol_new(c, s);
36 #endif
37
38 assert(m->userdata);
39 return 0;
40 }
41
42 void module_done(struct core *c, struct module*m) {
43 assert(c && m);
44
45 protocol_simple_free(m->userdata);
46 }