# Changing Flowgraph at runtime

**URL:** <https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405>\
**Category:** GNU Radio\
**Created:** [August 6, 2014, 1:38pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405 "2014-08-06T13:38:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 6, 2014, 1:38pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/1 "2014-08-06T13:38:27Z")

</div>

Hello everyone,

Does anyone know if it’s possible create and destroy blocks at runtime?

I know we can reconnect the blocks at runtime [lock(), reconnect,  
unlock()], but  
I don’t know if you can create or destroy…

Thanks.

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 2:11pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/2 "2014-08-06T14:11:09Z")

</div>

You can 🙂

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 2:43pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/3 "2014-08-06T14:43:53Z")

</div>

Ok,

The creation and destruction of blocks at runtime must be made ​​between  
lock() and unlock(). Is it right?  
How can I destroy a block at runtime? block-\>stop()?  
Do I also need a reset() in sptr [block.reset()]?

Thanks again!

2014-08-06 9:09 GMT-03:00 Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 2:52pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/4 "2014-08-06T14:52:15Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Destruction of course should only take place when a block is not  
connected, and connection can only take place between lock() and  
unlock(). Other than that, I’m not aware of any restrictions.

On 06.08.2014 14:42, Douglas Amorim Ferreira wrote:

> 2014-08-06 9:09 GMT-03:00 Marcus M.
> 
> > runtime?  
> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> > mailing

[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)://lists.gnu.org/mailman/listinfo/discuss-gnuradio

> >

* * *

> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1

iQEcBAEBAgAGBQJT4iSFAAoJEAFxB7BbsDrLngYH/1V2h/mSJZYD9YAa6HlOI1IL  
dkl1jQ4v0IyztZGi4N0D7GmS0sUQu1+2NMkJt18ClOVUyMHB8uQmS6PGtycxyxkw  
b4OZG5oqkP96ThfwHQEbatwL8EP+igMQ+wEHvxG6kFzW6kkJcqYPqOsj+hbDrOOG  
L1RrFks3S4Mo2E6luUil2LL7ttkSpbc4MrlFYhwNgJ9mnD57ycyS1wkmIhEpmImV  
7qgts2kqtQdhIGDyb1vZIdTjawXPZ465GmsCkJ/udkyzbeq+wVWBPnwLZRh/3YYR  
M+i2s1HT0eaBFNYfvptl0lGzpANwqUirzMGVItwBXaG2S8s9VNWLAvzKADN0RKE=  
=u37z  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 3:19pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/5 "2014-08-06T15:19:39Z")

</div>

I think Sylvain put his finger on a slightly painful place here:  
I think you might not be very clear about the idea what “destruction of  
a block” actually means.  
So, the most interesting question here is:  
Why would you manually want to destroy a block?

Greetings,  
Marcus

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 3:03pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/6 "2014-08-06T15:03:33Z")

</div>

> The creation and destruction of blocks at runtime must be made between  
> lock() and unlock(). Is it right?  
> How can I destroy a block at runtime? block-\>stop()?  
> Do I also need a reset() in sptr [block.reset()]?

Well, you never really destroy blocks yourself since all you get is  
sptr.

So once it’s disconnected and you “loose” the last sptr you have to  
it, then it should get deleted.

Cheers,

Sylvain

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 4:24pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/7 "2014-08-06T16:24:34Z")

</div>

Well,

I have a signal and I want to get some information from it.  
I want to create demodulators and filters at runtime, and so they are no  
longer needed, remove them (and freeing any resources associated with  
them).  
I’m having problems with an example that I am implementing.

Initially I have two blocks connected:

Audio source ----\> Audio sink  
At runtime I’m adding new branches:

Audio source ----\> Audio sink  
|—\> Some block ----\> Null sink  
|—\> Some block ----\> Null sink  
.  
.  
|—\> Some block ----\> Null sink

After adding 100 new branches, I remove all of them returning the  
initial  
topology. (Audio source ----\> Audio sink)

These additions and removals occur cyclically…

The strange thing is that after a few cycles, the audio starts to get  
delayed (occurring some audio underflow).

My big question is: this audio delay is related to the creation and  
removal of  
blocks or not?

Any suggestion?

Thanks again, and again!

2014-08-06 10:16 GMT-03:00 Marcus Müller [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c68b51/32.png) [@Douglas\_Amorim\_Ferr](https://www.ruby-forum.com/u/Douglas_Amorim_Ferr)\
**Post date:** [August 6, 2014, 4:31pm UTC](https://www.ruby-forum.com/t/changing-flowgraph-at-runtime/231405/8 "2014-08-06T16:31:43Z")

</div>

Sorry for the spam,  
Fixing: occurring some audio underrun…

2014-08-06 11:23 GMT-03:00 Douglas Amorim Ferreira  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):
