From 611c7d6cd3c583f324bc2b013d45a74f26838a06 Mon Sep 17 00:00:00 2001 From: Arun Raghavan Date: Tue, 14 Feb 2023 11:01:55 -0500 Subject: [PATCH] hlssink3: Allow GIOStream signal handlers to return None If creating a playlist or fragment stream fails (disk is full, the directory is removed, ...), we will currently crash because the signal handler expects a non-None GIOStream. The actual callback is allowed to return None values and we handle this in the caller, so let's not have this restriction on the signal handler. Part-of: --- net/hlssink3/src/imp.rs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/net/hlssink3/src/imp.rs b/net/hlssink3/src/imp.rs index d7c705e0..9b1eef6d 100644 --- a/net/hlssink3/src/imp.rs +++ b/net/hlssink3/src/imp.rs @@ -417,7 +417,7 @@ impl BinImpl for HlsSink3 { "splitmuxsink-fragment-closed" => { let s = msg.structure().unwrap(); if let Ok(fragment_closed_at) = s.get::("running-time") { - self.write_playlist(Some(fragment_closed_at)).unwrap(); + let _ = self.write_playlist(Some(fragment_closed_at)); } } _ => {} @@ -574,7 +574,7 @@ impl ObjectImpl for HlsSink3 { vec![ glib::subclass::Signal::builder(SIGNAL_GET_PLAYLIST_STREAM) .param_types([String::static_type()]) - .return_type::() + .return_type::>() .class_handler(|_, args| { let element = args[0] .get::() @@ -583,12 +583,7 @@ impl ObjectImpl for HlsSink3 { args[1].get::().expect("playlist-stream signal arg"); let hlssink3 = element.imp(); - Some( - hlssink3 - .new_file_stream(&playlist_location) - .ok()? - .to_value(), - ) + Some(hlssink3.new_file_stream(&playlist_location).ok().to_value()) }) .accumulator(|_hint, ret, value| { // First signal handler wins @@ -598,7 +593,7 @@ impl ObjectImpl for HlsSink3 { .build(), glib::subclass::Signal::builder(SIGNAL_GET_FRAGMENT_STREAM) .param_types([String::static_type()]) - .return_type::() + .return_type::>() .class_handler(|_, args| { let element = args[0] .get::() @@ -607,12 +602,7 @@ impl ObjectImpl for HlsSink3 { args[1].get::().expect("fragment-stream signal arg"); let hlssink3 = element.imp(); - Some( - hlssink3 - .new_file_stream(&fragment_location) - .ok()? - .to_value(), - ) + Some(hlssink3.new_file_stream(&fragment_location).ok().to_value()) }) .accumulator(|_hint, ret, value| { // First signal handler wins @@ -767,7 +757,8 @@ impl ElementImpl for HlsSink3 { }; if write_final { - self.write_final_playlist()?; + // Don't fail transitioning to READY if this fails + let _ = self.write_final_playlist(); } } gst::StateChange::ReadyToNull => {