#ifndef foomainloopapihfoo
#define foomainloopapihfoo
This file is part of PulseAudio.
Copyright 2004-2006 Lennart Poettering
Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation; either version 2.1 of the
License, or (at your option) any later version.
PulseAudio is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
***/
#include <sys/time.h>
#include <pulse/cdecl.h>
#include <pulse/version.h>
*
* Main loop abstraction layer. Both the PulseAudio core and the
* PulseAudio client library use a main loop abstraction layer. Due to
* this it is possible to embed PulseAudio into other
* applications easily. Three main loop implementations are
* currently available:
* \li A minimal implementation based on the C library's poll() function
* (See \ref mainloop.h).
* \li A special version of the previous implementation where all of
* PulseAudio's internal handling runs in a separate thread
* (See \ref thread-mainloop.h).
* \li A wrapper around the GLIB main loop. Use this to embed PulseAudio into
* your GLIB/GTK+/GNOME programs (See \ref glib-mainloop.h).
*
* The structure pa_mainloop_api is used as a vtable for the main loop abstraction.
*
* This mainloop abstraction layer has no direct support for UNIX signals.
* Generic, mainloop implementation agnostic support is available through
* \ref mainloop-signal.h.
* */
PA_C_DECL_BEGIN
typedef struct pa_mainloop_api pa_mainloop_api;
typedef enum pa_io_event_flags {
PA_IO_EVENT_NULL = 0,
PA_IO_EVENT_INPUT = 1,
PA_IO_EVENT_OUTPUT = 2,
PA_IO_EVENT_HANGUP = 4,
PA_IO_EVENT_ERROR = 8
} pa_io_event_flags_t;
typedef struct pa_io_event pa_io_event;
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);
typedef void (*pa_io_event_destroy_cb_t)(pa_mainloop_api*a, pa_io_event *e, void *userdata);
typedef struct pa_time_event pa_time_event;
typedef void (*pa_time_event_cb_t)(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata);
typedef void (*pa_time_event_destroy_cb_t)(pa_mainloop_api*a, pa_time_event *e, void *userdata);
typedef struct pa_defer_event pa_defer_event;
typedef void (*pa_defer_event_cb_t)(pa_mainloop_api*a, pa_defer_event* e, void *userdata);
typedef void (*pa_defer_event_destroy_cb_t)(pa_mainloop_api*a, pa_defer_event *e, void *userdata);
struct pa_mainloop_api {
void *userdata;
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);
void (*io_enable)(pa_io_event* e, pa_io_event_flags_t events);
void (*io_free)(pa_io_event* e);
void (*io_set_destroy)(pa_io_event *e, pa_io_event_destroy_cb_t cb);
pa_time_event* (*time_new)(pa_mainloop_api*a, const struct timeval *tv, pa_time_event_cb_t cb, void *userdata);
void (*time_restart)(pa_time_event* e, const struct timeval *tv);
void (*time_free)(pa_time_event* e);
void (*time_set_destroy)(pa_time_event *e, pa_time_event_destroy_cb_t cb);
pa_defer_event* (*defer_new)(pa_mainloop_api*a, pa_defer_event_cb_t cb, void *userdata);
void (*defer_enable)(pa_defer_event* e, int b);
void (*defer_free)(pa_defer_event* e);
void (*defer_set_destroy)(pa_defer_event *e, pa_defer_event_destroy_cb_t cb);
void (*quit)(pa_mainloop_api*a, int retval);
};
* anonymous defer event. If the mainloop runs in a different thread, you need
* to follow the mainloop implementation's rules regarding how to safely create
* defer events. In particular, if you're using \ref pa_threaded_mainloop, you
* must lock the mainloop before calling this function. */
void pa_mainloop_api_once(pa_mainloop_api*m, void (*callback)(pa_mainloop_api*m, void *userdata), void *userdata);
PA_C_DECL_END
#endif