mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-02 09:43:48 +00:00
fallbacksrc: Don't restart source if the element is just being shut down
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2455>
This commit is contained in:
parent
ef3c03074a
commit
2336688c8a
1 changed files with 52 additions and 67 deletions
|
@ -199,6 +199,7 @@ struct SourceBin {
|
||||||
// Actual source element, e.g. uridecodebin3
|
// Actual source element, e.g. uridecodebin3
|
||||||
source: gst::Element,
|
source: gst::Element,
|
||||||
pending_restart: bool,
|
pending_restart: bool,
|
||||||
|
running: bool,
|
||||||
is_live: bool,
|
is_live: bool,
|
||||||
is_image: bool,
|
is_image: bool,
|
||||||
|
|
||||||
|
@ -647,12 +648,16 @@ impl ObjectImpl for FallbackSrc {
|
||||||
"status" => {
|
"status" => {
|
||||||
let state_guard = self.state.lock();
|
let state_guard = self.state.lock();
|
||||||
|
|
||||||
// If we have no state then we'r stopped
|
// If we have no state then we're stopped
|
||||||
let state = match &*state_guard {
|
let state = match &*state_guard {
|
||||||
None => return Status::Stopped.to_value(),
|
None => return Status::Stopped.to_value(),
|
||||||
Some(ref state) => state,
|
Some(ref state) => state,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if !state.source.running {
|
||||||
|
return Status::Stopped.to_value();
|
||||||
|
}
|
||||||
|
|
||||||
// If any restarts/retries are pending, we're retrying
|
// If any restarts/retries are pending, we're retrying
|
||||||
if state.source.pending_restart
|
if state.source.pending_restart
|
||||||
|| state.source.pending_restart_timeout.is_some()
|
|| state.source.pending_restart_timeout.is_some()
|
||||||
|
@ -1161,6 +1166,7 @@ impl FallbackSrc {
|
||||||
bin,
|
bin,
|
||||||
source,
|
source,
|
||||||
pending_restart: false,
|
pending_restart: false,
|
||||||
|
running: false,
|
||||||
is_live: false,
|
is_live: false,
|
||||||
is_image: false,
|
is_image: false,
|
||||||
restart_timeout: None,
|
restart_timeout: None,
|
||||||
|
@ -1235,6 +1241,7 @@ impl FallbackSrc {
|
||||||
bin,
|
bin,
|
||||||
source,
|
source,
|
||||||
pending_restart: false,
|
pending_restart: false,
|
||||||
|
running: false,
|
||||||
is_live: false,
|
is_live: false,
|
||||||
is_image: false,
|
is_image: false,
|
||||||
restart_timeout: None,
|
restart_timeout: None,
|
||||||
|
@ -1696,6 +1703,7 @@ impl FallbackSrc {
|
||||||
&mut state.source
|
&mut state.source
|
||||||
};
|
};
|
||||||
|
|
||||||
|
source.running = transition.next() > gst::State::Ready;
|
||||||
if transition.current() <= transition.next() && source.pending_restart {
|
if transition.current() <= transition.next() && source.pending_restart {
|
||||||
gst::debug!(
|
gst::debug!(
|
||||||
CAT,
|
CAT,
|
||||||
|
@ -2847,6 +2855,9 @@ impl FallbackSrc {
|
||||||
if source.pending_restart {
|
if source.pending_restart {
|
||||||
gst::debug!(CAT, imp = self, "Has pending restart");
|
gst::debug!(CAT, imp = self, "Has pending restart");
|
||||||
return;
|
return;
|
||||||
|
} else if !source.running {
|
||||||
|
gst::debug!(CAT, imp = self, "Was shut down");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst::log!(
|
gst::log!(
|
||||||
|
@ -3836,6 +3847,14 @@ impl FallbackSrc {
|
||||||
if fallback_source { "fallback " } else { "" }
|
if fallback_source { "fallback " } else { "" }
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
} else if !source.running {
|
||||||
|
gst::debug!(
|
||||||
|
CAT,
|
||||||
|
imp = self,
|
||||||
|
"{}source was shut down",
|
||||||
|
if fallback_source { "fallback " } else { "" }
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Increase retry count only if there was no pending restart
|
// Increase retry count only if there was no pending restart
|
||||||
|
@ -3892,35 +3911,20 @@ impl FallbackSrc {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(State {
|
Some(State { source, .. })
|
||||||
source:
|
if !fallback_source && (!source.pending_restart || !source.running) =>
|
||||||
SourceBin {
|
{
|
||||||
pending_restart: false,
|
gst::debug!(CAT, imp = imp, "Restarting source not needed anymore");
|
||||||
..
|
|
||||||
},
|
|
||||||
..
|
|
||||||
}) if !fallback_source => {
|
|
||||||
gst::debug!(
|
|
||||||
CAT,
|
|
||||||
imp = imp,
|
|
||||||
"Restarting {}source not needed anymore",
|
|
||||||
if fallback_source { "fallback " } else { "" }
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(State {
|
Some(State {
|
||||||
fallback_source:
|
fallback_source: Some(ref source),
|
||||||
Some(SourceBin {
|
|
||||||
pending_restart: false,
|
|
||||||
..
|
|
||||||
}),
|
|
||||||
..
|
..
|
||||||
}) if fallback_source => {
|
}) if fallback_source && (!source.pending_restart || !source.running) => {
|
||||||
gst::debug!(
|
gst::debug!(
|
||||||
CAT,
|
CAT,
|
||||||
imp = imp,
|
imp = imp,
|
||||||
"Restarting {}source not needed anymore",
|
"Restarting fallback source not needed anymore",
|
||||||
if fallback_source { "fallback " } else { "" }
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -3997,35 +4001,20 @@ impl FallbackSrc {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(State {
|
Some(State { source, .. })
|
||||||
source:
|
if !fallback_source && (!source.pending_restart || !source.running) =>
|
||||||
SourceBin {
|
{
|
||||||
pending_restart: false,
|
gst::debug!(CAT, imp = imp, "Restarting source not needed anymore");
|
||||||
..
|
|
||||||
},
|
|
||||||
..
|
|
||||||
}) if !fallback_source => {
|
|
||||||
gst::debug!(
|
|
||||||
CAT,
|
|
||||||
imp = imp,
|
|
||||||
"Restarting {}source not needed anymore",
|
|
||||||
if fallback_source { "fallback " } else { "" }
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(State {
|
Some(State {
|
||||||
fallback_source:
|
fallback_source: Some(ref source),
|
||||||
Some(SourceBin {
|
|
||||||
pending_restart: false,
|
|
||||||
..
|
|
||||||
}),
|
|
||||||
..
|
..
|
||||||
}) if fallback_source => {
|
}) if fallback_source && (!source.pending_restart || !source.running) => {
|
||||||
gst::debug!(
|
gst::debug!(
|
||||||
CAT,
|
CAT,
|
||||||
imp = imp,
|
imp = imp,
|
||||||
"Restarting {}source not needed anymore",
|
"Restarting fallback source not needed anymore",
|
||||||
if fallback_source { "fallback " } else { "" }
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4083,35 +4072,23 @@ impl FallbackSrc {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(State {
|
Some(State { source, .. })
|
||||||
source:
|
if !fallback_source
|
||||||
SourceBin {
|
&& (!source.pending_restart || !source.running) =>
|
||||||
pending_restart: false,
|
{
|
||||||
..
|
gst::debug!(CAT, imp = imp, "Restarting source not needed anymore");
|
||||||
},
|
|
||||||
..
|
|
||||||
}) if !fallback_source => {
|
|
||||||
gst::debug!(
|
|
||||||
CAT,
|
|
||||||
imp = imp,
|
|
||||||
"Restarting {}source not needed anymore",
|
|
||||||
if fallback_source { "fallback " } else { "" }
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Some(State {
|
Some(State {
|
||||||
fallback_source:
|
fallback_source: Some(ref source),
|
||||||
Some(SourceBin {
|
|
||||||
pending_restart: false,
|
|
||||||
..
|
|
||||||
}),
|
|
||||||
..
|
..
|
||||||
}) if fallback_source => {
|
}) if fallback_source
|
||||||
|
&& (!source.pending_restart || !source.running) =>
|
||||||
|
{
|
||||||
gst::debug!(
|
gst::debug!(
|
||||||
CAT,
|
CAT,
|
||||||
imp = imp,
|
imp = imp,
|
||||||
"Restarting {}source not needed anymore",
|
"Restarting fallback source not needed anymore",
|
||||||
if fallback_source { "fallback " } else { "" }
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -4259,6 +4236,14 @@ impl FallbackSrc {
|
||||||
if fallback_source { "fallback " } else { "" },
|
if fallback_source { "fallback " } else { "" },
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
} else if !source.running {
|
||||||
|
gst::debug!(
|
||||||
|
CAT,
|
||||||
|
imp = self,
|
||||||
|
"Not scheduling {}source restart timeout because source was shut down",
|
||||||
|
if fallback_source { "fallback " } else { "" },
|
||||||
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if source.is_image {
|
if source.is_image {
|
||||||
|
|
Loading…
Reference in a new issue