Discussion:
[pjsip] Audio Underflow's effect on latency
John M
2017-06-15 19:19:04 UTC
Permalink
Hello all,

I am developing a Voip product with a max latency requirement of 150ms
mouth to ear. Our current tests show latency moving in a saw-tooth like
pattern between 180ms and 140ms.

The latency will begin at ~180ms, and then drop over time to around 160 to
140ms. Then, it jumps back up to ~180 and the process repeats.

This is all measured using oscilloscopes and similar instruments. Running
the pjsua application with a call to sip:localhost shows no sawtooth
pattern, and a call between two COTS Voip phones do not show the sawtooth
pattern.

What I recognized was that the latency would jump back up after a buffer
underflow on a split combo port:

17:59:27.446 scombdb-dn !Underflow, buf_cnt=1, will generate 1 frame

17:59:27.446 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

17:59:33.246 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

17:59:33.246 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

17:59:38.365 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

17:59:38.366 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

17:59:44.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

17:59:44.486 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

17:59:49.626 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

17:59:49.626 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

17:59:55.426 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

17:59:55.426 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

18:00:06.686 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

18:00:06.687 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

18:00:12.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

18:00:12.487 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

18:00:17.926 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame

18:00:17.926 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame




 some time later 




18:03:39.166 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame

18:03:39.166 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame

18:03:44.646 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame

18:03:44.646 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame

18:03:49.766 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame

18:03:49.766 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame


This reliably happens every 5 to 6 seconds.

What could be causing this underflow? We are looking for minimum latency,
so the jitter buffer is at a max of 60ms and the sound device has a play
and record latency of 40ms.

Any guidance would be appreciated.

Thanks,

John.
Bill Gardner
2017-06-15 19:55:49 UTC
Permalink
Hi John,

It's likely a mismatch in the sampling rates of the record and playback
devices. Unless they are using the same hardware clock there will be
drift and hence the wsola delay buf is necessary to prevent discontinuities.

Regards,

Bill
Post by John M
Hello all,
I am developing a Voip product with a max latency requirement of 150ms
mouth to ear. Our current tests show latency moving in a saw-tooth
like pattern between 180ms and 140ms.
The latency will begin at ~180ms, and then drop over time to around
160 to 140ms. Then, it jumps back up to ~180 and the process repeats.
This is all measured using oscilloscopes and similar instruments.
Running the pjsua application with a call to sip:localhost shows no
sawtooth pattern, and a call between two COTS Voip phones do not show
the sawtooth pattern.
What I recognized was that the latency would jump back up after a
17:59:27.446 scombdb-dn !Underflow, buf_cnt=1, will generate 1 frame
17:59:27.446 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:33.246 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:33.246 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:38.365 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:38.366 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:44.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:44.486 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:49.626 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:49.626 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:55.426 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:55.426 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:06.686 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:06.687 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:12.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:12.487 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:17.926 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:17.926 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

 some time later 

18:03:39.166 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:39.166 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
18:03:44.646 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:44.646 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
18:03:49.766 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:49.766 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
This reliably happens every 5 to 6 seconds.
What could be causing this underflow? We are looking for minimum
latency, so the jitter buffer is at a max of 60ms and the sound device
has a play and record latency of 40ms.
Any guidance would be appreciated.
Thanks,
John.
_______________________________________________
Visit our blog: http://blog.pjsip.org
pjsip mailing list
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
John M
2017-06-15 20:42:11 UTC
Permalink
Thanks for the quick response.

