File tree Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Expand file tree Collapse file tree 3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -422,14 +422,18 @@ impl AudioProcessor for AudioBufferSourceRenderer {
422
422
// Return early if start_time is beyond this block
423
423
if self . start_time >= next_block_time {
424
424
output. make_silent ( ) ;
425
- return true ;
425
+ // #462 AudioScheduledSourceNodes that have not been scheduled to start can safely
426
+ // return tail_time false in order to be collected if their control handle drops.
427
+ return self . start_time != f64:: MAX ;
426
428
}
427
429
428
430
// If the buffer has not been set wait for it.
429
431
let buffer = match & self . buffer {
430
432
None => {
431
433
output. make_silent ( ) ;
432
- return true ;
434
+ // #462 like the above arm, we can safely return tail_time false if this node has
435
+ // no buffer set.
436
+ return false ;
433
437
}
434
438
Some ( b) => b,
435
439
} ;
Original file line number Diff line number Diff line change @@ -192,7 +192,9 @@ impl AudioProcessor for ConstantSourceRenderer {
192
192
193
193
if self . start_time >= next_block_time {
194
194
output. make_silent ( ) ;
195
- return true ;
195
+ // #462 AudioScheduledSourceNodes that have not been scheduled to start can safely
196
+ // return tail_time false in order to be collected if their control handle drops.
197
+ return self . start_time != f64:: MAX ;
196
198
}
197
199
198
200
output. force_mono ( ) ;
@@ -314,6 +316,23 @@ mod tests {
314
316
assert_float_eq ! ( channel[ 128 ..] , vec![ 1. ; 128 ] [ ..] , abs_all <= 0. ) ;
315
317
}
316
318
319
+ #[ test]
320
+ fn test_start_in_the_future_while_dropped ( ) {
321
+ let sample_rate = 48000. ;
322
+ let mut context = OfflineAudioContext :: new ( 1 , 4 * 128 , sample_rate) ;
323
+
324
+ let mut src = context. create_constant_source ( ) ;
325
+ src. connect ( & context. destination ( ) ) ;
326
+ src. start_at ( 258. / sample_rate as f64 ) ; // in 3rd block
327
+ drop ( src) ; // explicit drop
328
+
329
+ let buffer = context. start_rendering_sync ( ) ;
330
+ let channel = buffer. get_channel_data ( 0 ) ;
331
+
332
+ assert_float_eq ! ( channel[ 0 ..258 ] , vec![ 0. ; 258 ] [ ..] , abs_all <= 0. ) ;
333
+ assert_float_eq ! ( channel[ 258 ..] , vec![ 1. ; 254 ] [ ..] , abs_all <= 0. ) ;
334
+ }
335
+
317
336
#[ test]
318
337
#[ should_panic]
319
338
fn test_start_twice ( ) {
Original file line number Diff line number Diff line change @@ -373,7 +373,9 @@ impl AudioProcessor for OscillatorRenderer {
373
373
374
374
if self . start_time >= next_block_time {
375
375
output. make_silent ( ) ;
376
- return true ;
376
+ // #462 AudioScheduledSourceNodes that have not been scheduled to start can safely
377
+ // return tail_time false in order to be collected if their control handle drops.
378
+ return self . start_time != f64:: MAX ;
377
379
} else if self . stop_time < scope. current_time {
378
380
output. make_silent ( ) ;
379
381
You can’t perform that action at this time.
0 commit comments