Mercurial > mplayer.hg
annotate libao2/audio_out.c @ 17820:4e04e61b54ac
close channels file before exiting dvb_get_channels() if malloc(dvb_channels_list) fails; closes cid 161
author | nicodvb |
---|---|
date | Sun, 12 Mar 2006 11:45:27 +0000 |
parents | 8dc8353c4ee8 |
children | 6927fabaef92 |
rev | line source |
---|---|
954 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
7848 | 3 #include <string.h> |
954 | 4 |
14123 | 5 #include "config.h" |
954 | 6 #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
|
7 |
14123 | 8 #include "mp_msg.h" |
9 #include "help_mp.h" | |
15058 | 10 #include "mplayer.h" /* for exit_player() */ |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
11 |
954 | 12 // there are some globals: |
3095 | 13 ao_data_t ao_data={0,0,0,0,OUTBURST,-1,0}; |
1185 | 14 char *ao_subdevice = NULL; |
954 | 15 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
16 #ifdef USE_OSS_AUDIO |
954 | 17 extern ao_functions_t audio_out_oss; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
18 #endif |
12792 | 19 #ifdef MACOSX |
20 extern ao_functions_t audio_out_macosx; | |
21 #endif | |
6214
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
22 #ifdef USE_ARTS |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
23 extern ao_functions_t audio_out_arts; |
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
24 #endif |
8572 | 25 #ifdef USE_ESD |
26 extern ao_functions_t audio_out_esd; | |
27 #endif | |
13878
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
28 #ifdef USE_POLYP |
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
29 extern ao_functions_t audio_out_polyp; |
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
30 #endif |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
31 #ifdef USE_JACK |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
32 extern ao_functions_t audio_out_jack; |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
33 #endif |
17634 | 34 #ifdef USE_OPENAL |
17633
e0ef5688cce7
OpenAL audio support, actual output is mono-only (no positioning yet).
reimar
parents:
17566
diff
changeset
|
35 extern ao_functions_t audio_out_openal; |
17634 | 36 #endif |
954 | 37 extern ao_functions_t audio_out_null; |
1007 | 38 #ifdef HAVE_ALSA5 |
39 extern ao_functions_t audio_out_alsa5; | |
40 #endif | |
1032 | 41 #ifdef HAVE_ALSA9 |
12462 | 42 extern ao_functions_t audio_out_alsa; |
1032 | 43 #endif |
11775 | 44 #ifdef HAVE_ALSA1X |
12462 | 45 extern ao_functions_t audio_out_alsa; |
11775 | 46 #endif |
3276 | 47 #ifdef HAVE_NAS |
48 extern ao_functions_t audio_out_nas; | |
49 #endif | |
966
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
50 #ifdef HAVE_SDL |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
51 extern ao_functions_t audio_out_sdl; |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
52 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
53 #ifdef USE_SUN_AUDIO |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
54 extern ao_functions_t audio_out_sun; |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
55 #endif |
2450 | 56 #ifdef USE_SGI_AUDIO |
57 extern ao_functions_t audio_out_sgi; | |
58 #endif | |
7916 | 59 #ifdef HAVE_WIN32WAVEOUT |
60 extern ao_functions_t audio_out_win32; | |
61 #endif | |
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 #ifdef HAVE_DIRECTX |
70d8f1975fc8
directsound audio output plugin, patch by Gabor Szecsi <deje at miki.hu> some minor modifications by me
faust3
parents:
12792
diff
changeset
|
63 extern ao_functions_t 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 |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
65 #ifdef HAVE_DXR2 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
66 extern ao_functions_t audio_out_dxr2; |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
67 #endif |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4097
diff
changeset
|
68 extern ao_functions_t audio_out_mpegpes; |
1107 | 69 extern ao_functions_t audio_out_pcm; |
1185 | 70 extern ao_functions_t audio_out_pss; |
954 | 71 |
72 ao_functions_t* audio_out_drivers[] = | |
73 { | |
7609 | 74 // vo-related: will fail unless you also do -vo mpegpes/dxr2 |
75 &audio_out_mpegpes, | |
76 #ifdef HAVE_DXR2 | |
77 &audio_out_dxr2, | |
78 #endif | |
79 // native: | |
13460
70d8f1975fc8
directsound audio output plugin, patch by Gabor Szecsi <deje at miki.hu> some minor modifications by me
faust3
parents:
12792
diff
changeset
|
80 #ifdef HAVE_DIRECTX |
70d8f1975fc8
directsound audio output plugin, patch by Gabor Szecsi <deje at miki.hu> some minor modifications by me
faust3
parents:
12792
diff
changeset
|
81 &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
|
82 #endif |
8729
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
83 #ifdef HAVE_WIN32WAVEOUT |
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
84 &audio_out_win32, |
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
85 #endif |
16732
644baf91233c
ao_macosx is a native audio output driver and should thus have priority
diego
parents:
15789
diff
changeset
|
86 #ifdef MACOSX |
644baf91233c
ao_macosx is a native audio output driver and should thus have priority
diego
parents:
15789
diff
changeset
|
87 &audio_out_macosx, |
644baf91233c
ao_macosx is a native audio output driver and should thus have priority
diego
parents:
15789
diff
changeset
|
88 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
89 #ifdef USE_OSS_AUDIO |
954 | 90 &audio_out_oss, |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
91 #endif |
11775 | 92 #ifdef HAVE_ALSA1X |
12462 | 93 &audio_out_alsa, |
11775 | 94 #endif |
7609 | 95 #ifdef HAVE_ALSA9 |
12462 | 96 &audio_out_alsa, |
6214
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
97 #endif |
7609 | 98 #ifdef HAVE_ALSA5 |
99 &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
|
100 #endif |
2450 | 101 #ifdef USE_SGI_AUDIO |
102 &audio_out_sgi, | |
103 #endif | |
7609 | 104 #ifdef USE_SUN_AUDIO |
105 &audio_out_sun, | |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
106 #endif |
7609 | 107 // wrappers: |
108 #ifdef USE_ARTS | |
109 &audio_out_arts, | |
1032 | 110 #endif |
8572 | 111 #ifdef USE_ESD |
112 &audio_out_esd, | |
113 #endif | |
13878
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
114 #ifdef USE_POLYP |
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
115 &audio_out_polyp, |
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
116 #endif |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
117 #ifdef USE_JACK |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
118 &audio_out_jack, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
119 #endif |
3276 | 120 #ifdef HAVE_NAS |
121 &audio_out_nas, | |
122 #endif | |
966
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
123 #ifdef HAVE_SDL |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
124 &audio_out_sdl, |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
125 #endif |
17634 | 126 #ifdef USE_OPENAL |
17633
e0ef5688cce7
OpenAL audio support, actual output is mono-only (no positioning yet).
reimar
parents:
17566
diff
changeset
|
127 &audio_out_openal, |
17634 | 128 #endif |
7609 | 129 &audio_out_null, |
130 // should not be auto-selected: | |
1107 | 131 &audio_out_pcm, |
954 | 132 NULL |
133 }; | |
3095 | 134 |
17566
f580a7755ac5
Patch by Stefan Huehner / stefan % huehner ! org \
rathann
parents:
16732
diff
changeset
|
135 void list_audio_out(void){ |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
136 int i=0; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
137 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers); |
15789
32d9c8a0a02b
adds some more -identify output, patch by kiriuja < mplayer DASH patches PAM en DASH directo POUM net>
gpoirier
parents:
15058
diff
changeset
|
138 if (identify) |
32d9c8a0a02b
adds some more -identify output, patch by kiriuja < mplayer DASH patches PAM en DASH directo POUM net>
gpoirier
parents:
15058
diff
changeset
|
139 mp_msg(MSGT_GLOBAL, MSGL_INFO, "ID_AUDIO_OUTPUTS\n"); |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
140 while (audio_out_drivers[i]) { |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
141 const ao_info_t *info = audio_out_drivers[i++]->info; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
142 printf("\t%s\t%s\n", info->short_name, info->name); |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
143 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
144 printf("\n"); |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
145 } |
3095 | 146 |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
147 ao_functions_t* init_best_audio_out(char** ao_list,int use_plugin,int rate,int channels,int format,int flags){ |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
148 int i; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
149 // 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
|
150 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
|
151 while(ao_list[0][0]){ |
13632 | 152 char* ao=ao_list[0]; |
153 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
|
154 if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) { |
ed7e91827ead
removing ao_alsa9.c and ao_alsa1x.c as they are superseded by ao_alsa.c
reimar
parents:
13520
diff
changeset
|
155 mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed); |
ed7e91827ead
removing ao_alsa9.c and ao_alsa1x.c as they are superseded by ao_alsa.c
reimar
parents:
13520
diff
changeset
|
156 exit_player(NULL); |
ed7e91827ead
removing ao_alsa9.c and ao_alsa1x.c as they are superseded by ao_alsa.c
reimar
parents:
13520
diff
changeset
|
157 } |
13632 | 158 if (ao_subdevice) { |
159 free(ao_subdevice); | |
160 ao_subdevice = NULL; | |
161 } | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
162 ao_subdevice=strchr(ao,':'); |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
163 if(ao_subdevice){ |
13632 | 164 ao_len = ao_subdevice - ao; |
165 ao_subdevice = strdup(&ao[ao_len + 1]); | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
166 } |
13632 | 167 else |
168 ao_len = strlen(ao); | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
169 for(i=0;audio_out_drivers[i];i++){ |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
170 ao_functions_t* audio_out=audio_out_drivers[i]; |
13632 | 171 if(!strncmp(audio_out->info->short_name,ao,ao_len)){ |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
172 // name matches, try it |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
173 if(audio_out->init(rate,channels,format,flags)) |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
174 return audio_out; // success! |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
175 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
176 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
177 // continue... |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
178 ++ao_list; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
179 if(!(ao_list[0])) return NULL; // do NOT fallback to others |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
180 } |
13632 | 181 if (ao_subdevice) { |
182 free(ao_subdevice); | |
183 ao_subdevice = NULL; | |
184 } | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
185 // now try the rest... |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
186 for(i=0;audio_out_drivers[i];i++){ |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
187 ao_functions_t* audio_out=audio_out_drivers[i]; |
14245 | 188 // if(audio_out->control(AOCONTROL_QUERY_FORMAT, (int)format) == CONTROL_TRUE) |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
189 if(audio_out->init(rate,channels,format,flags)) |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
190 return audio_out; // success! |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
191 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
192 return NULL; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
193 } |
3095 | 194 |