From f659c1af8f5a0e2e629ec67c9a3a4d54f8c7d529 Mon Sep 17 00:00:00 2001
From: michael-west <michael.west@ettus.com>
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 <michael.west@ettus.com>
---
 host/lib/rfnoc/rfnoc_rx_streamer.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

(limited to 'host/lib/rfnoc/rfnoc_rx_streamer.cpp')

diff --git a/host/lib/rfnoc/rfnoc_rx_streamer.cpp b/host/lib/rfnoc/rfnoc_rx_streamer.cpp
index 081682a94..180f5e87f 100644
--- a/host/lib/rfnoc/rfnoc_rx_streamer.cpp
+++ b/host/lib/rfnoc/rfnoc_rx_streamer.cpp
@@ -18,11 +18,13 @@ using namespace uhd::rfnoc;
 const std::string STREAMER_ID = "RxStreamer";
 static std::atomic<uint64_t> streamer_inst_ctr;
 
-rfnoc_rx_streamer::rfnoc_rx_streamer(
-    const size_t num_chans, const uhd::stream_args_t stream_args)
-    : rx_streamer_impl<chdr_rx_data_xport>(num_chans, stream_args)
+rfnoc_rx_streamer::rfnoc_rx_streamer(const size_t num_chans,
+    const uhd::stream_args_t stream_args,
+    disconnect_fn_t disconnect_cb)
+    : rx_streamer_impl<chdr_rx_data_xport>(stream_args.channels.size(), stream_args)
     , _unique_id(STREAMER_ID + "#" + std::to_string(streamer_inst_ctr++))
     , _stream_args(stream_args)
+    , _disconnect_cb(disconnect_cb)
 {
     set_overrun_handler([this]() { this->_handle_overrun(); });
 
@@ -90,6 +92,13 @@ rfnoc_rx_streamer::rfnoc_rx_streamer(
     node_accessor.init_props(this);
 }
 
+rfnoc_rx_streamer::~rfnoc_rx_streamer()
+{
+    if (_disconnect_cb) {
+        _disconnect_cb(_unique_id);
+    }
+}
+
 std::string rfnoc_rx_streamer::get_unique_id() const
 {
     return _unique_id;
-- 
cgit v1.2.3