@@ -39,7 +39,7 @@ static CAPTURE_MEAN_TIME: Lazy<Mutex<Option<Duration>>> = Lazy::new(|| Mutex::ne
3939///
4040/// # Lifecycle
4141///
42- /// 1. **Initialize**: Call `RecordingSession::init()` once at application startup
42+ /// 1. **Initialize**: Call `RecordingSession::init("eDP-1" )` once at application startup
4343/// 2. **Create**: Create a new session with `RecordingSession::new(config)`
4444/// 3. **Start**: Begin recording with `session.start()`
4545/// 4. **Wait**: Process frames and wait for completion with `session.wait()`
@@ -53,7 +53,7 @@ static CAPTURE_MEAN_TIME: Lazy<Mutex<Option<Duration>>> = Lazy::new(|| Mutex::ne
5353/// use std::path::PathBuf;
5454///
5555/// // Initialize once at application startup
56- /// RecordingSession::init().unwrap();
56+ /// RecordingSession::init("eDP-1" ).unwrap();
5757///
5858/// // Create configuration
5959/// let config = RecorderConfig::new(
@@ -119,19 +119,24 @@ impl RecordingSession {
119119 /// use recorder::RecordingSession;
120120 ///
121121 /// // Initialize once at application startup
122- /// RecordingSession::init().unwrap();
122+ /// RecordingSession::init("eDP-1" ).unwrap();
123123 /// ```
124- pub fn init ( ) -> Result < ( ) , RecorderError > {
125- let mean_time = capture:: capture_mean_time ( 10 ) . expect ( "can not evaluate capture mean time" ) ;
124+ pub fn init ( screen_name : & str ) -> Result < ( ) , RecorderError > {
125+ let mean_time = capture:: capture_mean_time ( screen_name, 10 )
126+ . expect ( "can not evaluate capture mean time" ) ;
126127 {
127128 * CAPTURE_MEAN_TIME . lock ( ) . unwrap ( ) = Some ( mean_time) ;
128129 }
129130
130- log:: debug !( "capture_mean_time: {mean_time:.2?}" ) ;
131+ log:: info !( "capture_mean_time: {mean_time:.2?}" ) ;
131132
132133 Ok ( ( ) )
133134 }
134135
136+ pub fn init_finished ( ) -> bool {
137+ CAPTURE_MEAN_TIME . lock ( ) . unwrap ( ) . is_some ( )
138+ }
139+
135140 /// Create a new recording session with the given configuration.
136141 ///
137142 /// This constructor sets up the internal channels and state for recording
@@ -388,6 +393,12 @@ impl RecordingSession {
388393 } )
389394 . map_err ( |e : AudioError | RecorderError :: AudioError ( e. to_string ( ) ) ) ?;
390395
396+ let audio_recorder = if self . config . audio_amplification . is_some ( ) {
397+ audio_recorder. with_amplification ( self . config . audio_amplification . clone ( ) . unwrap ( ) )
398+ } else {
399+ audio_recorder
400+ } ;
401+
391402 let audio_file_path = self
392403 . config
393404 . output_path
@@ -420,11 +431,18 @@ impl RecordingSession {
420431 ( None , None )
421432 } ;
422433
434+ let amplification = self . config . speaker_amplification . clone ( ) ;
423435 let enable_preview_mode = self . config . enable_preview_mode ;
424436 let handle = thread:: spawn ( move || {
425437 let recorder = SpeakerRecorder :: new ( save_path, stop_sig, sender, enable_preview_mode)
426438 . map_err ( |e| RecorderError :: SpeakerError ( e. to_string ( ) ) ) ?;
427439
440+ let recorder = if amplification. is_some ( ) {
441+ recorder. with_amplification ( amplification. unwrap ( ) )
442+ } else {
443+ recorder
444+ } ;
445+
428446 recorder
429447 . start_recording ( )
430448 . map_err ( |e| RecorderError :: SpeakerError ( e. to_string ( ) ) ) ?;
0 commit comments