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