diff options
author | Arun Raghavan <arun@asymptotic.io> | 2023-02-14 19:01:55 +0300 |
---|---|---|
committer | Arun Raghavan <arun@asymptotic.io> | 2023-02-14 19:25:44 +0300 |
commit | 487d7fb26b297f74c7aba6736f0ee75762ddf98e (patch) | |
tree | 1ee19959808bded6a7cf68dacd2f2a1bd1f6f6b3 /net/hlssink3 | |
parent | 77e99e92fb8554c7d4b0273e8c20a63202bf8053 (diff) |
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: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1093>
Diffstat (limited to 'net/hlssink3')
-rw-r--r-- | net/hlssink3/src/imp.rs | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/net/hlssink3/src/imp.rs b/net/hlssink3/src/imp.rs index 3dab2887b..4b6c8668c 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::<gst::ClockTime>("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::<gio::OutputStream>() + .return_type::<Option<gio::OutputStream>>() .class_handler(|_, args| { let element = args[0] .get::<super::HlsSink3>() @@ -583,12 +583,7 @@ impl ObjectImpl for HlsSink3 { args[1].get::<String>().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::<gio::OutputStream>() + .return_type::<Option<gio::OutputStream>>() .class_handler(|_, args| { let element = args[0] .get::<super::HlsSink3>() @@ -607,12 +602,7 @@ impl ObjectImpl for HlsSink3 { args[1].get::<String>().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 => { |