[ao] Two patches for libao2

John Ferlito johnf at inodes.org
Tue Oct 6 02:25:04 UTC 2009


Hi Heikki,

So libao is currently not maintained upstream. In the appropriate IRC
channels I'm lead to believe that there are better libraries out there
that should be used instead.

If so many debian packages didn't link against it I would seriously
consider dropping it all together.

It doesn't sound like it's worth anyone's time maintaining libao
properly upstream. I do have the appropriate access so I might start
making point releases which just role in patches that are lying
around. Assuming I can find the time and then roll out new debian
packages.


Cheers,
John

On Sun, Aug 30, 2009 at 11:52:01PM +0300, Heikki Orsila wrote:
> Please consider these two (Git) patches for inclusion into libao2.
> 
> 1. Trivial fix
> 
> 2. Make driver specific options configurable
> 	- With this patch, one can for example set ALSA's buffer_time
> 	  option for all programs that use libao
> 
> -- 
> Heikki Orsila
> heikki.orsila at iki.fi
> http://www.iki.fi/shd

> From 19f07a23f4f9e641e9d208930a346c3642c2869b Mon Sep 17 00:00:00 2001
> From: Heikki Orsila <heikki.orsila at iki.fi>
> Date: Sun, 30 Aug 2009 22:49:57 +0300
> Subject: [PATCH 1/2] audio_out: Handle strdup()'s return value correctly [CORRECTIVE]
> 
> ---
>  src/audio_out.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/src/audio_out.c b/src/audio_out.c
> index 88660c0..6e39047 100644
> --- a/src/audio_out.c
> +++ b/src/audio_out.c
> @@ -613,6 +613,7 @@ int ao_append_option(ao_option **options, const char *key, const char *value)
>  
>  	op->key = strdup(key);
>  	op->value = strdup(value);
> +	if (op->key == NULL || op->value == NULL) return 0;
>  	op->next = NULL;
>  
>  	if ((list = *options) != NULL) {
> -- 
> 1.6.1.2
> 

> From e905c74eca5c504d1665125df7a9523a685b987f Mon Sep 17 00:00:00 2001
> From: Heikki Orsila <heikki.orsila at iki.fi>
> Date: Sun, 30 Aug 2009 23:46:48 +0300
> Subject: [PATCH 2/2] Make driver specific options configurable
> 
> ---
>  doc/ao_open_file.html |    3 ++-
>  doc/ao_open_live.html |    3 ++-
>  doc/config.html       |    4 ++++
>  libao.conf.5          |    4 ++++
>  src/ao_private.h      |    3 +++
>  src/audio_out.c       |    8 ++++++--
>  src/config.c          |   32 +++++++++++++++++++++++---------
>  7 files changed, 44 insertions(+), 13 deletions(-)
> 
> diff --git a/doc/ao_open_file.html b/doc/ao_open_file.html
> index f6c3935..2a70aea 100644
> --- a/doc/ao_open_file.html
> +++ b/doc/ao_open_file.html
> @@ -46,7 +46,8 @@ preexisting file will cause the function to report a failure.</dd>
>  <dd>Pointer to a struct describing the sample format.  The caller retains ownership of this structure.</dd>
>  <dt><i>options</i></dt>
>  <dd>A linked list of options to be passed to the driver or NULL if no options
> -are needed.  Unsupported options are ignored.</dd>
> +are needed. If options is NULL, default values from libao.conf are used,
> +otherwise the defaults are ignored. Unsupported options are ignored.</dd>
>  </dl>
>  
>  <h3>Return Values</h3>
> diff --git a/doc/ao_open_live.html b/doc/ao_open_live.html
> index 388c7c8..8ffc709 100644
> --- a/doc/ao_open_live.html
> +++ b/doc/ao_open_live.html
> @@ -40,7 +40,8 @@
>  <dd>Pointer to a struct describing the sample format.  The caller retains ownership of this structure.</dd>
>  <dt><i>options</i></dt>
>  <dd>A linked list of options to be passed to the driver or NULL if no options
> -are needed.  Unsupported options are ignored.</dd>
> +are needed. If options is NULL, default values from libao.conf are used,
> +otherwise the defaults are ignored. Unsupported options are ignored.</dd>
>  </dl>
>  
>  <h3>Return Values</h3>
> diff --git a/doc/config.html b/doc/config.html
> index ac580e0..5f67f24 100644
> --- a/doc/config.html
> +++ b/doc/config.html
> @@ -39,6 +39,10 @@ There can be no extra spaces anywhere on the line.  Comment lines begin with a <
>  </dd>
>  </dl>
>  
> +<p>Any other option will be passed for the audio driver as a
> +key-value pair. E.g. buffer_time=100000 will set alsa driver's buffering
> +to 100ms.</p>
> +
>  <br><br>
>  <hr noshade>
>  <table border=0 width=100%>
> diff --git a/libao.conf.5 b/libao.conf.5
> index 161346f..7ec9d30 100644
> --- a/libao.conf.5
> +++ b/libao.conf.5
> @@ -52,6 +52,10 @@ systems as well as Solaris.  The "alsa" driver is for the 0.9.x ALSA API,
>  whereas the "alsa05" driver is for the 0.5.x API.
>  .RE
>  
> +Any other option will be passed for the audio driver as a
> +key-value pair. E.g. buffer_time=100000 will set alsa driver's buffering
> +to 100ms.
> +
>  .SH EXAMPLE
>  
>  Here is an example
> diff --git a/src/ao_private.h b/src/ao_private.h
> index 9fe382f..901593b 100644
> --- a/src/ao_private.h
> +++ b/src/ao_private.h
> @@ -26,6 +26,8 @@
>  #ifndef __AO_PRIVATE_H__
>  #define __AO_PRIVATE_H__
>  
> +#include "ao/ao.h"
> +
>  /* --- Operating System Compatibility --- */
>  
>  /* 
> @@ -61,6 +63,7 @@
>  
>  typedef struct ao_config {
>  	char *default_driver;
> +	ao_option *options;
>  } ao_config;
>  
>  /* --- Functions --- */
> diff --git a/src/audio_out.c b/src/audio_out.c
> index 6e39047..14012e4 100644
> --- a/src/audio_out.c
> +++ b/src/audio_out.c
> @@ -95,7 +95,8 @@ static ao_functions *static_drivers[] = {
>  
>  static driver_list *driver_head = NULL;
>  static ao_config config = {
> -	NULL /* default_driver */
> +	NULL, /* default_driver */
> +	NULL, /* options */
>  };
>  
>  static ao_info **info_table = NULL;
> @@ -501,7 +502,10 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
>  		errno = AO_EFAIL;
>  		return NULL; /* Couldn't init internal memory */
>  	}
> -	
> +
> +	if (options == NULL)
> +		options = config.options;
> +
>  	/* Load options */
>  	while (options != NULL) {
>  		if (!funcs->set_option(device, options->key, options->value)) {
> diff --git a/src/config.c b/src/config.c
> index 7c495da..eb6cd29 100644
> --- a/src/config.c
> +++ b/src/config.c
> @@ -54,21 +54,35 @@ int read_config_file(ao_config *config, const char *config_file)
>  	FILE *fp;
>  	char line[LINE_LEN];
>  	int end;
> -	
> -	
> +	char *separator;
> +	char *key;
> +	char *value;
> +
>  	if ( !(fp = fopen(config_file, "r")) )
>  		return 0; /* Can't open file */
>  	
>  	while (fgets(line, LINE_LEN, fp)) {
>  		/* All options are key=value */
> -		
> -		if (strncmp(line, "default_driver=", 15) == 0) {
> -			free(config->default_driver);
> -			end = strlen(line);
> -			if (line[end-1] == '\n')
> -				line[end-1] = 0; /* Remove trailing newline */
> +		if (line[0] == '#')
> +			continue;
>  
> -			config->default_driver = strdup(line+15);
> +		end = strlen(line);
> +		if (line[end - 1] == '\n')
> +			line[end - 1] = 0; /* Remove trailing newline */
> +
> +		separator = strchr(line, '=');
> +		if (separator == NULL)
> +			continue;
> +		*separator = 0;
> +		key = line;
> +		value = separator + 1;
> +
> +		if (strcmp(key, "default_driver") == 0) {
> +			free(config->default_driver);
> +			config->default_driver = strdup(value);
> +		} else {
> +			/* Assume it's an option for the audio driver */
> +			ao_append_option(&config->options, key, value);
>  		}
>  	}
>  
> -- 
> 1.6.1.2
> 

> --
> http://lists.alioth.debian.org/mailman/listinfo/pkg-xiph-maint


-- 
John
Blog                        http://www.inodes.org/blog
OLPC Friends                     http://olpcfriends.org




More information about the pkg-xiph-maint mailing list