Fix dvdnav call broken in pause changes
[mplayer.git] / libao2 / audio_out.c
blob71ebf94c82ecda140ea201a99178075d6ed087d6
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "config.h"
6 #include "audio_out.h"
8 #include "mp_msg.h"
9 #include "help_mp.h"
11 // there are some globals:
12 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
13 char *ao_subdevice = NULL;
15 extern ao_functions_t audio_out_oss;
16 extern ao_functions_t audio_out_macosx;
17 extern ao_functions_t audio_out_arts;
18 extern ao_functions_t audio_out_esd;
19 extern ao_functions_t audio_out_pulse;
20 extern ao_functions_t audio_out_jack;
21 extern ao_functions_t audio_out_openal;
22 extern ao_functions_t audio_out_null;
23 extern ao_functions_t audio_out_alsa5;
24 extern ao_functions_t audio_out_alsa;
25 extern ao_functions_t audio_out_nas;
26 extern ao_functions_t audio_out_sdl;
27 extern ao_functions_t audio_out_sun;
28 extern ao_functions_t audio_out_sgi;
29 extern ao_functions_t audio_out_win32;
30 extern ao_functions_t audio_out_dsound;
31 extern ao_functions_t audio_out_dxr2;
32 extern ao_functions_t audio_out_ivtv;
33 extern ao_functions_t audio_out_v4l2;
34 extern ao_functions_t audio_out_mpegpes;
35 extern ao_functions_t audio_out_pcm;
36 extern ao_functions_t audio_out_pss;
38 const ao_functions_t* const audio_out_drivers[] =
40 // native:
41 #ifdef CONFIG_DIRECTX
42 &audio_out_dsound,
43 #endif
44 #ifdef CONFIG_WIN32WAVEOUT
45 &audio_out_win32,
46 #endif
47 #ifdef CONFIG_COREAUDIO
48 &audio_out_macosx,
49 #endif
50 #ifdef CONFIG_OSS_AUDIO
51 &audio_out_oss,
52 #endif
53 #ifdef CONFIG_ALSA
54 &audio_out_alsa,
55 #endif
56 #ifdef CONFIG_ALSA5
57 &audio_out_alsa5,
58 #endif
59 #ifdef CONFIG_SGI_AUDIO
60 &audio_out_sgi,
61 #endif
62 #ifdef CONFIG_SUN_AUDIO
63 &audio_out_sun,
64 #endif
65 // wrappers:
66 #ifdef CONFIG_ARTS
67 &audio_out_arts,
68 #endif
69 #ifdef CONFIG_ESD
70 &audio_out_esd,
71 #endif
72 #ifdef CONFIG_PULSE
73 &audio_out_pulse,
74 #endif
75 #ifdef CONFIG_JACK
76 &audio_out_jack,
77 #endif
78 #ifdef CONFIG_NAS
79 &audio_out_nas,
80 #endif
81 #ifdef CONFIG_SDL
82 &audio_out_sdl,
83 #endif
84 #ifdef CONFIG_OPENAL
85 &audio_out_openal,
86 #endif
87 &audio_out_mpegpes,
88 #ifdef CONFIG_DXR2
89 &audio_out_dxr2,
90 #endif
91 #ifdef CONFIG_IVTV
92 &audio_out_ivtv,
93 #endif
94 #ifdef CONFIG_V4L2_DECODER
95 &audio_out_v4l2,
96 #endif
97 &audio_out_null,
98 // should not be auto-selected:
99 &audio_out_pcm,
100 NULL
103 void list_audio_out(void){
104 int i=0;
105 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
106 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n");
107 while (audio_out_drivers[i]) {
108 const ao_info_t *info = audio_out_drivers[i++]->info;
109 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name);
111 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n");
114 const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
115 int i;
116 // first try the preferred drivers, with their optional subdevice param:
117 if(ao_list && ao_list[0])
118 while(ao_list[0][0]){
119 char* ao=ao_list[0];
120 int ao_len;
121 if (ao_subdevice) {
122 free(ao_subdevice);
123 ao_subdevice = NULL;
125 ao_subdevice=strchr(ao,':');
126 if(ao_subdevice){
127 ao_len = ao_subdevice - ao;
128 ao_subdevice = strdup(&ao[ao_len + 1]);
130 else
131 ao_len = strlen(ao);
133 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver,
134 ao_len, ao, ao_subdevice ? ao_subdevice : "[none]");
136 for(i=0;audio_out_drivers[i];i++){
137 const ao_functions_t* audio_out=audio_out_drivers[i];
138 if(!strncmp(audio_out->info->short_name,ao,ao_len)){
139 // name matches, try it
140 if(audio_out->init(rate,channels,format,flags))
141 return audio_out; // success!
142 else
143 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao);
144 break;
147 if (!audio_out_drivers[i]) // we searched through the entire list
148 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao);
149 // continue...
150 ++ao_list;
151 if(!(ao_list[0])) return NULL; // do NOT fallback to others
153 if (ao_subdevice) {
154 free(ao_subdevice);
155 ao_subdevice = NULL;
158 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown);
160 // now try the rest...
161 for(i=0;audio_out_drivers[i];i++){
162 const ao_functions_t* audio_out=audio_out_drivers[i];
163 // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE)
164 if(audio_out->init(rate,channels,format,flags))
165 return audio_out; // success!
167 return NULL;