audio output: add a new AO driver API
[mplayer.git] / libao2 / audio_out.h
blobc60819e5459ce6d27b9130d02f5cd4ab769d9d6f
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #ifndef MPLAYER_AUDIO_OUT_H
20 #define MPLAYER_AUDIO_OUT_H
22 #include <stdbool.h>
24 typedef struct ao_info {
25 /* driver name ("Matrox Millennium G200/G400" */
26 const char *name;
27 /* short name (for config strings) ("mga") */
28 const char *short_name;
29 /* author ("Aaron Holtzman <aholtzma@ess.engr.uvic.ca>") */
30 const char *author;
31 /* any additional comments */
32 const char *comment;
33 } ao_info_t;
35 /* interface towards mplayer and */
36 typedef struct ao_old_functions {
37 int (*control)(int cmd, void *arg);
38 int (*init)(int rate, int channels, int format, int flags);
39 void (*uninit)(int immed);
40 void (*reset)(void);
41 int (*get_space)(void);
42 int (*play)(void *data, int len, int flags);
43 float (*get_delay)(void);
44 void (*pause)(void);
45 void (*resume)(void);
46 } ao_functions_t;
48 struct ao;
50 struct ao_driver {
51 bool is_new;
52 const struct ao_info *info;
53 const struct ao_old_functions *old_functions;
54 int (*control)(struct ao *ao, int cmd, void *arg);
55 int (*init)(struct ao *ao, char *params);
56 void (*uninit)(struct ao *ao, bool cut_audio);
57 void (*reset)(struct ao*ao);
58 int (*get_space)(struct ao *ao);
59 int (*play)(struct ao *ao, void *data, int len, int flags);
60 float (*get_delay)(struct ao *ao);
61 void (*pause)(struct ao *ao);
62 void (*resume)(struct ao *ao);
65 /* global data used by mplayer and plugins */
66 struct ao {
67 int samplerate;
68 int channels;
69 int format;
70 int bps;
71 int outburst;
72 int buffersize;
73 int pts;
74 bool initialized;
75 const struct ao_driver *driver;
76 void *priv;
79 extern char *ao_subdevice;
81 void list_audio_out(void);
83 #define CONTROL_OK 1
84 #define CONTROL_TRUE 1
85 #define CONTROL_FALSE 0
86 #define CONTROL_UNKNOWN -1
87 #define CONTROL_ERROR -2
88 #define CONTROL_NA -3
90 #define AOCONTROL_SET_DEVICE 1
91 #define AOCONTROL_GET_DEVICE 2
92 #define AOCONTROL_QUERY_FORMAT 3 /* test for availabilty of a format */
93 #define AOCONTROL_GET_VOLUME 4
94 #define AOCONTROL_SET_VOLUME 5
95 #define AOCONTROL_SET_PLUGIN_DRIVER 6
96 #define AOCONTROL_SET_PLUGIN_LIST 7
98 #define AOPLAY_FINAL_CHUNK 1
100 typedef struct ao_control_vol {
101 float left;
102 float right;
103 } ao_control_vol_t;
105 struct ao *ao_create(void);
106 void ao_init(struct ao *ao, char **ao_list);
107 void ao_uninit(struct ao *ao, bool cut_audio);
108 int ao_play(struct ao *ao, void *data, int len, int flags);
109 int ao_control(struct ao *ao, int cmd, void *arg);
110 double ao_get_delay(struct ao *ao);
111 int ao_get_space(struct ao *ao);
112 void ao_reset(struct ao *ao);
113 void ao_pause(struct ao *ao);
114 void ao_resume(struct ao *ao);
116 int old_ao_control(struct ao *ao, int cmd, void *arg);
117 int old_ao_init(struct ao *ao, char *params);
118 void old_ao_uninit(struct ao *ao, bool cut_audio);
119 void old_ao_reset(struct ao*ao);
120 int old_ao_get_space(struct ao *ao);
121 int old_ao_play(struct ao *ao, void *data, int len, int flags);
122 float old_ao_get_delay(struct ao *ao);
123 void old_ao_pause(struct ao *ao);
124 void old_ao_resume(struct ao *ao);
126 #endif /* MPLAYER_AUDIO_OUT_H */