Use main_loop to stop process gracefully
This commit is contained in:
parent
d6ae2282f7
commit
c189d88fdb
2 changed files with 3 additions and 1101 deletions
1099
Cargo.lock
generated
1099
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,7 +4,7 @@ use anyhow::Result;
|
||||||
use gst::glib;
|
use gst::glib;
|
||||||
use gst::glib::once_cell::sync::Lazy;
|
use gst::glib::once_cell::sync::Lazy;
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use std::{process, thread};
|
use std::thread;
|
||||||
use tokio::runtime::Builder;
|
use tokio::runtime::Builder;
|
||||||
|
|
||||||
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||||
|
@ -68,10 +68,11 @@ fn main() -> Result<()> {
|
||||||
|
|
||||||
ctrlc::set_handler({
|
ctrlc::set_handler({
|
||||||
let pipeline_weak = pipeline.downgrade();
|
let pipeline_weak = pipeline.downgrade();
|
||||||
|
let main_loop = main_loop.clone();
|
||||||
move || {
|
move || {
|
||||||
let pipeline = pipeline_weak.upgrade().unwrap();
|
let pipeline = pipeline_weak.upgrade().unwrap();
|
||||||
pipeline.set_state(gst::State::Null).unwrap();
|
pipeline.set_state(gst::State::Null).unwrap();
|
||||||
process::exit(0);
|
main_loop.quit();
|
||||||
}
|
}
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue