summaryrefslogtreecommitdiff
path: root/pjsip-apps
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2009-07-18 09:18:26 +0000
committerBenny Prijono <bennylp@teluu.com>2009-07-18 09:18:26 +0000
commitcc31ff27079508923376bc73c3d6bcad6cdcd1f2 (patch)
treed9004076b95507f5af1a577ea805912c6f0ab8aa /pjsip-apps
parentfa0d31107cf117f260d8b8678c1d10c1c159df92 (diff)
More ticket #920: fixed wrong latency calculation when there is loud noise in the start of recording
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@2840 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps')
-rw-r--r--pjsip-apps/src/pjsystest/systest.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/pjsip-apps/src/pjsystest/systest.c b/pjsip-apps/src/pjsystest/systest.c
index 600ba80c..81c8d638 100644
--- a/pjsip-apps/src/pjsystest/systest.c
+++ b/pjsip-apps/src/pjsystest/systest.c
@@ -615,6 +615,7 @@ static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav,
short *buf;
unsigned i, samples_per_frame, read, len;
unsigned start_pos;
+ pj_bool_t first;
pj_status_t status;
*lat_sum = 0;
@@ -644,8 +645,14 @@ static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav,
return -1;
}
+ /* Zero the first 500ms to remove loud click noises
+ * (keypad press, etc.)
+ */
+ pjmedia_zero_samples(buf, wav->info.clock_rate / 2);
+
/* Loop to calculate latency */
start_pos = 0;
+ first = PJ_TRUE;
while (start_pos < len/2 - wav->info.clock_rate) {
int max_signal = 0;
unsigned max_signal_pos = start_pos;
@@ -691,8 +698,9 @@ static int calculate_latency(pj_pool_t *pool, pjmedia_port *wav,
*lat_max = lat;
/* Advance next loop */
- if (start_pos == 0) {
+ if (first) {
start_pos = max_signal_pos + wav->info.clock_rate * 9 / 10;
+ first = PJ_FALSE;
} else {
start_pos += wav->info.clock_rate;
}