rtl: fix large output buffers handling
When size of output buffer was larger than size of input buffer, uderflow occured because no check on number of avalilable data was done. This also improves buffer filling for large output buffers, fill output until anny input is available.
This commit is contained in:
parent
3afecd6adf
commit
225faa2e6a
|
@ -347,37 +347,31 @@ int rtl_source_c::work( int noutput_items,
|
||||||
if (!_running)
|
if (!_running)
|
||||||
return WORK_DONE;
|
return WORK_DONE;
|
||||||
|
|
||||||
unsigned short *buf = _buf[_buf_head] + _buf_offset;
|
while (noutput_items && _buf_used) {
|
||||||
|
const int nout = std::min(noutput_items, _samp_avail);
|
||||||
|
const unsigned short *buf = _buf[_buf_head] + _buf_offset;
|
||||||
|
|
||||||
if (noutput_items <= _samp_avail) {
|
for (int i = 0; i < nout; ++i)
|
||||||
for (int i = 0; i < noutput_items; ++i)
|
|
||||||
*out++ = _lut[ *(buf + i) ];
|
*out++ = _lut[ *(buf + i) ];
|
||||||
|
|
||||||
_buf_offset += noutput_items;
|
noutput_items -= nout;
|
||||||
_samp_avail -= noutput_items;
|
_samp_avail -= nout;
|
||||||
} else {
|
|
||||||
for (int i = 0; i < _samp_avail; ++i)
|
|
||||||
*out++ = _lut[ *(buf + i) ];
|
|
||||||
|
|
||||||
{
|
if (!_samp_avail) {
|
||||||
boost::mutex::scoped_lock lock( _buf_mutex );
|
{
|
||||||
|
boost::mutex::scoped_lock lock( _buf_mutex );
|
||||||
|
|
||||||
_buf_head = (_buf_head + 1) % _buf_num;
|
_buf_head = (_buf_head + 1) % _buf_num;
|
||||||
_buf_used--;
|
_buf_used--;
|
||||||
|
}
|
||||||
|
_samp_avail = _buf_len / BYTES_PER_SAMPLE;
|
||||||
|
_buf_offset = 0;
|
||||||
|
} else {
|
||||||
|
_buf_offset += nout;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = _buf[_buf_head];
|
|
||||||
|
|
||||||
int remaining = noutput_items - _samp_avail;
|
|
||||||
|
|
||||||
for (int i = 0; i < remaining; ++i)
|
|
||||||
*out++ = _lut[ *(buf + i) ];
|
|
||||||
|
|
||||||
_buf_offset = remaining;
|
|
||||||
_samp_avail = (_buf_len / BYTES_PER_SAMPLE) - remaining;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return noutput_items;
|
return (out - ((gr_complex *)output_items[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> rtl_source_c::get_devices()
|
std::vector<std::string> rtl_source_c::get_devices()
|
||||||
|
|
Loading…
Reference in New Issue