From 9f9b96a67bd1a4c3aa4180822e65de0a98572227 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 11 Oct 2016 18:13:32 +0200 Subject: DTX: fix conversion from fn to ms Previously FN was converted to millisecondss incorrectly due to wrong conversion between FN and a number of voice samples. The conversion should be based on following: * there are 12/13 useful frames for audio in TCH * there is 1 RTP packet per 4 frame * there are 160 samples per RTP packet Fixes: OS#1801 Change-Id: I9cc70cacabde98621aa892cee74f4ac461645093 --- src/common/l1sap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/common/l1sap.c b/src/common/l1sap.c index 04cc8006..dd34d804 100644 --- a/src/common/l1sap.c +++ b/src/common/l1sap.c @@ -73,8 +73,10 @@ static int l1sap_down(struct gsm_bts_trx *trx, struct osmo_phsap_prim *l1sap); static uint32_t fn_ms_adj(uint32_t fn, uint32_t last_fn) { if (last_fn != LCHAN_FN_DUMMY) { - uint32_t ms_passed = GSM_FN_TO_MS(fn - last_fn), - samples_passed = GSM_MS_TO_SAMPLES(ms_passed); + /* 12/13 frames usable for audio in TCH, + 160 samples per RTP packet, + 1 RTP packet per 4 frames */ + uint32_t samples_passed = (fn - last_fn) * 12 * 160 / (13 * 4); /* round number of samples to the nearest multiple of GSM_RTP_DURATION */ uint32_t r = samples_passed + GSM_RTP_DURATION / 2; -- cgit v1.2.3