From 97fd10af58ecd4effcf1715eed502836e3c2e1da Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 9 May 2011 12:13:50 +0100 Subject: gr-qtgui: makes time sink a sync_block (since it is) and uses set_output_multiple instead of forecast. The result is that multiple streams maintain constant relationship, which they did not before. This should also prevent us from having to keep so much book-keeping of the indecies, and we will hopefully be able to clean this up soon. --- gr-qtgui/lib/qtgui_time_sink_c.cc | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'gr-qtgui/lib/qtgui_time_sink_c.cc') diff --git a/gr-qtgui/lib/qtgui_time_sink_c.cc b/gr-qtgui/lib/qtgui_time_sink_c.cc index 6c4793ea1..e5c4cd7d6 100644 --- a/gr-qtgui/lib/qtgui_time_sink_c.cc +++ b/gr-qtgui/lib/qtgui_time_sink_c.cc @@ -44,9 +44,9 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, const std::string &name, int nconnections, QWidget *parent) - : gr_block ("time_sink_c", - gr_make_io_signature (nconnections, nconnections, sizeof(gr_complex)), - gr_make_io_signature (0, 0, 0)), + : gr_sync_block ("time_sink_c", + gr_make_io_signature (nconnections, nconnections, sizeof(gr_complex)), + gr_make_io_signature (0, 0, 0)), d_size(size), d_bandwidth(bw), d_name(name), d_nconnections(2*nconnections), d_parent(parent) { @@ -59,6 +59,7 @@ qtgui_time_sink_c::qtgui_time_sink_c (int size, double bw, } initialize(); + set_output_multiple(d_size); } qtgui_time_sink_c::~qtgui_time_sink_c() @@ -69,15 +70,6 @@ qtgui_time_sink_c::~qtgui_time_sink_c() } } -void -qtgui_time_sink_c::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned int ninputs = ninput_items_required.size(); - for (unsigned int i = 0; i < ninputs; i++) { - ninput_items_required[i] = std::min(d_size, 8191); - } -} - void qtgui_time_sink_c::initialize() { @@ -144,10 +136,9 @@ qtgui_time_sink_c::set_color(int which, const std::string &color) } int -qtgui_time_sink_c::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +qtgui_time_sink_c::work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { int n=0, j=0, idx=0; const gr_complex *in = (const gr_complex*)input_items[idx]; @@ -159,7 +150,6 @@ qtgui_time_sink_c::general_work (int noutput_items, // If we have enough input for one full plot, do it if(datasize >= resid) { - d_current_time = get_highres_clock(); // Fill up residbufs with d_size number of items for(n = 0; n < d_nconnections; n+=2) { @@ -171,6 +161,7 @@ qtgui_time_sink_c::general_work (int noutput_items, } // Update the plot if its time + d_current_time = get_highres_clock(); if(diff_timespec(d_current_time, d_last_time) > d_update_time) { d_last_time = d_current_time; d_qApplication->postEvent(d_main_gui, @@ -181,7 +172,9 @@ qtgui_time_sink_c::general_work (int noutput_items, j += resid; } // Otherwise, copy what we received into the residbufs for next time + // because we set the output_multiple, this should never need to be called else { + assert(0); for(n = 0; n < d_nconnections; n+=2) { in = (const gr_complex*)input_items[idx++]; for(unsigned int k = 0; k < resid; k++) { @@ -193,7 +186,6 @@ qtgui_time_sink_c::general_work (int noutput_items, j += datasize; } } - - consume_each(j); - return j; + + return noutput_items; } -- cgit