constant qscale was broken due to libavcodec changes, fix taken from ve_lavc.c
[mplayer/greg.git] / libao2 / audio_out.c
blob6c7c65283f34598539e1741f933e18f515332520
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
5 #include "../config.h"
6 #include "audio_out.h"
7 #include "afmt.h"
9 #include "../mp_msg.h"
10 #include "../help_mp.h"
12 // there are some globals:
13 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0};
14 char *ao_subdevice = NULL;
16 #ifdef USE_OSS_AUDIO
17 extern ao_functions_t audio_out_oss;
18 #endif
19 #ifdef USE_ARTS
20 extern ao_functions_t audio_out_arts;
21 #endif
22 #ifdef USE_ESD
23 extern ao_functions_t audio_out_esd;
24 #endif
25 extern ao_functions_t audio_out_null;
26 #ifdef HAVE_ALSA5
27 extern ao_functions_t audio_out_alsa5;
28 #endif
29 #ifdef HAVE_ALSA9
30 extern ao_functions_t audio_out_alsa9;
31 #endif
32 #ifdef HAVE_NAS
33 extern ao_functions_t audio_out_nas;
34 #endif
35 #ifdef HAVE_SDL
36 extern ao_functions_t audio_out_sdl;
37 #endif
38 #ifdef USE_SUN_AUDIO
39 extern ao_functions_t audio_out_sun;
40 #endif
41 #ifdef USE_SGI_AUDIO
42 extern ao_functions_t audio_out_sgi;
43 #endif
44 #ifdef HAVE_WIN32WAVEOUT
45 extern ao_functions_t audio_out_win32;
46 #endif
47 #ifdef MACOSX
48 extern ao_functions_t audio_out_macosx;
49 #endif
50 #ifdef HAVE_DXR2
51 extern ao_functions_t audio_out_dxr2;
52 #endif
53 extern ao_functions_t audio_out_mpegpes;
54 extern ao_functions_t audio_out_pcm;
55 extern ao_functions_t audio_out_pss;
56 extern ao_functions_t audio_out_plugin;
58 ao_functions_t* audio_out_drivers[] =
60 // vo-related: will fail unless you also do -vo mpegpes/dxr2
61 &audio_out_mpegpes,
62 #ifdef HAVE_DXR2
63 &audio_out_dxr2,
64 #endif
65 // native:
66 #ifdef HAVE_WIN32WAVEOUT
67 &audio_out_win32,
68 #endif
69 #ifdef MACOSX
70 &audio_out_macosx,
71 #endif
72 #ifdef USE_OSS_AUDIO
73 &audio_out_oss,
74 #endif
75 #ifdef HAVE_ALSA9
76 &audio_out_alsa9,
77 #endif
78 #ifdef HAVE_ALSA5
79 &audio_out_alsa5,
80 #endif
81 #ifdef USE_SGI_AUDIO
82 &audio_out_sgi,
83 #endif
84 #ifdef USE_SUN_AUDIO
85 &audio_out_sun,
86 #endif
87 // wrappers:
88 #ifdef USE_ARTS
89 &audio_out_arts,
90 #endif
91 #ifdef USE_ESD
92 &audio_out_esd,
93 #endif
94 #ifdef HAVE_NAS
95 &audio_out_nas,
96 #endif
97 #ifdef HAVE_SDL
98 &audio_out_sdl,
99 #endif
100 &audio_out_null,
101 // should not be auto-selected:
102 &audio_out_pcm,
103 &audio_out_plugin,
104 NULL
107 void list_audio_out(){
108 int i=0;
109 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers);
110 while (audio_out_drivers[i]) {
111 const ao_info_t *info = audio_out_drivers[i++]->info;
112 printf("\t%s\t%s\n", info->short_name, info->name);
114 printf("\n");
117 ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){
118 int i;
119 // first try the preferred drivers, with their optional subdevice param:
120 if(ao_list && ao_list[0])
121 while(ao_list[0][0]){
122 char* ao=strdup(ao_list[0]);
123 ao_subdevice=strchr(ao,':');
124 if(ao_subdevice){
125 ao_subdevice[0]=0;
126 ++ao_subdevice;
128 for(i=0;audio_out_drivers[i];i++){
129 ao_functions_t* audio_out=audio_out_drivers[i];
130 if(!strcmp(audio_out->info->short_name,ao)){
131 // name matches, try it
132 if(use_plugin){
133 audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out);
134 audio_out=&audio_out_plugin;
136 if(audio_out->init(rate,channels,format,flags))
137 return audio_out; // success!
140 // continue...
141 ++ao_list;
142 if(!(ao_list[0])) return NULL; // do NOT fallback to others
144 // now try the rest...
145 ao_subdevice=NULL;
146 for(i=0;audio_out_drivers[i];i++){
147 ao_functions_t* audio_out=audio_out_drivers[i];
148 if(use_plugin){
149 audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out);
150 audio_out=&audio_out_plugin;
152 if(audio_out->init(rate,channels,format,flags))
153 return audio_out; // success!
155 return NULL;