aboutsummaryrefslogtreecommitdiffstats
path: root/op25
diff options
context:
space:
mode:
authorMax <ikj1234i@yahoo.com>2017-11-29 00:16:18 -0500
committerMax <ikj1234i@yahoo.com>2017-11-29 00:16:18 -0500
commit0927bc11a9117d86e9c9a3e2d8fbcf5d4ac1fe8b (patch)
treeb4477ae67c700a141e4160de1b5a79ca5c167933 /op25
parent796c81f219d3dc23166a8f2109d2a35ffac5cc0a (diff)
vocoder: fix excess cpu usage
Diffstat (limited to 'op25')
-rw-r--r--op25/gr-op25_repeater/lib/vocoder_impl.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/op25/gr-op25_repeater/lib/vocoder_impl.cc b/op25/gr-op25_repeater/lib/vocoder_impl.cc
index 3f2032d..967dde4 100644
--- a/op25/gr-op25_repeater/lib/vocoder_impl.cc
+++ b/op25/gr-op25_repeater/lib/vocoder_impl.cc
@@ -40,6 +40,8 @@
namespace gr {
namespace op25_repeater {
+ static const int FRAGMENT_SIZE = 864;
+
vocoder::sptr
vocoder::make(bool encode_flag, bool verbose_flag, int stretch_amt, char* udp_host, int udp_port, bool raw_vectors_flag)
{
@@ -73,6 +75,8 @@ namespace gr {
p1voice_encode(verbose_flag, stretch_amt, udp_host, udp_port, raw_vectors_flag, output_queue),
p1voice_decode(verbose_flag, udp_host, udp_port, output_queue_decode)
{
+ if (opt_encode_flag)
+ set_output_multiple(FRAGMENT_SIZE);
}
/*
@@ -131,13 +135,17 @@ vocoder_impl::general_work_encode (int noutput_items,
gr_vector_void_star &output_items)
{
const short *in = (const short *) input_items[0];
+ const int noutput_fragments = noutput_items / FRAGMENT_SIZE;
+ const int fragments_available = output_queue.size() / FRAGMENT_SIZE;
+ const int nsamples_consume = std::min(ninput_items[0], std::max(0,(noutput_fragments - fragments_available) * 9 * 160));
- p1voice_encode.compress_samp(in, ninput_items[0]);
+ if (nsamples_consume > 0)
+ p1voice_encode.compress_samp(in, nsamples_consume);
// Tell runtime system how many input items we consumed on
// each input stream.
- consume_each (ninput_items[0]);
+ consume_each (nsamples_consume);
if (opt_udp_port > 0) // in udp option, we are a gr sink only
return 0;