Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/thirdparty/linuxbsd_headers/pulse/mainloop-api.h
9905 views
1
#ifndef foomainloopapihfoo
2
#define foomainloopapihfoo
3
4
/***
5
This file is part of PulseAudio.
6
7
Copyright 2004-2006 Lennart Poettering
8
Copyright 2006 Pierre Ossman <[email protected]> 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
12
published by the Free Software Foundation; either version 2.1 of the
13
License, 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
Lesser General Public License for more details.
19
20
You should have received a copy of the GNU Lesser General Public
21
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
22
***/
23
24
#include <sys/time.h>
25
26
#include <pulse/cdecl.h>
27
#include <pulse/version.h>
28
29
/** \file
30
*
31
* Main loop abstraction layer. Both the PulseAudio core and the
32
* PulseAudio client library use a main loop abstraction layer. Due to
33
* this it is possible to embed PulseAudio into other
34
* applications easily. Two main loop implementations are
35
* currently available:
36
* \li A minimal implementation based on the C library's poll() function (See \ref mainloop.h)
37
* \li A wrapper around the GLIB main loop. Use this to embed PulseAudio into your GLIB/GTK+/GNOME programs (See \ref glib-mainloop.h)
38
*
39
* The structure pa_mainloop_api is used as vtable for the main loop abstraction.
40
*
41
* This mainloop abstraction layer has no direct support for UNIX signals. Generic, mainloop implementation agnostic support is available through \ref mainloop-signal.h.
42
* */
43
44
PA_C_DECL_BEGIN
45
46
/** An abstract mainloop API vtable */
47
typedef struct pa_mainloop_api pa_mainloop_api;
48
49
/** A bitmask for IO events */
50
typedef enum pa_io_event_flags {
51
PA_IO_EVENT_NULL = 0, /**< No event */
52
PA_IO_EVENT_INPUT = 1, /**< Input event */
53
PA_IO_EVENT_OUTPUT = 2, /**< Output event */
54
PA_IO_EVENT_HANGUP = 4, /**< Hangup event */
55
PA_IO_EVENT_ERROR = 8 /**< Error event */
56
} pa_io_event_flags_t;
57
58
/** An opaque IO event source object */
59
typedef struct pa_io_event pa_io_event;
60
/** An IO event callback prototype \since 0.9.3 */
61
typedef void (*pa_io_event_cb_t)(pa_mainloop_api*ea, pa_io_event* e, int fd, pa_io_event_flags_t events, void *userdata);
62
/** A IO event destroy callback prototype \since 0.9.3 */
63
typedef void (*pa_io_event_destroy_cb_t)(pa_mainloop_api*a, pa_io_event *e, void *userdata);
64
65
/** An opaque timer event source object */
66
typedef struct pa_time_event pa_time_event;
67
/** A time event callback prototype \since 0.9.3 */
68
typedef void (*pa_time_event_cb_t)(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata);
69
/** A time event destroy callback prototype \since 0.9.3 */
70
typedef void (*pa_time_event_destroy_cb_t)(pa_mainloop_api*a, pa_time_event *e, void *userdata);
71
72
/** An opaque deferred event source object. Events of this type are triggered once in every main loop iteration */
73
typedef struct pa_defer_event pa_defer_event;
74
/** A defer event callback prototype \since 0.9.3 */
75
typedef void (*pa_defer_event_cb_t)(pa_mainloop_api*a, pa_defer_event* e, void *userdata);
76
/** A defer event destroy callback prototype \since 0.9.3 */
77
typedef void (*pa_defer_event_destroy_cb_t)(pa_mainloop_api*a, pa_defer_event *e, void *userdata);
78
79
/** An abstract mainloop API vtable */
80
struct pa_mainloop_api {
81
/** A pointer to some private, arbitrary data of the main loop implementation */
82
void *userdata;
83
84
/** Create a new IO event source object */
85
pa_io_event* (*io_new)(pa_mainloop_api*a, int fd, pa_io_event_flags_t events, pa_io_event_cb_t cb, void *userdata);
86
/** Enable or disable IO events on this object */
87
void (*io_enable)(pa_io_event* e, pa_io_event_flags_t events);
88
/** Free a IO event source object */
89
void (*io_free)(pa_io_event* e);
90
/** Set a function that is called when the IO event source is destroyed. Use this to free the userdata argument if required */
91
void (*io_set_destroy)(pa_io_event *e, pa_io_event_destroy_cb_t cb);
92
93
/** Create a new timer event source object for the specified Unix time */
94
pa_time_event* (*time_new)(pa_mainloop_api*a, const struct timeval *tv, pa_time_event_cb_t cb, void *userdata);
95
/** Restart a running or expired timer event source with a new Unix time */
96
void (*time_restart)(pa_time_event* e, const struct timeval *tv);
97
/** Free a deferred timer event source object */
98
void (*time_free)(pa_time_event* e);
99
/** Set a function that is called when the timer event source is destroyed. Use this to free the userdata argument if required */
100
void (*time_set_destroy)(pa_time_event *e, pa_time_event_destroy_cb_t cb);
101
102
/** Create a new deferred event source object */
103
pa_defer_event* (*defer_new)(pa_mainloop_api*a, pa_defer_event_cb_t cb, void *userdata);
104
/** Enable or disable a deferred event source temporarily */
105
void (*defer_enable)(pa_defer_event* e, int b);
106
/** Free a deferred event source object */
107
void (*defer_free)(pa_defer_event* e);
108
/** Set a function that is called when the deferred event source is destroyed. Use this to free the userdata argument if required */
109
void (*defer_set_destroy)(pa_defer_event *e, pa_defer_event_destroy_cb_t cb);
110
111
/** Exit the main loop and return the specified retval*/
112
void (*quit)(pa_mainloop_api*a, int retval);
113
};
114
115
/** Run the specified callback function once from the main loop using an
116
* anonymous defer event. If the mainloop runs in a different thread, you need
117
* to follow the mainloop implementation's rules regarding how to safely create
118
* defer events. In particular, if you're using \ref pa_threaded_mainloop, you
119
* must lock the mainloop before calling this function. */
120
void pa_mainloop_api_once(pa_mainloop_api*m, void (*callback)(pa_mainloop_api*m, void *userdata), void *userdata);
121
122
PA_C_DECL_END
123
124
#endif
125
126