1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
/*
*
* ao_private.c
*
* Copyright (C) Stan Seibert - July 2001
*
* This file is part of libao, a cross-platform audio output library. See
* README for a history of this source code.
*
* libao is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* libao is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/
#ifndef __AO_PRIVATE_H__
#define __AO_PRIVATE_H__
/* --- Operating System Compatibility --- */
/*
OpenBSD systems with a.out binaries require dlsym()ed symbols to be
prepended with an underscore, so we need the following nasty #ifdef
hack.
*/
#if defined(__OpenBSD__) && !defined(__ELF__)
#define dlsym(h,s) dlsym(h, "_" s)
#endif
/* RTLD_NOW is the preferred symbol resolution behavior, but
* some platforms do not support it. The autoconf script will have
* already defined DLOPEN_FLAG if the default is unacceptable on the
* current platform.
*
* ALSA requires RTLD_GLOBAL.
*/
#if !defined(DLOPEN_FLAG)
#define DLOPEN_FLAG (RTLD_NOW | RTLD_GLOBAL)
#endif
/* --- Constants --- */
#ifndef AO_SYSTEM_CONFIG
#define AO_SYSTEM_CONFIG "/etc/libao.conf"
#endif
#ifndef AO_USER_CONFIG
#define AO_USER_CONFIG "/.libao"
#endif
/* --- Structures --- */
typedef struct ao_config {
char *default_driver;
} ao_config;
typedef enum {
AO_OUTPUT_MATRIX_UNDEFINED=0, /* matrix unset */
AO_OUTPUT_MATRIX_FIXED=1, /* fixed, immutable channel order, eg, ALSA */
AO_OUTPUT_MATRIX_COLLAPSIBLE=2, /* fixed order but only used channels sent, eg MACOS */
AO_OUTPUT_MATRIX_PERMUTABLE=3, /* channel map is fully permutable. eg Pulse */
} ao_outorder;
struct ao_device {
int type; /* live output or file output? */
int driver_id;
ao_functions *funcs;
FILE *file; /* File for output if this is a file driver */
/* input not necessarily == output. Right now, byte order, channel
count, and channel mappings may be altered. */
int client_byte_format;
int machine_byte_format;
int driver_byte_format;
char *swap_buffer;
int swap_buffer_size; /* Bytes allocated to swap_buffer */
int input_channels;
int output_channels;
int bytewidth;
int rate;
ao_outorder output_matrix_order;
char *output_matrix; /* physical output channel
ordering/numbering matrix set by
driver if there's a channel
name->number mapping useful to the
backend driver in some way. Eg,
Pulse has fully permutable input
channel masks, but specific channels
locations (eg, 'Center') still have
assigned numbers even if not a
specific slot int he input
interleave. */
int output_mask;
int *input_map; /* input permutation mapping from each
input channel to a location in the
output_matrix. Made by ao_open,
intended for convenience use by
driver in device open. */
char *inter_matrix; /* channel matrix as presented to the
backend API */
int *inter_permute; /* maps from each channel in the
inter_matrix back to an input channel
(if any) */
void *internal; /* Pointer to driver-specific data */
int verbose;
};
struct ao_functions {
int (*test)(void);
ao_info* (*driver_info)(void);
int (*device_init)(ao_device *device);
int (*set_option)(ao_device *device, const char *key,
const char *value);
int (*open)(ao_device *device, ao_sample_format *format);
int (*play)(ao_device *device, const char *output_samples,
uint_32 num_bytes);
int (*close)(ao_device *device);
void (*device_clear)(ao_device *device);
char* (*file_extension)(void);
};
/* --- Functions --- */
void ao_read_config_files (ao_config *config);
#define adebug(format, ...) {\
if(device->verbose==2){ \
if(strcmp(format,"\n")){ \
if(device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s debug: " format,device->funcs->driver_info()->short_name,##__VA_ARGS__); \
}else{ \
fprintf(stderr,"debug: " format,##__VA_ARGS__); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define averbose(format, ...) {\
if(device->verbose>0){ \
if(strcmp(format,"\n")){ \
if(device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s info: " format,device->funcs->driver_info()->short_name,##__VA_ARGS__); \
}else{ \
fprintf(stderr,"info: " format,##__VA_ARGS__); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define ainfo(format, ...) {\
if(device->verbose>=0){ \
if(strcmp(format,"\n")){ \
if(device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s info: " format,device->funcs->driver_info()->short_name,##__VA_ARGS__); \
}else{ \
fprintf(stderr,"info: " format,##__VA_ARGS__); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define awarn(format, ...) {\
if(device->verbose>=0){ \
if(strcmp(format,"\n")){ \
if(device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s WARNING: " format,device->funcs->driver_info()->short_name,##__VA_ARGS__); \
}else{ \
fprintf(stderr,"WARNING: " format,##__VA_ARGS__); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#define aerror(format, ...) { \
if(device->verbose>=0){ \
if(strcmp(format,"\n")){ \
if(device->funcs->driver_info()->short_name){ \
fprintf(stderr,"ao_%s ERROR: " format,device->funcs->driver_info()->short_name,##__VA_ARGS__); \
}else{ \
fprintf(stderr,"ERROR: " format,##__VA_ARGS__); \
} \
}else{ \
fprintf(stderr,"\n"); \
} \
} \
}
#endif /* __AO_PRIVATE_H__ */
|