subscribe.h 3.0 KB

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