Mercurial > mplayer.hg
annotate libao2/audio_out.c @ 36193:9beb155c77a0
Cosmetic: Adjust indent.
Additionally, merge variable definitions.
author | ib |
---|---|
date | Sun, 26 May 2013 15:51:54 +0000 |
parents | 9d4720deada1 |
children | c6843e5bf166 |
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_alsa; |
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_nas; |
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_sdl; |
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_sun; |
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_sgi; |
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_win32; |
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_dsound; |
30439 | 49 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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
55 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
|
56 extern const ao_functions_t audio_out_pss; |
954 | 57 |
25913 | 58 const ao_functions_t* const audio_out_drivers[] = |
954 | 59 { |
7609 | 60 // native: |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
61 #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
|
62 &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
|
63 #endif |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
64 #ifdef CONFIG_WIN32WAVEOUT |
8729
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
65 &audio_out_win32, |
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
66 #endif |
30439 | 67 #ifdef CONFIG_KAI |
68 &audio_out_kai, | |
69 #endif | |
28740
1f76d86e49ae
DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
28343
diff
changeset
|
70 #ifdef CONFIG_DART |
1f76d86e49ae
DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
28343
diff
changeset
|
71 &audio_out_dart, |
1f76d86e49ae
DART audio output driver for OS/2 by KO Myung-Hun, komh chollian net
diego
parents:
28343
diff
changeset
|
72 #endif |
27388
ac03760f7fcc
Rename all preprocessor directives related to Apple / Mac OS X.
diego
parents:
27387
diff
changeset
|
73 #ifdef CONFIG_COREAUDIO |
29209 | 74 &audio_out_coreaudio, |
16732
644baf91233c
ao_macosx is a native audio output driver and should thus have priority
diego
parents:
15789
diff
changeset
|
75 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
76 #ifdef CONFIG_OSS_AUDIO |
954 | 77 &audio_out_oss, |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
78 #endif |
27390
9d95dc936e66
Introduce CONFIG_ALSA preprocessor directive for ALSA 0.9 and 1.x.
diego
parents:
27388
diff
changeset
|
79 #ifdef CONFIG_ALSA |
26101 | 80 &audio_out_alsa, |
6214
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
81 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
82 #ifdef CONFIG_SGI_AUDIO |
2450 | 83 &audio_out_sgi, |
84 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
85 #ifdef CONFIG_SUN_AUDIO |
7609 | 86 &audio_out_sun, |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
87 #endif |
7609 | 88 // wrappers: |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
89 #ifdef CONFIG_ARTS |
7609 | 90 &audio_out_arts, |
1032 | 91 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
92 #ifdef CONFIG_ESD |
8572 | 93 &audio_out_esd, |
94 #endif | |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
95 #ifdef CONFIG_PULSE |
24781 | 96 &audio_out_pulse, |
13878
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
97 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
98 #ifdef CONFIG_JACK |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
99 &audio_out_jack, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
100 #endif |
27387
eb7bdbd98210
Rename some audio-output-related preprocessor directives.
diego
parents:
27370
diff
changeset
|
101 #ifdef CONFIG_NAS |
26101 | 102 &audio_out_nas, |
3276 | 103 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
104 #ifdef CONFIG_SDL |
966
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
105 &audio_out_sdl, |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
106 #endif |
27341
e7c989f7a7c9
Start unifying names of internal preprocessor directives.
diego
parents:
27091
diff
changeset
|
107 #ifdef CONFIG_OPENAL |
17633
e0ef5688cce7
OpenAL audio support, actual output is mono-only (no positioning yet).
reimar
parents:
17566
diff
changeset
|
108 &audio_out_openal, |
17634 | 109 #endif |
26101 | 110 &audio_out_mpegpes, |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
111 #ifdef CONFIG_DXR2 |
19409
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
112 &audio_out_dxr2, |
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
113 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
114 #ifdef CONFIG_IVTV |
19409
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
115 &audio_out_ivtv, |
37decab2ed46
Move mpeg aos to the end of the autodetection list. At least mpegpes
uau
parents:
19224
diff
changeset
|
116 #endif |
27370
14c5017f40d2
Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents:
27341
diff
changeset
|
117 #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
|
118 &audio_out_v4l2, |
fb63124c7920
v4l2 audio/video outputs for linux 2.6.22+ kernels (outputs formerly known as ivtv)
ben
parents:
19409
diff
changeset
|
119 #endif |
7609 | 120 &audio_out_null, |
121 // should not be auto-selected: | |
26101 | 122 &audio_out_pcm, |
123 NULL | |
954 | 124 }; |
3095 | 125 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16732
diff
changeset
|
126 void list_audio_out(void){ |
26101 | 127 int i=0; |
128 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers); | |
129 mp_msg(MSGT_IDENTIFY, MSGL_INFO, "ID_AUDIO_OUTPUTS\n"); | |
130 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
|
131 const ao_info_t *info = audio_out_drivers[i++]->info; |
26101 | 132 mp_msg(MSGT_GLOBAL, MSGL_INFO,"\t%s\t%s\n", info->short_name, info->name); |
133 } | |
134 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
|
135 } |
3095 | 136 |
25913 | 137 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
|
138 int i; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
139 // 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
|
140 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
|
141 while(ao_list[0][0]){ |
13632 | 142 char* ao=ao_list[0]; |
143 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
|
144 if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) { |
26101 | 145 mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed); |
30516 | 146 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
|
147 } |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30633
diff
changeset
|
148 free(ao_subdevice); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30633
diff
changeset
|
149 ao_subdevice = NULL; |
26101 | 150 ao_subdevice=strchr(ao,':'); |
151 if(ao_subdevice){ | |
152 ao_len = ao_subdevice - ao; | |
153 ao_subdevice = strdup(&ao[ao_len + 1]); | |
13632 | 154 } |
26101 | 155 else |
156 ao_len = strlen(ao); | |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
157 |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
32537
diff
changeset
|
158 mp_msg(MSGT_AO, MSGL_V, "Trying preferred audio driver '%.*s', options '%s'\n", |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
159 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
|
160 |
26101 | 161 for(i=0;audio_out_drivers[i];i++){ |
162 const ao_functions_t* audio_out=audio_out_drivers[i]; | |
163 if(!strncmp(audio_out->info->short_name,ao,ao_len)){ | |
164 // name matches, try it | |
165 if(audio_out->init(rate,channels,format,flags)) | |
166 return audio_out; // success! | |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
167 else |
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
168 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
|
169 break; |
26101 | 170 } |
171 } | |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
172 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
|
173 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
|
174 // continue... |
26101 | 175 ++ao_list; |
176 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
|
177 } |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30633
diff
changeset
|
178 free(ao_subdevice); |
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
30633
diff
changeset
|
179 ao_subdevice = NULL; |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
180 |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
32537
diff
changeset
|
181 mp_msg(MSGT_AO, MSGL_V, "Trying every known audio driver...\n"); |
27091
66e998895707
Add verbose messages about trying and searching for audio output drivers.
corey
parents:
26208
diff
changeset
|
182 |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
183 // now try the rest... |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
184 for(i=0;audio_out_drivers[i];i++){ |
26101 | 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! | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
189 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
190 return NULL; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
191 } |
34754 | 192 |
193 void mp_ao_resume_refill(const ao_functions_t *ao, int prepause_space) | |
194 { | |
195 int fillcnt = ao->get_space() - prepause_space; | |
196 if (fillcnt > 0 && !(ao_data.format & AF_FORMAT_SPECIAL_MASK)) { | |
197 void *silence = calloc(fillcnt, 1); | |
198 ao->play(silence, fillcnt, 0); | |
199 free(silence); | |
200 } | |
201 } |