title: How is noutput_items determined in GNU Radio?
body: <p>I'm looking at the source code for GrOsmoSdr's <a href="http://git.osmocom.org/gr-osmosdr/tree/lib/rtl_tcp/rtl_tcp_source_f.cc" rel="nofollow">rtl_tcp_source_f.cc</a>, which is a GNU Radio source which reads interleaved I/Q data from TCP.</p>
  
  <p>The work function looks like this:</p>
  
  <pre><code>int rtl_tcp_source_f::work (int noutput_items,
                              gr_vector_const_void_star &amp;input_items,
                              gr_vector_void_star &amp;output_items)
  {
    float *out = (float *) output_items[0];
    ssize_t r = 0;
  
    int bytesleft = noutput_items;
    int index = 0;
    int receivedbytes = 0;
    while(bytesleft &gt; 0) {
      receivedbytes = recv(d_socket, (char*)&amp;d_temp_buff[index], bytesleft, 0);
  
      if(receivedbytes == -1 &amp;&amp; !is_error(EAGAIN)){
        fprintf(stderr, "socket error\n");
        return -1;
      }
      bytesleft -= receivedbytes;
      index += receivedbytes;
    }
    r = noutput_items;
  
    for(int i=0; i&lt;r; ++i)
      out[i]=d_LUT[*(d_temp_buff+d_temp_offset+i)];
  
    return r;
  }
  </code></pre>
  
  <p>The buffer <code>d_temp_buff</code> is set up in the constructor:</p>
  
  <pre><code>d_temp_buff = new unsigned char[d_payload_size]; 
  </code></pre>
  
  <p>where <code>d_payload_size</code> is a constructor parameter which is passed in by configuration. </p>
  
  <p>The work function reads exactly <code>noutput_items</code> into <code>d_temp_buff</code>. How is <code>noutput_items</code> selected by Gnuradio in general, and how can this work function be sure that <code>noutput_items &lt;= d_payload_size</code>?</p>