Skip to content

Commit 8e3455f

Browse files
authored
Merge pull request #198 from b-ma/feature/zero-delay
Enable sub quantum delay
2 parents 438f016 + 143d4b6 commit 8e3455f

File tree

7 files changed

+719
-100
lines changed

7 files changed

+719
-100
lines changed

src/context/concrete_base.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,17 @@ impl ConcreteBaseAudioContext {
203203
}
204204
}
205205

206+
/// Inform render thread that this node can act as a cycle breaker
207+
#[doc(hidden)]
208+
pub fn mark_cycle_breaker(&self, reg: &AudioContextRegistration) {
209+
let id = reg.id().0;
210+
let message = ControlMessage::MarkCycleBreaker { id };
211+
212+
// Sending the message will fail when the render thread has already shut down.
213+
// This is fine
214+
let _r = self.inner.render_channel.send(message);
215+
}
216+
206217
/// `ChannelConfig` of the `AudioDestinationNode`
207218
pub(super) fn destination_channel_config(&self) -> ChannelConfig {
208219
self.inner.destination_channel_config.clone()

src/message.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,28 @@ pub(crate) enum ControlMessage {
2626
},
2727

2828
/// Clear the connection between two given nodes in the audio graph
29-
DisconnectNode { from: u64, to: u64 },
29+
DisconnectNode {
30+
from: u64,
31+
to: u64,
32+
},
3033

3134
/// Disconnect this node from the audio graph (drop all its connections)
32-
DisconnectAll { from: u64 },
35+
DisconnectAll {
36+
from: u64,
37+
},
3338

3439
/// Notify the render thread this node is dropped in the control thread
35-
FreeWhenFinished { id: u64 },
40+
FreeWhenFinished {
41+
id: u64,
42+
},
3643

3744
/// Pass an AudioParam AutomationEvent to the relevant node
3845
AudioParamEvent {
3946
to: Sender<AudioParamEvent>,
4047
event: AudioParamEvent,
4148
},
49+
50+
MarkCycleBreaker {
51+
id: u64,
52+
},
4253
}

src/node/constant_source.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ impl AudioProcessor for ConstantSourceRenderer {
162162
return true;
163163
}
164164

165-
if stop_time < scope.current_time {
166-
output.make_silent();
167-
return false;
168-
}
169-
170165
output.force_mono();
171166

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

189-
true
184+
// tail_time false when output has ended this quantum
185+
stop_time >= next_block_time
190186
}
191187
}
192188

0 commit comments

Comments
 (0)