Mercurial > mplayer.hg
annotate libao2/ao_alsa1x.c @ 1180:c50cd5db2359
added warning message
author | al3x |
---|---|
date | Thu, 21 Jun 2001 21:27:56 +0000 |
parents | a84610bb5476 |
children | bf18175dfad7 |
rev | line source |
---|---|
1050 | 1 /* |
2 ao_alsa9 - ALSA-0.9.x output plugin for MPlayer | |
3 | |
4 (C) Alex Beregszaszi <alex@naxine.org> | |
1180 | 5 |
6 Don't use this buggy driver, ALSA-0.9.x emulates OSS very well... | |
1050 | 7 */ |
8 | |
9 #include <errno.h> | |
10 #include <sys/asoundlib.h> | |
11 | |
12 #include "../config.h" | |
13 | |
14 #include "audio_out.h" | |
15 #include "audio_out_internal.h" | |
1058 | 16 #include "afmt.h" |
1050 | 17 |
18 extern int verbose; | |
19 | |
20 static ao_info_t info = | |
21 { | |
22 "ALSA-0.9.x audio output", | |
23 "alsa9", | |
24 "Alex Beregszaszi <alex@naxine.org>", | |
25 "under developement" | |
26 }; | |
27 | |
28 LIBAO_EXTERN(alsa9) | |
29 | |
30 /* global variables: | |
31 ao_samplerate | |
32 ao_channels | |
33 ao_format | |
34 ao_bps | |
35 ao_outburst | |
36 ao_buffersize | |
37 */ | |
38 | |
39 static snd_pcm_t *alsa_handler; | |
40 static snd_pcm_format_t alsa_format; | |
41 static snd_pcm_hw_params_t *alsa_hwparams; | |
42 static snd_pcm_sw_params_t *alsa_swparams; | |
43 static char *alsa_device; | |
44 #define ALSA_DEVICE_SIZE 48 | |
45 | |
1128 | 46 static int alsa_fragsize = 8192; /* 4096 */ |
47 static int alsa_fragcount = 8; | |
48 | |
1050 | 49 /* to set/get/query special features/parameters */ |
50 static int control(int cmd, int arg) | |
51 { | |
52 switch(cmd) | |
53 { | |
54 case AOCONTROL_GET_DEVICE: | |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
55 return((char *)alsa_device); /* egy kicsit brutalis, dehat :) */ |
1050 | 56 case AOCONTROL_SET_DEVICE: |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
57 { |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
58 int ret; |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
59 |
1050 | 60 strncpy(alsa_device, (char *)arg, ALSA_DEVICE_SIZE); |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
61 uninit(); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
62 ret = init(ao_samplerate, ao_channels, ao_format, 0); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
63 if (ret == 0) |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
64 return(CONTROL_ERROR); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
65 else |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
66 return(CONTROL_OK); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
67 } |
1050 | 68 } |
69 return(CONTROL_UNKNOWN); | |
70 } | |
71 | |
1128 | 72 #undef start |
73 #define buffersize | |
74 #undef buffertime | |
75 #define set_period | |
76 #undef sw_params | |
77 #undef set_start_mode | |
78 | |
1050 | 79 /* |
80 open & setup audio device | |
81 return: 1=success 0=fail | |
82 */ | |
83 static int init(int rate_hz, int channels, int format, int flags) | |
84 { | |
85 int err; | |
86 int cards = -1; | |
87 snd_pcm_info_t *alsa_info; | |
1180 | 88 |
89 printf("alsa-init: Don't use this buggy driver, ALSA-0.9.x emulates OSS very well...\n"); | |
1050 | 90 |
91 printf("alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz, | |
92 channels, audio_out_format_name(format)); | |
93 | |
94 alsa_handler = NULL; | |
95 | |
96 if (verbose) | |
97 printf("alsa-init: compiled for ALSA-%s (%d)\n", SND_LIB_VERSION_STR, | |
98 SND_LIB_VERSION); | |
99 | |
100 if ((err = snd_card_next(&cards)) < 0 || cards < 0) | |
101 { | |
102 printf("alsa-init: no soundcards found: %s\n", snd_strerror(err)); | |
103 return(0); | |
104 } | |
105 | |
1128 | 106 ao_samplerate = rate_hz; |
107 ao_bps = channels; /* really this is bytes per frame so bad varname */ | |
1050 | 108 ao_format = format; |
1128 | 109 ao_channels = channels; |
1050 | 110 ao_outburst = OUTBURST; |
111 ao_buffersize = 16384; | |
112 | |
113 switch (format) | |
114 { | |
115 case AFMT_S8: | |
116 alsa_format = SND_PCM_FORMAT_S8; | |
117 break; | |
118 case AFMT_U8: | |
119 alsa_format = SND_PCM_FORMAT_U8; | |
120 break; | |
121 case AFMT_U16_LE: | |
122 alsa_format = SND_PCM_FORMAT_U16_LE; | |
123 break; | |
124 case AFMT_U16_BE: | |
125 alsa_format = SND_PCM_FORMAT_U16_BE; | |
126 break; | |
127 case AFMT_S16_LE: | |
128 alsa_format = SND_PCM_FORMAT_S16_LE; | |
129 break; | |
130 case AFMT_S16_BE: | |
131 alsa_format = SND_PCM_FORMAT_S16_BE; | |
132 break; | |
133 default: | |
134 alsa_format = SND_PCM_FORMAT_MPEG; | |
135 break; | |
136 } | |
137 | |
138 switch(alsa_format) | |
139 { | |
140 case SND_PCM_FORMAT_S16_LE: | |
141 case SND_PCM_FORMAT_U16_LE: | |
142 ao_bps *= 2; | |
143 break; | |
144 case -1: | |
145 printf("alsa-init: invalid format (%s) requested - output disabled\n", | |
146 audio_out_format_name(format)); | |
147 return(0); | |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
148 default: |
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
149 break; |
1050 | 150 } |
1128 | 151 |
1050 | 152 if ((err = snd_pcm_info_malloc(&alsa_info)) < 0) |
153 { | |
154 printf("alsa-init: memory allocation error: %s\n", snd_strerror(err)); | |
155 return(0); | |
156 } | |
157 | |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
158 if (alsa_device == NULL) |
1050 | 159 { |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
160 if ((alsa_device = malloc(ALSA_DEVICE_SIZE)) == NULL) |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
161 { |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
162 printf("alsa-init: memory allocation error: %s\n", strerror(errno)); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
163 return(0); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
164 } |
1050 | 165 |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
166 snprintf(alsa_device, ALSA_DEVICE_SIZE, "hw:%d,%d", |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
167 snd_pcm_info_get_device(alsa_info), |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
168 snd_pcm_info_get_subdevice(alsa_info)); |
1050 | 169 |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
170 snd_pcm_info_free(alsa_info); |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
171 } |
1050 | 172 |
173 printf("alsa-init: %d soundcard%s found, using: %s\n", cards+1, | |
174 (cards >= 0) ? "" : "s", alsa_device); | |
175 | |
176 if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK, | |
177 0)) < 0) | |
178 { | |
179 printf("alsa-init: playback open error: %s\n", snd_strerror(err)); | |
180 return(0); | |
181 } | |
182 | |
183 snd_pcm_hw_params_malloc(&alsa_hwparams); | |
184 snd_pcm_sw_params_malloc(&alsa_swparams); | |
185 | |
186 if ((err = snd_pcm_hw_params_any(alsa_handler, alsa_hwparams)) < 0) | |
187 { | |
188 printf("alsa-init: unable to get initial parameters: %s\n", | |
189 snd_strerror(err)); | |
190 return(0); | |
191 } | |
192 | |
193 if ((err = snd_pcm_hw_params_set_access(alsa_handler, alsa_hwparams, | |
194 SND_PCM_ACCESS_RW_INTERLEAVED)) < 0) | |
195 { | |
196 printf("alsa-init: unable to set access type: %s\n", | |
197 snd_strerror(err)); | |
198 return(0); | |
199 } | |
200 | |
201 if ((err = snd_pcm_hw_params_set_format(alsa_handler, alsa_hwparams, | |
202 alsa_format)) < 0) | |
203 { | |
204 printf("alsa-init: unable to set format: %s\n", | |
205 snd_strerror(err)); | |
206 return(0); | |
207 } | |
208 | |
209 if ((err = snd_pcm_hw_params_set_channels(alsa_handler, alsa_hwparams, | |
210 ao_channels)) < 0) | |
211 { | |
212 printf("alsa-init: unable to set channels: %s\n", | |
213 snd_strerror(err)); | |
214 return(0); | |
215 } | |
216 | |
1129 | 217 if ((err = snd_pcm_hw_params_set_rate(alsa_handler, alsa_hwparams, |
1050 | 218 ao_samplerate, 0)) < 0) |
219 { | |
1128 | 220 printf("alsa-init: unable to set samplerate: %s\n", |
1050 | 221 snd_strerror(err)); |
222 return(0); | |
223 } | |
224 | |
1128 | 225 #ifdef set_period |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
226 { |
1128 | 227 if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, alsa_fragsize / 4, 0)) < 0) |
228 { | |
229 printf("alsa-init: unable to set periodsize: %s\n", | |
230 snd_strerror(err)); | |
231 return(0); | |
232 } | |
233 if ((err = snd_pcm_hw_params_set_periods(alsa_handler, alsa_hwparams, alsa_fragcount, 0)) < 0) | |
234 { | |
235 printf("alsa-init: unable to set periods: %s\n", | |
236 snd_strerror(err)); | |
237 return(0); | |
238 } | |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
239 } |
1128 | 240 #endif |
1050 | 241 #ifdef buffersize |
242 if ((err = snd_pcm_hw_params_get_buffer_size(alsa_hwparams)) < 0) | |
243 { | |
244 printf("alsa-init: unable to get buffer size: %s\n", | |
245 snd_strerror(err)); | |
246 return(0); | |
247 } else | |
1128 | 248 { |
1050 | 249 ao_buffersize = err; |
1146
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
250 if (verbose) |
a84610bb5476
hacked aocontrol_set_device working, and cleaned up a bit
al3x
parents:
1129
diff
changeset
|
251 printf("alsa-init: got buffersize %i\n", ao_buffersize); |
1128 | 252 } |
1050 | 253 #endif |
254 | |
255 #ifdef buffertime | |
256 { | |
257 int alsa_buffer_time = 60; | |
258 | |
259 if ((err = snd_pcm_hw_params_set_buffer_time_near(alsa_handler, alsa_hwparams, | |
260 alsa_buffer_time, 0)) < 0) | |
261 { | |
262 printf("alsa-init: unable to set buffer time near: %s\n", | |
263 snd_strerror(err)); | |
264 return(0); | |
265 } else | |
266 alsa_buffer_time = err; | |
267 | |
268 if ((err = snd_pcm_hw_params_set_period_time_near(alsa_handler, alsa_hwparams, | |
269 alsa_buffer_time/ao_bps, 0)) < 0) | |
270 { | |
271 printf("alsa-init: unable to set period time: %s\n", | |
272 snd_strerror(err)); | |
273 return(0); | |
274 } | |
1128 | 275 printf("alsa-init: buffer_time: %d, period_time :%d\n", |
276 alsa_buffer_time, err); | |
1050 | 277 } |
278 #endif | |
279 | |
280 if ((err = snd_pcm_hw_params(alsa_handler, alsa_hwparams)) < 0) | |
281 { | |
282 printf("alsa-init: unable to set parameters: %s\n", | |
283 snd_strerror(err)); | |
284 return(0); | |
285 } | |
1128 | 286 |
287 #ifdef sw_params | |
1050 | 288 if ((err = snd_pcm_sw_params_current(alsa_handler, alsa_swparams)) < 0) |
289 { | |
290 printf("alsa-init: unable to get parameters: %s\n", | |
291 snd_strerror(err)); | |
292 return(0); | |
293 } | |
294 | |
1128 | 295 #ifdef set_start_mode |
1050 | 296 if ((err = snd_pcm_sw_params_set_start_mode(alsa_handler, alsa_swparams, |
297 SND_PCM_START_DATA)) < 0) | |
298 { | |
299 printf("alsa-init: unable to set start mode: %s\n", | |
300 snd_strerror(err)); | |
301 return(0); | |
302 } | |
1128 | 303 #endif |
1050 | 304 |
305 if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0) | |
306 { | |
307 printf("alsa-init: unable to set parameters: %s\n", | |
308 snd_strerror(err)); | |
309 return(0); | |
310 } | |
311 | |
1128 | 312 // snd_pcm_sw_params_default(alsa_handler, alsa_swparams); |
313 #endif | |
1050 | 314 if ((err = snd_pcm_prepare(alsa_handler)) < 0) |
315 { | |
316 printf("alsa-init: pcm prepare error: %s\n", snd_strerror(err)); | |
317 return(0); | |
318 } | |
319 | |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
320 #ifdef start |
1050 | 321 if ((err = snd_pcm_start(alsa_handler)) < 0) |
322 { | |
323 printf("alsa-init: pcm start error: %s\n", snd_strerror(err)); | |
324 if (err != -EPIPE) | |
325 return(0); | |
326 if ((err = snd_pcm_start(alsa_handler)) < 0) | |
327 { | |
328 printf("alsa-init: pcm start error: %s\n", snd_strerror(err)); | |
329 return(0); | |
330 } | |
331 } | |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
332 #endif |
1128 | 333 printf("AUDIO: %d Hz/%d channels/%d bpf/%d bytes buffer/%s\n", |
334 ao_samplerate, ao_channels, ao_bps, ao_buffersize, | |
1050 | 335 snd_pcm_format_description(alsa_format)); |
336 return(1); | |
337 } | |
338 | |
339 /* close audio device */ | |
340 static void uninit() | |
341 { | |
342 int err; | |
343 | |
344 if (alsa_device != NULL) | |
345 free(alsa_device); | |
346 | |
347 snd_pcm_hw_params_free(alsa_hwparams); | |
348 snd_pcm_sw_params_free(alsa_swparams); | |
349 | |
350 if ((err = snd_pcm_drain(alsa_handler)) < 0) | |
351 { | |
352 printf("alsa-uninit: pcm drain error: %s\n", snd_strerror(err)); | |
353 return; | |
354 } | |
355 | |
1129 | 356 #ifdef start |
1050 | 357 if ((err = snd_pcm_reset(alsa_handler)) < 0) |
358 { | |
359 printf("alsa-uninit: pcm reset error: %s\n", snd_strerror(err)); | |
360 return; | |
361 } | |
1129 | 362 #endif |
1050 | 363 |
364 if ((err = snd_pcm_close(alsa_handler)) < 0) | |
365 { | |
366 printf("alsa-uninit: pcm close error: %s\n", snd_strerror(err)); | |
367 return; | |
368 } | |
369 } | |
370 | |
371 static void audio_pause() | |
372 { | |
373 int err; | |
374 | |
375 if ((err = snd_pcm_drain(alsa_handler)) < 0) | |
376 { | |
377 printf("alsa-pause: pcm drain error: %s\n", snd_strerror(err)); | |
378 return; | |
379 } | |
380 | |
1129 | 381 #ifdef reset |
1050 | 382 if ((err = snd_pcm_reset(alsa_handler)) < 0) |
383 { | |
384 printf("alsa-pause: pcm reset error: %s\n", snd_strerror(err)); | |
385 return; | |
386 } | |
1129 | 387 #endif |
1050 | 388 } |
389 | |
390 static void audio_resume() | |
391 { | |
392 int err; | |
393 | |
394 if ((err = snd_pcm_prepare(alsa_handler)) < 0) | |
395 { | |
396 printf("alsa-resume: pcm prepare error: %s\n", snd_strerror(err)); | |
397 return; | |
398 } | |
399 | |
1129 | 400 #ifdef start |
1050 | 401 if ((err = snd_pcm_start(alsa_handler)) < 0) |
402 { | |
403 printf("alsa-resume: pcm start error: %s\n", snd_strerror(err)); | |
404 return; | |
405 } | |
1129 | 406 #endif |
1050 | 407 } |
408 | |
409 /* stop playing and empty buffers (for seeking/pause) */ | |
410 static void reset() | |
411 { | |
412 int err; | |
413 | |
414 if ((err = snd_pcm_drain(alsa_handler)) < 0) | |
415 { | |
416 printf("alsa-reset: pcm drain error: %s\n", snd_strerror(err)); | |
417 return; | |
418 } | |
419 | |
1129 | 420 #ifdef start |
1050 | 421 if ((err = snd_pcm_reset(alsa_handler)) < 0) |
422 { | |
423 printf("alsa-reset: pcm reset error: %s\n", snd_strerror(err)); | |
424 return; | |
425 } | |
1129 | 426 #endif |
1050 | 427 |
428 if ((err = snd_pcm_prepare(alsa_handler)) < 0) | |
429 { | |
430 printf("alsa-reset: pcm prepare error: %s\n", snd_strerror(err)); | |
431 return; | |
432 } | |
433 | |
1129 | 434 #ifdef start |
1050 | 435 if ((err = snd_pcm_start(alsa_handler)) < 0) |
436 { | |
437 printf("alsa-reset: pcm start error: %s\n", snd_strerror(err)); | |
438 return; | |
439 } | |
1129 | 440 #endif |
1050 | 441 } |
442 | |
443 /* | |
444 plays 'len' bytes of 'data' | |
445 returns: number of bytes played | |
446 */ | |
447 static int play(void* data, int len, int flags) | |
448 { | |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
449 int got_len; |
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
450 |
1128 | 451 if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps)) |
1050 | 452 { |
1115
a16b569f2702
-Wall style cleanups, TEST IT, it can be working by others
al3x
parents:
1058
diff
changeset
|
453 if (got_len == -EPIPE) /* underrun? */ |
1050 | 454 { |
455 printf("alsa-play: alsa underrun, resetting stream\n"); | |
1128 | 456 if ((got_len = snd_pcm_prepare(alsa_handler)) < 0) |
1050 | 457 { |
1128 | 458 printf("alsa-play: playback prepare error: %s\n", snd_strerror(got_len)); |
1050 | 459 return(0); |
460 } | |
1128 | 461 if ((got_len = snd_pcm_writei(alsa_handler, data, (len/ao_bps))) != (len/ao_bps)) |
1050 | 462 { |
463 printf("alsa-play: write error after reset: %s - giving up\n", | |
1128 | 464 snd_strerror(got_len)); |
1050 | 465 return(0); |
466 } | |
467 return(len); /* 2nd write was ok */ | |
468 } | |
469 } | |
470 return(len); | |
471 } | |
472 | |
473 /* how many byes are free in the buffer */ | |
474 static int get_space() | |
475 { | |
476 snd_pcm_status_t *status; | |
477 int ret; | |
478 | |
479 if ((ret = snd_pcm_status_malloc(&status)) < 0) | |
480 { | |
481 printf("alsa-space: memory allocation error: %s\n", snd_strerror(ret)); | |
482 return(0); | |
483 } | |
484 | |
485 if ((ret = snd_pcm_status(alsa_handler, status)) < 0) | |
486 { | |
487 printf("alsa-space: cannot get pcm status: %s\n", snd_strerror(ret)); | |
488 return(0); | |
489 } | |
490 | |
491 switch(snd_pcm_status_get_state(status)) | |
492 { | |
493 case SND_PCM_STATE_OPEN: | |
494 case SND_PCM_STATE_PREPARED: | |
495 case SND_PCM_STATE_RUNNING: | |
496 ret = snd_pcm_status_get_avail(status) * ao_bps; | |
497 break; | |
498 default: | |
499 ret = 0; | |
500 } | |
501 | |
502 snd_pcm_status_free(status); | |
1129 | 503 |
504 if (ret < 0) | |
505 ret = 0; | |
1050 | 506 return(ret); |
507 } | |
508 | |
509 /* how many unplayed bytes are in the buffer */ | |
510 static int get_delay() | |
511 { | |
512 snd_pcm_status_t *status; | |
513 int ret; | |
514 | |
515 if ((ret = snd_pcm_status_malloc(&status)) < 0) | |
516 { | |
517 printf("alsa-delay: memory allocation error: %s\n", snd_strerror(ret)); | |
518 return(0); | |
519 } | |
520 | |
521 if ((ret = snd_pcm_status(alsa_handler, status)) < 0) | |
522 { | |
523 printf("alsa-delay: cannot get pcm status: %s\n", snd_strerror(ret)); | |
524 return(0); | |
525 } | |
526 | |
527 switch(snd_pcm_status_get_state(status)) | |
528 { | |
529 case SND_PCM_STATE_OPEN: | |
530 case SND_PCM_STATE_PREPARED: | |
531 case SND_PCM_STATE_RUNNING: | |
532 ret = snd_pcm_status_get_delay(status) * ao_bps; | |
533 break; | |
534 default: | |
535 ret = 0; | |
536 } | |
537 | |
538 snd_pcm_status_free(status); | |
1129 | 539 |
540 if (ret < 0) | |
541 ret = 0; | |
1050 | 542 return(ret); |
543 } |