Use main_loop to stop process gracefully

This commit is contained in:
Rafael Caricio 2023-03-26 01:05:57 +01:00
parent d6ae2282f7
commit c189d88fdb
Signed by: rafaelcaricio
GPG key ID: 3C86DBCE8E93C947
2 changed files with 3 additions and 1101 deletions

1099
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@ use anyhow::Result;
use gst::glib;
use gst::glib::once_cell::sync::Lazy;
use gst::prelude::*;
use std::{process, thread};
use std::thread;
use tokio::runtime::Builder;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
@ -68,10 +68,11 @@ fn main() -> Result<()> {
ctrlc::set_handler({
let pipeline_weak = pipeline.downgrade();
let main_loop = main_loop.clone();
move || {
let pipeline = pipeline_weak.upgrade().unwrap();
pipeline.set_state(gst::State::Null).unwrap();
process::exit(0);
main_loop.quit();
}
})?;