Mercurial > mplayer.hg
annotate libao2/audio_out.c @ 13980:e0d400094e88
24bit LPCM is signed...
author | reimar |
---|---|
date | Fri, 19 Nov 2004 14:42:17 +0000 |
parents | 66637fa67531 |
children | a92101a7eb49 |
rev | line source |
---|---|
954 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
7848 | 3 #include <string.h> |
954 | 4 |
5 #include "../config.h" | |
6 #include "audio_out.h" | |
1058 | 7 #include "afmt.h" |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
8 |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
9 #include "../mp_msg.h" |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
10 #include "../help_mp.h" |
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 |
954 | 34 extern ao_functions_t audio_out_null; |
1007 | 35 #ifdef HAVE_ALSA5 |
36 extern ao_functions_t audio_out_alsa5; | |
37 #endif | |
1032 | 38 #ifdef HAVE_ALSA9 |
12462 | 39 extern ao_functions_t audio_out_alsa; |
1032 | 40 #endif |
11775 | 41 #ifdef HAVE_ALSA1X |
12462 | 42 extern ao_functions_t audio_out_alsa; |
11775 | 43 #endif |
3276 | 44 #ifdef HAVE_NAS |
45 extern ao_functions_t audio_out_nas; | |
46 #endif | |
966
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
47 #ifdef HAVE_SDL |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
48 extern ao_functions_t audio_out_sdl; |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
49 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
50 #ifdef USE_SUN_AUDIO |
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
51 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
|
52 #endif |
2450 | 53 #ifdef USE_SGI_AUDIO |
54 extern ao_functions_t audio_out_sgi; | |
55 #endif | |
7916 | 56 #ifdef HAVE_WIN32WAVEOUT |
57 extern ao_functions_t audio_out_win32; | |
58 #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
|
59 #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
|
60 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
|
61 #endif |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
62 #ifdef HAVE_DXR2 |
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
63 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
|
64 #endif |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4097
diff
changeset
|
65 extern ao_functions_t audio_out_mpegpes; |
1107 | 66 extern ao_functions_t audio_out_pcm; |
1185 | 67 extern ao_functions_t audio_out_pss; |
3095 | 68 extern ao_functions_t audio_out_plugin; |
954 | 69 |
70 ao_functions_t* audio_out_drivers[] = | |
71 { | |
7609 | 72 // vo-related: will fail unless you also do -vo mpegpes/dxr2 |
73 &audio_out_mpegpes, | |
74 #ifdef HAVE_DXR2 | |
75 &audio_out_dxr2, | |
76 #endif | |
77 // 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
|
78 #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
|
79 &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
|
80 #endif |
8729
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
81 #ifdef HAVE_WIN32WAVEOUT |
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
82 &audio_out_win32, |
561aa9c850f7
Rearrange the vo and ao driver order to prefer the native drivers and give
diego
parents:
8572
diff
changeset
|
83 #endif |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
84 #ifdef USE_OSS_AUDIO |
954 | 85 &audio_out_oss, |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1032
diff
changeset
|
86 #endif |
11775 | 87 #ifdef HAVE_ALSA1X |
12462 | 88 &audio_out_alsa, |
11775 | 89 #endif |
7609 | 90 #ifdef HAVE_ALSA9 |
12462 | 91 &audio_out_alsa, |
6214
0398cb49fe5e
aRts audio out support by Michele Balistreri <brain at email.it>
atmos4
parents:
6069
diff
changeset
|
92 #endif |
7609 | 93 #ifdef HAVE_ALSA5 |
94 &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
|
95 #endif |
2450 | 96 #ifdef USE_SGI_AUDIO |
97 &audio_out_sgi, | |
98 #endif | |
7609 | 99 #ifdef USE_SUN_AUDIO |
100 &audio_out_sun, | |
6069
8e88e92fe331
Initial support for dxr2. Based on patch from Tobias Diedrich <ranma@gmx.at>.
albeu
parents:
5192
diff
changeset
|
101 #endif |
7609 | 102 // wrappers: |
103 #ifdef USE_ARTS | |
104 &audio_out_arts, | |
1032 | 105 #endif |
8572 | 106 #ifdef USE_ESD |
107 &audio_out_esd, | |
108 #endif | |
13878
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
109 #ifdef USE_POLYP |
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
110 &audio_out_polyp, |
66637fa67531
polyaudio audio driver patch by Lennart Poettering <mzzcynlre at 0pointer.de>
faust3
parents:
13632
diff
changeset
|
111 #endif |
12662
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
112 #ifdef USE_JACK |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
113 &audio_out_jack, |
05d46af5e2bf
JACK audio support through bio2jack by Kamil Strzelecki <esack@o2.pl>
alex
parents:
12636
diff
changeset
|
114 #endif |
3276 | 115 #ifdef HAVE_NAS |
116 &audio_out_nas, | |
117 #endif | |
966
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
118 #ifdef HAVE_SDL |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
119 &audio_out_sdl, |
69b4f944ce08
Added support for sdl audio out (buggy pre-alpha).
atmosfear
parents:
954
diff
changeset
|
120 #endif |
12636
58dca847caa0
move macosx in the priority list after sdl, patch by Dan Christiansen
alex
parents:
12462
diff
changeset
|
121 #ifdef MACOSX |
58dca847caa0
move macosx in the priority list after sdl, patch by Dan Christiansen
alex
parents:
12462
diff
changeset
|
122 &audio_out_macosx, |
58dca847caa0
move macosx in the priority list after sdl, patch by Dan Christiansen
alex
parents:
12462
diff
changeset
|
123 #endif |
7609 | 124 &audio_out_null, |
125 // should not be auto-selected: | |
1107 | 126 &audio_out_pcm, |
3095 | 127 &audio_out_plugin, |
954 | 128 NULL |
129 }; | |
3095 | 130 |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
131 void list_audio_out(){ |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
132 int i=0; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
133 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AvailableAudioOutputDrivers); |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
134 while (audio_out_drivers[i]) { |
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; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
136 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
|
137 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
138 printf("\n"); |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
139 } |
3095 | 140 |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
141 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
|
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) { |
ed7e91827ead
removing ao_alsa9.c and ao_alsa1x.c as they are superseded by ao_alsa.c
reimar
parents:
13520
diff
changeset
|
149 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
|
150 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
|
151 } |
13632 | 152 if (ao_subdevice) { |
153 free(ao_subdevice); | |
154 ao_subdevice = NULL; | |
155 } | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
156 ao_subdevice=strchr(ao,':'); |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
157 if(ao_subdevice){ |
13632 | 158 ao_len = ao_subdevice - ao; |
159 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
|
160 } |
13632 | 161 else |
162 ao_len = strlen(ao); | |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
163 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
|
164 ao_functions_t* audio_out=audio_out_drivers[i]; |
13632 | 165 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
|
166 // name matches, try it |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
167 if(use_plugin){ |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
8729
diff
changeset
|
168 audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out); |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
169 audio_out=&audio_out_plugin; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
170 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
171 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
|
172 return audio_out; // success! |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
173 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
174 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
175 // continue... |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
176 ++ao_list; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
177 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
|
178 } |
13632 | 179 if (ao_subdevice) { |
180 free(ao_subdevice); | |
181 ao_subdevice = NULL; | |
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++){ |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
185 ao_functions_t* audio_out=audio_out_drivers[i]; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
186 if(use_plugin){ |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
8729
diff
changeset
|
187 audio_out_plugin.control(AOCONTROL_SET_PLUGIN_DRIVER,audio_out); |
7563
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
188 audio_out=&audio_out_plugin; |
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 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
|
191 return audio_out; // success! |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
192 } |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
193 return NULL; |
e9e4398029de
audio out driver list support (example: -ao alsa9,sdl:esd,oss,sdl:oss,)
arpi
parents:
6214
diff
changeset
|
194 } |
3095 | 195 |