diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2021-02-09 19:57:34 +0300 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2021-02-09 19:57:34 +0300 |
commit | cbda137fbf128be6eb39b8eff5c996494476cefb (patch) | |
tree | fee6c0f8838f2dc9d2ad3cb6dfb33255285b2b05 /utils | |
parent | f63c4284c1f8661eae0df31bc949793bbf7a2c43 (diff) |
Fix various warnings from clippy 1.50
Diffstat (limited to 'utils')
-rw-r--r-- | utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs | 43 | ||||
-rw-r--r-- | utils/fallbackswitch/src/fallbacksrc/imp.rs | 81 | ||||
-rw-r--r-- | utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs | 22 |
3 files changed, 48 insertions, 98 deletions
diff --git a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs index 895390248..fa5a5c073 100644 --- a/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/custom_source/imp.rs @@ -158,7 +158,7 @@ impl ElementImpl for CustomSource { match transition { gst::StateChange::ReadyToNull => { - self.stop(element)?; + self.stop(element); } _ => (), } @@ -177,9 +177,7 @@ impl BinImpl for CustomSource { // TODO: Drop stream collection message for now, we only create a simple custom // one here so that fallbacksrc can know about our streams. It is never // forwarded. - if let Err(msg) = self.handle_source_no_more_pads(&bin) { - bin.post_error_message(msg); - } + self.handle_source_no_more_pads(&bin); } _ => self.parent_handle_message(bin, msg), } @@ -222,10 +220,7 @@ impl CustomSource { } if !has_sometimes_pads { - if let Err(msg) = self.handle_source_no_more_pads(&element) { - element.post_error_message(msg); - return Err(gst::StateChangeError); - } + self.handle_source_no_more_pads(&element); } else { gst_debug!(CAT, obj: element, "Found sometimes pads"); @@ -249,9 +244,7 @@ impl CustomSource { }; let src = CustomSource::from_instance(&element); - if let Err(msg) = src.handle_source_pad_removed(&element, pad) { - element.post_error_message(msg); - } + src.handle_source_pad_removed(&element, pad); }); let element_weak = element.downgrade(); @@ -262,9 +255,7 @@ impl CustomSource { }; let src = CustomSource::from_instance(&element); - if let Err(msg) = src.handle_source_no_more_pads(&element) { - element.post_error_message(msg); - } + src.handle_source_no_more_pads(&element); }); } @@ -347,11 +338,7 @@ impl CustomSource { Ok(()) } - fn handle_source_pad_removed( - &self, - element: &super::CustomSource, - pad: &gst::Pad, - ) -> Result<(), gst::ErrorMessage> { + fn handle_source_pad_removed(&self, element: &super::CustomSource, pad: &gst::Pad) { gst_debug!(CAT, obj: element, "Source removed pad {}", pad.get_name()); let mut state = self.state.lock().unwrap(); @@ -361,7 +348,7 @@ impl CustomSource { .enumerate() .find(|(_i, p)| &p.source_pad == pad) { - None => return Ok(()), + None => return, Some(v) => v, }; @@ -372,14 +359,9 @@ impl CustomSource { ghost_pad.set_active(false).unwrap(); let _ = ghost_pad.set_target(None::<&gst::Pad>); let _ = element.remove_pad(&ghost_pad); - - Ok(()) } - fn handle_source_no_more_pads( - &self, - element: &super::CustomSource, - ) -> Result<(), gst::ErrorMessage> { + fn handle_source_no_more_pads(&self, element: &super::CustomSource) { gst_debug!(CAT, obj: element, "Source signalled no-more-pads"); let state = self.state.lock().unwrap(); @@ -400,14 +382,9 @@ impl CustomSource { .src(element) .build(), ); - - Ok(()) } - fn stop( - &self, - element: &super::CustomSource, - ) -> Result<gst::StateChangeSuccess, gst::StateChangeError> { + fn stop(&self, element: &super::CustomSource) { gst_debug!(CAT, obj: element, "Stopping"); let mut state = self.state.lock().unwrap(); @@ -420,7 +397,5 @@ impl CustomSource { let _ = pad.ghost_pad.set_target(None::<&gst::Pad>); let _ = element.remove_pad(&pad.ghost_pad); } - - Ok(gst::StateChangeSuccess::Success) } } diff --git a/utils/fallbackswitch/src/fallbacksrc/imp.rs b/utils/fallbackswitch/src/fallbacksrc/imp.rs index 26631f346..4961bb29c 100644 --- a/utils/fallbackswitch/src/fallbacksrc/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/imp.rs @@ -640,7 +640,7 @@ impl ElementImpl for FallbackSrc { // Change the source state manually here to be able to catch errors. State changes always // happen from sink to source, so we do this after chaining up. - self.change_source_state(element, transition)?; + self.change_source_state(element, transition); // Ignore parent state change return to prevent spurious async/no-preroll return values // due to core state change bugs @@ -649,7 +649,7 @@ impl ElementImpl for FallbackSrc { Ok(gst::StateChangeSuccess::NoPreroll) } gst::StateChange::ReadyToNull => { - self.stop(element)?; + self.stop(element); Ok(gst::StateChangeSuccess::Success) } _ => Ok(gst::StateChangeSuccess::Success), @@ -689,7 +689,7 @@ impl FallbackSrc { element: &super::FallbackSrc, source: &Source, buffer_duration: i64, - ) -> Result<gst::Element, gst::StateChangeError> { + ) -> gst::Element { let source = match source { Source::Uri(ref uri) => { let source = gst::ElementFactory::make("uridecodebin3", Some("uridecodebin")) @@ -741,14 +741,12 @@ impl FallbackSrc { }; let src = FallbackSrc::from_instance(&element); - if let Err(msg) = src.handle_source_pad_removed(&element, pad) { - element.post_error_message(msg); - } + src.handle_source_pad_removed(&element, pad); }); element.add_many(&[&source]).unwrap(); - Ok(source) + source } fn create_fallback_video_input( @@ -756,14 +754,11 @@ impl FallbackSrc { _element: &super::FallbackSrc, min_latency: u64, fallback_uri: Option<&str>, - ) -> Result<gst::Element, gst::StateChangeError> { - Ok(VideoFallbackSource::new(fallback_uri, min_latency).upcast()) + ) -> gst::Element { + VideoFallbackSource::new(fallback_uri, min_latency).upcast() } - fn create_fallback_audio_input( - &self, - _element: &super::FallbackSrc, - ) -> Result<gst::Element, gst::StateChangeError> { + fn create_fallback_audio_input(&self, _element: &super::FallbackSrc) -> gst::Element { let input = gst::Bin::new(Some("fallback_audio")); let audiotestsrc = gst::ElementFactory::make("audiotestsrc", Some("fallback_audiosrc")) .expect("No audiotestsrc found"); @@ -781,7 +776,7 @@ impl FallbackSrc { ) .unwrap(); - Ok(input.upcast()) + input.upcast() } fn create_stream( @@ -791,11 +786,11 @@ impl FallbackSrc { min_latency: u64, is_audio: bool, fallback_uri: Option<&str>, - ) -> Result<Stream, gst::StateChangeError> { + ) -> Stream { let fallback_input = if is_audio { - self.create_fallback_audio_input(element)? + self.create_fallback_audio_input(element) } else { - self.create_fallback_video_input(element, min_latency, fallback_uri)? + self.create_fallback_video_input(element, min_latency, fallback_uri) }; let switch = @@ -865,7 +860,7 @@ impl FallbackSrc { element.add_pad(&ghostpad).unwrap(); - Ok(Stream { + Stream { fallback_input, source_srcpad: None, source_srcpad_block: None, @@ -874,7 +869,7 @@ impl FallbackSrc { clocksync_queue, switch, srcpad: ghostpad.upcast(), - }) + } } fn start(&self, element: &super::FallbackSrc) -> Result<(), gst::StateChangeError> { @@ -907,8 +902,7 @@ impl FallbackSrc { let fallback_uri = &settings.fallback_uri; // Create main input - let source = - self.create_main_input(element, &configured_source, settings.buffer_duration)?; + let source = self.create_main_input(element, &configured_source, settings.buffer_duration); let mut flow_combiner = gst_base::UniqueFlowCombiner::new(); @@ -920,7 +914,7 @@ impl FallbackSrc { settings.min_latency, false, fallback_uri.as_deref(), - )?; + ); flow_combiner.add_pad(&stream.srcpad); Some(stream) } else { @@ -930,7 +924,7 @@ impl FallbackSrc { // Create audio stream let audio_stream = if settings.enable_audio { let stream = - self.create_stream(element, settings.timeout, settings.min_latency, true, None)?; + self.create_stream(element, settings.timeout, settings.min_latency, true, None); flow_combiner.add_pad(&stream.srcpad); Some(stream) } else { @@ -964,12 +958,12 @@ impl FallbackSrc { Ok(()) } - fn stop(&self, element: &super::FallbackSrc) -> Result<(), gst::StateChangeError> { + fn stop(&self, element: &super::FallbackSrc) { gst_debug!(CAT, obj: element, "Stopping"); let mut state_guard = self.state.lock().unwrap(); let mut state = match state_guard.take() { Some(state) => state, - None => return Ok(()), + None => return, }; drop(state_guard); @@ -1018,19 +1012,14 @@ impl FallbackSrc { } gst_debug!(CAT, obj: element, "Stopped"); - Ok(()) } - fn change_source_state( - &self, - element: &super::FallbackSrc, - transition: gst::StateChange, - ) -> Result<(), gst::StateChangeError> { + fn change_source_state(&self, element: &super::FallbackSrc, transition: gst::StateChange) { gst_debug!(CAT, obj: element, "Changing source state: {:?}", transition); let mut state_guard = self.state.lock().unwrap(); let state = match &mut *state_guard { Some(state) => state, - None => return Ok(()), + None => return, }; if transition.current() <= transition.next() && state.source_pending_restart { @@ -1039,7 +1028,7 @@ impl FallbackSrc { obj: element, "Not starting source because pending restart" ); - return Ok(()); + return; } else if transition.next() <= gst::State::Ready && state.source_pending_restart { gst_debug!( CAT, @@ -1094,8 +1083,6 @@ impl FallbackSrc { } } } - - Ok(()) } fn proxy_pad_chain( @@ -1610,11 +1597,7 @@ impl FallbackSrc { } } - fn handle_source_pad_removed( - &self, - element: &super::FallbackSrc, - pad: &gst::Pad, - ) -> Result<(), gst::ErrorMessage> { + fn handle_source_pad_removed(&self, element: &super::FallbackSrc, pad: &gst::Pad) { gst_debug!( CAT, obj: element, @@ -1625,7 +1608,7 @@ impl FallbackSrc { let mut state_guard = self.state.lock().unwrap(); let state = match &mut *state_guard { None => { - return Ok(()); + return; } Some(state) => state, }; @@ -1646,7 +1629,7 @@ impl FallbackSrc { { stream } else { - return Ok(()); + return; }; stream.source_srcpad = None; @@ -1655,8 +1638,6 @@ impl FallbackSrc { drop(state_guard); element.notify("status"); - - Ok(()) } fn handle_buffering(&self, element: &super::FallbackSrc, m: &gst::message::Buffering) { @@ -1992,13 +1973,11 @@ impl FallbackSrc { // See https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/issues/746 element.remove(&state.source).unwrap(); - let source = src - .create_main_input( - element, - &state.configured_source, - state.settings.buffer_duration, - ) - .expect("failed to create new source"); + let source = src.create_main_input( + element, + &state.configured_source, + state.settings.buffer_duration, + ); ( source.clone(), diff --git a/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs b/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs index ca8053fc6..6fe8dd716 100644 --- a/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs +++ b/utils/fallbackswitch/src/fallbacksrc/video_fallback/imp.rs @@ -204,7 +204,7 @@ impl ElementImpl for VideoFallbackSource { match transition { gst::StateChange::ReadyToNull => { - self.stop(element)?; + self.stop(element); } _ => (), } @@ -220,9 +220,10 @@ impl BinImpl for VideoFallbackSource { match msg.view() { MessageView::Error(err) => { - if !self + if self .got_error - .compare_and_swap(false, true, Ordering::SeqCst) + .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst) + .is_err() { gst_warning!(CAT, obj: bin, "Got error {:?}", err); self.parent_handle_message(bin, msg) @@ -283,7 +284,7 @@ impl VideoFallbackSource { element: &super::VideoFallbackSource, min_latency: u64, uri: Option<&str>, - ) -> Result<gst::Element, gst::StateChangeError> { + ) -> gst::Element { gst_debug!(CAT, obj: element, "Creating source with uri {:?}", uri); let source = gst::Bin::new(None); @@ -440,7 +441,7 @@ impl VideoFallbackSource { ) .unwrap(); - Ok(source.upcast()) + source.upcast() } fn start( @@ -457,7 +458,7 @@ impl VideoFallbackSource { let settings = self.settings.lock().unwrap().clone(); let uri = &settings.uri; - let source = self.create_source(element, settings.min_latency, uri.as_deref())?; + let source = self.create_source(element, settings.min_latency, uri.as_deref()); element.add(&source).unwrap(); @@ -469,16 +470,13 @@ impl VideoFallbackSource { Ok(gst::StateChangeSuccess::Success) } - fn stop( - &self, - element: &super::VideoFallbackSource, - ) -> Result<gst::StateChangeSuccess, gst::StateChangeError> { + fn stop(&self, element: &super::VideoFallbackSource) { gst_debug!(CAT, obj: element, "Stopping"); let mut state_guard = self.state.lock().unwrap(); let state = match state_guard.take() { Some(state) => state, - None => return Ok(gst::StateChangeSuccess::Success), + None => return, }; drop(state_guard); @@ -488,7 +486,5 @@ impl VideoFallbackSource { element.remove(&state.source).unwrap(); self.got_error.store(false, Ordering::Relaxed); gst_debug!(CAT, obj: element, "Stopped"); - - Ok(gst::StateChangeSuccess::Success) } } |