PulseAudio 1.1
mainloop-api.h
Go to the documentation of this file.
00001 #ifndef foomainloopapihfoo
00002 #define foomainloopapihfoo
00003 
00004 /***
00005   This file is part of PulseAudio.
00006 
00007   Copyright 2004-2006 Lennart Poettering
00008   Copyright 2006 Pierre Ossman <ossman@cendio.se> for Cendio AB
00009 
00010   PulseAudio is free software; you can redistribute it and/or modify
00011   it under the terms of the GNU Lesser General Public License as
00012   published by the Free Software Foundation; either version 2.1 of the
00013   License, or (at your option) any later version.
00014 
00015   PulseAudio is distributed in the hope that it will be useful, but
00016   WITHOUT ANY WARRANTY; without even the implied warranty of
00017   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018   Lesser General Public License for more details.
00019 
00020   You should have received a copy of the GNU Lesser General Public
00021   License along with PulseAudio; if not, write to the Free Software
00022   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023   USA.
00024 ***/
00025 
00026 #include <sys/time.h>
00027 
00028 #include <pulse/cdecl.h>
00029 #include <pulse/version.h>
00030 
00046 PA_C_DECL_BEGIN
00047 
00049 typedef struct pa_mainloop_api pa_mainloop_api;
00050 
00052 typedef enum pa_io_event_flags {
00053     PA_IO_EVENT_NULL = 0,     
00054     PA_IO_EVENT_INPUT = 1,    
00055     PA_IO_EVENT_OUTPUT = 2,   
00056     PA_IO_EVENT_HANGUP = 4,   
00057     PA_IO_EVENT_ERROR = 8     
00058 } pa_io_event_flags_t;
00059 
00061 typedef struct pa_io_event pa_io_event;
00063 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);
00065 typedef void (*pa_io_event_destroy_cb_t)(pa_mainloop_api*a, pa_io_event *e, void *userdata);
00066 
00068 typedef struct pa_time_event pa_time_event;
00070 typedef void (*pa_time_event_cb_t)(pa_mainloop_api*a, pa_time_event* e, const struct timeval *tv, void *userdata);
00072 typedef void (*pa_time_event_destroy_cb_t)(pa_mainloop_api*a, pa_time_event *e, void *userdata);
00073 
00075 typedef struct pa_defer_event pa_defer_event;
00077 typedef void (*pa_defer_event_cb_t)(pa_mainloop_api*a, pa_defer_event* e, void *userdata);
00079 typedef void (*pa_defer_event_destroy_cb_t)(pa_mainloop_api*a, pa_defer_event *e, void *userdata);
00080 
00082 struct pa_mainloop_api {
00084     void *userdata;
00085 
00087     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);
00089     void (*io_enable)(pa_io_event* e, pa_io_event_flags_t events);
00091     void (*io_free)(pa_io_event* e);
00093     void (*io_set_destroy)(pa_io_event *e, pa_io_event_destroy_cb_t cb);
00094 
00096     pa_time_event* (*time_new)(pa_mainloop_api*a, const struct timeval *tv, pa_time_event_cb_t cb, void *userdata);
00098     void (*time_restart)(pa_time_event* e, const struct timeval *tv);
00100     void (*time_free)(pa_time_event* e);
00102     void (*time_set_destroy)(pa_time_event *e, pa_time_event_destroy_cb_t cb);
00103 
00105     pa_defer_event* (*defer_new)(pa_mainloop_api*a, pa_defer_event_cb_t cb, void *userdata);
00107     void (*defer_enable)(pa_defer_event* e, int b);
00109     void (*defer_free)(pa_defer_event* e);
00111     void (*defer_set_destroy)(pa_defer_event *e, pa_defer_event_destroy_cb_t cb);
00112 
00114     void (*quit)(pa_mainloop_api*a, int retval);
00115 };
00116 
00118 void pa_mainloop_api_once(pa_mainloop_api*m, void (*callback)(pa_mainloop_api*m, void *userdata), void *userdata);
00119 
00120 PA_C_DECL_END
00121 
00122 #endif