I am trying to get small delays with my application and I have been
playing with "latency" from alsa-lib/test.
The current delay with "latency" is equal to a minimum (that depends
on the sound card) plus *two* times the period time. If I disable
manual change of sound card state as described in the patch below the
delay becomes equal to a minimum *higher than the previous* plus *one*
time the period time.
The delay has been measured with an external box plugged on the sound
card.
I would like to mix both settings to get a delay of the lowest minimum
plus one time the period time. But for this I need to understand what
is happening, and more precisely:
* why is snd_pcm_link() mandatory? (no sound otherwise)
* why two buffers of silence and not just one?
* why is there no snd_pcm_start() for the playback device?
* why is the minimum delay lower with manual handling of the sound
card state?
Help is welcome :-)
Thanxs in advance.
--- latency.c.orig 2006-06-20 10:21:57.000000000 +0200
+++ latency.c 2006-06-20 11:06:10.000000000 +0200
@@ -148,11 +148,11 @@
printf("Unable to determine current swparams for %s: %s\n", id, snd_strerror(err
));
return err;
}
- err = snd_pcm_sw_params_set_start_threshold(handle, swparams, 0x7fffffff);
- if (err < 0) {
- printf("Unable to set start threshold mode for %s: %s\n", id, snd_strerror(err))
;
- return err;
- }
+/* err = snd_pcm_sw_params_set_start_threshold(handle, swparams, 0x7fffffff); */
+/* if (err < 0) { */
+/* printf("Unable to set start threshold mode for %s: %s\n", id, snd_strerror(err))
; */
+/* return err; */
+/* } */
tick_time_ok = 0;
if (tick_time > 0) {
unsigned int time, ttime;
@@ -273,10 +273,10 @@
exit(0);
}
- if ((err = snd_pcm_prepare(phandle)) < 0) {
- printf("Prepare error: %s\n", snd_strerror(err));
- exit(0);
- }
+/* if ((err = snd_pcm_prepare(phandle)) < 0) { */
+/* printf("Prepare error: %s\n", snd_strerror(err)); */
+/* exit(0); */
+/* } */
snd_pcm_dump(phandle, output);
snd_pcm_dump(chandle, output);
@@ -646,27 +646,27 @@
showlatency(latency);
if (tick_time_ok)
printf("Using tick time %ius\n", tick_time_ok);
- if ((err = snd_pcm_link(chandle, phandle)) < 0) {
- printf("Streams link error: %s\n", snd_strerror(err));
- exit(0);
- }
- if (snd_pcm_format_set_silence(format, buffer, latency*channels) < 0) {
- fprintf(stderr, "silence error\n");
- break;
- }
- if (writebuf(phandle, buffer, latency, &frames_out) < 0) {
- fprintf(stderr, "write error\n");
- break;
- }
- if (writebuf(phandle, buffer, latency, &frames_out) < 0) {
- fprintf(stderr, "write error\n");
- break;
- }
-
- if ((err = snd_pcm_start(chandle)) < 0) {
- printf("Go error: %s\n", snd_strerror(err));
- exit(0);
- }
+/* if ((err = snd_pcm_link(chandle, phandle)) < 0) { */
+/* printf("Streams link error: %s\n", snd_strerror(err)); */
+/* exit(0); */
+/* } */
+/* if (snd_pcm_format_set_silence(format, buffer, latency*channels) < 0) { */
+/* fprintf(stderr, "silence error\n"); */
+/* break; */
+/* } */
+/* if (writebuf(phandle, buffer, latency, &frames_out) < 0) { */
+/* fprintf(stderr, "write error\n"); */
+/* break; */
+/* } */
+/* if (writebuf(phandle, buffer, latency, &frames_out) < 0) { */
+/* fprintf(stderr, "write error\n"); */
+/* break; */
+/* } */
+
+/* if ((err = snd_pcm_start(chandle)) < 0) { */
+/* printf("Go error: %s\n", snd_strerror(err)); */
+/* exit(0); */
+/* } */
gettimestamp(phandle, &p_tstamp);
gettimestamp(chandle, &c_tstamp);
#if 0
_______________________________________________ Alsa-devel mailing list Alsa-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-devel