roc-streaming / roc-toolkit

Real-time audio streaming over the network.
https://roc-streaming.org
Mozilla Public License 2.0
1.06k stars 213 forks source link

Use core::Optional in roc_pipeline #389

Closed gavv closed 4 years ago

gavv commented 4 years ago

In roc_pipeline module we have numerous pipelines which construct a chain of smaller building blocks from lower-level modules, for example SenderSink and ReceiverSession.

The chain construction is be performed incrementally and sometimes conditionally. We create the first element, check for errors, then create the second element if it's enabled, and so on.

To achieve this, the pipeline fields are declared of type core::ScopedPtr<T> instead of just T, so that their initialization can be delayed.

The drawback of this approach is that we have lots of small allocations, while technically we could avoid it and perform a single bigger allocation for the whole pipeline object.

So this issue is for cleaning this up a bit. We now have core::Optional<T>, which can be used exactly for the purpose of the delayed initialization, but does not require an unnecessary allocation.

So we should just replace all those core::ScopedPtr<T> fields in roc_pipeline with core::Optional<T>, and adjust the initialization accordingly.

Villaquiranm commented 4 years ago

Hello @gavv, i would like to work on this if nobody else has started :)

gavv commented 4 years ago

Great, you're welcome! The issue is free.

gavv commented 4 years ago

Merged.