From 529a2834e6b7c823e9d765b543eb6bd0568312e0 Mon Sep 17 00:00:00 2001 From: Stan Seibert <volsung@xiph.org> Date: Fri, 31 Aug 2001 23:17:55 +0000 Subject: [PATCH] API update allowing library users to get the suggested file extension associated with a particular file output driver. The additional plugin function is optional, so drivers that don't need to implement it don't have to. That's why we don't need to bump the plugin API version number. git-svn-id: http://svn.xiph.org/trunk/ao@1946 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- configure.in | 6 +-- doc/ao_file_extension.html | 67 +++++++++++++++++++++++++++++++ doc/ao_plugin_file_extension.html | 59 +++++++++++++++++++++++++++ doc/libao-api.html | 1 + doc/plugin-api.html | 1 + include/ao/ao.h | 2 + include/ao/plugin.h | 3 +- src/ao_au.c | 10 ++++- src/ao_raw.c | 9 ++++- src/ao_wav.c | 10 ++++- src/audio_out.c | 17 ++++++++ 11 files changed, 177 insertions(+), 8 deletions(-) create mode 100644 doc/ao_file_extension.html create mode 100644 doc/ao_plugin_file_extension.html diff --git a/configure.in b/configure.in index beaca63..3c856ca 100644 --- a/configure.in +++ b/configure.in @@ -6,9 +6,9 @@ AM_INIT_AUTOMAKE(libao,0.8.1) AM_DISABLE_STATIC dnl Library versioning -LIB_CURRENT=2 -LIB_REVISION=2 -LIB_AGE=0 +LIB_CURRENT=3 +LIB_REVISION=0 +LIB_AGE=1 AC_SUBST(LIB_CURRENT) AC_SUBST(LIB_REVISION) AC_SUBST(LIB_AGE) diff --git a/doc/ao_file_extension.html b/doc/ao_file_extension.html new file mode 100644 index 0000000..9859087 --- /dev/null +++ b/doc/ao_file_extension.html @@ -0,0 +1,67 @@ +<html> + +<head> +<title>libao - function - ao_file_extension</title> +<link rel=stylesheet href="style.css" type="text/css"> +</head> + +<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff"> +<table border=0 width=100%> +<tr> +<td><p class=tiny>libao documentation</p></td> +<td align=right><p class=tiny>libao version 0.8.0 - 20010804</p></td> +</tr> +</table> + +<h1>ao_file_extension</h1> + +<p><i>declared in "ao/ao.h";</i></p> + +<p>Returns the normal file extension associated with a particular +driver (like "wav" or "au"). This is just an information function to +allow library users to guess appropriate file names. You can safely +ignore the recommended extension.</p> + +<br><br> +<table border=0 color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> +char* ao_file_extension(int driver_id); +</b></pre> + </td> +</tr> +</table> + +<h3>Parameters</h3> +<dl> +<dt><i>driver_id</i></dt> +<dd>The ID number of the driver as returned by either +<a href="ao_driver_id.html">ao_driver_id()</a> or +<a href="ao_default_driver_id.html">ao_default_driver_id()</a>.</dd> +</dl> + +<h3>Return Values</h3> +<blockquote> +<li>pointer to string containing suggested file extension.</li> + +<li>NULL if this driver has no file extension associated with it or if +this driver does not exist.</li> +</blockquote> +<p> + +<br><br> +<hr noshade> +<table border=0 width=100%> +<tr valign=top> +<td><p class=tiny>copyright © 2001 Stan Seibert</p></td> +<td align=right><p class=tiny><a href="http://www.xiph.org/">xiph.org</a><br><a href="mailto:indigo@aztec.asu.edu">indigo@aztec.asu.edu</a></p></td> +</tr><tr> +<td><p class=tiny>libao documentation</p></td> +<td align=right><p class=tiny>libao version 0.8.0 - 20010804</p></td> +</tr> +</table> + +</body> + +</html> diff --git a/doc/ao_plugin_file_extension.html b/doc/ao_plugin_file_extension.html new file mode 100644 index 0000000..6cb4898 --- /dev/null +++ b/doc/ao_plugin_file_extension.html @@ -0,0 +1,59 @@ +<html> + +<head> +<title>libao - function - ao_plugin_file_extension</title> +<link rel=stylesheet href="style.css" type="text/css"> +</head> + +<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff"> +<table border=0 width=100%> +<tr> +<td><p class=tiny>libao documentation</p></td> +<td align=right><p class=tiny>libao version 0.8.0 - 20010804</p></td> +</tr> +</table> + +<h1>ao_plugin_file_extension</h1> + +<p><i>declared in "ao/plugin.h";</i></p> + +<p>Returns the normal file extension associated with this driver (like +"wav" or "au"). This is an <b>optional</b> function. Live audio +plugins do not need to implement this function.</p> + +<br><br> +<table border=0 color=black cellspacing=0 cellpadding=7> +<tr bgcolor=#cccccc> + <td> +<pre><b> +char *ao_plugin_file_extension(int driver_id); +</b></pre> + </td> +</tr> +</table> + +<h3>Return Values</h3> +<blockquote> +<li>pointer to string containing suggested file extension.</li> + +<li>NULL if this driver has no file extension associated with it. +Live audio plugins must always return NULL if they do implement this +function.</li> +</blockquote> +<p> + +<br><br> +<hr noshade> +<table border=0 width=100%> +<tr valign=top> +<td><p class=tiny>copyright © 2001 Stan Seibert</p></td> +<td align=right><p class=tiny><a href="http://www.xiph.org/">xiph.org</a><br><a href="mailto:indigo@aztec.asu.edu">indigo@aztec.asu.edu</a></p></td> +</tr><tr> +<td><p class=tiny>libao documentation</p></td> +<td align=right><p class=tiny>libao version 0.8.0 - 20010804</p></td> +</tr> +</table> + +</body> + +</html> diff --git a/doc/libao-api.html b/doc/libao-api.html index 6b43227..16ca518 100644 --- a/doc/libao-api.html +++ b/doc/libao-api.html @@ -39,6 +39,7 @@ <a href="ao_default_driver_id.html">ao_default_driver_id()</a><br> <a href="ao_driver_info.html">ao_driver_info()</a><br> <a href="ao_driver_info_list.html">ao_driver_info_list()</a><br> +<a href="ao_file_extension.html">ao_file_extension()</a><br> <br> <b>Miscellaneous</b><br> <a href="ao_is_big_endian.html">ao_is_big_endian()</a><br> diff --git a/doc/plugin-api.html b/doc/plugin-api.html index 772db4e..a36c39d 100644 --- a/doc/plugin-api.html +++ b/doc/plugin-api.html @@ -24,6 +24,7 @@ <a href="ao_plugin_play.html">ao_plugin_play()</a><br> <a href="ao_plugin_close.html">ao_plugin_close()</a><br> <a href="ao_plugin_device_clear.html">ao_plugin_device_clear()</a><br> +<a href="ao_plugin_file_extension.html">ao_plugin_file_extension()</a><br> <br><br> <hr noshade> diff --git a/include/ao/ao.h b/include/ao/ao.h index 35e608f..a25ad52 100644 --- a/include/ao/ao.h +++ b/include/ao/ao.h @@ -104,6 +104,7 @@ struct ao_functions { uint_32 num_bytes); int (*close)(ao_device *device); void (*device_clear)(ao_device *device); + char* (*file_extension)(void); }; typedef struct ao_option { @@ -135,6 +136,7 @@ int ao_driver_id(const char *short_name); int ao_default_driver_id(); ao_info *ao_driver_info(int driver_id); ao_info **ao_driver_info_list(int *driver_count); +char *ao_file_extension(int driver_id); /* miscellaneous */ int ao_is_big_endian(void); diff --git a/include/ao/plugin.h b/include/ao/plugin.h index c22f560..29a3d96 100644 --- a/include/ao/plugin.h +++ b/include/ao/plugin.h @@ -2,7 +2,7 @@ * * plugin.h - function declarations for libao plugins * - * Copyright (C) Stan Seibert - June 2001C + * Copyright (C) Stan Seibert - June 2001 * * This file is part of libao, a cross-platform audio outputlibrary. See * README for a history of this source code. @@ -42,6 +42,7 @@ int ao_plugin_play(ao_device *device, const char *output_samples, uint_32 num_bytes); int ao_plugin_close(ao_device *device); void ao_plugin_device_clear(ao_device *device); +char *ao_plugin_file_extension(); #ifdef __cplusplus } diff --git a/src/ao_au.c b/src/ao_au.c index 83d38cc..3a86902 100644 --- a/src/ao_au.c +++ b/src/ao_au.c @@ -221,6 +221,13 @@ static void ao_au_device_clear(ao_device *device) free(internal); } + +static char *ao_au_file_extension(void) +{ + return "au"; +} + + ao_functions ao_au = { ao_au_test, ao_au_driver_info, @@ -229,5 +236,6 @@ ao_functions ao_au = { ao_au_open, ao_au_play, ao_au_close, - ao_au_device_clear + ao_au_device_clear, + ao_au_file_extension }; diff --git a/src/ao_raw.c b/src/ao_raw.c index a015bf1..d963279 100644 --- a/src/ao_raw.c +++ b/src/ao_raw.c @@ -136,6 +136,12 @@ static void ao_raw_device_clear(ao_device *device) } +static char *ao_raw_file_extension(void) +{ + return "raw"; +} + + ao_functions ao_raw = { ao_raw_test, ao_raw_driver_info, @@ -144,5 +150,6 @@ ao_functions ao_raw = { ao_raw_open, ao_raw_play, ao_raw_close, - ao_raw_device_clear + ao_raw_device_clear, + ao_raw_file_extension }; diff --git a/src/ao_wav.c b/src/ao_wav.c index 51c3e21..e611f57 100644 --- a/src/ao_wav.c +++ b/src/ao_wav.c @@ -257,6 +257,12 @@ static void ao_wav_device_clear(ao_device *device) } +static char *ao_wav_file_extension(void) +{ + return "wav"; +} + + ao_functions ao_wav = { ao_wav_test, ao_wav_driver_info, @@ -265,6 +271,6 @@ ao_functions ao_wav = { ao_wav_open, ao_wav_play, ao_wav_close, - ao_wav_device_clear + ao_wav_device_clear, + ao_wav_file_extension }; - diff --git a/src/audio_out.c b/src/audio_out.c index cd26035..56279e5 100644 --- a/src/audio_out.c +++ b/src/audio_out.c @@ -137,6 +137,11 @@ driver_list *_get_plugin(char *plugin_file) dlsym(dt->handle, "ao_plugin_device_clear"); if (dlerror()) { free(dt->functions); free(dt); return NULL; } + /* Optional function */ + dt->functions->file_extension = + dlsym(dt->handle, "ao_plugin_file_extension"); + if (dlerror()) { dt->functions->file_extension = NULL; } + } else { return NULL; @@ -698,6 +703,18 @@ ao_info **ao_driver_info_list(int *count) } +char *ao_file_extension(int driver_id) +{ + driver_list *driver; + + if ( (driver = _get_driver(driver_id)) + && driver->functions->file_extension != NULL) + return driver->functions->file_extension(); + else + return NULL; +} + + /* -- Miscellaneous -- */ /* Stolen from Vorbis' lib/vorbisfile.c */ -- GitLab