Add support for VDPAU video out, including hardware decoding.
[mplayer/glamo.git] / libao2 / audio_out.c
blob7fc9fdb6b41735efd45cecf972490cb3311cd48e
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 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
23 #include "config.h"
24 #include "audio_out.h"
26 #include "mp_msg.h"
27 #include "help_mp.h"
28 #include "mplayer.h" /* for exit_player() */
30 // there are some globals:
31 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
32 char *ao_subdevice = NULL;
34 extern ao_functions_t audio_out_oss;
35 extern ao_functions_t audio_out_macosx;
36 extern ao_functions_t audio_out_arts;
37 extern ao_functions_t audio_out_esd;
38 extern ao_functions_t audio_out_pulse;
39 extern ao_functions_t audio_out_jack;
40 extern ao_functions_t audio_out_openal;
41 extern ao_functions_t audio_out_null;
42 extern ao_functions_t audio_out_alsa5;
43 extern ao_functions_t audio_out_alsa;
44 extern ao_functions_t audio_out_nas;
45 extern ao_functions_t audio_out_sdl;
46 extern ao_functions_t audio_out_sun;
47 extern ao_functions_t audio_out_sgi;
48 extern ao_functions_t audio_out_win32;
49 extern ao_functions_t audio_out_dsound;
50 extern ao_functions_t audio_out_dxr2;
51 extern ao_functions_t audio_out_ivtv;
52 extern ao_functions_t audio_out_v4l2;
53 extern ao_functions_t audio_out_mpegpes;
54 extern ao_functions_t audio_out_pcm;
55 extern ao_functions_t audio_out_pss;
57 const ao_functions_t* const audio_out_drivers[] =
59 // native:
60 #ifdef CONFIG_DIRECTX
61 &audio_out_dsound,
62 #endif
63 #ifdef CONFIG_WIN32WAVEOUT
64 &audio_out_win32,
65 #endif
66 #ifdef CONFIG_COREAUDIO
67 &audio_out_macosx,
68 #endif
69 #ifdef CONFIG_OSS_AUDIO
70 &audio_out_oss,
71 #endif
72 #ifdef CONFIG_ALSA
73 &audio_out_alsa,
74 #endif
75 #ifdef CONFIG_ALSA5
76 &audio_out_alsa5,
77 #endif
78 #ifdef CONFIG_SGI_AUDIO
79 &audio_out_sgi,
80 #endif
81 #ifdef CONFIG_SUN_AUDIO
82 &audio_out_sun,
83 #endif
84 // wrappers:
85 #ifdef CONFIG_ARTS
86 &audio_out_arts,
87 #endif
88 #ifdef CONFIG_ESD
89 &audio_out_esd,
90 #endif
91 #ifdef CONFIG_PULSE
92 &audio_out_pulse,
93 #endif
94 #ifdef CONFIG_JACK
95 &audio_out_jack,
96 #endif
97 #ifdef CONFIG_NAS
98 &audio_out_nas,
99 #endif
100 #ifdef CONFIG_SDL
101 &audio_out_sdl,
102 #endif
103 #ifdef CONFIG_OPENAL
104 &audio_out_openal,
105 #endif
106 &audio_out_mpegpes,
107 #ifdef CONFIG_DXR2
108 &audio_out_dxr2,
109 #endif
110 #ifdef CONFIG_IVTV
111 &audio_out_ivtv,
112 #endif
113 #ifdef CONFIG_V4L2_DECODER
114 &audio_out_v4l2,
115 #endif
116 &audio_out_null,
117 // should not be auto-selected:
118 &audio_out_pcm,
119 NULL
122 void list_audio_out(void){
123 int i=0;
124 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
125 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
126 while (audio_out_drivers[i]) {
127 const ao_info_t *info = audio_out_drivers[i++]->info;
128 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
130 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
133 const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
134 int i;
135 // first try the preferred drivers, with their optional subdevice param:
136 if(ao_list && ao_list[0])
137 while(ao_list[0][0]){
138 char* ao=ao_list[0];
139 int ao_len;
140 if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) {
141 mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
142 exit_player(NULL);
144 if (ao_subdevice) {
145 free(ao_subdevice);
146 ao_subdevice = NULL;
148 ao_subdevice=strchr(ao,':');
149 if(ao_subdevice){
150 ao_len = ao_subdevice - ao;
151 ao_subdevice = strdup(&ao[ao_len + 1]);
153 else
154 ao_len = strlen(ao);
156 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver,
157 ao_len, ao, ao_subdevice ? ao_subdevice : "[none]");
159 for(i=0;audio_out_drivers[i];i++){
160 const ao_functions_t* audio_out=audio_out_drivers[i];
161 if(!strncmp(audio_out->info->short_name,ao,ao_len)){
162 // name matches, try it
163 if(audio_out->init(rate,channels,format,flags))
164 return audio_out; // success!
165 else
166 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao);
167 break;
170 if (!audio_out_drivers[i]) // we searched through the entire list
171 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao);
172 // continue...
173 ++ao_list;
174 if(!(ao_list[0])) return NULL; // do NOT fallback to others
176 if (ao_subdevice) {
177 free(ao_subdevice);
178 ao_subdevice = NULL;
181 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown);
183 // now try the rest...
184 for(i=0;audio_out_drivers[i];i++){
185 const ao_functions_t* audio_out=audio_out_drivers[i];
186 // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
187 if(audio_out->init(rate,channels,format,flags))
188 return audio_out; // success!
190 return NULL;