diff options
Diffstat (limited to 'host/lib/include/uhdlib/transport/rx_streamer_impl.hpp')
-rw-r--r-- | host/lib/include/uhdlib/transport/rx_streamer_impl.hpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp b/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp index 79c196f3f..f776d9373 100644 --- a/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp +++ b/host/lib/include/uhdlib/transport/rx_streamer_impl.hpp @@ -88,7 +88,6 @@ public: if (stream_args.args.has_key("spp")) { _spp = stream_args.args.cast<size_t>("spp", _spp); - _mtu = _spp * _convert_info.bytes_per_otw_item; } } @@ -97,7 +96,8 @@ public: // them virtual void connect_channel(const size_t channel, typename transport_t::uptr xport) { - const size_t mtu = xport->get_max_payload_size(); + const size_t mtu = xport->get_mtu(); + _hdr_len = std::max(_hdr_len, xport->get_chdr_hdr_len()); _zero_copy_streamer.connect_channel(channel, std::move(xport)); if (mtu < _mtu) { @@ -201,11 +201,15 @@ protected: return _mtu; } - //! Sets the MTU and calculates spp + //! Sets the MTU and checks spp. If spp would exceed the new MTU, it is + // reduced accordingly. void set_mtu(const size_t mtu) { _mtu = mtu; - _spp = _mtu / _convert_info.bytes_per_otw_item; + const size_t spp_from_mtu = (_mtu - _hdr_len) / _convert_info.bytes_per_otw_item; + if (spp_from_mtu < _spp) { + _spp = spp_from_mtu; + } } //! Configures sample rate for conversion of timestamp @@ -401,7 +405,12 @@ private: // MTU, determined when xport is connected and modifiable by subclass size_t _mtu = std::numeric_limits<std::size_t>::max(); - // Maximum number of samples per packet + // Size of CHDR header in bytes + size_t _hdr_len = 0; + + // Maximum number of samples per packet. Note that this is not necessarily + // related to the MTU, it is a user-chosen value. However, it is always + // bounded by the MTU. size_t _spp = std::numeric_limits<std::size_t>::max(); // Num samps remaining in buffer currently held by zero copy streamer |