Our input and output are both powered by the same master clock. They
communicate to the system over USB Audio though. Could it be possible
timing issues in USB transmission can cause a similar issue?
Post by Bill Gardner
Hi John,
It's likely a mismatch in the sampling rates of the record and playback
devices. Unless they are using the same hardware clock there will be drift
and hence the wsola delay buf is necessary to prevent discontinuities.
Regards,
Bill
Hello all,
I am developing a Voip product with a max latency requirement of 150ms
mouth to ear. Our current tests show latency moving in a saw-tooth like
pattern between 180ms and 140ms.
The latency will begin at ~180ms, and then drop over time to around 160 to
140ms. Then, it jumps back up to ~180 and the process repeats.
This is all measured using oscilloscopes and similar instruments. Running
the pjsua application with a call to sip:localhost shows no sawtooth
pattern, and a call between two COTS Voip phones do not show the sawtooth
pattern.
What I recognized was that the latency would jump back up after a buffer
17:59:27.446 scombdb-dn !Underflow, buf_cnt=1, will generate 1 frame
17:59:27.446 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:33.246 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:33.246 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:38.365 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:38.366 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:44.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:44.486 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:49.626 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:49.626 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:55.426 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:55.426 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:06.686 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:06.687 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:12.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:12.487 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:17.926 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:17.926 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

 some time later 

18:03:39.166 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:39.166 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
18:03:44.646 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:44.646 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
18:03:49.766 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:49.766 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
This reliably happens every 5 to 6 seconds.
What could be causing this underflow? We are looking for minimum latency,
so the jitter buffer is at a max of 60ms and the sound device has a play
and record latency of 40ms.
Any guidance would be appreciated.
Thanks,
John.
_______________________________________________
Visit our blog: http://blog.pjsip.org
_______________________________________________
Visit our blog: http://blog.pjsip.org
pjsip mailing list
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Bill Gardner
2017-06-15 20:55:46 UTC
Permalink
USB can't alter the audio sampling rate, but if the audio buffers don't
keep up then a missing record buffer would also trigger wsola
reconstruction. If you increase the audio buffer sizes does the latency
become more stable? Ideally the record and playback buffer callbacks
should alternate, but often you will get repeats (bursts), depending on
platform and audio device. Perhaps you are getting a repeat playback
every 5 seconds causing the record buffer to underflow.
Post by John M
Thanks for the quick response.
Our input and output are both powered by the same master clock. They
communicate to the system over USB Audio though. Could it be possible
timing issues in USB transmission can cause a similar issue?
Hi John,
It's likely a mismatch in the sampling rates of the record and
playback devices. Unless they are using the same hardware clock
there will be drift and hence the wsola delay buf is necessary to
prevent discontinuities.
Regards,
Bill
Post by John M
Hello all,
I am developing a Voip product with a max latency requirement of
150ms mouth to ear. Our current tests show latency moving in a
saw-tooth like pattern between 180ms and 140ms.
The latency will begin at ~180ms, and then drop over time to
around 160 to 140ms. Then, it jumps back up to ~180 and the
process repeats.
This is all measured using oscilloscopes and similar instruments.
Running the pjsua application with a call to sip:localhost shows
no sawtooth pattern, and a call between two COTS Voip phones do
not show the sawtooth pattern.
What I recognized was that the latency would jump back up after a
17:59:27.446 scombdb-dn !Underflow, buf_cnt=1, will generate 1 frame
17:59:27.446 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:33.246 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:33.246 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:38.365 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:38.366 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:44.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:44.486 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:49.626 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:49.626 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
17:59:55.426 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
17:59:55.426 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:06.686 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:06.687 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:12.486 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:12.487 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame
18:00:17.926 scombdb-dn Underflow, buf_cnt=1, will generate 1 frame
18:00:17.926 scombdb-dn Underflow, buf_cnt=126, will generate 1 frame

 some time later 

18:03:39.166 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:39.166 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
18:03:44.646 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:44.646 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
18:03:49.766 scombdb-dn Underflow, buf_cnt=121, will generate 1 frame
18:03:49.766 scombdb-dn Underflow, buf_cnt=21, will generate 1 frame
This reliably happens every 5 to 6 seconds.
What could be causing this underflow? We are looking for minimum
latency, so the jitter buffer is at a max of 60ms and the sound
device has a play and record latency of 40ms.
Any guidance would be appreciated.
Thanks,
John.
_______________________________________________
Visit our blog:http://blog.pjsip.org
pjsip mailing list
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
<http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org>
_______________________________________________
Visit our blog: http://blog.pjsip.org
pjsip mailing list
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
<http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org>
_______________________________________________
Visit our blog: http://blog.pjsip.org
pjsip mailing list
http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org
Loading...