From f659c1af8f5a0e2e629ec67c9a3a4d54f8c7d529 Mon Sep 17 00:00:00 2001 From: michael-west Date: Fri, 12 Jun 2020 10:14:55 -0700 Subject: RFNoC: Added support for destruction of streamers - Added rfnoc_graph method to disconnect a connection. - Added rfnoc_graph method to disconnect a streamer. - Added rfnoc_graph method to disconnect a port on a streamer. - Added disconnect callback to rfnoc_rx_streamer and rfnoc_tx_streamer. - Registered disconnect callback functions to streamers returned by get_rx_streamer and get_tx_streamer methods. Signed-off-by: michael-west --- host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp | 15 ++++++++++++++- host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'host/lib/include/uhdlib') diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp index 8ce3725a7..9cda81785 100644 --- a/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp +++ b/host/lib/include/uhdlib/rfnoc/rfnoc_rx_streamer.hpp @@ -22,13 +22,23 @@ namespace uhd { namespace rfnoc { class rfnoc_rx_streamer : public node_t, public transport::rx_streamer_impl { + using disconnect_fn_t = std::function; + public: /*! Constructor * * \param num_ports The number of ports * \param stream_args Arguments to aid the construction of the streamer + * \param disconnect_cb Callback function to disconnect the streamer when + * the object is destroyed + */ + rfnoc_rx_streamer(const size_t num_ports, + const uhd::stream_args_t stream_args, + disconnect_fn_t disconnect_cb); + + /*! Destructor */ - rfnoc_rx_streamer(const size_t num_ports, const uhd::stream_args_t stream_args); + ~rfnoc_rx_streamer(); /*! Returns a unique identifier string for this node. In every RFNoC graph, * no two nodes cannot have the same ID. Returns a string in the form of @@ -107,6 +117,9 @@ private: // Stream args provided at construction const uhd::stream_args_t _stream_args; + // Callback function to disconnect + const disconnect_fn_t _disconnect_cb; + std::atomic _overrun_handling_mode{false}; size_t _overrun_channel = 0; }; diff --git a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp index ce989420c..5d741a844 100644 --- a/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp +++ b/host/lib/include/uhdlib/rfnoc/rfnoc_tx_streamer.hpp @@ -22,13 +22,23 @@ namespace uhd { namespace rfnoc { class rfnoc_tx_streamer : public node_t, public transport::tx_streamer_impl { + using disconnect_fn_t = std::function; + public: /*! Constructor * * \param num_ports The number of ports * \param stream_args Arguments to aid the construction of the streamer + * \param disconnect_cb Callback function to disconnect the streamer when + * the object is destroyed + */ + rfnoc_tx_streamer(const size_t num_ports, + const uhd::stream_args_t stream_args, + disconnect_fn_t disconnect_cb); + + /*! Destructor */ - rfnoc_tx_streamer(const size_t num_chans, const uhd::stream_args_t stream_args); + ~rfnoc_tx_streamer(); /*! Returns a unique identifier string for this node. In every RFNoC graph, * no two nodes cannot have the same ID. Returns a string in the form of @@ -109,6 +119,9 @@ private: // Stream args provided at construction const uhd::stream_args_t _stream_args; + + // Callback function to disconnect + const disconnect_fn_t _disconnect_cb; }; }} // namespace uhd::rfnoc -- cgit v1.2.3