diff libgsmhr1/rxfe.c @ 631:6bad9af66f69

libgsmhr1 RxFE: reset speech ECU when passing through CNI state
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 16 Mar 2026 20:36:42 +0000
parents e2d5cad04cbf
children
line wrap: on
line diff
--- a/libgsmhr1/rxfe.c	Thu Mar 12 06:19:12 2026 +0000
+++ b/libgsmhr1/rxfe.c	Mon Mar 16 20:36:42 2026 +0000
@@ -216,6 +216,23 @@
 	st->in_dtx = 1;
 	st->dtx_bfi_count = 0;
 	st->dtx_muting = 0;
+	/*
+	 * Speech ECU state reset is an addition made by Themyscira Wireless,
+	 * not part of the original RxFE logic implemented as part of the
+	 * full speech decoder in GSM 06.06.  The original logic exhibits
+	 * this defect: if the speech ECU is in state 6 and then an accepted
+	 * SID frame (valid or invalid) puts us into DTX state, the first
+	 * good speech frame after this DTX pause will be dropped and replaced
+	 * with fully muted form of the last good speech frame from before the
+	 * CN insertion period, no matter how long that DTX pause was.
+	 *
+	 * Our solution: since only a good speech frame with BFI=0 and UFI=0
+	 * can make exit from CN insertion state, our reset of ECU state here
+	 * ensures that this good speech frame will pass through, and then
+	 * the ECU will be in state 0 after this talkspurt-opening good speech
+	 * frame.
+	 */
+	st->ecu_state = 7;
 }
 
 static void cn_output(struct gsmhr_rxfe_state *st, Shortword *prm_out)