mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-01-22 08:58:15 +00:00
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>
This commit is contained in:
parent
77e99e92fb
commit
487d7fb26b
1 changed files with 7 additions and 16 deletions
|
@ -417,7 +417,7 @@ impl BinImpl for HlsSink3 {
|
||||||
"splitmuxsink-fragment-closed" => {
|
"splitmuxsink-fragment-closed" => {
|
||||||
let s = msg.structure().unwrap();
|
let s = msg.structure().unwrap();
|
||||||
if let Ok(fragment_closed_at) = s.get::<gst::ClockTime>("running-time") {
|
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![
|
vec![
|
||||||
glib::subclass::Signal::builder(SIGNAL_GET_PLAYLIST_STREAM)
|
glib::subclass::Signal::builder(SIGNAL_GET_PLAYLIST_STREAM)
|
||||||
.param_types([String::static_type()])
|
.param_types([String::static_type()])
|
||||||
.return_type::<gio::OutputStream>()
|
.return_type::<Option<gio::OutputStream>>()
|
||||||
.class_handler(|_, args| {
|
.class_handler(|_, args| {
|
||||||
let element = args[0]
|
let element = args[0]
|
||||||
.get::<super::HlsSink3>()
|
.get::<super::HlsSink3>()
|
||||||
|
@ -583,12 +583,7 @@ impl ObjectImpl for HlsSink3 {
|
||||||
args[1].get::<String>().expect("playlist-stream signal arg");
|
args[1].get::<String>().expect("playlist-stream signal arg");
|
||||||
let hlssink3 = element.imp();
|
let hlssink3 = element.imp();
|
||||||
|
|
||||||
Some(
|
Some(hlssink3.new_file_stream(&playlist_location).ok().to_value())
|
||||||
hlssink3
|
|
||||||
.new_file_stream(&playlist_location)
|
|
||||||
.ok()?
|
|
||||||
.to_value(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.accumulator(|_hint, ret, value| {
|
.accumulator(|_hint, ret, value| {
|
||||||
// First signal handler wins
|
// First signal handler wins
|
||||||
|
@ -598,7 +593,7 @@ impl ObjectImpl for HlsSink3 {
|
||||||
.build(),
|
.build(),
|
||||||
glib::subclass::Signal::builder(SIGNAL_GET_FRAGMENT_STREAM)
|
glib::subclass::Signal::builder(SIGNAL_GET_FRAGMENT_STREAM)
|
||||||
.param_types([String::static_type()])
|
.param_types([String::static_type()])
|
||||||
.return_type::<gio::OutputStream>()
|
.return_type::<Option<gio::OutputStream>>()
|
||||||
.class_handler(|_, args| {
|
.class_handler(|_, args| {
|
||||||
let element = args[0]
|
let element = args[0]
|
||||||
.get::<super::HlsSink3>()
|
.get::<super::HlsSink3>()
|
||||||
|
@ -607,12 +602,7 @@ impl ObjectImpl for HlsSink3 {
|
||||||
args[1].get::<String>().expect("fragment-stream signal arg");
|
args[1].get::<String>().expect("fragment-stream signal arg");
|
||||||
let hlssink3 = element.imp();
|
let hlssink3 = element.imp();
|
||||||
|
|
||||||
Some(
|
Some(hlssink3.new_file_stream(&fragment_location).ok().to_value())
|
||||||
hlssink3
|
|
||||||
.new_file_stream(&fragment_location)
|
|
||||||
.ok()?
|
|
||||||
.to_value(),
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
.accumulator(|_hint, ret, value| {
|
.accumulator(|_hint, ret, value| {
|
||||||
// First signal handler wins
|
// First signal handler wins
|
||||||
|
@ -767,7 +757,8 @@ impl ElementImpl for HlsSink3 {
|
||||||
};
|
};
|
||||||
|
|
||||||
if write_final {
|
if write_final {
|
||||||
self.write_final_playlist()?;
|
// Don't fail transitioning to READY if this fails
|
||||||
|
let _ = self.write_final_playlist();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gst::StateChange::ReadyToNull => {
|
gst::StateChange::ReadyToNull => {
|
||||||
|
|
Loading…
Reference in a new issue