Skip to content

Commit

Permalink
Merge pull request #338 from orottier/bugfix/prevent-panic-on-slow-gr…
Browse files Browse the repository at this point in the history
…aph-init

Prevent render thread panic when the graph is not fully initialized yet
  • Loading branch information
orottier authored Jul 19, 2023
2 parents 273911b + 068352c commit db9ad3d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/render/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ impl Graph {
}
}

/// Check if the graph is fully initialized and can start rendering
pub fn is_active(&self) -> bool {
// currently we only require the destination node to be present
!self.nodes.is_empty()
}

pub fn add_node(
&mut self,
index: AudioNodeId,
Expand Down
2 changes: 1 addition & 1 deletion src/render/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl RenderThread {
self.handle_control_messages();

// if the thread is still booting, or shutting down, fill with silence
if self.graph.is_none() {
if !self.graph.as_ref().is_some_and(Graph::is_active) {
output_buffer.fill(S::from_sample_(0.));
return;
}
Expand Down

0 comments on commit db9ad3d

Please sign in to comment.