livesync: Use let-else in a few more places

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1635>
This commit is contained in:
Sebastian Dröge 2024-06-26 10:00:06 +03:00 committed by GStreamer Marge Bot
parent 505fab2e1c
commit 7caf6b2073

View file

@ -651,12 +651,9 @@ impl LiveSync {
gst::EventView::Segment(e) => { gst::EventView::Segment(e) => {
is_restart = true; is_restart = true;
let segment = match e.segment().downcast_ref() { let Some(segment) = e.segment().downcast_ref() else {
Some(s) => s, gst::error!(CAT, imp: self, "Got non-TIME segment");
None => { return false;
gst::error!(CAT, imp: self, "Got non-TIME segment");
return false;
}
}; };
let mut state = self.state.lock(); let mut state = self.state.lock();
@ -1218,14 +1215,12 @@ impl LiveSync {
} }
fn buffer_is_backwards(&self, state: &State, timestamp: Option<Timestamps>) -> BufferLateness { fn buffer_is_backwards(&self, state: &State, timestamp: Option<Timestamps>) -> BufferLateness {
let timestamp = match timestamp { let Some(timestamp) = timestamp else {
Some(t) => t, return BufferLateness::OnTime;
None => return BufferLateness::OnTime,
}; };
let out_timestamp = match state.out_timestamp { let Some(out_timestamp) = state.out_timestamp else {
Some(t) => t, return BufferLateness::OnTime;
None => return BufferLateness::OnTime,
}; };
if timestamp.end > out_timestamp.end { if timestamp.end > out_timestamp.end {
@ -1246,9 +1241,8 @@ impl LiveSync {
None => return BufferLateness::LateUnderThreshold, None => return BufferLateness::LateUnderThreshold,
}; };
let in_timestamp = match state.in_timestamp { let Some(in_timestamp) = state.in_timestamp else {
Some(t) => t, return BufferLateness::LateUnderThreshold;
None => return BufferLateness::LateUnderThreshold,
}; };
if timestamp.start > in_timestamp.end + late_threshold { if timestamp.start > in_timestamp.end + late_threshold {
@ -1259,14 +1253,12 @@ impl LiveSync {
} }
fn buffer_is_early(&self, state: &State, timestamp: Option<Timestamps>) -> bool { fn buffer_is_early(&self, state: &State, timestamp: Option<Timestamps>) -> bool {
let timestamp = match timestamp { let Some(timestamp) = timestamp else {
Some(t) => t, return false;
None => return false,
}; };
let out_timestamp = match state.out_timestamp { let Some(out_timestamp) = state.out_timestamp else {
Some(t) => t, return false;
None => return false,
}; };
// When out_timestamp is set, we also have an out_buffer // When out_timestamp is set, we also have an out_buffer