Skip to content
Snippets Groups Projects
Commit 6b3166c8 authored by Ralph Giles's avatar Ralph Giles
Browse files

API change. Rather than passing the driver options as single "key:value"
string, we have a slot for each in ao_append_option()

corresponding documentation changes, harmonized ao_append_option()
definition in the header and docs, plus some other doc fixups.


git-svn-id: http://svn.xiph.org/trunk/ao@1119 0101bb08-14d6-0310-b084-bc0e0c8e3800
parent 438bfa00
No related branches found
No related tags found
No related merge requests found
Aaron Holtzman
Stan Seibert <indigo@aztec.asu.edu>
Jack Moffitt <jack@icecast.org>
Ralph Giles <giles@ashlu.bc.ca>
0.6.0 - December 2000
- slight api modification with ao_append_option()
- fixed an option leak
0.5.0 - November 2000
- first official release under the Xiphophorus projects
libao - A Cross-platform Audio Library, Version 0.5.0
libao - A Cross-platform Audio Library, Version 0.6.0
Originally Copyright (C) Aaron Holtzman - May 1999
Changes Copyright (C) Stan Seibert - July 2000
......
dnl Process this file with autoconf to produce a configure script.
AC_INIT(src/audio_out.c)
AM_INIT_AUTOMAKE(libao,0.5.0)
AM_INIT_AUTOMAKE(libao,0.6.0)
AM_DISABLE_STATIC
dnl Library versioning
LIB_CURRENT=0
LIB_CURRENT=1
LIB_REVISION=0
LIB_AGE=0
AC_SUBST(LIB_CURRENT)
......
......@@ -20,8 +20,8 @@ this:
initialize it to NULL.
* Through successive calls to ao_append_option(), add any driver
specific options you need. Note that the option string has the
form "key:value" where supported keys are listed in the
specific options you need. Note that the options take the
form of key-value pairs where supported keys are listed in the
DRIVER file.
* Call ao_open() and save the returned device pointer.
......@@ -82,13 +82,15 @@ structure.
---
int ao_append_options(ao_option_t **options, const char *op_str)
int ao_append_option(ao_option_t **options, const char *key, const char *value)
Purpose: Append an option to a linked list of options.
Parameters:
ao_option_t **options - A pointer to the linked list pointer.
const char* op_str - The option string. Form "key:value".
ao_option_t **options - Address of a pointer to the head of the
option list, which may be NULL.
const char* key - The option key
const char* value - the setting for this particular option
Returns: 1 if the option was appended successfully
0 if the option was not appended (either due to memory
......@@ -113,8 +115,8 @@ Purpose: To open a particular device for writing.
Parameters:
int driver_id - ID number for the driver to use with this device
uint_32 bits - Bits per audio sample (8 or 16)
uint_32 rate - Samples per second (44100, 22050, etc.)
uint_32 bits - Bits per audio sample (8 or 16)
uint_32 rate - Samples per second (44100, 22050, etc.)
uint_32 channels - Audio channels (1 = mono, 2 = stereo)
ao_option_t *options - Option list
......@@ -130,7 +132,7 @@ void ao_play(ao_device_t *device, void* output_samples,
Purpose: To ouput some audio data to the device.
Parameters:
ao_device_t *device - Device pointer
ao_device_t *device - Device pointer
void *output_samples - Memory buffer containing audio data
uint_32 num_bytes - Number of bytes of audio data in memory buffer
......
......@@ -7,7 +7,7 @@ and link libao to your programs.
If you are using autoconf and automake, include the ao.m4 project in
your project (acinclude.m4 is the usual place) and call
AM_PATH_AO(minimum-required-version, action-if-found, action-if-not-found)
AM_PATH_AO(action-if-found, action-if-not-found)
in your configure.in. Please look at the ogg123 project for an example
of how this works.
......
......@@ -81,7 +81,7 @@ int ao_get_driver_id(const char *short_name);
ao_info_t *ao_get_driver_info(int driver_id);
/* driver options */
int ao_append_options(ao_option_t **options, const char *op_str);
int ao_append_option(ao_option_t **options, const char *key, const char *value);
void ao_free_options(ao_option_t *options);
/* the meat: open/play/close */
......
......@@ -272,51 +272,26 @@ void ao_close(ao_device_t *device)
/* --- Option Functions --- */
ao_option_t* _parse_option(const char* op_str)
int ao_append_option(ao_option_t **options, const char *key, const char *value)
{
char *copy;
char *value_ptr;
char *colon;
ao_option_t *op = NULL;
copy = strdup(op_str);
colon = strchr(copy, ':');
if (colon != NULL) {
value_ptr = colon + 1;
*colon = 0x00; // Null terminate the key part
/* Allocate the option structure */
op = malloc(sizeof(ao_option_t));
if (op != NULL) {
op->key = strdup(copy);
op->value = strdup(value_ptr);
op->next = NULL;
}
}
free(copy);
return op;
}
ao_option_t *op, *list;
op = malloc(sizeof(ao_option_t));
if (op == NULL) return 0;
int ao_append_option(ao_option_t **options, const char *op_str)
{
ao_option_t *temp;
temp = _parse_option(op_str);
op->key = strdup(key);
op->value = strdup(value);
op->next = NULL;
if (temp == NULL)
return 0; //Bad option format
if (*options != NULL) {
while ((*options)->next != NULL)
*options = (*options)->next;
(*options)->next = temp;
if ((list = *options) != NULL) {
list = *options;
while (list->next != NULL) list = list->next;
list->next = op;
} else {
*options = temp;
*options = op;
}
return 1;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment