Mercurial > mplayer.hg
annotate libao2/ao_sgi.c @ 35580:f47dbb805ecb
Replace an unnecessary SSE4 instruction.
author | upsuper |
---|---|
date | Thu, 13 Dec 2012 05:19:20 +0000 |
parents | 32725ca88fed |
children |
rev | line source |
---|---|
2451 | 1 /* |
28343 | 2 * SGI/IRIX audio output driver |
3 * | |
4 * copyright (c) 2001 oliver.schoenbrunner@jku.at | |
5 * | |
6 * This file is part of MPlayer. | |
7 * | |
8 * MPlayer is free software; you can redistribute it and/or modify | |
9 * it under the terms of the GNU General Public License as published by | |
10 * the Free Software Foundation; either version 2 of the License, or | |
11 * (at your option) any later version. | |
12 * | |
13 * MPlayer is distributed in the hope that it will be useful, | |
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 * GNU General Public License for more details. | |
17 * | |
18 * You should have received a copy of the GNU General Public License along | |
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
21 */ | |
2451 | 22 |
23 #include <stdio.h> | |
24 #include <stdlib.h> | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
25 #include <unistd.h> |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
26 #include <errno.h> |
2451 | 27 #include <dmedia/audio.h> |
28 | |
29 #include "audio_out.h" | |
30 #include "audio_out_internal.h" | |
14123 | 31 #include "mp_msg.h" |
32 #include "help_mp.h" | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
33 #include "libaf/af_format.h" |
2451 | 34 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
35 static const ao_info_t info = |
2451 | 36 { |
37 "sgi audio output", | |
38 "sgi", | |
13549 | 39 "Oliver Schoenbrunner", |
2451 | 40 "" |
41 }; | |
42 | |
43 LIBAO_EXTERN(sgi) | |
44 | |
45 | |
46 static ALconfig ao_config; | |
47 static ALport ao_port; | |
11323 | 48 static int sample_rate; |
49 static int queue_size; | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
50 static int bytes_per_frame; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
51 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
52 /** |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
53 * \param [in/out] format |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
54 * \param [out] width |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
55 * |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
56 * \return the closest matching SGI AL sample format |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
57 * |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
58 * \note width is set to required per-channel sample width |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
59 * format is updated to match the SGI AL sample format |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
60 */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
61 static int fmt2sgial(int *format, int *width) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
62 int smpfmt = AL_SAMPFMT_TWOSCOMP; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
63 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
64 /* SGI AL only supports float and signed integers in native |
24595 | 65 * endianness. If this is something else, we must rely on the audio |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
66 * filter to convert it to a compatible format. */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
67 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
68 /* 24-bit audio is supported, but only with 32-bit alignment. |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
69 * mplayer's 24-bit format is packed, unfortunately. |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
70 * So we must upgrade 24-bit requests to 32 bits. Then we drop the |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
71 * lowest 8 bits during playback. */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
72 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
73 switch(*format) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
74 case AF_FORMAT_U8: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
75 case AF_FORMAT_S8: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
76 *width = AL_SAMPLE_8; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
77 *format = AF_FORMAT_S8; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
78 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
79 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
80 case AF_FORMAT_U16_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
81 case AF_FORMAT_U16_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
82 case AF_FORMAT_S16_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
83 case AF_FORMAT_S16_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
84 *width = AL_SAMPLE_16; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
85 *format = AF_FORMAT_S16_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
86 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
87 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
88 case AF_FORMAT_U24_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
89 case AF_FORMAT_U24_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
90 case AF_FORMAT_S24_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
91 case AF_FORMAT_S24_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
92 case AF_FORMAT_U32_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
93 case AF_FORMAT_U32_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
94 case AF_FORMAT_S32_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
95 case AF_FORMAT_S32_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
96 *width = AL_SAMPLE_24; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
97 *format = AF_FORMAT_S32_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
98 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
99 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
100 case AF_FORMAT_FLOAT_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
101 case AF_FORMAT_FLOAT_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
102 *width = 4; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
103 *format = AF_FORMAT_FLOAT_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
104 smpfmt = AL_SAMPFMT_FLOAT; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
105 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
106 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
107 default: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
108 *width = AL_SAMPLE_16; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
109 *format = AF_FORMAT_S16_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
110 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
111 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
112 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
113 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
114 return smpfmt; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
115 } |
2451 | 116 |
117 // to set/get/query special features/parameters | |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
3095
diff
changeset
|
118 static int control(int cmd, void *arg){ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
119 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
120 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_INFO); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
121 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
122 switch(cmd) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
123 case AOCONTROL_QUERY_FORMAT: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
124 /* Do not reject any format: return the closest matching |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
125 * format if the request is not supported natively. */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
126 return CONTROL_TRUE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
127 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
128 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
129 return CONTROL_UNKNOWN; |
2451 | 130 } |
131 | |
132 // open & setup audio device | |
133 // return: 1=success 0=fail | |
134 static int init(int rate, int channels, int format, int flags) { | |
14249 | 135 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
136 int smpwidth, smpfmt; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
137 int rv = AL_DEFAULT_OUTPUT; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
138 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
139 smpfmt = fmt2sgial(&format, &smpwidth); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
140 |
14264 | 141 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_InitInfo, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
142 |
2451 | 143 { /* from /usr/share/src/dmedia/audio/setrate.c */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
144 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
145 double frate, realrate; |
2451 | 146 ALpv x[2]; |
147 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
148 if(ao_subdevice) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
149 rv = alGetResourceByName(AL_SYSTEM, ao_subdevice, AL_OUTPUT_DEVICE_TYPE); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
150 if (!rv) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
151 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InvalidDevice); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
152 return 0; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
153 } |
2451 | 154 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
155 |
2451 | 156 frate = rate; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
157 |
2451 | 158 x[0].param = AL_RATE; |
159 x[0].value.ll = alDoubleToFixed(rate); | |
160 x[1].param = AL_MASTER_CLOCK; | |
161 x[1].value.i = AL_CRYSTAL_MCLK_TYPE; | |
162 | |
163 if (alSetParams(rv,x, 2)<0) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
164 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetParms_Samplerate, alGetErrorString(oserror())); |
2451 | 165 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
166 |
2451 | 167 if (x[0].sizeOut < 0) { |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
168 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetAlRate); |
2451 | 169 } |
170 | |
171 if (alGetParams(rv,x, 1)<0) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
172 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantGetParms, alGetErrorString(oserror())); |
2451 | 173 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
174 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
175 realrate = alFixedToDouble(x[0].value.ll); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
176 if (frate != realrate) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
177 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_SampleRateInfo, realrate, frate); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
178 } |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
179 sample_rate = (int)realrate; |
2451 | 180 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
181 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
182 bytes_per_frame = channels * smpwidth; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
183 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
184 ao_data.samplerate = sample_rate; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
185 ao_data.channels = channels; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
186 ao_data.format = format; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
187 ao_data.bps = sample_rate * bytes_per_frame; |
3095 | 188 ao_data.buffersize=131072; |
189 ao_data.outburst = ao_data.buffersize/16; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
190 |
2451 | 191 ao_config = alNewConfig(); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
192 |
2451 | 193 if (!ao_config) { |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
194 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror())); |
2451 | 195 return 0; |
196 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
197 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
198 if(alSetChannels(ao_config, channels) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
199 alSetWidth(ao_config, smpwidth) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
200 alSetSampFmt(ao_config, smpfmt) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
201 alSetQueueSize(ao_config, sample_rate) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
202 alSetDevice(ao_config, rv) < 0) { |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
203 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror())); |
2451 | 204 return 0; |
205 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
206 |
2451 | 207 ao_port = alOpenPort("mplayer", "w", ao_config); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
208 |
2451 | 209 if (!ao_port) { |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
210 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitOpenAudioFailed, alGetErrorString(oserror())); |
2451 | 211 return 0; |
212 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
213 |
2451 | 214 // printf("ao_sgi, init: port %d config %d\n", ao_port, ao_config); |
11323 | 215 queue_size = alGetQueueSize(ao_config); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
216 return 1; |
2451 | 217 |
218 } | |
219 | |
220 // close audio device | |
12145 | 221 static void uninit(int immed) { |
2451 | 222 |
223 /* TODO: samplerate should be set back to the value before mplayer was started! */ | |
224 | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
225 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Uninit); |
2451 | 226 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
227 if (ao_config) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
228 alFreeConfig(ao_config); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
229 ao_config = NULL; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
230 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
231 |
2451 | 232 if (ao_port) { |
14849
d313f591d1a4
aos should respect the immed uninit flag (quit immediatly vs waiting till file
reimar
parents:
14264
diff
changeset
|
233 if (!immed) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
234 while(alGetFilled(ao_port) > 0) sginap(1); |
2451 | 235 alClosePort(ao_port); |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
236 ao_port = NULL; |
2451 | 237 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
238 |
2451 | 239 } |
240 | |
241 // stop playing and empty buffers (for seeking/pause) | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
242 static void reset(void) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
243 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
244 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Reset); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
245 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
246 alDiscardFrames(ao_port, queue_size); |
2451 | 247 } |
248 | |
249 // stop playing, keep buffers (for pause) | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
250 static void audio_pause(void) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
251 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
252 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_PauseInfo); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
253 |
2451 | 254 } |
255 | |
256 // resume playing, after audio_pause() | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
257 static void audio_resume(void) { |
2451 | 258 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
259 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_ResumeInfo); |
2451 | 260 |
261 } | |
262 | |
263 // return: how many bytes can be played without blocking | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
264 static int get_space(void) { |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
265 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
266 // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_data.outburst); |
2451 | 267 // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
268 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
269 return alGetFillable(ao_port) * bytes_per_frame; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
270 |
2451 | 271 } |
272 | |
273 | |
274 // plays 'len' bytes of 'data' | |
275 // it should round it down to outburst*n | |
276 // return: number of bytes played | |
277 static int play(void* data, int len, int flags) { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
278 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
279 /* Always process data in quadword-aligned chunks (64-bits). */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
280 const int plen = len / (sizeof(uint64_t) * bytes_per_frame); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
281 const int framecount = plen * sizeof(uint64_t); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
282 |
2451 | 283 // printf("ao_sgi, play: len %d flags %d (%d %d)\n", len, flags, ao_port, ao_config); |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
284 // printf("channels %d\n", ao_data.channels); |
2451 | 285 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
286 if(ao_data.format == AF_FORMAT_S32_NE) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
287 /* The zen of this is explained in fmt2sgial() */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
288 int32_t *smpls = data; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
289 const int32_t *smple = smpls + (framecount * ao_data.channels); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
290 while(smpls < smple) |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
291 *smpls++ >>= 8; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
292 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
293 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
294 alWriteFrames(ao_port, data, framecount); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
295 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
296 return framecount * bytes_per_frame; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
297 |
2451 | 298 } |
299 | |
3095 | 300 // return: delay in seconds between first and last sample in buffer |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
301 static float get_delay(void){ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
302 |
2451 | 303 // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28823
diff
changeset
|
304 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
305 // return (float)queue_size/((float)sample_rate); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
306 const int outstanding = alGetFilled(ao_port); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
307 return (float)((outstanding < 0) ? queue_size : outstanding) / |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
308 ((float)sample_rate); |
2451 | 309 } |