diff --git a/Plugins/nosUtilities/Source/Ring.h b/Plugins/nosUtilities/Source/Ring.h index b9ea8376..7891f4bd 100644 --- a/Plugins/nosUtilities/Source/Ring.h +++ b/Plugins/nosUtilities/Source/Ring.h @@ -794,18 +794,40 @@ struct RingNodeBase : NodeContext resource = std::make_unique(); else resource = std::make_unique(); + if (auto inputVal = GetWatchedPinValue(NSN_Input)) + resource->CheckNewResource(NSN_Input, *inputVal, std::nullopt); + if (auto alignmentVal = GetWatchedPinValue(NSN_Alignment)) + resource->CheckNewResource(NSN_Alignment, *alignmentVal, std::nullopt); + uint32_t size = 1; + if (auto sizeVal = GetWatchedPinValue(NSN_Size)) + size = *InterpretPinValue(*sizeVal); + Ring = std::make_unique(size, std::move(resource)); - Ring = std::make_unique(1, std::move(resource)); Ring->Stop(); + } + + RingNodeBase(nosFbNodePtr node, OnRestartType onRestart) : NodeContext(node), OnRestart(onRestart), TypeInfo(NSN_Generic) + { + nos::Name typeName = NSN_Generic; + if(auto* pins = node->pins()) + for (auto* pin : *pins) + if (pin->name()->c_str() == NSN_Output) + IsOutLive = pin->live(); + for (auto& pin : Pins | std::views::values) + if (pin.TypeName != NSN_Generic && (pin.Name == NSN_Output || pin.Name == NSN_Input)) + typeName = pin.TypeName; + AddPinValueWatcher(NSN_Size, [this](nos::Buffer const& newSize, std::optional oldVal) { + if (!Ring) + return; uint32_t size = *newSize.As(); if (oldVal && oldVal == newSize) return; RequestRingResize(size); }); AddPinValueWatcher(NSN_Input, [this](nos::Buffer const& newBuf, std::optional oldVal) { - if (Ring->ResInterface->CheckNewResource(NSN_Input, newBuf, oldVal)) + if (Ring && Ring->ResInterface->CheckNewResource(NSN_Input, newBuf, oldVal)) { SendPathRestart(); Ring->Stop(); @@ -813,28 +835,18 @@ struct RingNodeBase : NodeContext } }); AddPinValueWatcher(NSN_Alignment, [this](nos::Buffer const& newAlignment, std::optional oldVal) { - if (Ring->ResInterface->CheckNewResource(NSN_Alignment, newAlignment, oldVal)) + if (Ring && Ring->ResInterface->CheckNewResource(NSN_Alignment, newAlignment, oldVal)) { SendPathRestart(); Ring->Stop(); NeedsRecreation = true; } }); - AddPinValueWatcher(NOS_NAME_STATIC("RepeatWhenFilling"), [this](nos::Buffer const& newVal, std::optional oldVal) { - RepeatWhenFilling = *newVal.As(); - }); - } - - RingNodeBase(nosFbNodePtr node, OnRestartType onRestart) : NodeContext(node), OnRestart(onRestart), TypeInfo(NSN_Generic) - { - nos::Name typeName = NSN_Generic; - if(auto* pins = node->pins()) - for (auto* pin : *pins) - if (pin->name()->c_str() == NSN_Output) - IsOutLive = pin->live(); - for (auto& pin : Pins | std::views::values) - if (pin.TypeName != NSN_Generic && (pin.Name == NSN_Output || pin.Name == NSN_Input)) - typeName = pin.TypeName; + AddPinValueWatcher(NOS_NAME_STATIC("RepeatWhenFilling"), + [this](nos::Buffer const& newVal, std::optional oldVal) { + RepeatWhenFilling = *newVal.As(); + nosEngine.SendPathRestart(NodeId); + }); if (typeName != NSN_Generic) { TypeInfo = nos::TypeInfo(typeName); Init();