[PATCH] gr-osmosdr/rtl: small fix to send final samples

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/osmocom-sdr@lists.osmocom.org/.

Karl Semich 0xloem at gmail.com
Sun Sep 23 12:41:45 UTC 2018


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




More information about the osmocom-sdr mailing list