From 126159c762a029b8fc6dc3dce53e06f60157fa92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sat, 11 Nov 2017 13:31:01 +0100 Subject: [PATCH] Run everything through rustfmt once again --- examples/src/bin/player.rs | 5 +- gstreamer-audio/src/audio_channel_position.rs | 63 +++++++++++-------- gstreamer/src/lib.rs | 2 +- gstreamer/src/object.rs | 8 +-- tutorials/src/bin/basic-tutorial-7.rs | 10 ++- 5 files changed, 50 insertions(+), 38 deletions(-) diff --git a/examples/src/bin/player.rs b/examples/src/bin/player.rs index a0daf4417..6807cd24a 100644 --- a/examples/src/bin/player.rs +++ b/examples/src/bin/player.rs @@ -61,7 +61,7 @@ fn main_loop(uri: &str) -> Result<(), Error> { let guard = error.as_ref().lock().unwrap(); - guard.clone().map_err(|e|e.into()) + guard.clone().map_err(|e| e.into()) } #[allow(unused_variables)] @@ -74,7 +74,8 @@ fn main() { std::process::exit(-1); }; - #[cfg(not(feature = "gst-player"))] { + #[cfg(not(feature = "gst-player"))] + { eprintln!("Feature gst-player is required. Please rebuild with --features gst-player"); std::process::exit(-1); } diff --git a/gstreamer-audio/src/audio_channel_position.rs b/gstreamer-audio/src/audio_channel_position.rs index c9dc24e91..882c843b7 100644 --- a/gstreamer-audio/src/audio_channel_position.rs +++ b/gstreamer-audio/src/audio_channel_position.rs @@ -34,12 +34,13 @@ impl AudioChannelPosition { return None; } - let positions_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= len as usize { + let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { positions[i].to_glib() - }); + } + }); unsafe { let mut mask = mem::uninitialized(); @@ -100,12 +101,13 @@ impl AudioChannelPosition { } let len = positions.len(); - let mut positions_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= len as usize { + let mut positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy( + |i| if i >= len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { positions[i].to_glib() - }); + }, + ); let valid: bool = unsafe { from_glib(ffi::gst_audio_channel_positions_to_valid_order( @@ -143,12 +145,13 @@ impl AudioChannelPosition { } let len = positions.len(); - let positions_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= len as usize { + let positions_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { positions[i].to_glib() - }); + } + }); unsafe { from_glib(ffi::gst_audio_check_valid_channel_positions( @@ -176,19 +179,21 @@ pub fn buffer_reorder_channels( let from_len = from.len(); let to_len = to.len(); - let from_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= from_len as usize { + let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= from_len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { from[i].to_glib() - }); + } + }); - let to_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= to_len as usize { + let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= to_len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { to[i].to_glib() - }); + } + }); let valid: bool = unsafe { from_glib(ffi::gst_audio_buffer_reorder_channels( @@ -223,19 +228,21 @@ pub fn reorder_channels( let from_len = from.len(); let to_len = to.len(); - let from_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= from_len as usize { + let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= from_len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { from[i].to_glib() - }); + } + }); - let to_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= to_len as usize { + let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= to_len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { to[i].to_glib() - }); + } + }); let valid: bool = unsafe { from_glib(ffi::gst_audio_reorder_channels( @@ -269,19 +276,21 @@ pub fn get_channel_reorder_map( let from_len = from.len(); let to_len = to.len(); - let from_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= from_len as usize { + let from_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= from_len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { from[i].to_glib() - }); + } + }); - let to_raw: [ffi::GstAudioChannelPosition; 64] = - array_init::array_init_copy(|i| if i >= to_len as usize { + let to_raw: [ffi::GstAudioChannelPosition; 64] = array_init::array_init_copy(|i| { + if i >= to_len as usize { ffi::GST_AUDIO_CHANNEL_POSITION_INVALID } else { to[i].to_glib() - }); + } + }); let mut reorder_map_raw = [0i32, 64]; let valid: bool = unsafe { diff --git a/gstreamer/src/lib.rs b/gstreamer/src/lib.rs index 950067c95..9b16ff55f 100644 --- a/gstreamer/src/lib.rs +++ b/gstreamer/src/lib.rs @@ -120,7 +120,7 @@ pub use device_provider::DeviceProviderExtManual; pub use parse_context::ParseContext; #[cfg(feature = "futures")] pub use bus::BusStream; -pub use enums::{StateChangeSuccess, StateChangeError}; +pub use enums::{StateChangeError, StateChangeSuccess}; pub use clock_time::ClockTime; pub use format::FormatValue; diff --git a/gstreamer/src/object.rs b/gstreamer/src/object.rs index edd2cea59..4bda95890 100644 --- a/gstreamer/src/object.rs +++ b/gstreamer/src/object.rs @@ -7,7 +7,7 @@ // except according to those terms. use glib; -use glib::{IsA, Cast}; +use glib::{Cast, IsA}; use glib::translate::ToGlibPtr; use glib::signal::SignalHandlerId; use glib::object::ObjectExt; @@ -29,11 +29,7 @@ impl + IsA + glib::value::SetValue> GstObjectExtM f: F, ) -> SignalHandlerId { self.connect("deep-notify", false, move |values| { - let obj: O = values[0] - .get::() - .unwrap() - .downcast() - .unwrap(); + let obj: O = values[0].get::().unwrap().downcast().unwrap(); let prop_obj: ::Object = values[1].get().unwrap(); let prop_name = unsafe { diff --git a/tutorials/src/bin/basic-tutorial-7.rs b/tutorials/src/bin/basic-tutorial-7.rs index d1b57e6b1..0c9a7cca6 100644 --- a/tutorials/src/bin/basic-tutorial-7.rs +++ b/tutorials/src/bin/basic-tutorial-7.rs @@ -65,7 +65,10 @@ fn main() { let queue_video_pad = video_queue.get_static_pad("sink").unwrap(); tee_video_pad.link(&queue_video_pad).into_result().unwrap(); - pipeline.set_state(gst::State::Playing).into_result().expect("Unable to set the pipeline to the Playing state."); + pipeline + .set_state(gst::State::Playing) + .into_result() + .expect("Unable to set the pipeline to the Playing state."); let bus = pipeline.get_bus().unwrap(); while let Some(msg) = bus.timed_pop(gst::CLOCK_TIME_NONE) { use gst::MessageView; @@ -84,5 +87,8 @@ fn main() { } } - pipeline.set_state(gst::State::Null).into_result().expect("Unable to set the pipeline to the Null state."); + pipeline + .set_state(gst::State::Null) + .into_result() + .expect("Unable to set the pipeline to the Null state."); }