File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed
crates/recording/src/sources Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -114,10 +114,7 @@ impl AudioMixerBuilder {
114114 let mut amix = filter_graph. add (
115115 & ffmpeg:: filter:: find ( "amix" ) . expect ( "Failed to find amix filter" ) ,
116116 "amix" ,
117- & format ! (
118- "inputs={}:duration=first:dropout_transition=0" ,
119- abuffers. len( )
120- ) ,
117+ & format ! ( "inputs={}:duration=longest" , abuffers. len( ) ) ,
121118 ) ?;
122119
123120 let aformat_args = format ! (
@@ -388,16 +385,21 @@ impl AudioMixer {
388385 let elapsed = Duration :: from_secs_f64 ( self . samples_out as f64 / output_rate) ;
389386 let timestamp = start. instant ( ) + start_timestamp. duration_since ( start) + elapsed;
390387
391- self . samples_out += filtered. samples ( ) ;
388+ let frame_samples = filtered. samples ( ) ;
389+ let mut frame = AudioFrame :: new ( filtered, Timestamp :: Instant ( timestamp) ) ;
392390
393- if self
394- . output
395- . try_send ( AudioFrame :: new ( filtered, Timestamp :: Instant ( timestamp) ) )
396- . is_err ( )
397- {
398- return Err ( ( ) ) ;
391+ loop {
392+ match self . output . try_send ( frame) {
393+ Ok ( ( ) ) => break ,
394+ Err ( err) if err. is_full ( ) => {
395+ frame = err. into_inner ( ) ;
396+ std:: thread:: sleep ( Duration :: from_millis ( 1 ) ) ;
397+ }
398+ Err ( _) => return Err ( ( ) ) ,
399+ }
399400 }
400401
402+ self . samples_out += frame_samples;
401403 filtered = ffmpeg:: frame:: Audio :: empty ( ) ;
402404 }
403405
You can’t perform that action at this time.
0 commit comments