Use Option::is_some_and(...) instead of Option::map_or(false, ...)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1630>
This commit is contained in:
Sebastian Dröge 2024-06-19 11:11:18 +03:00 committed by GStreamer Marge Bot
parent 23d998a1db
commit 9b323a6519
23 changed files with 57 additions and 67 deletions

View file

@ -495,7 +495,7 @@ impl GopBuffer {
}); });
if newest_ts if newest_ts
.opt_saturating_sub(oldest_ts) .opt_saturating_sub(oldest_ts)
.map_or(false, |diff| diff > gst::Signed::Positive(max_time)) .is_some_and(|diff| diff > gst::Signed::Positive(max_time))
{ {
gst::warning!(CAT, obj: obj, "Stored data has overflowed the maximum allowed stored time {}, pushing oldest GOP", max_time.display()); gst::warning!(CAT, obj: obj, "Stored data has overflowed the maximum allowed stored time {}, pushing oldest GOP", max_time.display());
gops_to_push.push(stream.oldest_gop().unwrap()); gops_to_push.push(stream.oldest_gop().unwrap());

View file

@ -472,7 +472,7 @@ impl SinkHandler {
(Some(earliest_pts), Some(pts)) if pts < earliest_pts => true, (Some(earliest_pts), Some(pts)) if pts < earliest_pts => true,
(Some(earliest_pts), Some(pts)) if pts == earliest_pts => state (Some(earliest_pts), Some(pts)) if pts == earliest_pts => state
.earliest_seqnum .earliest_seqnum
.map_or(false, |earliest_seqnum| seq > earliest_seqnum), .is_some_and(|earliest_seqnum| seq > earliest_seqnum),
_ => false, _ => false,
}; };
@ -527,7 +527,7 @@ impl SinkHandler {
if let Some((next_wakeup, _)) = next_wakeup { if let Some((next_wakeup, _)) = next_wakeup {
if let Some((previous_next_wakeup, ref abort_handle)) = state.wait_handle { if let Some((previous_next_wakeup, ref abort_handle)) = state.wait_handle {
if previous_next_wakeup.is_none() if previous_next_wakeup.is_none()
|| next_wakeup.map_or(false, |next| previous_next_wakeup.unwrap() > next) || next_wakeup.is_some_and(|next| previous_next_wakeup.unwrap() > next)
{ {
gst::debug!( gst::debug!(
CAT, CAT,
@ -1166,7 +1166,7 @@ impl TaskImpl for JitterBufferTask {
context_wait, context_wait,
); );
if let Some((Some(next_wakeup), _)) = next_wakeup { if let Some((Some(next_wakeup), _)) = next_wakeup {
if now.map_or(false, |now| next_wakeup > now) { if now.is_some_and(|now| next_wakeup > now) {
// Reschedule and wait a bit longer in the next iteration // Reschedule and wait a bit longer in the next iteration
return Ok(()); return Ok(());
} }

View file

@ -301,9 +301,7 @@ impl Scheduler {
.borrow() .borrow()
.as_ref() .as_ref()
.and_then(HandleWeak::upgrade) .and_then(HandleWeak::upgrade)
.map_or(false, |cur| { .is_some_and(|cur| std::ptr::eq(self, Arc::as_ptr(&cur.0.scheduler)))
std::ptr::eq(self, Arc::as_ptr(&cur.0.scheduler))
})
}) })
} }
} }

View file

@ -1063,7 +1063,7 @@ impl FMP4Mux {
// previously drained a partial GOP because the GOP is ending too far after the // previously drained a partial GOP because the GOP is ending too far after the
// planned fragment end. // planned fragment end.
if gop.start_pts > fragment_end_pts if gop.start_pts > fragment_end_pts
&& !gop.buffers.first().map_or(false, |b| { && !gop.buffers.first().is_some_and(|b| {
b.buffer.flags().contains(gst::BufferFlags::DELTA_UNIT) b.buffer.flags().contains(gst::BufferFlags::DELTA_UNIT)
}) })
{ {
@ -1144,7 +1144,7 @@ impl FMP4Mux {
if gop.end_pts >= chunk_end_pts if gop.end_pts >= chunk_end_pts
// only if there's another GOP or at least one further buffer // only if there's another GOP or at least one further buffer
&& (gop_idx > 0 && (gop_idx > 0
|| last_pts.map_or(false, |last_pts| last_pts.saturating_sub(chunk_start_pts) > chunk_duration)) || last_pts.is_some_and(|last_pts| last_pts.saturating_sub(chunk_start_pts) > chunk_duration))
{ {
gst::debug!(CAT, obj: stream.sinkpad, "Stream queued enough data for this chunk"); gst::debug!(CAT, obj: stream.sinkpad, "Stream queued enough data for this chunk");
stream.chunk_filled = true; stream.chunk_filled = true;
@ -1303,7 +1303,7 @@ impl FMP4Mux {
}; };
let fku_time = let fku_time =
if current_position.map_or(false, |current_position| current_position > fku_time) { if current_position.is_some_and(|current_position| current_position > fku_time) {
gst::warning!( gst::warning!(
CAT, CAT,
obj: stream.sinkpad, obj: stream.sinkpad,
@ -1856,14 +1856,14 @@ impl FMP4Mux {
.iter() .iter()
.find(|s| { .find(|s| {
!s.sinkpad.is_eos() !s.sinkpad.is_eos()
&& s.queued_gops.back().map_or(false, |gop| { && s.queued_gops.back().is_some_and(|gop| {
gop.start_pts <= fragment_start_pts + settings.fragment_duration gop.start_pts <= fragment_start_pts + settings.fragment_duration
// In chunk mode we might've drained a partial GOP as a chunk after // In chunk mode we might've drained a partial GOP as a chunk after
// the fragment end if the keyframe came too late. The GOP now // the fragment end if the keyframe came too late. The GOP now
// starts with a non-keyframe after the fragment end but is part of // starts with a non-keyframe after the fragment end but is part of
// the fragment: the fragment is extended after the end. Allow this // the fragment: the fragment is extended after the end. Allow this
// situation here. // situation here.
|| gop.buffers.first().map_or(false, |b| { || gop.buffers.first().is_some_and(|b| {
b.buffer.flags().contains(gst::BufferFlags::DELTA_UNIT) b.buffer.flags().contains(gst::BufferFlags::DELTA_UNIT)
}) })
}) })
@ -1934,7 +1934,7 @@ impl FMP4Mux {
// If nothing was dequeued for the first stream then this is OK if we're at // If nothing was dequeued for the first stream then this is OK if we're at
// EOS or this stream simply has only buffers after this chunk: we just // EOS or this stream simply has only buffers after this chunk: we just
// consider the next stream as first stream then. // consider the next stream as first stream then.
let stream_after_chunk = stream.queued_gops.back().map_or(false, |gop| { let stream_after_chunk = stream.queued_gops.back().is_some_and(|gop| {
gop.start_pts gop.start_pts
>= if fragment_filled { >= if fragment_filled {
fragment_start_pts + settings.fragment_duration fragment_start_pts + settings.fragment_duration
@ -2214,7 +2214,7 @@ impl FMP4Mux {
}; };
let fku_time = let fku_time =
if current_position.map_or(false, |current_position| current_position > fku_time) { if current_position.is_some_and(|current_position| current_position > fku_time) {
gst::warning!( gst::warning!(
CAT, CAT,
obj: stream.sinkpad, obj: stream.sinkpad,

View file

@ -1635,9 +1635,7 @@ impl TranslateSrcPad {
#[inline] #[inline]
fn needs_translation(input_lang: &str, output_lang: Option<&str>) -> bool { fn needs_translation(input_lang: &str, output_lang: Option<&str>) -> bool {
output_lang.map_or(false, |other| { output_lang.is_some_and(|other| !input_lang.eq_ignore_ascii_case(other.as_ref()))
!input_lang.eq_ignore_ascii_case(other.as_ref())
})
} }
#[inline] #[inline]

View file

@ -354,7 +354,7 @@ impl NdiSrcDemux {
gst::info!(CAT, imp: self, "Allowed audio caps {allowed_caps:?}"); gst::info!(CAT, imp: self, "Allowed audio caps {allowed_caps:?}");
state.audio_non_interleaved = allowed_caps state.audio_non_interleaved = allowed_caps
.map_or(false, |allowed_caps| allowed_caps.can_intersect(&caps)); .is_some_and(|allowed_caps| allowed_caps.can_intersect(&caps));
gst::info!( gst::info!(
CAT, CAT,

View file

@ -480,7 +480,7 @@ impl OnvifMetadataParse {
// configured latency has passed. // configured latency has passed.
let queued_time = self.calculate_queued_time(&state); let queued_time = self.calculate_queued_time(&state);
if queued_time.map_or(false, |queued_time| queued_time >= state.configured_latency) { if queued_time.is_some_and(|queued_time| queued_time >= state.configured_latency) {
gst::trace!( gst::trace!(
CAT, CAT,
imp: self, imp: self,
@ -632,7 +632,7 @@ impl OnvifMetadataParse {
let utc_time = *queued_frames.iter().next().unwrap().0; let utc_time = *queued_frames.iter().next().unwrap().0;
// Check if this frame should still be drained // Check if this frame should still be drained
if drain_utc_time.map_or(false, |drain_utc_time| drain_utc_time < utc_time) { if drain_utc_time.is_some_and(|drain_utc_time| drain_utc_time < utc_time) {
break; break;
} }
@ -728,7 +728,7 @@ impl OnvifMetadataParse {
let diff = position.saturating_sub(frame_pts); let diff = position.saturating_sub(frame_pts);
if settings if settings
.max_lateness .max_lateness
.map_or(false, |max_lateness| diff > max_lateness) .is_some_and(|max_lateness| diff > max_lateness)
{ {
gst::warning!( gst::warning!(
CAT, CAT,

View file

@ -39,7 +39,7 @@ impl AudioDiscont {
return true; return true;
} }
if self.last_rate.map_or(false, |last_rate| last_rate != rate) { if self.last_rate.is_some_and(|last_rate| last_rate != rate) {
self.discont_pending = true; self.discont_pending = true;
} }
self.last_rate = Some(rate); self.last_rate = Some(rate);

View file

@ -281,7 +281,7 @@ impl RtpBaseDepay2 {
while state while state
.pending_packets .pending_packets
.front() .front()
.map_or(false, |p| p.ext_seqnum <= end) .is_some_and(|p| p.ext_seqnum <= end)
{ {
let _ = state.pending_packets.pop_front(); let _ = state.pending_packets.pop_front();
} }
@ -517,7 +517,7 @@ impl RtpBaseDepay2 {
while state while state
.pending_packets .pending_packets
.front() .front()
.map_or(false, |p| p.ext_seqnum < seqnum_start) .is_some_and(|p| p.ext_seqnum < seqnum_start)
{ {
let p = state.pending_packets.pop_front().unwrap(); let p = state.pending_packets.pop_front().unwrap();
gst::trace!(CAT, imp: self, "Dropping packet with extended seqnum {}", p.ext_seqnum); gst::trace!(CAT, imp: self, "Dropping packet with extended seqnum {}", p.ext_seqnum);
@ -577,9 +577,7 @@ impl RtpBaseDepay2 {
} }
} else if state } else if state
.last_used_ext_seqnum .last_used_ext_seqnum
.map_or(false, |last_used_ext_seqnum| { .is_some_and(|last_used_ext_seqnum| seqnum_end <= last_used_ext_seqnum)
seqnum_end <= last_used_ext_seqnum
})
{ {
// If we have no timestamp offset and this is not the first time a buffer for this // If we have no timestamp offset and this is not the first time a buffer for this
// packet is queued then unset the PTS. It's not going to be correct. // packet is queued then unset the PTS. It's not going to be correct.
@ -698,7 +696,7 @@ impl RtpBaseDepay2 {
let mut list = gst::BufferList::new_sized(num_buffers); let mut list = gst::BufferList::new_sized(num_buffers);
{ {
let list = list.get_mut().unwrap(); let list = list.get_mut().unwrap();
while state.pending_buffers.front().map_or(false, |b| { while state.pending_buffers.front().is_some_and(|b| {
b.metadata_set && (b.buffer.pts() == pts || b.buffer.pts().is_none()) b.metadata_set && (b.buffer.pts() == pts || b.buffer.pts().is_none())
}) { }) {
let buffer = state.pending_buffers.pop_front().unwrap().buffer; let buffer = state.pending_buffers.pop_front().unwrap().buffer;
@ -1401,7 +1399,7 @@ impl RtpBaseDepay2 {
while state while state
.pending_packets .pending_packets
.front() .front()
.map_or(false, |b| b.ext_seqnum < last_used_ext_seqnum) .is_some_and(|b| b.ext_seqnum < last_used_ext_seqnum)
{ {
let _ = state.pending_packets.pop_front(); let _ = state.pending_packets.pop_front();
} }

View file

@ -274,7 +274,7 @@ impl RtpBasePay2 {
return; return;
} }
while state.pending_buffers.front().map_or(false, |b| b.id <= end) { while state.pending_buffers.front().is_some_and(|b| b.id <= end) {
let _ = state.pending_buffers.pop_front(); let _ = state.pending_buffers.pop_front();
} }
} }
@ -374,7 +374,7 @@ impl RtpBasePay2 {
while state while state
.pending_buffers .pending_buffers
.front() .front()
.map_or(false, |b| b.id < id_start) .is_some_and(|b| b.id < id_start)
{ {
let b = state.pending_buffers.pop_front().unwrap(); let b = state.pending_buffers.pop_front().unwrap();
gst::trace!(CAT, imp: self, "Dropping buffer with id {}", b.id); gst::trace!(CAT, imp: self, "Dropping buffer with id {}", b.id);
@ -793,7 +793,7 @@ impl RtpBasePay2 {
while state while state
.pending_packets .pending_packets
.front() .front()
.map_or(false, |p| p.buffer.pts() == Some(pts)) .is_some_and(|p| p.buffer.pts() == Some(pts))
{ {
let buffer = state.pending_packets.pop_front().unwrap().buffer; let buffer = state.pending_packets.pop_front().unwrap().buffer;
gst::trace!(CAT, imp: self, "Finishing buffer {buffer:?}"); gst::trace!(CAT, imp: self, "Finishing buffer {buffer:?}");
@ -1027,7 +1027,7 @@ impl RtpBasePay2 {
let clock_rate_changed = state let clock_rate_changed = state
.clock_rate .clock_rate
.map_or(false, |old_clock_rate| old_clock_rate != clock_rate); .is_some_and(|old_clock_rate| old_clock_rate != clock_rate);
state.negotiated_src_caps = Some(src_caps.clone()); state.negotiated_src_caps = Some(src_caps.clone());
state.clock_rate = Some(clock_rate); state.clock_rate = Some(clock_rate);
self.stats.lock().unwrap().as_mut().unwrap().clock_rate = Some(clock_rate); self.stats.lock().unwrap().as_mut().unwrap().clock_rate = Some(clock_rate);
@ -1526,7 +1526,7 @@ impl RtpBasePay2 {
while state while state
.pending_buffers .pending_buffers
.front() .front()
.map_or(false, |b| b.id < state.last_used_buffer_id) .is_some_and(|b| b.id < state.last_used_buffer_id)
{ {
let _ = state.pending_buffers.pop_front(); let _ = state.pending_buffers.pop_front();
} }

View file

@ -682,7 +682,7 @@ impl ExponentialMovingAverage {
} }
fn estimate_is_close(&self, value: Bitrate) -> bool { fn estimate_is_close(&self, value: Bitrate) -> bool {
self.average.map_or(false, |avg| { self.average.is_some_and(|avg| {
((avg - STANDARD_DEVIATION_CLOSE_NUM * self.standard_dev) ((avg - STANDARD_DEVIATION_CLOSE_NUM * self.standard_dev)
..(avg + STANDARD_DEVIATION_CLOSE_NUM * self.standard_dev)) ..(avg + STANDARD_DEVIATION_CLOSE_NUM * self.standard_dev))
.contains(&(value as f64)) .contains(&(value as f64))

View file

@ -594,9 +594,9 @@ impl RtpRecv {
Err(e) => { Err(e) => {
// If this is a valid RTCP packet then it was muxed with the RTP stream and can be // If this is a valid RTCP packet then it was muxed with the RTP stream and can be
// handled just fine. // handled just fine.
if rtcp_types::Compound::parse(&mapped).map_or(false, |mut rtcp| { if rtcp_types::Compound::parse(&mapped)
rtcp.next().map_or(false, |rtcp| rtcp.is_ok()) .is_ok_and(|mut rtcp| rtcp.next().is_some_and(|rtcp| rtcp.is_ok()))
}) { {
drop(mapped); drop(mapped);
return Self::rtcp_recv_sink_chain(self, id, buffer); return Self::rtcp_recv_sink_chain(self, id, buffer);
} }

View file

@ -497,7 +497,7 @@ impl crate::basepay::RtpBasePay2Impl for RtpVp8Pay {
// Drop VP8 custom meta, handle all other metas normally. // Drop VP8 custom meta, handle all other metas normally.
if meta if meta
.try_as_custom_meta() .try_as_custom_meta()
.map_or(false, |meta| meta.has_name("GstVP8Meta")) .is_some_and(|meta| meta.has_name("GstVP8Meta"))
{ {
return; return;
} }

View file

@ -299,9 +299,9 @@ impl crate::basedepay::RtpBaseDepay2Impl for RtpVp9Depay {
// Any previously queued picture data needs to be drained now. // Any previously queued picture data needs to be drained now.
if is_start_of_picture if is_start_of_picture
|| state.last_timestamp != Some(packet.ext_timestamp()) || state.last_timestamp != Some(packet.ext_timestamp())
|| state.last_picture_id.map_or(false, |picture_id| { || state
Some(picture_id) != payload_descriptor.picture_id .last_picture_id
}) .is_some_and(|picture_id| Some(picture_id) != payload_descriptor.picture_id)
{ {
// Missed the marker packet for the last picture // Missed the marker packet for the last picture
if state.current_picture_payload_descriptor.is_some() { if state.current_picture_payload_descriptor.is_some() {
@ -328,9 +328,7 @@ impl crate::basedepay::RtpBaseDepay2Impl for RtpVp9Depay {
if last_keyframe_payloader_descriptor if last_keyframe_payloader_descriptor
.scalability_structure .scalability_structure
.as_ref() .as_ref()
.map_or(false, |scalability_structure| { .is_some_and(|scalability_structure| scalability_structure.num_spatial_layers > 1)
scalability_structure.num_spatial_layers > 1
})
&& !payload_descriptor.flexible_mode && !payload_descriptor.flexible_mode
&& payload_descriptor.picture_id.is_none() && payload_descriptor.picture_id.is_none()
{ {
@ -376,7 +374,7 @@ impl crate::basedepay::RtpBaseDepay2Impl for RtpVp9Depay {
&& payload_descriptor && payload_descriptor
.layer_index .layer_index
.as_ref() .as_ref()
.map_or(false, |layer_index| layer_index.temporal_layer_id != 0) .is_some_and(|layer_index| layer_index.temporal_layer_id != 0)
{ {
gst::warning!(CAT, imp: self, "Temporal layer ID of non-inter-predicted frame must be 0"); gst::warning!(CAT, imp: self, "Temporal layer ID of non-inter-predicted frame must be 0");
// TODO: Could potentially drain here? // TODO: Could potentially drain here?

View file

@ -578,7 +578,7 @@ impl Codec {
|encoding_names| { |encoding_names| {
encoding_names.iter().any(|v| { encoding_names.iter().any(|v| {
v.get::<&str>() v.get::<&str>()
.map_or(false, |encoding_name| encoding_name == codec) .is_ok_and(|encoding_name| encoding_name == codec)
}) })
}, },
) )
@ -884,7 +884,7 @@ impl Codecs {
codec codec
.encoding_info .encoding_info
.as_ref() .as_ref()
.map_or(false, |_| codec.caps.can_intersect(&caps)) .is_some_and(|_| codec.caps.can_intersect(&caps))
}) })
.and_then(|codec| { .and_then(|codec| {
/* Assign a payload type to the codec */ /* Assign a payload type to the codec */

View file

@ -569,7 +569,7 @@ impl FallbackSwitch {
/* If we're already running behind, fire the timeout immediately */ /* If we're already running behind, fire the timeout immediately */
let now = clock.time(); let now = clock.time();
if now.map_or(false, |now| wait_until <= now) { if now.is_some_and(|now| wait_until <= now) {
self.handle_timeout(state, settings); self.handle_timeout(state, settings);
return true; return true;
} }
@ -780,7 +780,7 @@ impl FallbackSwitch {
state.upstream_latency + settings.latency, state.upstream_latency + settings.latency,
) )
} else if state.output_running_time.is_some() } else if state.output_running_time.is_some()
&& end_running_time.map_or(false, |end_running_time| { && end_running_time.is_some_and(|end_running_time| {
end_running_time < state.output_running_time.unwrap() end_running_time < state.output_running_time.unwrap()
}) })
{ {

View file

@ -547,7 +547,7 @@ fn setup_pipeline(
loop { loop {
while let Some(clock_id) = clock.peek_next_pending_id().and_then(|clock_id| { while let Some(clock_id) = clock.peek_next_pending_id().and_then(|clock_id| {
// Process if the clock ID is in the past or now // Process if the clock ID is in the past or now
if clock.time().map_or(false, |time| time >= clock_id.time()) { if clock.time().is_some_and(|time| time >= clock_id.time()) {
Some(clock_id) Some(clock_id)
} else { } else {
None None

View file

@ -31,7 +31,7 @@ fn audio_info_from_caps(
caps: &gst::CapsRef, caps: &gst::CapsRef,
) -> Result<Option<gst_audio::AudioInfo>, glib::BoolError> { ) -> Result<Option<gst_audio::AudioInfo>, glib::BoolError> {
caps.structure(0) caps.structure(0)
.map_or(false, |s| s.has_name("audio/x-raw")) .is_some_and(|s| s.has_name("audio/x-raw"))
.then(|| gst_audio::AudioInfo::from_caps(caps)) .then(|| gst_audio::AudioInfo::from_caps(caps))
.transpose() .transpose()
} }

View file

@ -708,7 +708,7 @@ impl ToggleRecord {
gst::FlowError::Error gst::FlowError::Error
})?; })?;
if data.dts().map_or(false, |dts| dts != pts) { if data.dts().is_some_and(|dts| dts != pts) {
gst::element_imp_error!( gst::element_imp_error!(
self, self,
gst::StreamError::Format, gst::StreamError::Format,
@ -848,9 +848,9 @@ impl ToggleRecord {
// and possibly current_running_time_end at some point. // and possibly current_running_time_end at some point.
if data.can_clip(&state) if data.can_clip(&state)
&& current_running_time.map_or(false, |cur_rt| cur_rt < last_recording_start) && current_running_time.is_some_and(|cur_rt| cur_rt < last_recording_start)
&& current_running_time_end && current_running_time_end
.map_or(false, |cur_rt_end| cur_rt_end > last_recording_start) .is_some_and(|cur_rt_end| cur_rt_end > last_recording_start)
{ {
// Otherwise if we're before the recording start but the end of the buffer is after // Otherwise if we're before the recording start but the end of the buffer is after
// the start and we can clip, clip the buffer and pass it onwards. // the start and we can clip, clip the buffer and pass it onwards.
@ -1028,11 +1028,11 @@ impl ToggleRecord {
// The start of our buffer must be before the last recording stop as // The start of our buffer must be before the last recording stop as
// otherwise we would be in Stopped state already // otherwise we would be in Stopped state already
assert!(current_running_time.map_or(false, |cur_rt| cur_rt < last_recording_stop)); assert!(current_running_time.is_some_and(|cur_rt| cur_rt < last_recording_stop));
let current_running_time = current_running_time.expect("checked above"); let current_running_time = current_running_time.expect("checked above");
if current_running_time_end if current_running_time_end
.map_or(false, |cur_rt_end| cur_rt_end <= last_recording_stop) .is_some_and(|cur_rt_end| cur_rt_end <= last_recording_stop)
{ {
gst::log!( gst::log!(
CAT, CAT,
@ -1045,7 +1045,7 @@ impl ToggleRecord {
} else if data.can_clip(&state) } else if data.can_clip(&state)
&& current_running_time < last_recording_stop && current_running_time < last_recording_stop
&& current_running_time_end && current_running_time_end
.map_or(false, |cur_rt_end| cur_rt_end > last_recording_stop) .is_some_and(|cur_rt_end| cur_rt_end > last_recording_stop)
{ {
gst::log!( gst::log!(
CAT, CAT,
@ -1111,7 +1111,7 @@ impl ToggleRecord {
// The start of our buffer must be before the last recording start as // The start of our buffer must be before the last recording start as
// otherwise we would be in Recording state already // otherwise we would be in Recording state already
assert!(current_running_time.map_or(false, |cur_rt| cur_rt < last_recording_start)); assert!(current_running_time.is_some_and(|cur_rt| cur_rt < last_recording_start));
let current_running_time = current_running_time.expect("checked_above"); let current_running_time = current_running_time.expect("checked_above");
if current_running_time >= last_recording_start { if current_running_time >= last_recording_start {
@ -1126,7 +1126,7 @@ impl ToggleRecord {
} else if data.can_clip(&state) } else if data.can_clip(&state)
&& current_running_time < last_recording_start && current_running_time < last_recording_start
&& current_running_time_end && current_running_time_end
.map_or(false, |cur_rt_end| cur_rt_end > last_recording_start) .is_some_and(|cur_rt_end| cur_rt_end > last_recording_start)
{ {
gst::log!( gst::log!(
CAT, CAT,
@ -1547,9 +1547,7 @@ impl ToggleRecord {
let mut state = stream.state.lock(); let mut state = stream.state.lock();
state.eos = false; state.eos = false;
let main_is_eos = main_state let main_is_eos = main_state.as_ref().is_some_and(|main_state| main_state.eos);
.as_ref()
.map_or(false, |main_state| main_state.eos);
if !main_is_eos { if !main_is_eos {
let mut rec_state = self.state.lock(); let mut rec_state = self.state.lock();

View file

@ -481,7 +481,7 @@ impl MccParse {
if state if state
.segment .segment
.start() .start()
.map_or(false, |seg_start| nsecs >= seg_start) .is_some_and(|seg_start| nsecs >= seg_start)
{ {
state.seeking = false; state.seeking = false;
state.discont = true; state.discont = true;

View file

@ -369,7 +369,7 @@ impl SccParse {
num_bufs, num_bufs,
); );
if segment_start.map_or(false, |seg_start| stop_time > seg_start) { if segment_start.is_some_and(|seg_start| stop_time > seg_start) {
state.seeking = false; state.seeking = false;
state.discont = true; state.discont = true;
state.need_flush_stop = true; state.need_flush_stop = true;

View file

@ -538,7 +538,7 @@ impl Frame {
.and_then(|m| { .and_then(|m| {
let ctx = m.context(); let ctx = m.context();
if wrapped_context if wrapped_context
.map_or(false, |wrapped_context| wrapped_context.can_share(ctx)) .is_some_and(|wrapped_context| wrapped_context.can_share(ctx))
{ {
Some(ctx) Some(ctx)
} else { } else {

View file

@ -283,7 +283,7 @@ impl PaintableImpl for Paintable {
let context_requires_premult = { let context_requires_premult = {
#[cfg(feature = "gtk_v4_14")] #[cfg(feature = "gtk_v4_14")]
{ {
self.gl_context.borrow().as_ref().map_or(false, |context| { self.gl_context.borrow().as_ref().is_some_and(|context| {
context.api() != gdk::GLAPI::GLES || context.version().0 < 3 context.api() != gdk::GLAPI::GLES || context.version().0 < 3
}) })
} }