]>
code.delx.au - pulseaudio/blob - polyp/howl-wrap.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
8 published by the Free Software Foundation; either version 2 of the
9 License, 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
17 License along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 #include "howl-wrap.h"
29 #define HOWL_PROPERTY "howl"
31 struct pa_howl_wrapper
{
35 struct pa_io_event
*io_event
;
36 sw_discovery discovery
;
40 static void howl_io_event(struct pa_mainloop_api
*m
, struct pa_io_event
*e
, int fd
, enum pa_io_event_flags f
, void *userdata
) {
41 struct pa_howl_wrapper
*w
= userdata
;
42 assert(m
&& e
&& fd
>= 0 && w
&& w
->ref
>= 1);
44 if (f
& (PA_IO_EVENT_HANGUP
|PA_IO_EVENT_ERROR
))
47 if (sw_discovery_read_socket(w
->discovery
) != SW_OKAY
)
53 pa_log(__FILE__
": howl connection died.\n");
54 w
->core
->mainloop
->io_free(w
->io_event
);
58 static struct pa_howl_wrapper
* howl_wrapper_new(struct pa_core
*c
) {
59 struct pa_howl_wrapper
*h
;
63 if (sw_discovery_init(&session
) != SW_OKAY
) {
64 pa_log("sw_discovery_init() failed.\n");
68 h
= pa_xmalloc(sizeof(struct pa_howl_wrapper
));
71 h
->discovery
= session
;
73 h
->io_event
= c
->mainloop
->io_new(c
->mainloop
, sw_discovery_socket(session
), PA_IO_EVENT_INPUT
, howl_io_event
, h
);
78 static void howl_wrapper_free(struct pa_howl_wrapper
*h
) {
81 sw_discovery_fina(h
->discovery
);
84 h
->core
->mainloop
->io_free(h
->io_event
);
89 struct pa_howl_wrapper
* pa_howl_wrapper_get(struct pa_core
*c
) {
90 struct pa_howl_wrapper
*h
;
93 if ((h
= pa_property_get(c
, HOWL_PROPERTY
)))
94 return pa_howl_wrapper_ref(h
);
96 return howl_wrapper_new(c
);
99 struct pa_howl_wrapper
* pa_howl_wrapper_ref(struct pa_howl_wrapper
*h
) {
100 assert(h
&& h
->ref
>= 1);
105 void pa_howl_wrapper_unref(struct pa_howl_wrapper
*h
) {
106 assert(h
&& h
->ref
>= 1);
108 howl_wrapper_free(h
);
111 sw_discovery
pa_howl_wrapper_get_discovery(struct pa_howl_wrapper
*h
) {
112 assert(h
&& h
->ref
>= 1);