Skip to content

Commit

Permalink
Merge pull request #198 from b-ma/feature/zero-delay
Browse files Browse the repository at this point in the history
Enable sub quantum delay
  • Loading branch information
orottier authored Aug 15, 2022
2 parents 438f016 + 143d4b6 commit 8e3455f
Show file tree
Hide file tree
Showing 7 changed files with 719 additions and 100 deletions.
11 changes: 11 additions & 0 deletions src/context/concrete_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@ impl ConcreteBaseAudioContext {
}
}

/// Inform render thread that this node can act as a cycle breaker
#[doc(hidden)]
pub fn mark_cycle_breaker(&self, reg: &AudioContextRegistration) {
let id = reg.id().0;
let message = ControlMessage::MarkCycleBreaker { id };

// Sending the message will fail when the render thread has already shut down.
// This is fine
let _r = self.inner.render_channel.send(message);
}

/// `ChannelConfig` of the `AudioDestinationNode`
pub(super) fn destination_channel_config(&self) -> ChannelConfig {
self.inner.destination_channel_config.clone()
Expand Down
17 changes: 14 additions & 3 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,28 @@ pub(crate) enum ControlMessage {
},

/// Clear the connection between two given nodes in the audio graph
DisconnectNode { from: u64, to: u64 },
DisconnectNode {
from: u64,
to: u64,
},

/// Disconnect this node from the audio graph (drop all its connections)
DisconnectAll { from: u64 },
DisconnectAll {
from: u64,
},

/// Notify the render thread this node is dropped in the control thread
FreeWhenFinished { id: u64 },
FreeWhenFinished {
id: u64,
},

/// Pass an AudioParam AutomationEvent to the relevant node
AudioParamEvent {
to: Sender<AudioParamEvent>,
event: AudioParamEvent,
},

MarkCycleBreaker {
id: u64,
},
}
8 changes: 2 additions & 6 deletions src/node/constant_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,6 @@ impl AudioProcessor for ConstantSourceRenderer {
return true;
}

if stop_time < scope.current_time {
output.make_silent();
return false;
}

output.force_mono();

let offset_values = params.get(&self.offset);
Expand All @@ -186,7 +181,8 @@ impl AudioProcessor for ConstantSourceRenderer {
current_time += dt;
}

true
// tail_time false when output has ended this quantum
stop_time >= next_block_time
}
}

Expand Down
Loading

0 comments on commit 8e3455f

Please sign in to comment.