1 /* 2 * 3 * ao.h 4 * 5 * Original Copyright (C) Aaron Holtzman - May 1999 6 * Modifications Copyright (C) Stan Seibert - July 2000, July 2001 7 * More Modifications Copyright (C) Jack Moffitt - October 2000 8 * 9 * This file is part of libao, a cross-platform audio outputlibrary. See 10 * README for a history of this source code. 11 * 12 * libao is free software; you can redistribute it and/or modify 13 * it under the terms of the GNU General Public License as published by 14 * the Free Software Foundation; either version 2, or (at your option) 15 * any later version. 16 * 17 * libao is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with GNU Make; see the file COPYING. If not, write to 24 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 25 * 26 */ 27 #ifndef __AO_H__ 28 #define __AO_H__ 29 30 #ifdef __cplusplus 31 extern "C" 32 { 33 #endif /* __cplusplus */ 34 35 #include <stdio.h> 36 #include <stdlib.h> 37 #include <stdint.h> 38 #include <errno.h> 39 40 /* --- Constants ---*/ 41 42 #define AO_TYPE_LIVE 1 43 #define AO_TYPE_FILE 2 44 45 46 #define AO_ENODRIVER 1 47 #define AO_ENOTFILE 2 48 #define AO_ENOTLIVE 3 49 #define AO_EBADOPTION 4 50 #define AO_EOPENDEVICE 5 51 #define AO_EOPENFILE 6 52 #define AO_EFILEEXISTS 7 53 #define AO_EBADFORMAT 8 54 55 #define AO_EFAIL 100 56 57 58 #define AO_FMT_LITTLE 1 59 #define AO_FMT_BIG 2 60 #define AO_FMT_NATIVE 4 61 62 /* --- Structures --- */ 63 64 typedef struct ao_info { 65 int type; /* live output or file output? */ 66 char *name; /* full name of driver */ 67 char *short_name; /* short name of driver */ 68 char *author; /* driver author */ 69 char *comment; /* driver comment */ 70 int preferred_byte_format; 71 int priority; 72 char **options; 73 int option_count; 74 } ao_info; 75 76 typedef struct ao_functions ao_functions; 77 typedef struct ao_device ao_device; 78 79 typedef struct ao_sample_format { 80 int bits; /* bits per sample */ 81 int rate; /* samples per second (in a single channel) */ 82 int channels; /* number of audio channels */ 83 int byte_format; /* Byte ordering in sample, see constants below */ 84 char *matrix; /* input channel location/ordering */ 85 } ao_sample_format; 86 87 typedef struct ao_option { 88 char *key; 89 char *value; 90 struct ao_option *next; 91 } ao_option; 92 93 #if defined(AO_BUILDING_LIBAO) 94 #include "ao_private.h" 95 #endif 96 97 /* --- Functions --- */ 98 99 /* library setup/teardown */ 100 void ao_initialize(void); 101 void ao_shutdown(void); 102 103 /* device setup/playback/teardown */ 104 int ao_append_global_option(const char *key, 105 const char *value); 106 int ao_append_option(ao_option **options, 107 const char *key, 108 const char *value); 109 void ao_free_options(ao_option *options); 110 111 char* ao_get_option(ao_option *options, const char* key); 112 113 ao_device* ao_open_live(int driver_id, 114 ao_sample_format *format, 115 ao_option *option); 116 ao_device* ao_open_file(int driver_id, 117 const char *filename, 118 int overwrite, 119 ao_sample_format *format, 120 ao_option *option); 121 122 int ao_play(ao_device *device, 123 char *output_samples, 124 uint32_t num_bytes); 125 int ao_close(ao_device *device); 126 127 /* driver information */ 128 int ao_driver_id(const char *short_name); 129 int ao_default_driver_id(void); 130 ao_info *ao_driver_info(int driver_id); 131 ao_info **ao_driver_info_list(int *driver_count); 132 char *ao_file_extension(int driver_id); 133 134 /* miscellaneous */ 135 int ao_is_big_endian(void); 136 137 138 #ifdef __cplusplus 139 } 140 #endif /* __cplusplus */ 141 142 #endif /* __AO_H__ */ 143 144 extern struct AudioOutput g_ao; 145 struct AudioOutput 146 { 147 void (*ao_initialize)(void); 148 int (*ao_play)(ao_device *, char *, uint32_t); 149 int (*ao_default_driver_id)(void); 150 ao_device* (*ao_open_live)( int, ao_sample_format *, ao_option *); 151 int (*ao_close)(ao_device *); 152 /* -- Device Setup/Playback/Teardown -- */ 153 int (*ao_append_option)(ao_option **, const char *, const char *); 154 void (*ao_free_options)(ao_option *); 155 char* (*ao_get_option)(ao_option *, const char* ); 156 void (*ao_set_metadata)(const char *buffer, unsigned int size); 157 void (*ao_set_metadata_coverart)(const char *buffer, unsigned int size); 158 }; 159