mirror of
https://github.com/xlmnxp/blue-recorder.git
synced 2025-03-31 23:04:55 +03:00
kill ffmmpeg befora closing main_window
This commit is contained in:
parent
1cacf26b39
commit
5d49c81f03
@ -1083,14 +1083,51 @@ fn build_ui(application: &Application, error_dialog: MessageDialog, error_messag
|
||||
adw::gtk::Inhibit(true)
|
||||
});
|
||||
|
||||
// Close the application when main window destroy
|
||||
// Stop recording before close the application
|
||||
let mut _ffmpeg_record_interface = ffmpeg_record_interface.clone();
|
||||
main_window.connect_destroy(move |main_window| {
|
||||
// Stop recording before close the application
|
||||
_ffmpeg_record_interface.borrow_mut().stop_input_audio().unwrap();
|
||||
_ffmpeg_record_interface.borrow_mut().stop_output_audio().unwrap();
|
||||
_ffmpeg_record_interface.borrow_mut().stop_video().unwrap();
|
||||
main_window.connect_close_request(move |main_window| {
|
||||
let file_name = _ffmpeg_record_interface.borrow_mut().filename.clone();
|
||||
if Path::new(&file_name).try_exists().is_ok() {
|
||||
std::fs::remove_file(file_name).unwrap();
|
||||
}
|
||||
if _ffmpeg_record_interface.borrow_mut().video_process.is_some() {
|
||||
std::process::Command::new("kill")
|
||||
.arg(format!(
|
||||
"{}",
|
||||
_ffmpeg_record_interface.borrow_mut()
|
||||
.video_process
|
||||
.clone()
|
||||
.unwrap()
|
||||
.borrow_mut()
|
||||
.as_inner().id()
|
||||
)).output().unwrap();
|
||||
}
|
||||
if _ffmpeg_record_interface.borrow_mut().input_audio_process.is_some() {
|
||||
std::process::Command::new("kill")
|
||||
.arg(format!(
|
||||
"{}",
|
||||
_ffmpeg_record_interface.borrow_mut()
|
||||
.input_audio_process
|
||||
.clone()
|
||||
.unwrap()
|
||||
.borrow_mut()
|
||||
.as_inner().id()
|
||||
)).output().unwrap();
|
||||
}
|
||||
if _ffmpeg_record_interface.borrow_mut().output_audio_process.is_some() {
|
||||
std::process::Command::new("kill")
|
||||
.arg(format!(
|
||||
"{}",
|
||||
_ffmpeg_record_interface.borrow_mut()
|
||||
.output_audio_process
|
||||
.clone()
|
||||
.unwrap()
|
||||
.borrow_mut()
|
||||
.as_inner().id()
|
||||
)).output().unwrap();
|
||||
}
|
||||
main_window.close();
|
||||
adw::gtk::Inhibit(true)
|
||||
});
|
||||
|
||||
// Apply CSS
|
||||
|
Loading…
Reference in New Issue
Block a user