From 7a2f2aeeb180a67eb7abd6740a1f9d3fb650e790 Mon Sep 17 00:00:00 2001 From: Steve Underwood Date: Mon, 27 Aug 2012 23:04:05 +0800 Subject: [PATCH] More cleanups of fax modem stuff --- libs/spandsp/src/fax.c | 89 ++++++++-------------------------- libs/spandsp/src/fax_modems.c | 5 -- libs/spandsp/src/t31.c | 63 +++++++++--------------- libs/spandsp/src/t38_gateway.c | 43 ++++++++-------- 4 files changed, 62 insertions(+), 138 deletions(-) diff --git a/libs/spandsp/src/fax.c b/libs/spandsp/src/fax.c index 0b53b11c4b..2a2b6437b8 100644 --- a/libs/spandsp/src/fax.c +++ b/libs/spandsp/src/fax.c @@ -176,19 +176,6 @@ static int v17_v21_rx(void *user_data, const int16_t amp[], int len) } /*- End of function --------------------------------------------------------*/ -static int v17_v21_rx_fillin(void *user_data, int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v17_rx_fillin(&s->fast_modems.v17_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) { fax_state_t *t; @@ -215,19 +202,6 @@ static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) } /*- End of function --------------------------------------------------------*/ -static int v27ter_v21_rx_fillin(void *user_data, int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v27ter_rx_fillin(&s->fast_modems.v27ter_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - static int v29_v21_rx(void *user_data, const int16_t amp[], int len) { fax_state_t *t; @@ -254,19 +228,6 @@ static int v29_v21_rx(void *user_data, const int16_t amp[], int len) } /*- End of function --------------------------------------------------------*/ -static int v29_v21_rx_fillin(void *user_data, int len) -{ - fax_state_t *t; - fax_modems_state_t *s; - - t = (fax_state_t *) user_data; - s = &t->modems; - v29_rx_fillin(&s->fast_modems.v29_rx, len); - fsk_rx_fillin(&s->v21_rx, len); - return 0; -} -/*- End of function --------------------------------------------------------*/ - SPAN_DECLARE_NONSTD(int) fax_rx(fax_state_t *s, int16_t *amp, int len) { int i; @@ -383,8 +344,6 @@ SPAN_DECLARE_NONSTD(int) fax_tx(fax_state_t *s, int16_t *amp, int max_len) static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc) { fax_state_t *s; - put_bit_func_t put_bit_func; - void *put_bit_user_data; fax_modems_state_t *t; s = (fax_state_t *) user_data; @@ -396,36 +355,34 @@ static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_t t->rx_bit_rate = bit_rate; if (use_hdlc) { - put_bit_func = (put_bit_func_t) hdlc_rx_put_bit; - put_bit_user_data = (void *) &t->hdlc_rx; + fax_modems_set_put_bit(t, (put_bit_func_t) hdlc_rx_put_bit, &t->hdlc_rx); hdlc_rx_init(&t->hdlc_rx, FALSE, TRUE, HDLC_FRAMING_OK_THRESHOLD, t30_hdlc_accept, &s->t30); } else { - put_bit_func = t30_non_ecm_put_bit; - put_bit_user_data = (void *) &s->t30; + fax_modems_set_put_bit(t, (put_bit_func_t) t30_non_ecm_put_bit, &s->t30); } switch (type) { case T30_MODEM_V21: - fsk_rx_init(&t->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, put_bit_user_data); + fsk_rx_init(&t->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) hdlc_rx_put_bit, t->put_bit_user_data); fsk_rx_signal_cutoff(&t->v21_rx, -45.5f); fax_modems_set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &t->v21_rx); break; case T30_MODEM_V27TER: v27ter_rx_restart(&t->fast_modems.v27ter_rx, bit_rate, FALSE); - v27ter_rx_set_put_bit(&t->fast_modems.v27ter_rx, put_bit_func, put_bit_user_data); - fax_modems_set_rx_handler(t, &v27ter_v21_rx, s, &v27ter_v21_rx_fillin, s); + v27ter_rx_set_put_bit(&t->fast_modems.v27ter_rx, t->put_bit, t->put_bit_user_data); + fax_modems_set_rx_handler(t, &v27ter_v21_rx, s, &fax_modems_v27ter_v21_rx_fillin, t); break; case T30_MODEM_V29: v29_rx_restart(&t->fast_modems.v29_rx, bit_rate, FALSE); - v29_rx_set_put_bit(&t->fast_modems.v29_rx, put_bit_func, put_bit_user_data); - fax_modems_set_rx_handler(t, &v29_v21_rx, s, &v29_v21_rx_fillin, s); + v29_rx_set_put_bit(&t->fast_modems.v29_rx, t->put_bit, t->put_bit_user_data); + fax_modems_set_rx_handler(t, &v29_v21_rx, s, &fax_modems_v29_v21_rx_fillin, t); break; case T30_MODEM_V17: v17_rx_restart(&t->fast_modems.v17_rx, bit_rate, short_train); - v17_rx_set_put_bit(&t->fast_modems.v17_rx, put_bit_func, put_bit_user_data); - fax_modems_set_rx_handler(t, &v17_v21_rx, s, &v17_v21_rx_fillin, s); + v17_rx_set_put_bit(&t->fast_modems.v17_rx, t->put_bit, t->put_bit_user_data); + fax_modems_set_rx_handler(t, &v17_v21_rx, s, &fax_modems_v17_v21_rx_fillin, t); break; case T30_MODEM_DONE: span_log(&s->logging, SPAN_LOG_FLOW, "FAX exchange complete\n"); @@ -439,8 +396,6 @@ static void fax_set_rx_type(void *user_data, int type, int bit_rate, int short_t static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_train, int use_hdlc) { fax_state_t *s; - get_bit_func_t get_bit_func; - void *get_bit_user_data; fax_modems_state_t *t; int tone; @@ -450,15 +405,9 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t if (t->current_tx_type == type) return; if (use_hdlc) - { - get_bit_func = (get_bit_func_t) hdlc_tx_get_bit; - get_bit_user_data = (void *) &t->hdlc_tx; - } + fax_modems_set_get_bit(t, (get_bit_func_t) hdlc_tx_get_bit, &t->hdlc_tx); else - { - get_bit_func = t30_non_ecm_get_bit; - get_bit_user_data = (void *) &s->t30; - } + fax_modems_set_get_bit(t, (get_bit_func_t) t30_non_ecm_get_bit, &s->t30); switch (type) { case T30_MODEM_PAUSE: @@ -479,9 +428,9 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t t->transmit = TRUE; break; case T30_MODEM_V21: - fsk_tx_init(&t->v21_tx, &preset_fsk_specs[FSK_V21CH2], get_bit_func, get_bit_user_data); + fsk_tx_init(&t->v21_tx, &preset_fsk_specs[FSK_V21CH2], t->get_bit, t->get_bit_user_data); /* The spec says 1s +-15% of preamble. So, the minimum is 32 octets. */ - hdlc_tx_flags(&t->hdlc_tx, 32); + fax_modems_hdlc_tx_flags(t, 32); /* Pause before switching from phase C, as per T.30 5.3.2.2. If we omit this, the receiver might not see the carrier fall between the high speed and low speed sections. In practice, a 75ms gap before any V.21 transmission is harmless, adds little to the overall length of @@ -494,9 +443,9 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t case T30_MODEM_V17: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); /* For any fast modem, set 200ms of preamble flags */ - hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); + fax_modems_hdlc_tx_flags(t, bit_rate/(8*5)); v17_tx_restart(&t->fast_modems.v17_tx, bit_rate, t->use_tep, short_train); - v17_tx_set_get_bit(&t->fast_modems.v17_tx, get_bit_func, get_bit_user_data); + v17_tx_set_get_bit(&t->fast_modems.v17_tx, t->get_bit, t->get_bit_user_data); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); t->transmit = TRUE; @@ -504,9 +453,9 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t case T30_MODEM_V27TER: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); /* For any fast modem, set 200ms of preamble flags */ - hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); + fax_modems_hdlc_tx_flags(t, bit_rate/(8*5)); v27ter_tx_restart(&t->fast_modems.v27ter_tx, bit_rate, t->use_tep); - v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, get_bit_func, get_bit_user_data); + v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, t->get_bit, t->get_bit_user_data); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); t->transmit = TRUE; @@ -514,9 +463,9 @@ static void fax_set_tx_type(void *user_data, int type, int bit_rate, int short_t case T30_MODEM_V29: silence_gen_alter(&t->silence_gen, ms_to_samples(75)); /* For any fast modem, set 200ms of preamble flags */ - hdlc_tx_flags(&t->hdlc_tx, bit_rate/(8*5)); + fax_modems_hdlc_tx_flags(t, bit_rate/(8*5)); v29_tx_restart(&t->fast_modems.v29_tx, bit_rate, t->use_tep); - v29_tx_set_get_bit(&t->fast_modems.v29_tx, get_bit_func, get_bit_user_data); + v29_tx_set_get_bit(&t->fast_modems.v29_tx, t->get_bit, t->get_bit_user_data); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); t->transmit = TRUE; diff --git a/libs/spandsp/src/fax_modems.c b/libs/spandsp/src/fax_modems.c index 0eba221e3e..46524b4e0f 100644 --- a/libs/spandsp/src/fax_modems.c +++ b/libs/spandsp/src/fax_modems.c @@ -257,11 +257,6 @@ SPAN_DECLARE_NONSTD(int) fax_modems_v29_v21_rx_fillin(void *user_data, int len) static void v21_rx_status_handler(void *user_data, int status) { -#if 0 - fax_modems_state_t *s; - - s = (fax_modems_state_t *) user_data; -#endif } /*- End of function --------------------------------------------------------*/ diff --git a/libs/spandsp/src/t31.c b/libs/spandsp/src/t31.c index 6f041a6b2f..f8a2b07966 100644 --- a/libs/spandsp/src/t31.c +++ b/libs/spandsp/src/t31.c @@ -1764,7 +1764,7 @@ static int restart_modem(t31_state_t *s, int new_modem) case FAX_MODEM_V17_RX: if (!s->t38_mode) { - fax_modems_set_rx_handler(t, (span_rx_handler_t) &v17_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v17_v21_rx_fillin, &s->audio.modems); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &v17_v21_rx, t, (span_rx_fillin_handler_t) &fax_modems_v17_v21_rx_fillin, t); v17_rx_restart(&t->fast_modems.v17_rx, s->bit_rate, s->short_train); /* Allow for +FCERROR/+FRH:3 */ t31_v21_rx(s); @@ -1801,7 +1801,7 @@ static int restart_modem(t31_state_t *s, int new_modem) case FAX_MODEM_V27TER_RX: if (!s->t38_mode) { - fax_modems_set_rx_handler(t, (span_rx_handler_t) &v27ter_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v27ter_v21_rx_fillin, &s->audio.modems); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &v27ter_v21_rx, t, (span_rx_fillin_handler_t) &fax_modems_v27ter_v21_rx_fillin, t); v27ter_rx_restart(&t->fast_modems.v27ter_rx, s->bit_rate, FALSE); /* Allow for +FCERROR/+FRH:3 */ t31_v21_rx(s); @@ -1838,7 +1838,7 @@ static int restart_modem(t31_state_t *s, int new_modem) case FAX_MODEM_V29_RX: if (!s->t38_mode) { - fax_modems_set_rx_handler(t, (span_rx_handler_t) &v29_v21_rx, s, (span_rx_fillin_handler_t) &fax_modems_v29_v21_rx_fillin, &s->audio.modems); + fax_modems_set_rx_handler(t, (span_rx_handler_t) &v29_v21_rx, t, (span_rx_fillin_handler_t) &fax_modems_v29_v21_rx_fillin, t); v29_rx_restart(&t->fast_modems.v29_rx, s->bit_rate, FALSE); /* Allow for +FCERROR/+FRH:3 */ t31_v21_rx(s); @@ -2298,12 +2298,11 @@ static int cng_rx(void *user_data, const int16_t amp[], int len) static int v17_v21_rx(void *user_data, const int16_t amp[], int len) { - t31_state_t *t; fax_modems_state_t *s; - t = (t31_state_t *) user_data; - s = &t->audio.modems; + s = (fax_modems_state_t *) user_data; v17_rx(&s->fast_modems.v17_rx, amp, len); + fsk_rx(&s->v21_rx, amp, len); if (s->rx_trained) { /* The fast modem has trained, so we no longer need to run the slow @@ -2311,16 +2310,12 @@ static int v17_v21_rx(void *user_data, const int16_t amp[], int len) span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.17 (%.2fdBm0)\n", v17_rx_signal_power(&s->fast_modems.v17_rx)); fax_modems_set_rx_handler(s, (span_rx_handler_t) &v17_rx, &s->fast_modems.v17_rx, (span_rx_fillin_handler_t) &v17_rx_fillin, &s->fast_modems.v17_rx); } - else + else if (s->rx_frame_received) { - fsk_rx(&s->v21_rx, amp, len); - if (t->rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } + /* We have received something, and the fast modem has not trained. We must + be receiving valid V.21 */ + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.17 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); } return len; } @@ -2328,12 +2323,11 @@ static int v17_v21_rx(void *user_data, const int16_t amp[], int len) static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) { - t31_state_t *t; fax_modems_state_t *s; - t = (t31_state_t *) user_data; - s = &t->audio.modems; + s = (fax_modems_state_t *) user_data; v27ter_rx(&s->fast_modems.v27ter_rx, amp, len); + fsk_rx(&s->v21_rx, amp, len); if (s->rx_trained) { /* The fast modem has trained, so we no longer need to run the slow @@ -2341,16 +2335,12 @@ static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.27ter (%.2fdBm0)\n", v27ter_rx_signal_power(&s->fast_modems.v27ter_rx)); fax_modems_set_rx_handler(s, (span_rx_handler_t) &v27ter_rx, &s->fast_modems.v27ter_rx, (span_rx_fillin_handler_t) &v27ter_rx_fillin, &s->fast_modems.v27ter_rx); } - else + else if (s->rx_frame_received) { - fsk_rx(&s->v21_rx, amp, len); - if (t->rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } + /* We have received something, and the fast modem has not trained. We must + be receiving valid V.21 */ + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.27ter + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); } return len; } @@ -2358,12 +2348,11 @@ static int v27ter_v21_rx(void *user_data, const int16_t amp[], int len) static int v29_v21_rx(void *user_data, const int16_t amp[], int len) { - t31_state_t *t; fax_modems_state_t *s; - t = (t31_state_t *) user_data; - s = &t->audio.modems; + s = (fax_modems_state_t *) user_data; v29_rx(&s->fast_modems.v29_rx, amp, len); + fsk_rx(&s->v21_rx, amp, len); if (s->rx_trained) { /* The fast modem has trained, so we no longer need to run the slow @@ -2371,16 +2360,12 @@ static int v29_v21_rx(void *user_data, const int16_t amp[], int len) span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.29 (%.2fdBm0)\n", v29_rx_signal_power(&s->fast_modems.v29_rx)); fax_modems_set_rx_handler(s, (span_rx_handler_t) &v29_rx, &s->fast_modems.v29_rx, (span_rx_fillin_handler_t) &v29_rx_fillin, &s->fast_modems.v29_rx); } - else + else if (s->rx_frame_received) { - fsk_rx(&s->v21_rx, amp, len); - if (t->rx_frame_received) - { - /* We have received something, and the fast modem has not trained. We must - be receiving valid V.21 */ - span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); - fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); - } + /* We have received something, and the fast modem has not trained. We must + be receiving valid V.21 */ + span_log(&s->logging, SPAN_LOG_FLOW, "Switching from V.29 + V.21 to V.21 (%.2fdBm0)\n", fsk_rx_signal_power(&s->v21_rx)); + fax_modems_set_rx_handler(s, (span_rx_handler_t) &fsk_rx, &s->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &s->v21_rx); } return len; } diff --git a/libs/spandsp/src/t38_gateway.c b/libs/spandsp/src/t38_gateway.c index 96b700fa92..200bdcfde7 100644 --- a/libs/spandsp/src/t38_gateway.c +++ b/libs/spandsp/src/t38_gateway.c @@ -347,11 +347,10 @@ static int set_next_tx_type(t38_gateway_state_t *s) { int indicator; fax_modems_state_t *t; - get_bit_func_t get_bit_func; - void *get_bit_user_data; t38_gateway_hdlc_state_t *u; - int short_train; int bit_rate; + int short_train; + //int use_hdlc; t = &s->audio.modems; t38_non_ecm_buffer_report_output_status(&s->core.non_ecm_to_modem, &s->logging); @@ -393,14 +392,14 @@ static int set_next_tx_type(t38_gateway_state_t *s) { span_log(&s->logging, SPAN_LOG_FLOW, "HDLC mode\n"); hdlc_tx_init(&t->hdlc_tx, FALSE, 2, TRUE, hdlc_underflow_handler, s); - get_bit_func = (get_bit_func_t) hdlc_tx_get_bit; - get_bit_user_data = (void *) &t->hdlc_tx; + fax_modems_set_get_bit(t, (get_bit_func_t) hdlc_tx_get_bit, &t->hdlc_tx); + //use_hdlc = TRUE; } else { span_log(&s->logging, SPAN_LOG_FLOW, "Non-ECM mode\n"); - get_bit_func = t38_non_ecm_buffer_get_bit; - get_bit_user_data = (void *) &s->core.non_ecm_to_modem; + fax_modems_set_get_bit(t, (get_bit_func_t) t38_non_ecm_buffer_get_bit, &s->core.non_ecm_to_modem); + //use_hdlc = FALSE; } /*endif*/ switch (indicator) @@ -445,7 +444,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) t->tx_bit_rate = (indicator == T38_IND_V27TER_4800_TRAINING) ? 4800 : 2400; silence_gen_alter(&t->silence_gen, ms_to_samples(75)); v27ter_tx_restart(&t->fast_modems.v27ter_tx, t->tx_bit_rate, t->use_tep); - v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, get_bit_func, get_bit_user_data); + v27ter_tx_set_get_bit(&t->fast_modems.v27ter_tx, t->get_bit, t->get_bit_user_data); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v27ter_tx, &t->fast_modems.v27ter_tx); fax_modems_set_rx_active(t, TRUE); @@ -456,7 +455,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) t->tx_bit_rate = (indicator == T38_IND_V29_9600_TRAINING) ? 9600 : 7200; silence_gen_alter(&t->silence_gen, ms_to_samples(75)); v29_tx_restart(&t->fast_modems.v29_tx, t->tx_bit_rate, t->use_tep); - v29_tx_set_get_bit(&t->fast_modems.v29_tx, get_bit_func, get_bit_user_data); + v29_tx_set_get_bit(&t->fast_modems.v29_tx, t->get_bit, t->get_bit_user_data); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v29_tx, &t->fast_modems.v29_tx); fax_modems_set_rx_active(t, TRUE); @@ -505,7 +504,7 @@ static int set_next_tx_type(t38_gateway_state_t *s) t->tx_bit_rate = bit_rate; silence_gen_alter(&t->silence_gen, ms_to_samples(75)); v17_tx_restart(&t->fast_modems.v17_tx, t->tx_bit_rate, t->use_tep, short_train); - v17_tx_set_get_bit(&t->fast_modems.v17_tx, get_bit_func, get_bit_user_data); + v17_tx_set_get_bit(&t->fast_modems.v17_tx, t->get_bit, t->get_bit_user_data); fax_modems_set_tx_handler(t, (span_tx_handler_t) &silence_gen, &t->silence_gen); fax_modems_set_next_tx_handler(t, (span_tx_handler_t) &v17_tx, &t->fast_modems.v17_tx); fax_modems_set_rx_active(t, TRUE); @@ -2020,8 +2019,6 @@ static void t38_hdlc_rx_put_bit(hdlc_rx_state_t *t, int new_bit) static int restart_rx_modem(t38_gateway_state_t *s) { fax_modems_state_t *t; - put_bit_func_t put_bit_func; - void *put_bit_user_data; if (s->core.to_t38.in_bits || s->core.to_t38.out_octets) { @@ -2049,21 +2046,19 @@ static int restart_rx_modem(t38_gateway_state_t *s) s->t38x.current_tx_data_type = T38_DATA_V21; fsk_rx_init(&t->v21_rx, &preset_fsk_specs[FSK_V21CH2], FSK_FRAME_MODE_SYNC, (put_bit_func_t) t38_hdlc_rx_put_bit, &t->hdlc_rx); #if 0 - fsk_rx_signal_cutoff(&t->v21_rx, -45.5f); + fsk_rx_signal_cutoff(&t->v21_rx, -39.09f); #endif if (s->core.image_data_mode && s->core.ecm_mode) { - put_bit_func = (put_bit_func_t) t38_hdlc_rx_put_bit; - put_bit_user_data = (void *) &t->hdlc_rx; + fax_modems_set_put_bit(t, (put_bit_func_t) t38_hdlc_rx_put_bit, &t->hdlc_rx); } else { if (s->core.image_data_mode && s->core.to_t38.fill_bit_removal) - put_bit_func = non_ecm_remove_fill_and_put_bit; + fax_modems_set_put_bit(t, (put_bit_func_t) non_ecm_remove_fill_and_put_bit, s); else - put_bit_func = non_ecm_put_bit; + fax_modems_set_put_bit(t, (put_bit_func_t) non_ecm_put_bit, s); /*endif*/ - put_bit_user_data = (void *) s; } /*endif*/ to_t38_buffer_init(&s->core.to_t38); @@ -2072,21 +2067,21 @@ static int restart_rx_modem(t38_gateway_state_t *s) { case FAX_MODEM_V27TER_RX: v27ter_rx_restart(&t->fast_modems.v27ter_rx, s->core.fast_bit_rate, FALSE); - v27ter_rx_set_put_bit(&t->fast_modems.v27ter_rx, put_bit_func, put_bit_user_data); + v27ter_rx_set_put_bit(&t->fast_modems.v27ter_rx, t->put_bit, t->put_bit_user_data); set_rx_handler(t, &v27ter_v21_rx, t, &fax_modems_v27ter_v21_rx_fillin, t); - s->core.fast_rx_active = FAX_MODEM_V27TER_RX; + s->core.fast_rx_active = s->core.fast_rx_modem; break; case FAX_MODEM_V29_RX: v29_rx_restart(&t->fast_modems.v29_rx, s->core.fast_bit_rate, FALSE); - v29_rx_set_put_bit(&t->fast_modems.v29_rx, put_bit_func, put_bit_user_data); + v29_rx_set_put_bit(&t->fast_modems.v29_rx, t->put_bit, t->put_bit_user_data); set_rx_handler(t, &v29_v21_rx, t, &fax_modems_v29_v21_rx_fillin, t); - s->core.fast_rx_active = FAX_MODEM_V29_RX; + s->core.fast_rx_active = s->core.fast_rx_modem; break; case FAX_MODEM_V17_RX: v17_rx_restart(&t->fast_modems.v17_rx, s->core.fast_bit_rate, s->core.short_train); - v17_rx_set_put_bit(&t->fast_modems.v17_rx, put_bit_func, put_bit_user_data); + v17_rx_set_put_bit(&t->fast_modems.v17_rx, t->put_bit, t->put_bit_user_data); set_rx_handler(t, &v17_v21_rx, t, &fax_modems_v17_v21_rx_fillin, t); - s->core.fast_rx_active = FAX_MODEM_V17_RX; + s->core.fast_rx_active = s->core.fast_rx_modem; break; default: set_rx_handler(t, (span_rx_handler_t) &fsk_rx, &t->v21_rx, (span_rx_fillin_handler_t) &fsk_rx_fillin, &t->v21_rx);