diff options
author | Clayton Smith <argilo@gmail.com> | 2020-10-12 09:04:02 -0400 |
---|---|---|
committer | Andrej Rode <mail@andrejro.de> | 2020-10-16 16:19:25 +0200 |
commit | 70b3680ad3cc2339f6a5d87ac54b6257b70083c7 (patch) | |
tree | 4c8cb0ee8e6d5cfae4fb988bf6d50423478f1948 /gr-vocoder/lib/freedv_tx_ss_impl.h | |
parent | e935de54575436ee4b9345fb9668c27cbb0ef082 (diff) |
vocoder: refactor get_next_tx_char callback
The get_next_tx_char callback in the FreeDV modulator block is one of
the last places where snprintf is used. I've eliminated it by using C++
string methods instead. This also removes the 79-character limit.
This change also fixes a bug where the last character of the message was
not transmitted.
Lastly, I refactored the callback to be a static member function,
eliminating the need for a separate structure to hold the callback
state.
Diffstat (limited to 'gr-vocoder/lib/freedv_tx_ss_impl.h')
-rw-r--r-- | gr-vocoder/lib/freedv_tx_ss_impl.h | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/gr-vocoder/lib/freedv_tx_ss_impl.h b/gr-vocoder/lib/freedv_tx_ss_impl.h index 31ed023eb7..f4f341b97e 100644 --- a/gr-vocoder/lib/freedv_tx_ss_impl.h +++ b/gr-vocoder/lib/freedv_tx_ss_impl.h @@ -13,18 +13,6 @@ #include <gnuradio/vocoder/freedv_tx_ss.h> -extern "C" { -struct freedv_tx_callback_state { - char tx_str[80]; - char* ptx_str; - int calls; -}; -char get_next_tx_char(void* callback_state); -void get_next_proto(void* callback_state, char* proto_bits); -void datarx(void* callback_state, unsigned char* packet, size_t size); -void datatx(void* callback_state, unsigned char* packet, size_t* size); -} - namespace gr { namespace vocoder { @@ -33,7 +21,9 @@ class freedv_tx_ss_impl : public freedv_tx_ss private: short* d_speech_in; short* d_mod_out; - struct freedv_tx_callback_state d_cb_state; + std::string d_tx_str; + std::string::size_type d_tx_str_offset = 0; + static char get_next_tx_char(void* callback_state); struct freedv* d_freedv; int d_mode; std::string d_msg_text; |