summaryrefslogtreecommitdiff
path: root/gr-qtgui/lib/const_sink_c_impl.cc
diff options
context:
space:
mode:
Diffstat (limited to 'gr-qtgui/lib/const_sink_c_impl.cc')
-rw-r--r--gr-qtgui/lib/const_sink_c_impl.cc62
1 files changed, 14 insertions, 48 deletions
diff --git a/gr-qtgui/lib/const_sink_c_impl.cc b/gr-qtgui/lib/const_sink_c_impl.cc
index 2f203901d7..568949c977 100644
--- a/gr-qtgui/lib/const_sink_c_impl.cc
+++ b/gr-qtgui/lib/const_sink_c_impl.cc
@@ -18,6 +18,7 @@
#include <gnuradio/prefs.h>
#include <qwt_symbol.h>
#include <volk/volk.h>
+#include <volk/volk_alloc.hh>
#include <cstring>
namespace gr {
@@ -42,39 +43,15 @@ const_sink_c_impl::const_sink_c_impl(int size,
d_nconnections(nconnections),
d_parent(parent)
{
- // Required now for Qt; argc must be greater than 0 and argv
- // must have at least one valid character. Must be valid through
- // life of the qApplication:
- // http://harmattan-dev.nokia.com/docs/library/html/qt4/qapplication.html
- d_argc = 1;
- d_argv = new char;
- d_argv[0] = '\0';
-
- d_main_gui = NULL;
-
- d_index = 0;
-
// setup PDU handling input port
message_port_register_in(pmt::mp("in"));
set_msg_handler(pmt::mp("in"), [this](pmt::pmt_t msg) { this->handle_pdus(msg); });
- for (int i = 0; i < d_nconnections; i++) {
- d_residbufs_real.push_back(
- (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
- d_residbufs_imag.push_back(
- (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
- memset(d_residbufs_real[i], 0, d_buffer_size * sizeof(double));
- memset(d_residbufs_imag[i], 0, d_buffer_size * sizeof(double));
+ for (int i = 0; i < d_nconnections + 1; i++) {
+ d_residbufs_real.emplace_back(d_buffer_size);
+ d_residbufs_imag.emplace_back(d_buffer_size);
}
- // Used for PDU message input
- d_residbufs_real.push_back(
- (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
- d_residbufs_imag.push_back(
- (double*)volk_malloc(d_buffer_size * sizeof(double), volk_get_alignment()));
- memset(d_residbufs_real[d_nconnections], 0, d_buffer_size * sizeof(double));
- memset(d_residbufs_imag[d_nconnections], 0, d_buffer_size * sizeof(double));
-
// Set alignment properties for VOLK
const int alignment_multiple = volk_get_alignment() / sizeof(gr_complex);
set_alignment(std::max(1, alignment_multiple));
@@ -90,14 +67,6 @@ const_sink_c_impl::~const_sink_c_impl()
{
if (!d_main_gui->isClosed())
d_main_gui->close();
-
- // d_main_gui is a qwidget destroyed with its parent
- for (int i = 0; i < d_nconnections + 1; i++) {
- volk_free(d_residbufs_real[i]);
- volk_free(d_residbufs_imag[i]);
- }
-
- delete d_argv;
}
bool const_sink_c_impl::check_topology(int ninputs, int noutputs)
@@ -276,15 +245,10 @@ void const_sink_c_impl::set_nsamps(const int newsize)
// Resize residbuf and replace data
// +1 to handle PDU message input buffers
for (int i = 0; i < d_nconnections + 1; i++) {
- volk_free(d_residbufs_real[i]);
- volk_free(d_residbufs_imag[i]);
- d_residbufs_real[i] = (double*)volk_malloc(d_buffer_size * sizeof(double),
- volk_get_alignment());
- d_residbufs_imag[i] = (double*)volk_malloc(d_buffer_size * sizeof(double),
- volk_get_alignment());
-
- memset(d_residbufs_real[i], 0, d_buffer_size * sizeof(double));
- memset(d_residbufs_imag[i], 0, d_buffer_size * sizeof(double));
+ d_residbufs_real[i].clear();
+ d_residbufs_imag[i].clear();
+ d_residbufs_real[i].resize(d_buffer_size);
+ d_residbufs_imag[i].resize(d_buffer_size);
}
d_main_gui->setNPoints(d_size);
@@ -437,10 +401,10 @@ int const_sink_c_impl::work(int noutput_items,
if ((d_triggered) && (d_index == d_end)) {
// Copy data to be plotted to start of buffers.
for (n = 0; n < d_nconnections; n++) {
- memmove(d_residbufs_real[n],
+ memmove(d_residbufs_real[n].data(),
&d_residbufs_real[n][d_start],
d_size * sizeof(double));
- memmove(d_residbufs_imag[n],
+ memmove(d_residbufs_imag[n].data(),
&d_residbufs_imag[n][d_start],
d_size * sizeof(double));
}
@@ -500,8 +464,10 @@ void const_sink_c_impl::handle_pdus(pmt::pmt_t msg)
d_last_time = gr::high_res_timer_now();
// Copy data into the buffers.
- volk_32fc_deinterleave_64f_x2(
- d_residbufs_real[d_nconnections], d_residbufs_imag[d_nconnections], in, len);
+ volk_32fc_deinterleave_64f_x2(d_residbufs_real[d_nconnections].data(),
+ d_residbufs_imag[d_nconnections].data(),
+ in,
+ len);
d_qApplication->postEvent(
d_main_gui, new ConstUpdateEvent(d_residbufs_real, d_residbufs_imag, len));