libao documentation | libao version 1.2.0 - 201401271

# ao_open_file

declared in "ao/ao.h";

Open a file for audio output. The file format is determined by the audio driver used.

    ao_device* ao_open_file(int driver_id, const char *filename, int overwrite,
                                   ao_sample_format *format, ao_option *options);

### Parameters

driver_id
  The ID number of the driver as returned by ao_driver_id().
filename
  Name of the file in which to store the audio. The special filename "-" corresponds to `stdout`.
overwrite
  If non-zero, the file is automatically overwritten. If zero, then a preexisting file will cause the function to report a failure.
format
  Pointer to a struct describing the sample format. The caller retains ownership of this structure.
options
  A linked list of options to be passed to the driver or NULL if no options are needed. Unsupported options are ignored.

### Return Values

> - non-NULL pointer inicates success. This pointer must be passed in subsequent calls to ao_play() and ao_close().
> - NULL indicates failure. `errno` will contain the specific cause of the failure:
> - AO_ENODRIVER - No driver corresponds to `driver_id`.
> - AO_ENOTFILE - This driver is not a file output driver.
> - AO_EBADOPTION - A valid option key has an invalid value.
> - AO_EOPENFILE - Cannot open the file.
> - AO_EFILEEXISTS - The file already exists. (Only if `overwrite == 0`)
> - AO_EFAIL - Any other cause of failure.

### Notes

Live output drivers cannot be used with this function. Use ao_open_live() instead. Some file formats (notably .WAV) cannot be correctly written to non-seekable files (like `stdout`).

When passed to ao_open_file(), the `byte_format` member of an ao_sample_format struct does not specify the byte format that will be used in the file output, just the input sample format.

copyright © 2001-2003 Stan Seibert, 2010-2011 Monty | xiph.org monty@xiph.org
libao documentation | libao version 1.2.0 - 201401271