~ubuntu-branches/ubuntu/trusty/libao/trusty

« back to all changes in this revision

Viewing changes to include/ao/ao_private.h

  • Committer: Bazaar Package Importer
  • Author(s): John Francesco Ferlito
  • Date: 2010-04-11 11:04:30 UTC
  • mfrom: (5.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100411110430-wldc1w7ll1j6c4yc
Tags: 1.0.0-4
Actually depend on libao.

Show diffs side-by-side

added added

removed removed

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