1 module pulse.subscribe;
2 
3 import pulse.context;
4 import pulse.operation;
5 import pulse.def;
6 
7 extern (C):
8 
9 /***
10   This file is part of PulseAudio.
11 
12   Copyright 2004-2006 Lennart Poettering
13   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
14 
15   PulseAudio is free software; you can redistribute it and/or modify
16   it under the terms of the GNU Lesser General Public License as published
17   by the Free Software Foundation; either version 2.1 of the License,
18   or (at your option) any later version.
19 
20   PulseAudio is distributed in the hope that it will be useful, but
21   WITHOUT ANY WARRANTY; without even the implied warranty of
22   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23   General Public License for more details.
24 
25   You should have received a copy of the GNU Lesser General Public License
26   along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
27 ***/
28 
29 /** \page subscribe Event Subscription
30  *
31  * \section overv_sec Overview
32  *
33  * The application can be notified, asynchronously, whenever the internal
34  * layout of the server changes. Possible notifications are described in the
35  * \ref pa_subscription_event_type and \ref pa_subscription_mask
36  * enumerations.
37  *
38  * The application sets the notification mask using pa_context_subscribe()
39  * and the function that will be called whenever a notification occurs using
40  * pa_context_set_subscribe_callback().
41  *
42  * The callback will be called with a \ref pa_subscription_event_type_t
43  * representing the event that caused the callback. Clients can examine what
44  * object changed using \ref PA_SUBSCRIPTION_EVENT_FACILITY_MASK. The actual
45  * event type can then be extracted with \ref PA_SUBSCRIPTION_EVENT_TYPE_MASK.
46  * Please note that the masked values are integers, not flags (so you will
47  * check the object/event type using a comparison not a binary AND). For
48  * example, the callback might look something like:
49  *
50 @verbatim
51 void my_subscription_callback(pa_context *c, pa_subscription_event_type_t t,
52                               uint32_t idx, void *userdata) {
53     if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE) {
54         if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
55             ... a source was added, let's do stuff! ...
56         }
57     }
58 }
59 @endverbatim
60  */
61 
62 /** \file
63  * Daemon introspection event subscription subsystem.
64  *
65  * See also \subpage subscribe
66  */
67 
68 /** Subscription event callback prototype */
69 alias pa_context_subscribe_cb_t = void function (pa_context* c, pa_subscription_event_type_t t, uint idx, void* userdata);
70 
71 /** Enable event notification */
72 pa_operation* pa_context_subscribe (pa_context* c, pa_subscription_mask_t m, pa_context_success_cb_t cb, void* userdata);
73 
74 /** Set the context specific call back function that is called whenever the state of the daemon changes */
75 void pa_context_set_subscribe_callback (pa_context* c, pa_context_subscribe_cb_t cb, void* userdata);
76