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 handling of complex features like events, channel mappings and volume control. It is, however, very simple to use and quite sufficent for many programs.
The first step before using the sound system is to connect to the server. This is normally done this way:
At this point a connected object is returned, or NULL if there was a problem connecting.
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 call
pa_simple_read() and
pa_simple_write(). Note that these operations always block.
If a playback stream is used then a few other operations are available:
- pa_simple_drain() - Will wait for all sent data to finish playing.
- pa_simple_flush() - Will throw away all data currently in buffers.
- pa_simple_get_playback_latency() - Will return the total latency of the playback pipeline.
Once playback or capture is complete, the connection should be closed and resources freed. This is done through: