]>
code.delx.au - pulseaudio/blob - polyp/protocol-cli.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 Lesser 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 Lesser 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
29 #include "protocol-cli.h"
33 struct pa_protocol_cli
{
34 struct pa_module
*module
;
36 struct pa_socket_server
*server
;
37 struct pa_idxset
*connections
;
40 static void cli_eof_cb(struct pa_cli
*c
, void*userdata
) {
41 struct pa_protocol_cli
*p
= userdata
;
43 pa_idxset_remove_by_data(p
->connections
, c
, NULL
);
47 static void on_connection(struct pa_socket_server
*s
, struct pa_iochannel
*io
, void *userdata
) {
48 struct pa_protocol_cli
*p
= userdata
;
52 c
= pa_cli_new(p
->core
, io
, p
->module
);
54 pa_cli_set_eof_callback(c
, cli_eof_cb
, p
);
56 pa_idxset_put(p
->connections
, c
, NULL
);
59 struct pa_protocol_cli
* pa_protocol_cli_new(struct pa_core
*core
, struct pa_socket_server
*server
, struct pa_module
*m
, struct pa_modargs
*ma
) {
60 struct pa_protocol_cli
* p
;
61 assert(core
&& server
);
63 p
= pa_xmalloc(sizeof(struct pa_protocol_cli
));
67 p
->connections
= pa_idxset_new(NULL
, NULL
);
69 pa_socket_server_set_callback(p
->server
, on_connection
, p
);
74 static void free_connection(void *p
, void *userdata
) {
79 void pa_protocol_cli_free(struct pa_protocol_cli
*p
) {
82 pa_idxset_free(p
->connections
, free_connection
, NULL
);
83 pa_socket_server_unref(p
->server
);