diff options
author | Max <msuraev@sysmocom.de> | 2016-10-11 18:13:32 +0200 |
---|---|---|
committer | Max <msuraev@sysmocom.de> | 2016-10-11 18:20:15 +0200 |
commit | 9f9b96a67bd1a4c3aa4180822e65de0a98572227 (patch) | |
tree | 1e5813de2b27cbb8cecf4fcad4b5c04ad6028a90 /src/common/l1sap.c | |
parent | c1b86d80d1354c37c72bf6aad1f6230d54930e19 (diff) |
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
Diffstat (limited to 'src/common/l1sap.c')
-rw-r--r-- | src/common/l1sap.c | 6 |
1 files 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; |