@@ -462,41 +462,10 @@ impl OutputStream {
462462 } )
463463 }
464464
465- fn build_stream_for_sample_type < T , S , E > (
466- device : & cpal:: Device ,
467- config : & cpal:: StreamConfig ,
468- mut samples : S ,
469- error_callback : E ,
470- ) -> Result < cpal:: Stream , cpal:: BuildStreamError >
471- where
472- T : dasp_sample:: Sample
473- + cpal:: Sample
474- + cpal:: SizedSample
475- + cpal:: FromSample < crate :: Sample >
476- + Send
477- + ' static ,
478- S : Source + Send + ' static ,
479- E : FnMut ( cpal:: StreamError ) + Send + ' static ,
480- {
481- device. build_output_stream :: < T , _ , _ > (
482- config,
483- move |data, _| {
484- data. iter_mut ( ) . for_each ( |d| {
485- * d = samples
486- . next ( )
487- . map ( Sample :: from_sample)
488- . unwrap_or ( T :: EQUILIBRIUM )
489- } )
490- } ,
491- error_callback,
492- None ,
493- )
494- }
495-
496465 fn init_stream < S , E > (
497466 device : & cpal:: Device ,
498467 config : & OutputStreamConfig ,
499- samples : S ,
468+ mut samples : S ,
500469 error_callback : E ,
501470 ) -> Result < cpal:: Stream , StreamError >
502471 where
@@ -509,11 +478,18 @@ impl OutputStream {
509478 ( $( $sample_format: tt, $generic: ty) ;+) => {
510479 match config. sample_format {
511480 $(
512- cpal:: SampleFormat :: $sample_format => Self :: build_stream_for_sample_type:: <$generic, _, _>(
513- device,
481+ cpal:: SampleFormat :: $sample_format => device. build_output_stream:: <$generic, _, _>(
514482 & cpal_config,
515- samples,
483+ move |data, _| {
484+ data. iter_mut( ) . for_each( |d| {
485+ * d = samples
486+ . next( )
487+ . map( Sample :: from_sample)
488+ . unwrap_or( <$generic>:: EQUILIBRIUM )
489+ } )
490+ } ,
516491 error_callback,
492+ None ,
517493 ) ,
518494 ) +
519495 _ => return Err ( StreamError :: UnsupportedSampleFormat ) ,
0 commit comments