]>
code.delx.au - pulseaudio/blob - polyp/module-protocol-stub.c
4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
30 #include <arpa/inet.h>
34 #include "socket-server.h"
35 #include "socket-util.h"
39 #if defined(USE_PROTOCOL_SIMPLE)
40 #include "protocol-simple.h"
41 #define protocol_new pa_protocol_simple_new
42 #define protocol_free pa_protocol_simple_free
43 #define IPV4_PORT 4711
44 #define UNIX_SOCKET "/tmp/polypaudio/simple"
45 #define MODULE_ARGUMENTS "rate", "format", "channels", "sink", "source", "playback", "record",
46 #elif defined(USE_PROTOCOL_CLI)
47 #include "protocol-cli.h"
48 #define protocol_new pa_protocol_cli_new
49 #define protocol_free pa_protocol_cli_free
50 #define IPV4_PORT 4712
51 #define UNIX_SOCKET "/tmp/polypaudio/cli"
52 #define MODULE_ARGUMENTS
53 #elif defined(USE_PROTOCOL_NATIVE)
54 #include "protocol-native.h"
55 #define protocol_new pa_protocol_native_new
56 #define protocol_free pa_protocol_native_free
57 #define IPV4_PORT 4713
58 #define UNIX_SOCKET "/tmp/polypaudio/native"
59 #define MODULE_ARGUMENTS "public", "cookie",
60 #elif defined(USE_PROTOCOL_ESOUND)
61 #include "protocol-esound.h"
63 #define protocol_new pa_protocol_esound_new
64 #define protocol_free pa_protocol_esound_free
65 #define IPV4_PORT ESD_DEFAULT_PORT
66 #define UNIX_SOCKET ESD_UNIX_SOCKET_NAME
67 #define MODULE_ARGUMENTS "sink", "source", "public", "cookie",
69 #error "Broken build system"
72 static const char* const valid_modargs
[] = {
74 #ifdef USE_TCP_SOCKETS
83 static struct pa_socket_server
*create_socket_server(struct pa_core
*c
, struct pa_modargs
*ma
) {
84 struct pa_socket_server
*s
;
85 #ifdef USE_TCP_SOCKETS
86 uint32_t loopback
= 1, port
= IPV4_PORT
;
88 if (pa_modargs_get_value_u32(ma
, "loopback", &loopback
) < 0) {
89 fprintf(stderr
, "loopback= expects a numerical argument.\n");
93 if (pa_modargs_get_value_u32(ma
, "port", &port
) < 0) {
94 fprintf(stderr
, "port= expects a numerical argument.\n");
98 if (!(s
= pa_socket_server_new_ipv4(c
->mainloop
, loopback
? INADDR_LOOPBACK
: INADDR_ANY
, port
)))
104 p
= pa_modargs_get_value(ma
, "socket", UNIX_SOCKET
);
107 if (pa_unix_socket_make_secure_dir(p
) < 0) {
108 fprintf(stderr
, "Failed to create secure socket directory.\n");
112 if ((r
= pa_unix_socket_remove_stale(p
)) < 0) {
113 fprintf(stderr
, "Failed to remove stale UNIX socket '%s': %s\n", p
, strerror(errno
));
118 fprintf(stderr
, "Removed stale UNIX socket '%s'.", p
);
120 if (!(s
= pa_socket_server_new_unix(c
->mainloop
, p
)))
127 int pa_module_init(struct pa_core
*c
, struct pa_module
*m
) {
128 struct pa_socket_server
*s
;
129 struct pa_modargs
*ma
= NULL
;
133 if (!(ma
= pa_modargs_new(m
->argument
, valid_modargs
))) {
134 fprintf(stderr
, "Failed to parse module arguments\n");
138 if (!(s
= create_socket_server(c
, ma
)))
141 if (!(m
->userdata
= protocol_new(c
, s
, m
, ma
))) {
142 pa_socket_server_unref(s
);
155 void pa_module_done(struct pa_core
*c
, struct pa_module
*m
) {
158 protocol_free(m
->userdata
);