Open Broadcaster Software
Free, open source software for live streaming and recording
pulseaudio-wrapper.h File Reference

Go to the source code of this file.

Data Structures

struct  pulseaudio_default_output
 
struct  enum_cb
 

Functions

void get_default_id (char **id)
 
bool devices_match (const char *id1, const char *id2)
 
int_fast32_t pulseaudio_init ()
 
void pulseaudio_unref ()
 
void pulseaudio_lock ()
 
void pulseaudio_unlock ()
 
void pulseaudio_wait ()
 
void pulseaudio_signal (int wait_for_accept)
 
void pulseaudio_accept ()
 
int_fast32_t pulseaudio_get_source_info_list (pa_source_info_cb_t cb, void *userdata)
 
int_fast32_t pulseaudio_get_source_info (pa_source_info_cb_t cb, const char *name, void *userdata)
 
int_fast32_t pulseaudio_get_server_info (pa_server_info_cb_t cb, void *userdata)
 
pa_stream * pulseaudio_stream_new (const char *name, const pa_sample_spec *ss, const pa_channel_map *map)
 
int_fast32_t pulseaudio_connect_playback (pa_stream *s, const char *name, const pa_buffer_attr *attr, pa_stream_flags_t flags)
 
void pulseaudio_write_callback (pa_stream *p, pa_stream_request_cb_t cb, void *userdata)
 
void pulseaudio_set_underflow_callback (pa_stream *p, pa_stream_notify_cb_t cb, void *userdata)
 

Function Documentation

◆ devices_match()

bool devices_match ( const char *  id1,
const char *  id2 
)

◆ get_default_id()

void get_default_id ( char **  id)

◆ pulseaudio_accept()

void pulseaudio_accept ( )

Signal the waiting callback to return

This function is used in conjunction with pulseaudio_signal()

◆ pulseaudio_connect_playback()

int_fast32_t pulseaudio_connect_playback ( pa_stream *  s,
const char *  name,
const pa_buffer_attr *  attr,
pa_stream_flags_t  flags 
)

Connect to a pulseaudio playback stream

Parameters
spa_stream to connect to. NULL for default
attrpa_buffer_attr
nameDevice name. NULL for default device
flagspa_stream_flags_t
Returns
negative on error

◆ pulseaudio_get_server_info()

int_fast32_t pulseaudio_get_server_info ( pa_server_info_cb_t  cb,
void *  userdata 
)

Request server information

The function will block until the operation was executed and the mainloop called the provided callback function.

Returns
negative on error
Note
The function will block until the server context is ready.
Warning
call without active locks

◆ pulseaudio_get_source_info()

int_fast32_t pulseaudio_get_source_info ( pa_source_info_cb_t  cb,
const char *  name,
void *  userdata 
)

Request source information from a specific source

The function will block until the operation was executed and the mainloop called the provided callback function.

Parameters
cbpointer to the callback function
namethe source name to get information for
userdatapointer to userdata the callback will be called with
Returns
negative on error
Note
The function will block until the server context is ready.
Warning
call without active locks

◆ pulseaudio_get_source_info_list()

int_fast32_t pulseaudio_get_source_info_list ( pa_source_info_cb_t  cb,
void *  userdata 
)

Request source information

The function will block until the operation was executed and the mainloop called the provided callback function.

Returns
negative on error
Note
The function will block until the server context is ready.
Warning
call without active locks

◆ pulseaudio_init()

int_fast32_t pulseaudio_init ( )

Initialize the pulseaudio mainloop and increase the reference count

◆ pulseaudio_lock()

void pulseaudio_lock ( )

Lock the mainloop

In order to allow for multiple threads to use the same mainloop pulseaudio provides it's own locking mechanism. This function should be called before using any pulseaudio function that is in any way related to the mainloop or context.

Note
use of this function may cause deadlocks
Warning
do not use with pulseaudio_ wrapper functions

◆ pulseaudio_set_underflow_callback()

void pulseaudio_set_underflow_callback ( pa_stream *  p,
pa_stream_notify_cb_t  cb,
void *  userdata 
)

Sets a callback function for when an underflow happen

Parameters
ppa_stream to connect to. NULL for default
cbpa_stream_notify_cb_t
userdatapointer to userdata the callback will be called with

◆ pulseaudio_signal()

void pulseaudio_signal ( int  wait_for_accept)

Wait for accept signal from calling thread

This function tells the pulseaudio mainloop whether the data provided to the callback should be retained until the calling thread executes pulseaudio_accept()

If wait_for_accept is 0 the function returns and the data is freed.

◆ pulseaudio_stream_new()

pa_stream* pulseaudio_stream_new ( const char *  name,
const pa_sample_spec *  ss,
const pa_channel_map *  map 
)

Create a new stream with the default properties

Note
The function will block until the server context is ready.
Warning
call without active locks

◆ pulseaudio_unlock()

void pulseaudio_unlock ( )

Unlock the mainloop

See also
pulseaudio_lock()

◆ pulseaudio_unref()

void pulseaudio_unref ( )

Unreference the pulseaudio mainloop, when the reference count reaches zero the mainloop will automatically be destroyed

◆ pulseaudio_wait()

void pulseaudio_wait ( )

Wait for events to happen

This function should be called when waiting for an event to happen.

◆ pulseaudio_write_callback()

void pulseaudio_write_callback ( pa_stream *  p,
pa_stream_request_cb_t  cb,
void *  userdata 
)

Sets a callback function for when data can be written to the stream

Parameters
ppa_stream to connect to. NULL for default
cbpa_stream_request_cb_t
userdatapointer to userdata the callback will be called with