PulseAudio  5.0
mainloop-api.h File Reference

Main loop abstraction layer. More...

Go to the source code of this file.

Data Structures

struct  pa_mainloop_api
 An abstract mainloop API vtable. More...
 

Typedefs

typedef struct pa_mainloop_api pa_mainloop_api
 An abstract mainloop API vtable. More...
 
typedef enum pa_io_event_flags pa_io_event_flags_t
 A bitmask for IO events. More...
 
typedef struct pa_io_event pa_io_event
 An opaque IO event source object. More...
 
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)
 An IO event callback prototype. More...
 
typedef void(* pa_io_event_destroy_cb_t )(pa_mainloop_api *a, pa_io_event *e, void *userdata)
 A IO event destroy callback prototype \ since 0.9.3. More...
 
typedef struct pa_time_event pa_time_event
 An opaque timer event source object. More...
 
typedef void(* pa_time_event_cb_t )(pa_mainloop_api *a, pa_time_event *e, const struct timeval *tv, void *userdata)
 A time event callback prototype. More...
 
typedef void(* pa_time_event_destroy_cb_t )(pa_mainloop_api *a, pa_time_event *e, void *userdata)
 A time event destroy callback prototype \ since 0.9.3. More...
 
typedef struct pa_defer_event pa_defer_event
 An opaque deferred event source object. More...
 
typedef void(* pa_defer_event_cb_t )(pa_mainloop_api *a, pa_defer_event *e, void *userdata)
 A defer event callback prototype. More...
 
typedef void(* pa_defer_event_destroy_cb_t )(pa_mainloop_api *a, pa_defer_event *e, void *userdata)
 A defer event destroy callback prototype \ since 0.9.3. More...
 

Enumerations

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
}
 A bitmask for IO events. More...
 

Functions

void pa_mainloop_api_once (pa_mainloop_api *m, void(*callback)(pa_mainloop_api *m, void *userdata), void *userdata)
 Run the specified callback function once from the main loop using an anonymous defer event. More...
 

Detailed Description

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. Two main loop implementations are currently available:

  • A minimal implementation based on the C library's poll() function (See mainloop.h)
  • A wrapper around the GLIB main loop. Use this to embed PulseAudio into your GLIB/GTK+/GNOME programs (See glib-mainloop.h)

The structure pa_mainloop_api is used as 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 mainloop-signal.h.

Typedef Documentation

An opaque deferred event source object.

Events of this type are triggered once in every main loop iteration

typedef void(* pa_defer_event_cb_t)(pa_mainloop_api *a, pa_defer_event *e, void *userdata)

A defer event callback prototype.

Since
0.9.3
typedef void(* pa_defer_event_destroy_cb_t)(pa_mainloop_api *a, pa_defer_event *e, void *userdata)

A defer event destroy callback prototype \ since 0.9.3.

typedef struct pa_io_event pa_io_event

An opaque IO event source object.

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)

An IO event callback prototype.

Since
0.9.3
typedef void(* pa_io_event_destroy_cb_t)(pa_mainloop_api *a, pa_io_event *e, void *userdata)

A IO event destroy callback prototype \ since 0.9.3.

A bitmask for IO events.

An abstract mainloop API vtable.

typedef struct pa_time_event pa_time_event

An opaque timer event source object.

typedef void(* pa_time_event_cb_t)(pa_mainloop_api *a, pa_time_event *e, const struct timeval *tv, void *userdata)

A time event callback prototype.

Since
0.9.3
typedef void(* pa_time_event_destroy_cb_t)(pa_mainloop_api *a, pa_time_event *e, void *userdata)

A time event destroy callback prototype \ since 0.9.3.

Enumeration Type Documentation

A bitmask for IO events.

Enumerator
PA_IO_EVENT_NULL 

No event.

PA_IO_EVENT_INPUT 

Input event.

PA_IO_EVENT_OUTPUT 

Output event.

PA_IO_EVENT_HANGUP 

Hangup event.

PA_IO_EVENT_ERROR 

Error event.

Function Documentation

void pa_mainloop_api_once ( pa_mainloop_api m,
void(*)(pa_mainloop_api *m, void *userdata)  callback,
void *  userdata 
)

Run the specified callback function once from the main loop using an anonymous defer event.

Note that this performs multiple mainloop operations non-atomically. If, for example, you are using a pa_threaded_mainloop, you will need to take the mainloop lock before this call.