Skip to content

Commit db9ad3d

Browse files
authored
Merge pull request #338 from orottier/bugfix/prevent-panic-on-slow-graph-init
Prevent render thread panic when the graph is not fully initialized yet
2 parents 273911b + 068352c commit db9ad3d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/render/graph.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,12 @@ impl Graph {
105105
}
106106
}
107107

108+
/// Check if the graph is fully initialized and can start rendering
109+
pub fn is_active(&self) -> bool {
110+
// currently we only require the destination node to be present
111+
!self.nodes.is_empty()
112+
}
113+
108114
pub fn add_node(
109115
&mut self,
110116
index: AudioNodeId,

src/render/thread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ impl RenderThread {
242242
self.handle_control_messages();
243243

244244
// if the thread is still booting, or shutting down, fill with silence
245-
if self.graph.is_none() {
245+
if !self.graph.as_ref().is_some_and(Graph::is_active) {
246246
output_buffer.fill(S::from_sample_(0.));
247247
return;
248248
}

0 commit comments

Comments
 (0)