]>
code.delx.au - pulseaudio/blob - src/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 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
29 #include "protocol-cli.h"
32 struct pa_protocol_cli
{
33 struct pa_module
*module
;
35 struct pa_socket_server
*server
;
36 struct pa_idxset
*connections
;
39 static void cli_eof_cb(struct pa_cli
*c
, void*userdata
) {
40 struct pa_protocol_cli
*p
= userdata
;
42 pa_idxset_remove_by_data(p
->connections
, c
, NULL
);
46 static void on_connection(struct pa_socket_server
*s
, struct pa_iochannel
*io
, void *userdata
) {
47 struct pa_protocol_cli
*p
= userdata
;
51 c
= pa_cli_new(p
->core
, io
, p
->module
);
53 pa_cli_set_eof_callback(c
, cli_eof_cb
, p
);
55 pa_idxset_put(p
->connections
, c
, NULL
);
58 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
) {
59 struct pa_protocol_cli
* p
;
60 assert(core
&& server
);
62 p
= malloc(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_free(p
->server
);