From 5333d0d9323325dbb6321188852ccd48d54cb47a Mon Sep 17 00:00:00 2001 From: Aaron Rossetto Date: Fri, 14 Aug 2020 12:10:32 -0500 Subject: multi_usrp: Use multi_usrp::sptrs in graph disconnect lambdas --- host/lib/usrp/multi_usrp_rfnoc.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'host') diff --git a/host/lib/usrp/multi_usrp_rfnoc.cpp b/host/lib/usrp/multi_usrp_rfnoc.cpp index c937cb892..26932ef30 100644 --- a/host/lib/usrp/multi_usrp_rfnoc.cpp +++ b/host/lib/usrp/multi_usrp_rfnoc.cpp @@ -157,7 +157,8 @@ std::string bytes_to_str(std::vector str_b) } // namespace -class multi_usrp_rfnoc : public multi_usrp +class multi_usrp_rfnoc : public multi_usrp, + public std::enable_shared_from_this { public: struct rx_chan_t @@ -287,11 +288,12 @@ public: // Create the streamer // The disconnect callback must disconnect the entire chain because the radio // relies on the connections to determine what is enabled. - auto rx_streamer = std::make_shared(args.channels.size(), + auto this_multi_usrp = shared_from_this(); + auto rx_streamer = std::make_shared(args.channels.size(), args, - [this, channels = args.channels](const std::string& id) { - this->_graph->disconnect(id); - this->_disconnect_rx_chains(channels); + [channels = args.channels, this_multi_usrp](const std::string& id) { + this_multi_usrp->_graph->disconnect(id); + this_multi_usrp->_disconnect_rx_chains(channels); }); // Connect the streamer @@ -361,11 +363,12 @@ public: // Create a streamer // The disconnect callback must disconnect the entire chain because the radio // relies on the connections to determine what is enabled. - auto tx_streamer = std::make_shared(args.channels.size(), + auto this_multi_usrp = shared_from_this(); + auto tx_streamer = std::make_shared(args.channels.size(), args, - [this, channels = args.channels](const std::string& id) { - this->_graph->disconnect(id); - this->_disconnect_tx_chains(channels); + [channels = args.channels, this_multi_usrp](const std::string& id) { + this_multi_usrp->_graph->disconnect(id); + this_multi_usrp->_disconnect_tx_chains(channels); }); // Connect the streamer -- cgit v1.2.3