mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
latency: add timestamps to the POS lines
- remove first capture pos line - measure the snd_pcm_start() call, too Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
3e4aeba25b
commit
a0836e2af1
1 changed files with 6 additions and 11 deletions
|
|
@ -556,7 +556,7 @@ int main(int argc, char *argv[])
|
||||||
snd_pcm_t *phandle, *chandle;
|
snd_pcm_t *phandle, *chandle;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int err, latency, morehelp;
|
int err, latency, morehelp;
|
||||||
int ok, first_avail;
|
int ok;
|
||||||
snd_timestamp_t p_tstamp, c_tstamp;
|
snd_timestamp_t p_tstamp, c_tstamp;
|
||||||
ssize_t r, cap_avail, cap_avail_max, pbk_fill, pbk_fill_min;
|
ssize_t r, cap_avail, cap_avail_max, pbk_fill, pbk_fill_min;
|
||||||
size_t frames_in, frames_out, in_max;
|
size_t frames_in, frames_out, in_max;
|
||||||
|
|
@ -723,12 +723,14 @@ int main(int argc, char *argv[])
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (realtime_check)
|
||||||
|
timestamp_now(&tstamp_start);
|
||||||
if ((err = snd_pcm_start(chandle)) < 0) {
|
if ((err = snd_pcm_start(chandle)) < 0) {
|
||||||
printf("Go error: %s\n", snd_strerror(err));
|
printf("Go error: %s\n", snd_strerror(err));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if (realtime_check)
|
if (realtime_check)
|
||||||
timestamp_now(&tstamp_start);
|
printf("[%lldus] Stream start\n", timestamp_diff_micro(&tstamp_start));
|
||||||
gettimestamp(phandle, &p_tstamp);
|
gettimestamp(phandle, &p_tstamp);
|
||||||
gettimestamp(chandle, &c_tstamp);
|
gettimestamp(chandle, &c_tstamp);
|
||||||
#if 0
|
#if 0
|
||||||
|
|
@ -740,7 +742,6 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
ok = 1;
|
ok = 1;
|
||||||
in_max = 0;
|
in_max = 0;
|
||||||
first_avail = 1;
|
|
||||||
while (ok && frames_in < loop_limit) {
|
while (ok && frames_in < loop_limit) {
|
||||||
cap_avail = latency;
|
cap_avail = latency;
|
||||||
if (sys_latency > 0) {
|
if (sys_latency > 0) {
|
||||||
|
|
@ -751,12 +752,6 @@ int main(int argc, char *argv[])
|
||||||
ok = 0;
|
ok = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (first_avail && realtime_check) {
|
|
||||||
long long diff = timestamp_diff_micro(&tstamp_start);
|
|
||||||
long long pos = frames_to_micro(cap_avail);
|
|
||||||
printf("POS FIRST CHECK: c=%zd (rt=%lldus)\n", cap_avail, pos - diff);
|
|
||||||
first_avail = 0;
|
|
||||||
}
|
|
||||||
} else if (use_poll) {
|
} else if (use_poll) {
|
||||||
/* use poll to wait for next event */
|
/* use poll to wait for next event */
|
||||||
snd_pcm_wait(chandle, 1000);
|
snd_pcm_wait(chandle, 1000);
|
||||||
|
|
@ -775,8 +770,8 @@ int main(int argc, char *argv[])
|
||||||
long long diff = timestamp_diff_micro(&tstamp_start);
|
long long diff = timestamp_diff_micro(&tstamp_start);
|
||||||
long long cap_pos = frames_to_micro(frames_in + cap_avail);
|
long long cap_pos = frames_to_micro(frames_in + cap_avail);
|
||||||
long long pbk_pos = frames_to_micro(frames_out - pbk_fill);
|
long long pbk_pos = frames_to_micro(frames_out - pbk_fill);
|
||||||
printf("POS: p=%zd (min=%zd, rt=%lldus) c=%zd (max=%zd, rt=%lldus)\n",
|
printf("[%lldus] POS: p=%zd (min=%zd, rt=%lldus) c=%zd (max=%zd, rt=%lldus)\n",
|
||||||
pbk_fill, pbk_fill_min, pbk_pos - diff,
|
diff, pbk_fill, pbk_fill_min, pbk_pos - diff,
|
||||||
cap_avail, cap_avail_max, cap_pos - diff);
|
cap_avail, cap_avail_max, cap_pos - diff);
|
||||||
} else if (pos_dump) {
|
} else if (pos_dump) {
|
||||||
printf("POS: p=%zd (min=%zd), c=%zd (max=%zd)\n",
|
printf("POS: p=%zd (min=%zd), c=%zd (max=%zd)\n",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue