diff options
author | Jean-Francois Dionne <jf.dionne@nutaq.com> | 2017-01-24 12:10:13 -0500 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2017-02-01 19:13:16 +0000 |
commit | a760a043c4153770fe9577259989169cb2286a82 (patch) | |
tree | c9eae9c50a3e6bc6124f7e5c6a1b304d699c6bf1 /src/common/dtx_dl_amr_fsm.c | |
parent | 16b4179fbeaf3289e7aa41e4f9a0ac5d9d6206f6 (diff) |
Fix AMR HR DTX FSM logic.
Fix SID_FIRST_INH detection during speech and when SID_FIRST is interrupted by FACCH.
Fix SID_UPDATE_INH detection during silence and when SID_UPDATE is interrupted by FACCH.
Add a delay for SID_FIRST to appear at the right time after FACCH.
Fix extra byte sent in downlink for SID_FIRST and SID_UPDATE.
Change-Id: Ia811305e15541f2376005df736bd610e8b0d2f69
Diffstat (limited to 'src/common/dtx_dl_amr_fsm.c')
-rw-r--r-- | src/common/dtx_dl_amr_fsm.c | 171 |
1 files changed, 126 insertions, 45 deletions
diff --git a/src/common/dtx_dl_amr_fsm.c b/src/common/dtx_dl_amr_fsm.c index 832e8b4e..d5990489 100644 --- a/src/common/dtx_dl_amr_fsm.c +++ b/src/common/dtx_dl_amr_fsm.c @@ -29,9 +29,14 @@ void dtx_fsm_voice(struct osmo_fsm_inst *fi, uint32_t event, void *data) case E_FACCH: break; case E_SID_F: - case E_SID_U: osmo_fsm_inst_state_chg(fi, ST_SID_F1, 0, 0); break; + case E_SID_U: + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); + break; + case E_INHIB: + osmo_fsm_inst_state_chg(fi, ST_F1_INH_V, 0, 0); + break; default: LOGP(DL1P, LOGL_ERROR, "Inexpected event %d\n", event); OSMO_ASSERT(0); @@ -49,18 +54,12 @@ void dtx_fsm_sid_f1(struct osmo_fsm_inst *fi, uint32_t event, void *data) case E_SID_U: osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; - case E_VOICE: - osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); - break; case E_FACCH: - osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_F1_INH_F, 0, 0); break; case E_FIRST: osmo_fsm_inst_state_chg(fi, ST_SID_F2, 0, 0); break; - case E_INHIB: - osmo_fsm_inst_state_chg(fi, ST_F1_INH, 0, 0); - break; case E_ONSET: osmo_fsm_inst_state_chg(fi, ST_ONSET_V, 0, 0); break; @@ -75,10 +74,7 @@ void dtx_fsm_sid_f2(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_SID_U, 0, 0); - break; - case E_VOICE: - osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_NOINH, 0, 0); break; case E_FACCH: osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); @@ -93,11 +89,37 @@ void dtx_fsm_sid_f2(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } -void dtx_fsm_f1_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_v(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_F1_INH_V_REC, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_f1_inh_f(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_F1_INH_F_REC, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_v(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_F1_INH_REC, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_V_REC, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -106,11 +128,11 @@ void dtx_fsm_f1_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } -void dtx_fsm_u_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_u_inh_f(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_COMPL: - osmo_fsm_inst_state_chg(fi, ST_U_INH_REC, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_F_REC, 0, 0); break; default: LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); @@ -119,9 +141,10 @@ void dtx_fsm_u_inh(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } -void dtx_fsm_f1_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_v_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { + case E_VOICE: case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; @@ -132,9 +155,24 @@ void dtx_fsm_f1_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } -void dtx_fsm_u_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +void dtx_fsm_f1_inh_f_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { + case E_FACCH: + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_FACCH, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + +void dtx_fsm_u_inh_v_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_VOICE: case E_COMPL: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; @@ -145,6 +183,20 @@ void dtx_fsm_u_inh_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) } } +void dtx_fsm_u_inh_f_rec(struct osmo_fsm_inst *fi, uint32_t event, void *data) +{ + switch (event) { + case E_FACCH: + case E_COMPL: + osmo_fsm_inst_state_chg(fi, ST_FACCH, 0, 0); + break; + default: + LOGP(DL1P, LOGL_ERROR, "Unexpected event %d\n", event); + OSMO_ASSERT(0); + break; + } +} + void dtx_fsm_u_noinh(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { @@ -176,13 +228,13 @@ void dtx_fsm_sid_upd(struct osmo_fsm_inst *fi, uint32_t event, void *data) { switch (event) { case E_FACCH: - osmo_fsm_inst_state_chg(fi, ST_ONSET_F, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_F, 0, 0); break; case E_VOICE: osmo_fsm_inst_state_chg(fi, ST_VOICE, 0, 0); break; case E_INHIB: - osmo_fsm_inst_state_chg(fi, ST_U_INH, 0, 0); + osmo_fsm_inst_state_chg(fi, ST_U_INH_V, 0, 0); break; case E_SID_U: case E_SID_F: @@ -270,40 +322,54 @@ void dtx_fsm_facch(struct osmo_fsm_inst *fi, uint32_t event, void *data) static struct osmo_fsm_state dtx_dl_amr_fsm_states[] = { /* default state for non-DTX and DTX when SPEECH is in progress */ [ST_VOICE] = { - .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH), - .out_state_mask = X(ST_SID_F1), + .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_INHIB), + .out_state_mask = X(ST_SID_F1) | X(ST_U_NOINH) | X(ST_F1_INH_V), .name = "Voice", .action = dtx_fsm_voice, }, /* SID-FIRST or SID-FIRST-P1 in case of AMR HR: start of silence period (might be interrupted in case of AMR HR) */ [ST_SID_F1]= { - .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_VOICE) | X(E_FACCH) | X(E_FIRST) | X(E_INHIB) | X(E_ONSET), - .out_state_mask = X(ST_U_NOINH) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_F1_INH) | X(ST_ONSET_V), + .in_event_mask = X(E_SID_F) | X(E_SID_U) | X(E_FACCH) | X(E_FIRST) | X(E_ONSET), + .out_state_mask = X(ST_U_NOINH) | X(ST_ONSET_F) | X(ST_SID_F2) | X(ST_ONSET_V), .name = "SID-FIRST (P1)", .action = dtx_fsm_sid_f1, }, /* SID-FIRST P2 (only for AMR HR): actual start of silence period in case of AMR HR */ [ST_SID_F2]= { - .in_event_mask = X(E_COMPL) | X(E_VOICE) | X(E_FACCH) | X(E_ONSET), - .out_state_mask = X(ST_SID_U) | X(ST_VOICE) | X(ST_ONSET_F) | X(ST_ONSET_V), + .in_event_mask = X(E_COMPL) | X(E_FACCH) | X(E_ONSET), + .out_state_mask = X(ST_U_NOINH) | X(ST_ONSET_F) | X(ST_ONSET_V), .name = "SID-FIRST (P2)", .action = dtx_fsm_sid_f2, }, /* SID-FIRST Inhibited: incoming SPEECH (only for AMR HR) */ - [ST_F1_INH]= { + [ST_F1_INH_V]= { + .in_event_mask = X(E_COMPL), + .out_state_mask = X(ST_F1_INH_V_REC), + .name = "SID-FIRST (Inh, SPEECH)", + .action = dtx_fsm_f1_inh_v, + }, + /* SID-FIRST Inhibited: incoming FACCH frame (only for AMR HR) */ + [ST_F1_INH_F]= { .in_event_mask = X(E_COMPL), - .out_state_mask = X(ST_F1_INH_REC), - .name = "SID-FIRST (Inh)", - .action = dtx_fsm_f1_inh, + .out_state_mask = X(ST_F1_INH_F_REC), + .name = "SID-FIRST (Inh, FACCH)", + .action = dtx_fsm_f1_inh_f, }, /* SID-UPDATE Inhibited: incoming SPEECH (only for AMR HR) */ - [ST_U_INH]= { + [ST_U_INH_V]= { .in_event_mask = X(E_COMPL), - .out_state_mask = X(ST_U_INH_REC), - .name = "SID-UPDATE (Inh)", - .action = dtx_fsm_u_inh, + .out_state_mask = X(ST_U_INH_V_REC), + .name = "SID-UPDATE (Inh, SPEECH)", + .action = dtx_fsm_u_inh_v, + }, + /* SID-UPDATE Inhibited: incoming FACCH frame (only for AMR HR) */ + [ST_U_INH_F]= { + .in_event_mask = X(E_COMPL), + .out_state_mask = X(ST_U_INH_F_REC), + .name = "SID-UPDATE (Inh, FACCH)", + .action = dtx_fsm_u_inh_f, }, /* SID-UPDATE: Inhibited not allowed (only for AMR HR) */ [ST_U_NOINH]= { @@ -314,24 +380,40 @@ static struct osmo_fsm_state dtx_dl_amr_fsm_states[] = { }, /* SID-FIRST Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ - [ST_F1_INH_REC]= { - .in_event_mask = X(E_COMPL), + [ST_F1_INH_V_REC]= { + .in_event_mask = X(E_COMPL) | X(E_VOICE), .out_state_mask = X(ST_VOICE), - .name = "SID-FIRST (Inh, Rec)", - .action = dtx_fsm_f1_inh_rec, + .name = "SID-FIRST (Inh, SPEECH, Rec)", + .action = dtx_fsm_f1_inh_v_rec, + }, + /* SID-FIRST Inhibition recursion in progress: + Inhibit itself was already sent, now have to send the data that caused it */ + [ST_F1_INH_F_REC]= { + .in_event_mask = X(E_COMPL) | X(E_FACCH), + .out_state_mask = X(ST_FACCH), + .name = "SID-FIRST (Inh, FACCH, Rec)", + .action = dtx_fsm_f1_inh_f_rec, }, /* SID-UPDATE Inhibition recursion in progress: Inhibit itself was already sent, now have to send the voice that caused it */ - [ST_U_INH_REC]= { - .in_event_mask = X(E_COMPL), + [ST_U_INH_V_REC]= { + .in_event_mask = X(E_COMPL) | X(E_VOICE), .out_state_mask = X(ST_VOICE), - .name = "SID-UPDATE (Inh, Rec)", - .action = dtx_fsm_u_inh_rec, + .name = "SID-UPDATE (Inh, SPEECH, Rec)", + .action = dtx_fsm_u_inh_v_rec, + }, + /* SID-UPDATE Inhibition recursion in progress: + Inhibit itself was already sent, now have to send the data that caused it */ + [ST_U_INH_F_REC]= { + .in_event_mask = X(E_COMPL) | X(E_FACCH), + .out_state_mask = X(ST_FACCH), + .name = "SID-UPDATE (Inh, FACCH, Rec)", + .action = dtx_fsm_u_inh_f_rec, }, /* Silence period with periodic comfort noise data updates */ [ST_SID_U]= { .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_INHIB) | X(E_SID_U) | X(E_SID_F), - .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH) | X(ST_U_NOINH), + .out_state_mask = X(ST_ONSET_F) | X(ST_VOICE) | X(ST_U_INH_V) | X(ST_U_INH_F) | X(ST_U_NOINH), .name = "SID-UPDATE (AMR/HR)", .action = dtx_fsm_sid_upd, }, @@ -365,8 +447,7 @@ static struct osmo_fsm_state dtx_dl_amr_fsm_states[] = { .name = "ONSET (FACCH, Rec)", .action = dtx_fsm_onset_f_rec, }, - /* FACCH sending state: no SPEECH was observed before so once we're done - FSM should get back to silent period via SID-FIRST */ + /* FACCH sending state */ [ST_FACCH]= { .in_event_mask = X(E_FACCH) | X(E_VOICE) | X(E_COMPL) | X(E_SID_U) | X(E_SID_F), .out_state_mask = X(ST_VOICE) | X(ST_SID_F1), |