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.
24 #include "audio_out.h"
28 // there are some globals:
29 ao_data_t ao_data
={0,0,0,0,OUTBURST
,-1,0};
30 char *ao_subdevice
= NULL
;
32 extern const ao_functions_t audio_out_oss
;
33 extern const ao_functions_t audio_out_coreaudio
;
34 extern const ao_functions_t audio_out_arts
;
35 extern const ao_functions_t audio_out_esd
;
36 extern const ao_functions_t audio_out_pulse
;
37 extern const ao_functions_t audio_out_jack
;
38 extern const ao_functions_t audio_out_openal
;
39 extern const ao_functions_t audio_out_null
;
40 extern const ao_functions_t audio_out_alsa5
;
41 extern const ao_functions_t audio_out_alsa
;
42 extern const ao_functions_t audio_out_nas
;
43 extern const ao_functions_t audio_out_sdl
;
44 extern const ao_functions_t audio_out_sun
;
45 extern const ao_functions_t audio_out_sgi
;
46 extern const ao_functions_t audio_out_win32
;
47 extern const ao_functions_t audio_out_dsound
;
48 extern const ao_functions_t audio_out_kai
;
49 extern const ao_functions_t audio_out_dart
;
50 extern const ao_functions_t audio_out_ivtv
;
51 extern const ao_functions_t audio_out_v4l2
;
52 extern const ao_functions_t audio_out_mpegpes
;
53 extern const ao_functions_t audio_out_pcm
;
54 extern const ao_functions_t audio_out_pss
;
56 const ao_functions_t
* const audio_out_drivers
[] =
62 #ifdef CONFIG_WIN32WAVEOUT
71 #ifdef CONFIG_COREAUDIO
74 #ifdef CONFIG_OSS_AUDIO
83 #ifdef CONFIG_SGI_AUDIO
86 #ifdef CONFIG_SUN_AUDIO
115 #ifdef CONFIG_V4L2_DECODER
119 // should not be auto-selected:
124 void list_audio_out(void){
126 mp_tmsg(MSGT_AO
, MSGL_INFO
, "Available audio output drivers:\n");
127 mp_msg(MSGT_IDENTIFY
, MSGL_INFO
, "ID_AUDIO_OUTPUTS\n");
128 while (audio_out_drivers
[i
]) {
129 const ao_info_t
*info
= audio_out_drivers
[i
++]->info
;
130 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\t%s\t%s\n", info
->short_name
, info
->name
);
132 mp_msg(MSGT_GLOBAL
, MSGL_INFO
,"\n");
135 const ao_functions_t
* init_best_audio_out(char** ao_list
,int use_plugin
,int rate
,int channels
,int format
,int flags
){
137 // first try the preferred drivers, with their optional subdevice param:
138 if(ao_list
&& ao_list
[0])
139 while(ao_list
[0][0]){
144 ao_subdevice
=strchr(ao
,':');
146 ao_len
= ao_subdevice
- ao
;
147 ao_subdevice
= strdup(&ao
[ao_len
+ 1]);
152 mp_tmsg(MSGT_AO
, MSGL_V
, "Trying preferred audio driver '%.*s', options '%s'\n",
153 ao_len
, ao
, ao_subdevice
? ao_subdevice
: "[none]");
155 for(i
=0;audio_out_drivers
[i
];i
++){
156 const ao_functions_t
* audio_out
=audio_out_drivers
[i
];
157 if(!strncmp(audio_out
->info
->short_name
,ao
,ao_len
)){
158 // name matches, try it
159 if(audio_out
->init(rate
,channels
,format
,flags
))
160 return audio_out
; // success!
162 mp_tmsg(MSGT_AO
, MSGL_WARN
, "Failed to initialize audio driver '%s'\n", ao
);
166 if (!audio_out_drivers
[i
]) // we searched through the entire list
167 mp_tmsg(MSGT_AO
, MSGL_WARN
, "No such audio driver '%.*s'\n", ao_len
, ao
);
170 if(!(ao_list
[0])) return NULL
; // do NOT fallback to others
175 mp_tmsg(MSGT_AO
, MSGL_V
, "Trying every known audio driver...\n");
177 // now try the rest...
178 for(i
=0;audio_out_drivers
[i
];i
++){
179 const ao_functions_t
* audio_out
=audio_out_drivers
[i
];
180 // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
181 if(audio_out
->init(rate
,channels
,format
,flags
))
182 return audio_out
; // success!