commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 01/03: uhd: Replace zero-timeout double-rec


From: git
Subject: [Commit-gnuradio] [gnuradio] 01/03: uhd: Replace zero-timeout double-recv() with one recv() call
Date: Sat, 24 Sep 2016 17:48:09 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch master
in repository gnuradio.

commit a7d2479de44f06610e91ff74405f0919133d8d4a
Author: Martin Braun <address@hidden>
Date:   Fri Sep 23 14:55:32 2016 -0700

    uhd: Replace zero-timeout double-recv() with one recv() call
    
    For most cases, the zero-timeout call will just return empty buffers,
    resulting in extra overhead.
---
 gr-uhd/lib/usrp_source_impl.cc | 19 +++++++++----------
 gr-uhd/lib/usrp_source_impl.h  |  3 ++-
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/gr-uhd/lib/usrp_source_impl.cc b/gr-uhd/lib/usrp_source_impl.cc
index ebfdf4a..b48b151 100644
--- a/gr-uhd/lib/usrp_source_impl.cc
+++ b/gr-uhd/lib/usrp_source_impl.cc
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2010-2015 Free Software Foundation, Inc.
+ * Copyright 2010-2016 Free Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -70,6 +70,7 @@ namespace gr {
                     io_signature::make(0, 0, 0),
                     args_to_io_sig(stream_args)),
       usrp_block_impl(device_addr, stream_args, ""),
+      _recv_timeout(0.1), // seconds
       _tag_now(false),
       _issue_stream_cmd_on_start(issue_stream_cmd_on_start)
     {
@@ -613,15 +614,13 @@ namespace gr {
       //In order to allow for low-latency:
       //We receive all available packets without timeout.
       //This call can timeout under regular operation...
-      size_t num_samps = _rx_stream->recv
-        (output_items, noutput_items, _metadata, 0.0);
-
-      //If receive resulted in a timeout condition:
-      //We now receive a single packet with a large timeout.
-      if(_metadata.error_code == ::uhd::rx_metadata_t::ERROR_CODE_TIMEOUT) {
-        num_samps = _rx_stream->recv
-          (output_items, noutput_items, _metadata, 0.1, true/*one pkt*/);
-      }
+      size_t num_samps = _rx_stream->recv(
+          output_items,
+          noutput_items,
+          _metadata,
+          _recv_timeout,
+          true /* one packet -> minimize latency */
+      );
 #else
       size_t num_samps = _dev->get_device()->recv
         (output_items, noutput_items, _metadata,
diff --git a/gr-uhd/lib/usrp_source_impl.h b/gr-uhd/lib/usrp_source_impl.h
index f6225a7..ab0f5c6 100644
--- a/gr-uhd/lib/usrp_source_impl.h
+++ b/gr-uhd/lib/usrp_source_impl.h
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2010-2013 Free Software Foundation, Inc.
+ * Copyright 2010-2016 Software Foundation, Inc.
  *
  * This file is part of GNU Radio
  *
@@ -126,6 +126,7 @@ namespace gr {
 #ifdef GR_UHD_USE_STREAM_API
       ::uhd::rx_streamer::sptr _rx_stream;
       size_t _samps_per_packet;
+      double _recv_timeout;
 #endif
       bool _tag_now;
       ::uhd::rx_metadata_t _metadata;



reply via email to

[Prev in Thread] Current Thread [Next in Thread]