PulseAudio  16.0
simple.h File Reference

A simple but limited synchronous playback and recording API. More...

Go to the source code of this file.

Typedefs

typedef struct pa_simple pa_simple
 

Functions

pa_simplepa_simple_new (const char *server, const char *name, pa_stream_direction_t dir, const char *dev, const char *stream_name, const pa_sample_spec *ss, const pa_channel_map *map, const pa_buffer_attr *attr, int *error)
 Create a new connection to the server. More...
 
void pa_simple_free (pa_simple *s)
 Close and free the connection to the server. More...
 
int pa_simple_write (pa_simple *s, const void *data, size_t bytes, int *error)
 Write some data to the server. More...
 
int pa_simple_drain (pa_simple *s, int *error)
 Wait until all data already written is played by the daemon. More...
 
int pa_simple_read (pa_simple *s, void *data, size_t bytes, int *error)
 Read some data from the server. More...
 
pa_usec_t pa_simple_get_latency (pa_simple *s, int *error)
 Return the playback or record latency. More...
 
int pa_simple_flush (pa_simple *s, int *error)
 Flush the playback or record buffer. More...
 

Detailed Description

A simple but limited synchronous playback and recording API.

This is a synchronous, simplified wrapper around the standard asynchronous API.

See also Simple API

Typedef Documentation

◆ pa_simple

typedef struct pa_simple pa_simple

Function Documentation

◆ pa_simple_drain()

int pa_simple_drain ( pa_simple s,
int *  error 
)

Wait until all data already written is played by the daemon.

Returns zero on success, negative on error.

Examples
pacat-simple.c.

◆ pa_simple_flush()

int pa_simple_flush ( pa_simple s,
int *  error 
)

Flush the playback or record buffer.

This discards any audio in the buffer. Returns zero on success, negative on error.

◆ pa_simple_free()

void pa_simple_free ( pa_simple s)

Close and free the connection to the server.

The connection object becomes invalid when this is called.

Examples
pacat-simple.c, and parec-simple.c.

◆ pa_simple_get_latency()

pa_usec_t pa_simple_get_latency ( pa_simple s,
int *  error 
)

Return the playback or record latency.

Examples
pacat-simple.c.

◆ pa_simple_new()

pa_simple* pa_simple_new ( const char *  server,
const char *  name,
pa_stream_direction_t  dir,
const char *  dev,
const char *  stream_name,
const pa_sample_spec ss,
const pa_channel_map map,
const pa_buffer_attr attr,
int *  error 
)

Create a new connection to the server.

Parameters
serverServer name, or NULL for default
nameA descriptive name for this client (application name, ...)
dirOpen this stream for recording or playback?
devSink (resp. source) name, or NULL for default
stream_nameA descriptive name for this stream (application name, song title, ...)
ssThe sample type to use
mapThe channel map to use, or NULL for default
attrBuffering attributes, or NULL for default
errorA pointer where the error code is stored when the routine returns NULL. It is OK to pass NULL here.
Examples
pacat-simple.c, and parec-simple.c.

◆ pa_simple_read()

int pa_simple_read ( pa_simple s,
void *  data,
size_t  bytes,
int *  error 
)

Read some data from the server.

This function blocks until bytes amount of data has been received from the server, or until an error occurs. Returns zero on success, negative on failure.

Parameters
sThe connection object.
dataA pointer to a buffer.
bytesThe number of bytes to read.
errorA pointer where the error code is stored when the function returns a negative value. It is OK to pass NULL here.
Examples
parec-simple.c.

◆ pa_simple_write()

int pa_simple_write ( pa_simple s,
const void *  data,
size_t  bytes,
int *  error 
)

Write some data to the server.

Returns zero on success, negative on error.

Examples
pacat-simple.c.