Whole document tree
    

Whole document tree

libao - Documentation

libao documentation

libao version 0.8.0 - 20010804

libao Overview

Libao is designed to make it easy to do simple audio output using various audio devices and libraries. For this reason, complex audio control features are missing and will probably never be added. However, if you just want to be able to open whatever audio device is available and play sound, libao should be just fine.

The libao API makes a distinction between drivers and devices. A driver is a set of functions that allow audio to be played on a particular platform (i.e. Solaris, ESD, etc.). A device is a particular output target that uses a driver. In addition, libao distinguishes between live output drivers, which write audio to playback devices (sound cards, etc.), and file output drivers, which write audio to disk in a particular format.

To use libao in your program, you need to follow these steps:

  • Include the <ao/ao.h> header into your program.

  • Call ao_initialize() to initialize the library. This loads the plugins from disk, reads the libao configuration files, and identifies an appropriate default output driver if none is specified in the configuration files.

  • Call ao_default_driver_id() to get the ID number of the default output driver. This may not be successful if no audio hardware is available, it is in use, or is not in the "standard" configuration. If you want to specify a particular output driver, you may call ao_driver_id() with a string corresponding to the short name of the device (i.e. "oss", "wav", etc.) instead.

  • If you are using the default device, no extra options are needed. However, if you wish to to pass special options to the driver, you will need to:

    • Create an option list pointer of type (ao_option *) and initialize it to NULL.

    • Through successive calls to ao_append_option(), add any driver-specific options you need. Note that the options take the form of key/value pairs where supported keys are listed in the driver documentation.

  • Call ao_open_live() and save the returned device pointer. If you are using a file output driver, you will need to call ao_open_file() instead.

  • Call ao_play() to output each block of audio.

  • Call ao_close() to close the device. Note that this will automatically free the memory that was allocated for the device. Do not attempt to free the device pointer yourself!

  • Call ao_shutdown() to close the library.



copyright © 2001 Stan Seibert

xiph.org
indigo@aztec.asu.edu

libao documentation

libao version 0.8.0 - 20010804