Mercurial > mplayer.hg
annotate libao2/audio_out.c @ 32293:ee6230fe46e9
cosmetics: Rename function_check{_broken}() --> statement_check{_broken}().
author | diego |
---|---|
date | Mon, 27 Sep 2010 00:02:59 +0000 |
parents | 32725ca88fed |
children | 8fa2f43cb760 |
rev | line source |
---|---|
28343 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
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. | |
8 * | |
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. | |
13 * | |
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. | |
17 */ | |
18 | |
954 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
7848 | 21 #include <string.h> |
954 | 22 |
14123 | 23 #include "config.h" |
954 | 24 #include "audio_out.h" |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
25 |
14123 | 26 #include "mp_msg.h" |
27 #include "help_mp.h" | |
30516 | 28 #include "mp_core.h" /* for exit_player() */ |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
29 |
954 | 30 // there are some globals: |
3095 | 31 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0}; |
1185 | 32 char *ao_subdevice = NULL; |
954 | 33 |
28824
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
34 extern const ao_functions_t audio_out_oss; |
29209 | 35 extern const ao_functions_t audio_out_coreaudio; |
28824
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
36 extern const ao_functions_t audio_out_arts; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
37 extern const ao_functions_t audio_out_esd; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
38 extern const ao_functions_t audio_out_pulse; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
39 extern const ao_functions_t audio_out_jack; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
40 extern const ao_functions_t audio_out_openal; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
41 extern const ao_functions_t audio_out_null; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
42 extern const ao_functions_t audio_out_alsa5; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
43 extern const ao_functions_t audio_out_alsa; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
44 extern const ao_functions_t audio_out_nas; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
45 extern const ao_functions_t audio_out_sdl; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
46 extern const ao_functions_t audio_out_sun; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
47 extern const ao_functions_t audio_out_sgi; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
48 extern const ao_functions_t audio_out_win32; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
49 extern const ao_functions_t audio_out_dsound; |
30439 | 50 extern const ao_functions_t audio_out_kai; |
28824
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
51 extern const ao_functions_t audio_out_dart; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
52 extern const ao_functions_t audio_out_dxr2; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
53 extern const ao_functions_t audio_out_ivtv; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
54 extern const ao_functions_t audio_out_v4l2; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
55 extern const ao_functions_t audio_out_mpegpes; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
56 extern const ao_functions_t audio_out_pcm; |
f92673eb6683
Make audio_out_* structs const so they end up in .rodata
reimar
parents:
28740
diff
changeset
|
57 extern const ao_functions_t audio_out_pss; |
954 | 58 |
25913 | 59 const ao_functions_t* const audio_out_drivers[] = |
954 | 60 { |
7609 | 61 // native: |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
62 #ifdef CONFIG_DIRECTX |
13460
70d8f1975fc8
directsound audio output plugin, patch by Gabor Szecsi <deje at miki.hu> some minor modifications by me
faust3
parents:
12792
diff
changeset
|
63 &audio_out_dsound, |
70d8f1975fc8
directsound audio output plugin, patch by Gabor Szecsi <deje at miki.hu> some minor modifications by me
faust3
parents:
12792
diff
changeset
|
64 #endif |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
65 #ifdef CONFIG_WIN32WAVEOUT |
8729
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
66 &audio_out_win32, |
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
67 #endif |
30439 | 68 #ifdef CONFIG_KAI |
69 &audio_out_kai, | |
70 #endif | |
28740
1f76d86e49ae
DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
28343
diff
changeset
|
71 #ifdef CONFIG_DART |
1f76d86e49ae
DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
28343
diff
changeset
|
72 &audio_out_dart, |
1f76d86e49ae
DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
28343
diff
changeset
|
73 #endif |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
27387
diff
changeset
|
74 #ifdef CONFIG_COREAUDIO |
29209 | 75 &audio_out_coreaudio, |
16732
644baf91233c
ao_macosx is a native audio output driver and should thus have priority
diego
parents:
15789
diff
changeset
|
76 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
77 #ifdef CONFIG_OSS_AUDIO |
954 | 78 &audio_out_oss, |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
79 #endif |
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27388
diff
changeset
|
80 #ifdef CONFIG_ALSA |
26101 | 81 &audio_out_alsa, |
6214
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
82 #endif |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
83 #ifdef CONFIG_ALSA5 |
26101 | 84 &audio_out_alsa5, |
1725
24e75b632740
Move the sun audio driver near the start of the list of audio drivers, so
jkeil
parents:
1528
diff
changeset
|
85 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
86 #ifdef CONFIG_SGI_AUDIO |
2450 | 87 &audio_out_sgi, |
88 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
89 #ifdef CONFIG_SUN_AUDIO |
7609 | 90 &audio_out_sun, |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
91 #endif |
7609 | 92 // wrappers: |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
93 #ifdef CONFIG_ARTS |
7609 | 94 &audio_out_arts, |
1032 | 95 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
96 #ifdef CONFIG_ESD |
8572 | 97 &audio_out_esd, |
98 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
99 #ifdef CONFIG_PULSE |
24781 | 100 &audio_out_pulse, |
13878
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
101 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
102 #ifdef CONFIG_JACK |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
103 &audio_out_jack, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
104 #endif |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
105 #ifdef CONFIG_NAS |
26101 | 106 &audio_out_nas, |
3276 | 107 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
108 #ifdef CONFIG_SDL |
966
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
109 &audio_out_sdl, |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
110 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
111 #ifdef CONFIG_OPENAL |
17633
e0ef5688cce7
OpenAL audio support, actual output is mono-only (no positioning yet).
reimar
parents:
17566
diff
changeset
|
112 &audio_out_openal, |
17634 | 113 #endif |
26101 | 114 &audio_out_mpegpes, |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
115 #ifdef CONFIG_DXR2 |
19409
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
116 &audio_out_dxr2, |
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
117 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
118 #ifdef CONFIG_IVTV |
19409
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
119 &audio_out_ivtv, |
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
120 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
121 #ifdef CONFIG_V4L2_DECODER |
23905
fb63124c7920
v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
19409
diff
changeset
|
122 &audio_out_v4l2, |
fb63124c7920
v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
19409
diff
changeset
|
123 #endif |
7609 | 124 &audio_out_null, |
125 // should not be auto-selected: | |
26101 | 126 &audio_out_pcm, |
127 NULL | |
954 | 128 }; |
3095 | 129 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16732
diff
changeset
|
130 void list_audio_out(void){ |
26101 | 131 int i=0; |
132 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers); | |
133 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n"); | |
134 while (audio_out_drivers[i]) { | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
135 const ao_info_t *info = audio_out_drivers[i++]->info; |
26101 | 136 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name); |
137 } | |
138 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\n"); | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
139 } |
3095 | 140 |
25913 | 141 const ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){ |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
142 int i; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
143 // first try the preferred drivers, with their optional subdevice param: |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
144 if(ao_list && ao_list[0]) |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
145 while(ao_list[0][0]){ |
13632 | 146 char* ao=ao_list[0]; |
147 int ao_len; | |
13542
ed7e91827ead
removing ao_alsa9.c and ao_alsa1x.c as they are superseded by ao_alsa.c
reimar
parents:
13520
diff
changeset
|
148 if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) { |
26101 | 149 mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed); |
30516 | 150 exit_player(EXIT_NONE); |
13542
ed7e91827ead
removing ao_alsa9.c and ao_alsa1x.c as they are superseded by ao_alsa.c
reimar
parents:
13520
diff
changeset
|
151 } |
13632 | 152 if (ao_subdevice) { |
26101 | 153 free(ao_subdevice); |
154 ao_subdevice = NULL; | |
155 } | |
156 ao_subdevice=strchr(ao,':'); | |
157 if(ao_subdevice){ | |
158 ao_len = ao_subdevice - ao; | |
159 ao_subdevice = strdup(&ao[ao_len + 1]); | |
13632 | 160 } |
26101 | 161 else |
162 ao_len = strlen(ao); | |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
163 |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
164 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingPreferredAudioDriver, |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
165 ao_len, ao, ao_subdevice ? ao_subdevice : "[none]"); |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
166 |
26101 | 167 for(i=0;audio_out_drivers[i];i++){ |
168 const ao_functions_t* audio_out=audio_out_drivers[i]; | |
169 if(!strncmp(audio_out->info->short_name,ao,ao_len)){ | |
170 // name matches, try it | |
171 if(audio_out->init(rate,channels,format,flags)) | |
172 return audio_out; // success! | |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
173 else |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
174 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_FailedInit, ao); |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
175 break; |
26101 | 176 } |
177 } | |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
178 if (!audio_out_drivers[i]) // we searched through the entire list |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
179 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao); |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
180 // continue... |
26101 | 181 ++ao_list; |
182 if(!(ao_list[0])) return NULL; // do NOT fallback to others | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
183 } |
13632 | 184 if (ao_subdevice) { |
26101 | 185 free(ao_subdevice); |
186 ao_subdevice = NULL; | |
13632 | 187 } |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
188 |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
189 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown); |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
190 |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
191 // now try the rest... |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
192 for(i=0;audio_out_drivers[i];i++){ |
26101 | 193 const ao_functions_t* audio_out=audio_out_drivers[i]; |
194 // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE) | |
195 if(audio_out->init(rate,channels,format,flags)) | |
196 return audio_out; // success! | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
197 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
198 return NULL; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
199 } |