153a5a1b3Sopenharmony_ci#ifndef foosubscribehfoo
253a5a1b3Sopenharmony_ci#define foosubscribehfoo
353a5a1b3Sopenharmony_ci
453a5a1b3Sopenharmony_ci/***
553a5a1b3Sopenharmony_ci  This file is part of PulseAudio.
653a5a1b3Sopenharmony_ci
753a5a1b3Sopenharmony_ci  Copyright 2004-2006 Lennart Poettering
853a5a1b3Sopenharmony_ci  Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
953a5a1b3Sopenharmony_ci
1053a5a1b3Sopenharmony_ci  PulseAudio is free software; you can redistribute it and/or modify
1153a5a1b3Sopenharmony_ci  it under the terms of the GNU Lesser General Public License as published
1253a5a1b3Sopenharmony_ci  by the Free Software Foundation; either version 2.1 of the License,
1353a5a1b3Sopenharmony_ci  or (at your option) any later version.
1453a5a1b3Sopenharmony_ci
1553a5a1b3Sopenharmony_ci  PulseAudio is distributed in the hope that it will be useful, but
1653a5a1b3Sopenharmony_ci  WITHOUT ANY WARRANTY; without even the implied warranty of
1753a5a1b3Sopenharmony_ci  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1853a5a1b3Sopenharmony_ci  General Public License for more details.
1953a5a1b3Sopenharmony_ci
2053a5a1b3Sopenharmony_ci  You should have received a copy of the GNU Lesser General Public License
2153a5a1b3Sopenharmony_ci  along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
2253a5a1b3Sopenharmony_ci***/
2353a5a1b3Sopenharmony_ci
2453a5a1b3Sopenharmony_ci#include <inttypes.h>
2553a5a1b3Sopenharmony_ci
2653a5a1b3Sopenharmony_ci#include <pulse/def.h>
2753a5a1b3Sopenharmony_ci#include <pulse/context.h>
2853a5a1b3Sopenharmony_ci#include <pulse/cdecl.h>
2953a5a1b3Sopenharmony_ci#include <pulse/version.h>
3053a5a1b3Sopenharmony_ci
3153a5a1b3Sopenharmony_ci/** \page subscribe Event Subscription
3253a5a1b3Sopenharmony_ci *
3353a5a1b3Sopenharmony_ci * \section overv_sec Overview
3453a5a1b3Sopenharmony_ci *
3553a5a1b3Sopenharmony_ci * The application can be notified, asynchronously, whenever the internal
3653a5a1b3Sopenharmony_ci * layout of the server changes. Possible notifications are described in the
3753a5a1b3Sopenharmony_ci * \ref pa_subscription_event_type and \ref pa_subscription_mask
3853a5a1b3Sopenharmony_ci * enumerations.
3953a5a1b3Sopenharmony_ci *
4053a5a1b3Sopenharmony_ci * The application sets the notification mask using pa_context_subscribe()
4153a5a1b3Sopenharmony_ci * and the function that will be called whenever a notification occurs using
4253a5a1b3Sopenharmony_ci * pa_context_set_subscribe_callback().
4353a5a1b3Sopenharmony_ci *
4453a5a1b3Sopenharmony_ci * The callback will be called with a \ref pa_subscription_event_type_t
4553a5a1b3Sopenharmony_ci * representing the event that caused the callback. Clients can examine what
4653a5a1b3Sopenharmony_ci * object changed using \ref PA_SUBSCRIPTION_EVENT_FACILITY_MASK. The actual
4753a5a1b3Sopenharmony_ci * event type can then be extracted with \ref PA_SUBSCRIPTION_EVENT_TYPE_MASK.
4853a5a1b3Sopenharmony_ci * Please note that the masked values are integers, not flags (so you will
4953a5a1b3Sopenharmony_ci * check the object/event type using a comparison not a binary AND). For
5053a5a1b3Sopenharmony_ci * example, the callback might look something like:
5153a5a1b3Sopenharmony_ci *
5253a5a1b3Sopenharmony_ci@verbatim
5353a5a1b3Sopenharmony_civoid my_subscription_callback(pa_context *c, pa_subscription_event_type_t t,
5453a5a1b3Sopenharmony_ci                              uint32_t idx, void *userdata) {
5553a5a1b3Sopenharmony_ci    if ((t & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SOURCE) {
5653a5a1b3Sopenharmony_ci        if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
5753a5a1b3Sopenharmony_ci            ... a source was added, let's do stuff! ...
5853a5a1b3Sopenharmony_ci        }
5953a5a1b3Sopenharmony_ci    }
6053a5a1b3Sopenharmony_ci}
6153a5a1b3Sopenharmony_ci@endverbatim
6253a5a1b3Sopenharmony_ci */
6353a5a1b3Sopenharmony_ci
6453a5a1b3Sopenharmony_ci/** \file
6553a5a1b3Sopenharmony_ci * Daemon introspection event subscription subsystem.
6653a5a1b3Sopenharmony_ci *
6753a5a1b3Sopenharmony_ci * See also \subpage subscribe
6853a5a1b3Sopenharmony_ci */
6953a5a1b3Sopenharmony_ci
7053a5a1b3Sopenharmony_ciPA_C_DECL_BEGIN
7153a5a1b3Sopenharmony_ci
7253a5a1b3Sopenharmony_ci/** Subscription event callback prototype */
7353a5a1b3Sopenharmony_citypedef void (*pa_context_subscribe_cb_t)(pa_context *c, pa_subscription_event_type_t t, uint32_t idx, void *userdata);
7453a5a1b3Sopenharmony_ci
7553a5a1b3Sopenharmony_ci/** Enable event notification */
7653a5a1b3Sopenharmony_cipa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_context_success_cb_t cb, void *userdata);
7753a5a1b3Sopenharmony_ci
7853a5a1b3Sopenharmony_ci/** Set the context specific call back function that is called whenever the state of the daemon changes */
7953a5a1b3Sopenharmony_civoid pa_context_set_subscribe_callback(pa_context *c, pa_context_subscribe_cb_t cb, void *userdata);
8053a5a1b3Sopenharmony_ci
8153a5a1b3Sopenharmony_ciPA_C_DECL_END
8253a5a1b3Sopenharmony_ci
8353a5a1b3Sopenharmony_ci#endif
84