2004-06-08 23:54:24 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
|
|
#include "module.h"
|
|
|
|
|
#include "socket-server.h"
|
2004-06-19 18:51:30 +00:00
|
|
|
|
|
|
|
|
#ifdef USE_PROTOCOL_SIMPLE
|
|
|
|
|
#include "protocol-simple.h"
|
2004-06-19 19:27:47 +00:00
|
|
|
#define protocol_free protocol_simple_free
|
2004-06-20 01:12:13 +00:00
|
|
|
#define IPV4_PORT 4711
|
2004-06-24 23:27:06 +00:00
|
|
|
#define UNIX_SOCKET "/tmp/polypaudio_simple"
|
2004-06-19 18:51:30 +00:00
|
|
|
#else
|
|
|
|
|
#ifdef USE_PROTOCOL_CLI
|
|
|
|
|
#include "protocol-cli.h"
|
|
|
|
|
#define protocol_new protocol_cli_new
|
|
|
|
|
#define protocol_free protocol_cli_free
|
2004-06-20 01:12:13 +00:00
|
|
|
#define IPV4_PORT 4712
|
2004-06-24 23:27:06 +00:00
|
|
|
#define UNIX_SOCKET "/tmp/polypaudio_cli"
|
2004-06-19 18:51:30 +00:00
|
|
|
#else
|
2004-06-20 01:12:13 +00:00
|
|
|
#ifdef USE_PROTOCOL_NATIVE
|
|
|
|
|
#include "protocol-native.h"
|
|
|
|
|
#define protocol_new protocol_native_new
|
|
|
|
|
#define protocol_free protocol_native_free
|
|
|
|
|
#define IPV4_PORT 4713
|
2004-06-24 23:27:06 +00:00
|
|
|
#define UNIX_SOCKET "/tmp/polypaudio_native"
|
2004-06-20 01:12:13 +00:00
|
|
|
#else
|
|
|
|
|
#error "Broken build system"
|
|
|
|
|
#endif
|
2004-06-19 18:51:30 +00:00
|
|
|
#endif
|
|
|
|
|
#endif
|
2004-06-08 23:54:24 +00:00
|
|
|
|
|
|
|
|
int module_init(struct core *c, struct module*m) {
|
|
|
|
|
struct socket_server *s;
|
|
|
|
|
assert(c && m);
|
|
|
|
|
|
2004-06-19 18:41:24 +00:00
|
|
|
#ifdef USE_TCP_SOCKETS
|
2004-06-19 19:27:47 +00:00
|
|
|
if (!(s = socket_server_new_ipv4(c->mainloop, INADDR_LOOPBACK, IPV4_PORT)))
|
2004-06-08 23:54:24 +00:00
|
|
|
return -1;
|
2004-06-19 18:41:24 +00:00
|
|
|
#else
|
2004-06-24 23:27:06 +00:00
|
|
|
if (!(s = socket_server_new_unix(c->mainloop, UNIX_SOCKET)))
|
2004-06-19 18:41:24 +00:00
|
|
|
return -1;
|
|
|
|
|
#endif
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-06-19 18:51:30 +00:00
|
|
|
#ifdef USE_PROTOCOL_SIMPLE
|
2004-06-08 23:54:24 +00:00
|
|
|
m->userdata = protocol_simple_new(c, s, PROTOCOL_SIMPLE_PLAYBACK);
|
2004-06-19 18:51:30 +00:00
|
|
|
#else
|
|
|
|
|
m->userdata = protocol_new(c, s);
|
|
|
|
|
#endif
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
assert(m->userdata);
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void module_done(struct core *c, struct module*m) {
|
|
|
|
|
assert(c && m);
|
|
|
|
|
|
2004-06-19 19:27:47 +00:00
|
|
|
protocol_free(m->userdata);
|
2004-06-08 23:54:24 +00:00
|
|
|
}
|