Mercurial > mplayer.hg
annotate libao2/ao_sgi.c @ 21875:d81cf0be50f0
Frametime was being read from the wrong offset, compare
http://www.onicos.com/staff/iz/formats/gif.html#gceb
patch by John Koleszar, jkoleszar on2 com
author | diego |
---|---|
date | Sat, 13 Jan 2007 06:00:34 +0000 |
parents | 99e20a22d5d0 |
children | 85f669a84e7a |
rev | line source |
---|---|
2451 | 1 /* |
2 ao_sgi - sgi/irix output plugin for MPlayer | |
3 | |
4 22oct2001 oliver.schoenbrunner@jku.at | |
5 | |
6 */ | |
7 | |
8 #include <stdio.h> | |
9 #include <stdlib.h> | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
10 #include <unistd.h> |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
11 #include <errno.h> |
2451 | 12 #include <dmedia/audio.h> |
13 | |
14 #include "audio_out.h" | |
15 #include "audio_out_internal.h" | |
14123 | 16 #include "mp_msg.h" |
17 #include "help_mp.h" | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
18 #include "libaf/af_format.h" |
2451 | 19 |
20 static ao_info_t info = | |
21 { | |
22 "sgi audio output", | |
23 "sgi", | |
13549 | 24 "Oliver Schoenbrunner", |
2451 | 25 "" |
26 }; | |
27 | |
28 LIBAO_EXTERN(sgi) | |
29 | |
30 | |
31 static ALconfig ao_config; | |
32 static ALport ao_port; | |
11323 | 33 static int sample_rate; |
34 static int queue_size; | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
35 static int bytes_per_frame; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
36 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
37 /** |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
38 * \param [in/out] format |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
39 * \param [out] width |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
40 * |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
41 * \return the closest matching SGI AL sample format |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
42 * |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
43 * \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
|
44 * 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
|
45 */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
46 static int fmt2sgial(int *format, int *width) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
47 int smpfmt = AL_SAMPFMT_TWOSCOMP; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
48 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
49 /* SGI AL only supports float and signed integers in native |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
50 * endianess. If this is something else, we must rely on the audio |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
51 * filter to convert it to a compatible format. */ |
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 /* 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
|
54 * mplayer's 24-bit format is packed, unfortunately. |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
55 * 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
|
56 * lowest 8 bits during playback. */ |
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 switch(*format) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
59 case AF_FORMAT_U8: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
60 case AF_FORMAT_S8: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
61 *width = AL_SAMPLE_8; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
62 *format = AF_FORMAT_S8; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
63 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
64 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
65 case AF_FORMAT_U16_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
66 case AF_FORMAT_U16_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
67 case AF_FORMAT_S16_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
68 case AF_FORMAT_S16_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
69 *width = AL_SAMPLE_16; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
70 *format = AF_FORMAT_S16_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
71 break; |
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 case AF_FORMAT_U24_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
74 case AF_FORMAT_U24_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
75 case AF_FORMAT_S24_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
76 case AF_FORMAT_S24_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
77 case AF_FORMAT_U32_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
78 case AF_FORMAT_U32_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
79 case AF_FORMAT_S32_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
80 case AF_FORMAT_S32_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
81 *width = AL_SAMPLE_24; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
82 *format = AF_FORMAT_S32_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
83 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
84 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
85 case AF_FORMAT_FLOAT_LE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
86 case AF_FORMAT_FLOAT_BE: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
87 *width = 4; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
88 *format = AF_FORMAT_FLOAT_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
89 smpfmt = AL_SAMPFMT_FLOAT; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
90 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
91 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
92 default: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
93 *width = AL_SAMPLE_16; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
94 *format = AF_FORMAT_S16_NE; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
95 break; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
96 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
97 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
98 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
99 return smpfmt; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
100 } |
2451 | 101 |
102 // to set/get/query special features/parameters | |
9633
12b1790038b0
64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents:
3095
diff
changeset
|
103 static int control(int cmd, void *arg){ |
2451 | 104 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
105 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_INFO); |
2451 | 106 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
107 switch(cmd) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
108 case AOCONTROL_QUERY_FORMAT: |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
109 /* 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
|
110 * format if the request is not supported natively. */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
111 return CONTROL_TRUE; |
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 CONTROL_UNKNOWN; |
2451 | 115 } |
116 | |
117 // open & setup audio device | |
118 // return: 1=success 0=fail | |
119 static int init(int rate, int channels, int format, int flags) { | |
14249 | 120 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
121 int smpwidth, smpfmt; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
122 int rv = AL_DEFAULT_OUTPUT; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
123 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
124 smpfmt = fmt2sgial(&format, &smpwidth); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
125 |
14264 | 126 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_InitInfo, rate, (channels > 1) ? "Stereo" : "Mono", af_fmt2str_short(format)); |
2451 | 127 |
128 { /* from /usr/share/src/dmedia/audio/setrate.c */ | |
129 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
130 double frate, realrate; |
2451 | 131 ALpv x[2]; |
132 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
133 if(ao_subdevice) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
134 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
|
135 if (!rv) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
136 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
|
137 return 0; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
138 } |
2451 | 139 } |
140 | |
141 frate = rate; | |
11323 | 142 |
2451 | 143 x[0].param = AL_RATE; |
144 x[0].value.ll = alDoubleToFixed(rate); | |
145 x[1].param = AL_MASTER_CLOCK; | |
146 x[1].value.i = AL_CRYSTAL_MCLK_TYPE; | |
147 | |
148 if (alSetParams(rv,x, 2)<0) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
149 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetParms_Samplerate, alGetErrorString(oserror())); |
2451 | 150 } |
151 | |
152 if (x[0].sizeOut < 0) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
153 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantSetAlRate); |
2451 | 154 } |
155 | |
156 if (alGetParams(rv,x, 1)<0) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
157 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_SGI_CantGetParms, alGetErrorString(oserror())); |
2451 | 158 } |
159 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
160 realrate = alFixedToDouble(x[0].value.ll); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
161 if (frate != realrate) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
162 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_SampleRateInfo, realrate, frate); |
2451 | 163 } |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
164 sample_rate = (int)realrate; |
2451 | 165 } |
166 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
167 bytes_per_frame = channels * smpwidth; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
168 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
169 ao_data.samplerate = sample_rate; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
170 ao_data.channels = channels; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
171 ao_data.format = format; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
172 ao_data.bps = sample_rate * bytes_per_frame; |
3095 | 173 ao_data.buffersize=131072; |
174 ao_data.outburst = ao_data.buffersize/16; | |
2451 | 175 |
176 ao_config = alNewConfig(); | |
177 | |
178 if (!ao_config) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
179 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror())); |
2451 | 180 return 0; |
181 } | |
182 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
183 if(alSetChannels(ao_config, channels) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
184 alSetWidth(ao_config, smpwidth) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
185 alSetSampFmt(ao_config, smpfmt) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
186 alSetQueueSize(ao_config, sample_rate) < 0 || |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
187 alSetDevice(ao_config, rv) < 0) { |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
188 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitConfigError, alGetErrorString(oserror())); |
2451 | 189 return 0; |
190 } | |
191 | |
192 ao_port = alOpenPort("mplayer", "w", ao_config); | |
193 | |
194 if (!ao_port) { | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
195 mp_msg(MSGT_AO, MSGL_ERR, MSGTR_AO_SGI_InitOpenAudioFailed, alGetErrorString(oserror())); |
2451 | 196 return 0; |
197 } | |
198 | |
199 // printf("ao_sgi, init: port %d config %d\n", ao_port, ao_config); | |
11323 | 200 queue_size = alGetQueueSize(ao_config); |
2451 | 201 return 1; |
202 | |
203 } | |
204 | |
205 // close audio device | |
12145 | 206 static void uninit(int immed) { |
2451 | 207 |
208 /* TODO: samplerate should be set back to the value before mplayer was started! */ | |
209 | |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
210 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Uninit); |
2451 | 211 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
212 if (ao_config) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
213 alFreeConfig(ao_config); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
214 ao_config = NULL; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
215 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
216 |
2451 | 217 if (ao_port) { |
14849
d313f591d1a4
aos should respect the immed uninit flag (quit immediatly vs waiting till file
reimar
parents:
14264
diff
changeset
|
218 if (!immed) |
2451 | 219 while(alGetFilled(ao_port) > 0) sginap(1); |
220 alClosePort(ao_port); | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
221 ao_port = NULL; |
2451 | 222 } |
223 | |
224 } | |
225 | |
226 // stop playing and empty buffers (for seeking/pause) | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
227 static void reset(void) { |
2451 | 228 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
229 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_Reset); |
2451 | 230 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
231 alDiscardFrames(ao_port, queue_size); |
2451 | 232 } |
233 | |
234 // stop playing, keep buffers (for pause) | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
235 static void audio_pause(void) { |
2451 | 236 |
13383
c1955840883d
mp_msg transition of unmaintained audio output drivers.
ivo
parents:
12145
diff
changeset
|
237 mp_msg(MSGT_AO, MSGL_INFO, MSGTR_AO_SGI_PauseInfo); |
2451 | 238 |
239 } | |
240 | |
241 // resume playing, after audio_pause() | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
242 static void audio_resume(void) { |
2451 | 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_ResumeInfo); |
2451 | 245 |
246 } | |
247 | |
248 // return: how many bytes can be played without blocking | |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
249 static int get_space(void) { |
2451 | 250 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
251 // printf("ao_sgi, get_space: (ao_outburst %d)\n", ao_data.outburst); |
2451 | 252 // printf("ao_sgi, get_space: alGetFillable [%d] \n", alGetFillable(ao_port)); |
253 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
254 return alGetFillable(ao_port) * bytes_per_frame; |
2451 | 255 |
256 } | |
257 | |
258 | |
259 // plays 'len' bytes of 'data' | |
260 // it should round it down to outburst*n | |
261 // return: number of bytes played | |
262 static int play(void* data, int len, int flags) { | |
263 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
264 /* 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
|
265 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
|
266 const int framecount = plen * sizeof(uint64_t); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
267 |
2451 | 268 // 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
|
269 // printf("channels %d\n", ao_data.channels); |
2451 | 270 |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
271 if(ao_data.format == AF_FORMAT_S32_NE) { |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
272 /* The zen of this is explained in fmt2sgial() */ |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
273 int32_t *smpls = data; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
274 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
|
275 while(smpls < smple) |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
276 *smpls++ >>= 8; |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
277 } |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
278 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
279 alWriteFrames(ao_port, data, framecount); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
280 |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
281 return framecount * bytes_per_frame; |
2451 | 282 |
283 } | |
284 | |
3095 | 285 // return: delay in seconds between first and last sample in buffer |
18915
99e20a22d5d0
modifies function declarations without parameters from ()
reynaldo
parents:
16667
diff
changeset
|
286 static float get_delay(void){ |
2451 | 287 |
288 // printf("ao_sgi, get_delay: (ao_buffersize %d)\n", ao_buffersize); | |
289 | |
16667
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
290 // return (float)queue_size/((float)sample_rate); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
291 const int outstanding = alGetFilled(ao_port); |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
292 return (float)((outstanding < 0) ? queue_size : outstanding) / |
27a2bc4aad72
General bug fixes, like missing includes, formats that were incorrectly
reimar
parents:
14849
diff
changeset
|
293 ((float)sample_rate); |
2451 | 294 } |
295 | |
296 | |
297 | |
298 | |
299 | |
300 |