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