Small change to work function to finish draining buffers
before closing when device disappears. Provides a little
more data when device is unexpectedly lost.
---
lib/rtl/rtl_source_c.cc | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/rtl/rtl_source_c.cc b/lib/rtl/rtl_source_c.cc
index a371464..c0ba0b3 100644
--- a/lib/rtl/rtl_source_c.cc
+++ b/lib/rtl/rtl_source_c.cc
@@ -340,13 +340,18 @@ int rtl_source_c::work( int noutput_items,
{
boost::mutex::scoped_lock lock( _buf_mutex );
- while (_buf_used < 3 && _running) // collect at least 3 buffers
+ while (_buf_used < 3) // collect at least 3 buffers
+ {
+ if (!_running) {
+ // finish when remaining samples are drained
+ if (!_buf_used)
+ return WORK_DONE;
+ break;
+ }
_buf_cond.wait( lock );
+ }
}
- if (!_running)
- return WORK_DONE;
-
while (noutput_items && _buf_used) {
const int nout = std::min(noutput_items, _samp_avail);
const unsigned char *buf = _buf[_buf_head] + _buf_offset * 2;
--
2.11.0