PulseAudio  5.0
Simple API

Overview

The simple API is designed for applications with very basic sound playback or capture needs. It can only support a single stream per connection and has no support for handling of complex features like events, channel mappings and volume control. It is, however, very simple to use and quite sufficient for many programs.

Connecting

The first step before using the sound system is to connect to the server. This is normally done this way:

ss.channels = 2;
ss.rate = 44100;
s = pa_simple_new(NULL, // Use the default server.
"Fooapp", // Our application's name.
NULL, // Use the default device.
"Music", // Description of our stream.
&ss, // Our sample format.
NULL, // Use default channel map
NULL, // Use default buffering attributes.
NULL, // Ignore error code.
);

At this point a connected object is returned, or NULL if there was a problem connecting.

Transferring Data

Once the connection is established to the server, data can start flowing. Using the connection is very similar to the normal read() and write() system calls. The main difference is that they're called pa_simple_read() and pa_simple_write(). Note that these operations always block.

Buffer control

If a playback stream is used then the following operation is available:

Cleanup

Once playback or capture is complete, the connection should be closed and resources freed. This is done through: