@@ -281,6 +281,14 @@ where
281281 }
282282}
283283
284+ fn playback_total_frames ( playback : & PlaybackData ) -> usize {
285+ if playback. input_channels == 0 {
286+ 0
287+ } else {
288+ playback. samples . len ( ) / playback. input_channels
289+ }
290+ }
291+
284292fn fill_output_without_resampler < T , F > (
285293 data : & mut [ T ] ,
286294 output_channels : usize ,
@@ -329,7 +337,6 @@ fn fill_output_with_rubato<T, F>(
329337 output_channels : usize ,
330338 output_sample_rate : u32 ,
331339 playback : & mut PlaybackData ,
332- total_frames : usize ,
333340 render_state : & mut RenderState ,
334341 shared : & SharedPlayback ,
335342 convert : & F ,
@@ -371,6 +378,7 @@ fn fill_output_with_rubato<T, F>(
371378 render_state. frame_buffer . resize ( output_channels, 0. ) ;
372379 }
373380
381+ let total_frames = playback_total_frames ( playback) ;
374382 let step = playback. sample_rate as f64 / output_sample_rate as f64 ;
375383 let mut reached_end = false ;
376384 let mut process_error: Option < ( usize , String ) > = None ;
@@ -457,7 +465,7 @@ fn fill_output<T, F>(
457465 return ;
458466 }
459467
460- let total_frames = playback . samples . len ( ) / playback. input_channels ;
468+ let total_frames = playback_total_frames ( & playback) ;
461469 if total_frames == 0 {
462470 playback. is_playing = false ;
463471 playback. position_frame = 0. ;
@@ -484,7 +492,6 @@ fn fill_output<T, F>(
484492 output_channels,
485493 output_sample_rate,
486494 & mut playback,
487- total_frames,
488495 render_state,
489496 shared,
490497 & convert,
@@ -521,7 +528,7 @@ fn build_output_stream(
521528 selected_sr,
522529 & shared,
523530 & mut render_state,
524- |x| x ,
531+ std :: convert :: identity ,
525532 ) ;
526533 } ,
527534 err_fn,
@@ -540,7 +547,7 @@ fn build_output_stream(
540547 selected_sr,
541548 & shared,
542549 & mut render_state,
543- |x| <i16 as Sample >:: from_sample ( x ) ,
550+ <i16 as Sample >:: from_sample,
544551 ) ;
545552 } ,
546553 err_fn,
@@ -559,7 +566,7 @@ fn build_output_stream(
559566 selected_sr,
560567 & shared,
561568 & mut render_state,
562- |x| <u16 as Sample >:: from_sample ( x ) ,
569+ <u16 as Sample >:: from_sample,
563570 ) ;
564571 } ,
565572 err_fn,
@@ -578,7 +585,7 @@ fn build_output_stream(
578585 selected_sr,
579586 & shared,
580587 & mut render_state,
581- |x| <cpal:: I24 as Sample >:: from_sample ( x ) ,
588+ <cpal:: I24 as Sample >:: from_sample,
582589 ) ;
583590 } ,
584591 err_fn,
@@ -597,7 +604,7 @@ fn build_output_stream(
597604 selected_sr,
598605 & shared,
599606 & mut render_state,
600- |x| <cpal:: U24 as Sample >:: from_sample ( x ) ,
607+ <cpal:: U24 as Sample >:: from_sample,
601608 ) ;
602609 } ,
603610 err_fn,
0 commit comments