@@ -529,6 +529,15 @@ impl AudioProcessor for AudioBufferSourceRenderer {
529529 self . render_state . is_aligned = false ;
530530 }
531531
532+ // If some user defined end of rendering, i.e. explicit stop_time or duration,
533+ // is within this render quantum force slow track as well. It might imply
534+ // resampling e.g. if stop_time is between 2 samples
535+ if buffer_time + block_duration > self . duration
536+ || block_time + block_duration > self . stop_time
537+ {
538+ self . render_state . is_aligned = false ;
539+ }
540+
532541 if self . render_state . is_aligned {
533542 // ---------------------------------------------------------------
534543 // Fast track
@@ -537,22 +546,9 @@ impl AudioProcessor for AudioBufferSourceRenderer {
537546 self . render_state . started = true ;
538547 }
539548
540- // check if buffer ends within this block
541- if buffer_time + block_duration > buffer_duration
542- || buffer_time + block_duration > self . duration
543- || block_time + block_duration > self . stop_time
544- {
545- let end_index = if block_time + block_duration > self . stop_time
546- || buffer_time + block_duration > self . duration
547- {
548- let dt = ( self . stop_time - block_time) . min ( self . duration - buffer_time) ;
549- let end_buffer_time = buffer_time + dt;
550- let end_index = ( end_buffer_time * sample_rate) . round ( ) as usize ;
551- end_index. min ( buffer. length ( ) )
552- } else {
553- buffer. length ( )
554- } ;
555-
549+ // buffer ends within this block
550+ if buffer_time + block_duration > buffer_duration {
551+ let end_index = buffer. length ( ) ;
556552 // In case of a loop point in the middle of the block, this value will
557553 // be used to recompute `buffer_time` according to the actual loop point.
558554 let mut loop_point_index: Option < usize > = None ;
0 commit comments