aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2021-06-07 22:25:58 +0200
committerfixeria <vyanitskiy@sysmocom.de>2021-06-10 21:50:48 +0000
commitef4a6a0f4302a7d284093028fa15246a9f065044 (patch)
tree17f0d581e999f9cd488ba28454cc0d28fc36f0f7
parent4590b099bf4409b8456872bd1eec9cf3ba2a42a9 (diff)
l1sap: fix TDMA frame number arithmetic in fn_ms_adj()HEADmaster
Using the normal arithmetic for TDMA frame numbers is wrong. Change-Id: Ie17670d150489014a4a2e140cede42086100bbc0
-rw-r--r--src/common/l1sap.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index cd2af57a..0debae04 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -139,7 +139,8 @@ static uint32_t fn_ms_adj(uint32_t fn, const struct gsm_lchan *lchan)
/* 12/13 frames usable for audio in TCH,
160 samples per RTP packet,
1 RTP packet per 4 frames */
- samples_passed = (fn - lchan->tch.last_fn) * 12 * 160 / (13 * 4);
+ const uint32_t num_fn = GSM_TDMA_FN_SUB(fn, lchan->tch.last_fn);
+ samples_passed = num_fn * 12 * 160 / (13 * 4);
/* round number of samples to the nearest multiple of
GSM_RTP_DURATION */
r = samples_passed + GSM_RTP_DURATION / 2;