On Fri, Jun 8, 2012 at 11:03 AM, Alexandru Csete <oz9...@gmail.com> wrote:
> Is there a smart way to delete a GNU Radio block in C++? > Until now I have been using the shared_ptr().reset() method but it > seems to me that it will only call the destructor if the parent > top_block has not been run. > "Don't do that." The reference count in the smart pointer is designed to increment and decrement according to usage and scoping. Calling reset() is reserved for very special situations. The reason the destructor doesn't get called is that the flowgraph structure itself (created by the call to connect() ) internally stores a copy of the pointer; thus, the reference count never goes to zero. Resetting it manually is an invitation to a future segfault. > This gives me problems when I try to delete and recreate a hardware > input block (e.g. gr-audio input) where the new device can be the same > as the old one, in which case it will report "device busy". > > [...] > > Perhaps these hardware input blocks are coded incorrectly and should > close the device in their stop() method? Or is there something else we > can do? > You've pegged the real issue. It's probably a good idea to make start() and stop() do the actual hardware acquisition and release. I expect this is not trivial, but would be a great improvement in how those blocks can be used. Johnathan
_______________________________________________ Discuss-gnuradio mailing list Discuss-gnuradio@gnu.org https://lists.gnu.org/mailman/listinfo/discuss-gnuradio