Fix/hide various clippy warnings in gstreamer

This commit is contained in:
Sebastian Dröge 2017-09-10 14:54:43 +03:00
parent a0ba290d4d
commit 85b335fd89
14 changed files with 154 additions and 190 deletions

View file

@ -142,6 +142,12 @@ impl GstRc<BufferRef> {
} }
} }
impl Default for GstRc<BufferRef> {
fn default() -> Self {
Self::new()
}
}
impl BufferRef { impl BufferRef {
pub fn map_readable(&self) -> Option<BufferMap<Readable>> { pub fn map_readable(&self) -> Option<BufferMap<Readable>> {
let mut map_info: ffi::GstMapInfo = unsafe { mem::zeroed() }; let mut map_info: ffi::GstMapInfo = unsafe { mem::zeroed() };

View file

@ -68,11 +68,21 @@ impl BufferListRef {
unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize } unsafe { ffi::gst_buffer_list_length(self.as_mut_ptr()) as usize }
} }
pub fn is_empty(&self) -> bool {
self.len() == 0
}
pub fn iter(&self) -> Iter { pub fn iter(&self) -> Iter {
Iter::new(self) Iter::new(self)
} }
} }
impl Default for GstRc<BufferListRef> {
fn default() -> Self {
Self::new()
}
}
impl ToOwned for BufferListRef { impl ToOwned for BufferListRef {
type Owned = GstRc<BufferListRef>; type Owned = GstRc<BufferListRef>;

View file

@ -37,6 +37,7 @@ unsafe extern "C" fn trampoline_watch(
func: gpointer, func: gpointer,
) -> gboolean { ) -> gboolean {
let _guard = CallbackGuard::new(); let _guard = CallbackGuard::new();
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let func: &RefCell<Box<FnMut(&Bus, &Message) -> Continue + Send + 'static>> = transmute(func); let func: &RefCell<Box<FnMut(&Bus, &Message) -> Continue + Send + 'static>> = transmute(func);
(&mut *func.borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib() (&mut *func.borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib()
} }
@ -49,6 +50,7 @@ unsafe extern "C" fn destroy_closure_watch(ptr: gpointer) {
} }
fn into_raw_watch<F: FnMut(&Bus, &Message) -> Continue + Send + 'static>(func: F) -> gpointer { fn into_raw_watch<F: FnMut(&Bus, &Message) -> Continue + Send + 'static>(func: F) -> gpointer {
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
let func: Box<RefCell<Box<FnMut(&Bus, &Message) -> Continue + Send + 'static>>> = let func: Box<RefCell<Box<FnMut(&Bus, &Message) -> Continue + Send + 'static>>> =
Box::new(RefCell::new(Box::new(func))); Box::new(RefCell::new(Box::new(func)));
Box::into_raw(func) as gpointer Box::into_raw(func) as gpointer
@ -60,6 +62,7 @@ unsafe extern "C" fn trampoline_sync(
func: gpointer, func: gpointer,
) -> ffi::GstBusSyncReply { ) -> ffi::GstBusSyncReply {
let _guard = CallbackGuard::new(); let _guard = CallbackGuard::new();
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static) = transmute(func); let f: &&(Fn(&Bus, &Message) -> BusSyncReply + Send + Sync + 'static) = transmute(func);
f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib() f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib()
} }

View file

@ -39,6 +39,7 @@ unsafe extern "C" fn trampoline_wait_async(
func: gpointer, func: gpointer,
) -> gboolean { ) -> gboolean {
let _guard = CallbackGuard::new(); let _guard = CallbackGuard::new();
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let f: &&(Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static) = transmute(func); let f: &&(Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static) = transmute(func);
f(&from_glib_borrow(clock), time, &from_glib_borrow(id)).to_glib() f(&from_glib_borrow(clock), time, &from_glib_borrow(id)).to_glib()
} }
@ -51,6 +52,7 @@ unsafe extern "C" fn destroy_closure_wait_async(ptr: gpointer) {
fn into_raw_wait_async<F: Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static>( fn into_raw_wait_async<F: Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static>(
func: F, func: F,
) -> gpointer { ) -> gpointer {
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
let func: Box<Box<Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static>> = let func: Box<Box<Fn(&Clock, ClockTime, &ClockId) -> bool + Send + 'static>> =
Box::new(Box::new(func)); Box::new(Box::new(func));
Box::into_raw(func) as gpointer Box::into_raw(func) as gpointer

View file

@ -69,66 +69,41 @@ impl EventRef {
pub fn view(&self) -> EventView { pub fn view(&self) -> EventView {
let type_ = unsafe { (*self.as_ptr()).type_ }; let type_ = unsafe { (*self.as_ptr()).type_ };
if type_ == ffi::GST_EVENT_FLUSH_START { match type_ {
EventView::FlushStart(FlushStart(self)) ffi::GST_EVENT_FLUSH_START => EventView::FlushStart(FlushStart(self)),
} else if type_ == ffi::GST_EVENT_FLUSH_STOP { ffi::GST_EVENT_FLUSH_STOP => EventView::FlushStop(FlushStop(self)),
EventView::FlushStop(FlushStop(self)) ffi::GST_EVENT_STREAM_START => EventView::StreamStart(StreamStart(self)),
} else if type_ == ffi::GST_EVENT_STREAM_START { ffi::GST_EVENT_CAPS => EventView::Caps(Caps(self)),
EventView::StreamStart(StreamStart(self)) ffi::GST_EVENT_SEGMENT => EventView::Segment(Segment(self)),
} else if type_ == ffi::GST_EVENT_CAPS { ffi::GST_EVENT_STREAM_COLLECTION => EventView::StreamCollection(StreamCollection(self)),
EventView::Caps(Caps(self)) ffi::GST_EVENT_TAG => EventView::Tag(Tag(self)),
} else if type_ == ffi::GST_EVENT_SEGMENT { ffi::GST_EVENT_BUFFERSIZE => EventView::BufferSize(BufferSize(self)),
EventView::Segment(Segment(self)) ffi::GST_EVENT_SINK_MESSAGE => EventView::SinkMessage(SinkMessage(self)),
} else if type_ == ffi::GST_EVENT_STREAM_COLLECTION { ffi::GST_EVENT_STREAM_GROUP_DONE => EventView::StreamGroupDone(StreamGroupDone(self)),
EventView::StreamCollection(StreamCollection(self)) ffi::GST_EVENT_EOS => EventView::Eos(Eos(self)),
} else if type_ == ffi::GST_EVENT_TAG { ffi::GST_EVENT_TOC => EventView::Toc(Toc(self)),
EventView::Tag(Tag(self)) ffi::GST_EVENT_PROTECTION => EventView::Protection(Protection(self)),
} else if type_ == ffi::GST_EVENT_BUFFERSIZE { ffi::GST_EVENT_SEGMENT_DONE => EventView::SegmentDone(SegmentDone(self)),
EventView::BufferSize(BufferSize(self)) ffi::GST_EVENT_GAP => EventView::Gap(Gap(self)),
} else if type_ == ffi::GST_EVENT_SINK_MESSAGE { ffi::GST_EVENT_QOS => EventView::Qos(Qos(self)),
EventView::SinkMessage(SinkMessage(self)) ffi::GST_EVENT_SEEK => EventView::Seek(Seek(self)),
} else if type_ == ffi::GST_EVENT_STREAM_GROUP_DONE { ffi::GST_EVENT_NAVIGATION => EventView::Navigation(Navigation(self)),
EventView::StreamGroupDone(StreamGroupDone(self)) ffi::GST_EVENT_LATENCY => EventView::Latency(Latency(self)),
} else if type_ == ffi::GST_EVENT_EOS { ffi::GST_EVENT_STEP => EventView::Step(Step(self)),
EventView::Eos(Eos(self)) ffi::GST_EVENT_RECONFIGURE => EventView::Reconfigure(Reconfigure(self)),
} else if type_ == ffi::GST_EVENT_TOC { ffi::GST_EVENT_TOC_SELECT => EventView::TocSelect(TocSelect(self)),
EventView::Toc(Toc(self)) ffi::GST_EVENT_SELECT_STREAMS => EventView::SelectStreams(SelectStreams(self)),
} else if type_ == ffi::GST_EVENT_PROTECTION { ffi::GST_EVENT_CUSTOM_UPSTREAM => EventView::CustomUpstream(CustomUpstream(self)),
EventView::Protection(Protection(self)) ffi::GST_EVENT_CUSTOM_DOWNSTREAM => EventView::CustomDownstream(CustomDownstream(self)),
} else if type_ == ffi::GST_EVENT_SEGMENT_DONE { ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB => {
EventView::SegmentDone(SegmentDone(self)) EventView::CustomDownstreamOob(CustomDownstreamOob(self))
} else if type_ == ffi::GST_EVENT_GAP { }
EventView::Gap(Gap(self)) ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY => {
} else if type_ == ffi::GST_EVENT_QOS { EventView::CustomDownstreamSticky(CustomDownstreamSticky(self))
EventView::Qos(Qos(self)) }
} else if type_ == ffi::GST_EVENT_SEEK { ffi::GST_EVENT_CUSTOM_BOTH => EventView::CustomBoth(CustomBoth(self)),
EventView::Seek(Seek(self)) ffi::GST_EVENT_CUSTOM_BOTH_OOB => EventView::CustomBothOob(CustomBothOob(self)),
} else if type_ == ffi::GST_EVENT_NAVIGATION { _ => EventView::Other,
EventView::Navigation(Navigation(self))
} else if type_ == ffi::GST_EVENT_LATENCY {
EventView::Latency(Latency(self))
} else if type_ == ffi::GST_EVENT_STEP {
EventView::Step(Step(self))
} else if type_ == ffi::GST_EVENT_RECONFIGURE {
EventView::Reconfigure(Reconfigure(self))
} else if type_ == ffi::GST_EVENT_TOC_SELECT {
EventView::TocSelect(TocSelect(self))
} else if type_ == ffi::GST_EVENT_SELECT_STREAMS {
EventView::SelectStreams(SelectStreams(self))
} else if type_ == ffi::GST_EVENT_CUSTOM_UPSTREAM {
EventView::CustomUpstream(CustomUpstream(self))
} else if type_ == ffi::GST_EVENT_CUSTOM_DOWNSTREAM {
EventView::CustomDownstream(CustomDownstream(self))
} else if type_ == ffi::GST_EVENT_CUSTOM_DOWNSTREAM_OOB {
EventView::CustomDownstreamOob(CustomDownstreamOob(self))
} else if type_ == ffi::GST_EVENT_CUSTOM_DOWNSTREAM_STICKY {
EventView::CustomDownstreamSticky(CustomDownstreamSticky(self))
} else if type_ == ffi::GST_EVENT_CUSTOM_BOTH {
EventView::CustomBoth(CustomBoth(self))
} else if type_ == ffi::GST_EVENT_CUSTOM_BOTH_OOB {
EventView::CustomBothOob(CustomBothOob(self))
} else {
EventView::Other
} }
} }
} }

View file

@ -21,6 +21,7 @@ glib_wrapper! {
} }
impl Iterator { impl Iterator {
#[cfg_attr(feature = "cargo-clippy", allow(should_implement_trait))]
pub fn next(&mut self) -> Result<Value, IteratorResult> { pub fn next(&mut self) -> Result<Value, IteratorResult> {
unsafe { unsafe {
let mut value = Value::uninitialized(); let mut value = Value::uninitialized();

View file

@ -52,6 +52,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))] #[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))] #[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))] #[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
mod auto; mod auto;
pub use auto::*; pub use auto::*;
pub use auto::functions::*; pub use auto::functions::*;

View file

@ -49,80 +49,52 @@ impl MessageRef {
pub fn view(&self) -> MessageView { pub fn view(&self) -> MessageView {
let type_ = unsafe { (*self.as_ptr()).type_ }; let type_ = unsafe { (*self.as_ptr()).type_ };
if type_ == ffi::GST_MESSAGE_EOS { match type_ {
MessageView::Eos(Eos(self)) ffi::GST_MESSAGE_EOS => MessageView::Eos(Eos(self)),
} else if type_ == ffi::GST_MESSAGE_ERROR { ffi::GST_MESSAGE_ERROR => MessageView::Error(Error(self)),
MessageView::Error(Error(self)) ffi::GST_MESSAGE_WARNING => MessageView::Warning(Warning(self)),
} else if type_ == ffi::GST_MESSAGE_WARNING { ffi::GST_MESSAGE_INFO => MessageView::Info(Info(self)),
MessageView::Warning(Warning(self)) ffi::GST_MESSAGE_TAG => MessageView::Tag(Tag(self)),
} else if type_ == ffi::GST_MESSAGE_INFO { ffi::GST_MESSAGE_BUFFERING => MessageView::Buffering(Buffering(self)),
MessageView::Info(Info(self)) ffi::GST_MESSAGE_STATE_CHANGED => MessageView::StateChanged(StateChanged(self)),
} else if type_ == ffi::GST_MESSAGE_TAG { ffi::GST_MESSAGE_STATE_DIRTY => MessageView::StateDirty(StateDirty(self)),
MessageView::Tag(Tag(self)) ffi::GST_MESSAGE_STEP_DONE => MessageView::StepDone(StepDone(self)),
} else if type_ == ffi::GST_MESSAGE_BUFFERING { ffi::GST_MESSAGE_CLOCK_PROVIDE => MessageView::ClockProvide(ClockProvide(self)),
MessageView::Buffering(Buffering(self)) ffi::GST_MESSAGE_CLOCK_LOST => MessageView::ClockLost(ClockLost(self)),
} else if type_ == ffi::GST_MESSAGE_STATE_CHANGED { ffi::GST_MESSAGE_NEW_CLOCK => MessageView::NewClock(NewClock(self)),
MessageView::StateChanged(StateChanged(self)) ffi::GST_MESSAGE_STRUCTURE_CHANGE => {
} else if type_ == ffi::GST_MESSAGE_STATE_DIRTY { MessageView::StructureChange(StructureChange(self))
MessageView::StateDirty(StateDirty(self)) }
} else if type_ == ffi::GST_MESSAGE_STEP_DONE { ffi::GST_MESSAGE_STREAM_STATUS => MessageView::StreamStatus(StreamStatus(self)),
MessageView::StepDone(StepDone(self)) ffi::GST_MESSAGE_APPLICATION => MessageView::Application(Application(self)),
} else if type_ == ffi::GST_MESSAGE_CLOCK_PROVIDE { ffi::GST_MESSAGE_ELEMENT => MessageView::Element(Element(self)),
MessageView::ClockProvide(ClockProvide(self)) ffi::GST_MESSAGE_SEGMENT_START => MessageView::SegmentStart(SegmentStart(self)),
} else if type_ == ffi::GST_MESSAGE_CLOCK_LOST { ffi::GST_MESSAGE_SEGMENT_DONE => MessageView::SegmentDone(SegmentDone(self)),
MessageView::ClockLost(ClockLost(self)) ffi::GST_MESSAGE_DURATION_CHANGED => {
} else if type_ == ffi::GST_MESSAGE_NEW_CLOCK { MessageView::DurationChanged(DurationChanged(self))
MessageView::NewClock(NewClock(self)) }
} else if type_ == ffi::GST_MESSAGE_STRUCTURE_CHANGE { ffi::GST_MESSAGE_LATENCY => MessageView::Latency(Latency(self)),
MessageView::StructureChange(StructureChange(self)) ffi::GST_MESSAGE_ASYNC_START => MessageView::AsyncStart(AsyncStart(self)),
} else if type_ == ffi::GST_MESSAGE_STREAM_STATUS { ffi::GST_MESSAGE_ASYNC_DONE => MessageView::AsyncDone(AsyncDone(self)),
MessageView::StreamStatus(StreamStatus(self)) ffi::GST_MESSAGE_REQUEST_STATE => MessageView::RequestState(RequestState(self)),
} else if type_ == ffi::GST_MESSAGE_APPLICATION { ffi::GST_MESSAGE_STEP_START => MessageView::StepStart(StepStart(self)),
MessageView::Application(Application(self)) ffi::GST_MESSAGE_QOS => MessageView::Qos(Qos(self)),
} else if type_ == ffi::GST_MESSAGE_ELEMENT { ffi::GST_MESSAGE_PROGRESS => MessageView::Progress(Progress(self)),
MessageView::Element(Element(self)) ffi::GST_MESSAGE_TOC => MessageView::Toc(Toc(self)),
} else if type_ == ffi::GST_MESSAGE_SEGMENT_START { ffi::GST_MESSAGE_RESET_TIME => MessageView::ResetTime(ResetTime(self)),
MessageView::SegmentStart(SegmentStart(self)) ffi::GST_MESSAGE_STREAM_START => MessageView::StreamStart(StreamStart(self)),
} else if type_ == ffi::GST_MESSAGE_SEGMENT_DONE { ffi::GST_MESSAGE_NEED_CONTEXT => MessageView::NeedContext(NeedContext(self)),
MessageView::SegmentDone(SegmentDone(self)) ffi::GST_MESSAGE_HAVE_CONTEXT => MessageView::HaveContext(HaveContext(self)),
} else if type_ == ffi::GST_MESSAGE_DURATION_CHANGED { ffi::GST_MESSAGE_DEVICE_ADDED => MessageView::DeviceAdded(DeviceAdded(self)),
MessageView::DurationChanged(DurationChanged(self)) ffi::GST_MESSAGE_DEVICE_REMOVED => MessageView::DeviceRemoved(DeviceRemoved(self)),
} else if type_ == ffi::GST_MESSAGE_LATENCY { ffi::GST_MESSAGE_PROPERTY_NOTIFY => MessageView::PropertyNotify(PropertyNotify(self)),
MessageView::Latency(Latency(self)) ffi::GST_MESSAGE_STREAM_COLLECTION => {
} else if type_ == ffi::GST_MESSAGE_ASYNC_START { MessageView::StreamCollection(StreamCollection(self))
MessageView::AsyncStart(AsyncStart(self)) }
} else if type_ == ffi::GST_MESSAGE_ASYNC_DONE { ffi::GST_MESSAGE_STREAMS_SELECTED => {
MessageView::AsyncDone(AsyncDone(self)) MessageView::StreamsSelected(StreamsSelected(self))
} else if type_ == ffi::GST_MESSAGE_REQUEST_STATE { }
MessageView::RequestState(RequestState(self)) _ => MessageView::Other,
} else if type_ == ffi::GST_MESSAGE_STEP_START {
MessageView::StepStart(StepStart(self))
} else if type_ == ffi::GST_MESSAGE_QOS {
MessageView::Qos(Qos(self))
} else if type_ == ffi::GST_MESSAGE_PROGRESS {
MessageView::Progress(Progress(self))
} else if type_ == ffi::GST_MESSAGE_TOC {
MessageView::Toc(Toc(self))
} else if type_ == ffi::GST_MESSAGE_RESET_TIME {
MessageView::ResetTime(ResetTime(self))
} else if type_ == ffi::GST_MESSAGE_STREAM_START {
MessageView::StreamStart(StreamStart(self))
} else if type_ == ffi::GST_MESSAGE_NEED_CONTEXT {
MessageView::NeedContext(NeedContext(self))
} else if type_ == ffi::GST_MESSAGE_HAVE_CONTEXT {
MessageView::HaveContext(HaveContext(self))
} else if type_ == ffi::GST_MESSAGE_DEVICE_ADDED {
MessageView::DeviceAdded(DeviceAdded(self))
} else if type_ == ffi::GST_MESSAGE_DEVICE_REMOVED {
MessageView::DeviceRemoved(DeviceRemoved(self))
} else if type_ == ffi::GST_MESSAGE_PROPERTY_NOTIFY {
MessageView::PropertyNotify(PropertyNotify(self))
} else if type_ == ffi::GST_MESSAGE_STREAM_COLLECTION {
MessageView::StreamCollection(StreamCollection(self))
} else if type_ == ffi::GST_MESSAGE_STREAMS_SELECTED {
MessageView::StreamsSelected(StreamsSelected(self))
} else {
MessageView::Other
} }
} }
} }
@ -1181,8 +1153,7 @@ pub struct ErrorBuilder<'a> {
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
#[allow(unused)] #[allow(unused)] details: Option<Structure>,
details: Option<Structure>,
} }
impl<'a> ErrorBuilder<'a> { impl<'a> ErrorBuilder<'a> {
fn new(error: &'a glib::Error) -> Self { fn new(error: &'a glib::Error) -> Self {
@ -1242,8 +1213,7 @@ pub struct WarningBuilder<'a> {
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
#[allow(unused)] #[allow(unused)] details: Option<Structure>,
details: Option<Structure>,
} }
impl<'a> WarningBuilder<'a> { impl<'a> WarningBuilder<'a> {
fn new(error: &'a glib::Error) -> Self { fn new(error: &'a glib::Error) -> Self {
@ -1303,8 +1273,7 @@ pub struct InfoBuilder<'a> {
seqnum: Option<u32>, seqnum: Option<u32>,
error: &'a glib::Error, error: &'a glib::Error,
debug: Option<&'a str>, debug: Option<&'a str>,
#[allow(unused)] #[allow(unused)] details: Option<Structure>,
details: Option<Structure>,
} }
impl<'a> InfoBuilder<'a> { impl<'a> InfoBuilder<'a> {
fn new(error: &'a glib::Error) -> Self { fn new(error: &'a glib::Error) -> Self {
@ -1877,13 +1846,7 @@ pub struct QosBuilder {
stats: Option<(::Format, u64, u64)>, stats: Option<(::Format, u64, u64)>,
} }
impl QosBuilder { impl QosBuilder {
fn new( fn new(live: bool, running_time: u64, stream_time: u64, timestamp: u64, duration: u64) -> Self {
live: bool,
running_time: u64,
stream_time: u64,
timestamp: u64,
duration: u64,
) -> Self {
skip_assert_initialized!(); skip_assert_initialized!();
Self { Self {
src: None, src: None,
@ -2182,10 +2145,8 @@ impl<'a> StreamCollectionBuilder<'a> {
pub struct StreamsSelectedBuilder<'a> { pub struct StreamsSelectedBuilder<'a> {
src: Option<Object>, src: Option<Object>,
seqnum: Option<u32>, seqnum: Option<u32>,
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")] collection: &'a ::StreamCollection,
collection: &'a ::StreamCollection, #[cfg(feature = "v1_10")] streams: Option<&'a [&'a ::Stream]>,
#[cfg(feature = "v1_10")]
streams: Option<&'a [&'a ::Stream]>,
} }
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
impl<'a> StreamsSelectedBuilder<'a> { impl<'a> StreamsSelectedBuilder<'a> {
@ -2224,6 +2185,7 @@ pub struct RedirectBuilder<'a> {
location: &'a str, location: &'a str,
tag_list: Option<&'a TagList>, tag_list: Option<&'a TagList>,
entry_struct: Option<Structure>, entry_struct: Option<Structure>,
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
entries: Option<&'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)]>, entries: Option<&'a [(&'a str, Option<&'a TagList>, Option<&'a Structure>)]>,
} }
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]
@ -2271,7 +2233,7 @@ impl<'a> RedirectBuilder<'a> {
); );
if let Some(entries) = s.entries { if let Some(entries) = s.entries {
for &(location, tag_list, entry_struct) in entries { for &(location, tag_list, entry_struct) in entries {
let entry_struct = entry_struct.map(|s| s.clone()); let entry_struct = entry_struct.cloned();
let entry_struct_ptr = if let Some(entry_struct) = entry_struct { let entry_struct_ptr = if let Some(entry_struct) = entry_struct {
entry_struct.into_ptr() entry_struct.into_ptr()
} else { } else {

View file

@ -241,6 +241,7 @@ impl<'a, T: MiniObject + 'static> ToGlibPtrMut<'a, *mut T::GstType> for GstRc<T>
} }
impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstType> for GstRc<T> { impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstType> for GstRc<T> {
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
type Storage = (Vec<Stash<'a, *mut T::GstType, GstRc<T>>>, Option<Vec<*mut T::GstType>>); type Storage = (Vec<Stash<'a, *mut T::GstType, GstRc<T>>>, Option<Vec<*mut T::GstType>>);
fn to_glib_none_from_slice(t: &'a [GstRc<T>]) -> (*mut *mut T::GstType, Self::Storage) { fn to_glib_none_from_slice(t: &'a [GstRc<T>]) -> (*mut *mut T::GstType, Self::Storage) {
@ -284,6 +285,7 @@ impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *mut *mut T::GstT
} }
impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *const *mut T::GstType> for GstRc<T> { impl<'a, T: MiniObject + 'static> ToGlibContainerFromSlice<'a, *const *mut T::GstType> for GstRc<T> {
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
type Storage = (Vec<Stash<'a, *mut T::GstType, GstRc<T>>>, Option<Vec<*mut T::GstType>>); type Storage = (Vec<Stash<'a, *mut T::GstType, GstRc<T>>>, Option<Vec<*mut T::GstType>>);
fn to_glib_none_from_slice(t: &'a [GstRc<T>]) -> (*const *mut T::GstType, Self::Storage) { fn to_glib_none_from_slice(t: &'a [GstRc<T>]) -> (*const *mut T::GstType, Self::Storage) {

View file

@ -289,6 +289,7 @@ unsafe extern "C" fn trampoline_pad_probe(
func: gpointer, func: gpointer,
) -> ffi::GstPadProbeReturn { ) -> ffi::GstPadProbeReturn {
let _guard = CallbackGuard::new(); let _guard = CallbackGuard::new();
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
let func: &&(Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static) = let func: &&(Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static) =
transmute(func); transmute(func);
let mut data_type = None; let mut data_type = None;

View file

@ -43,3 +43,9 @@ impl ParseContext {
} }
} }
} }
impl Default for ParseContext {
fn default() -> Self {
Self::new()
}
}

View file

@ -145,44 +145,26 @@ impl QueryRef {
pub fn view(&self) -> QueryView<&Self> { pub fn view(&self) -> QueryView<&Self> {
let type_ = unsafe { (*self.as_ptr()).type_ }; let type_ = unsafe { (*self.as_ptr()).type_ };
if type_ == ffi::GST_QUERY_POSITION { match type_ {
QueryView::Position(Position(self)) ffi::GST_QUERY_POSITION => QueryView::Position(Position(self)),
} else if type_ == ffi::GST_QUERY_DURATION { ffi::GST_QUERY_DURATION => QueryView::Duration(Duration(self)),
QueryView::Duration(Duration(self)) ffi::GST_QUERY_LATENCY => QueryView::Latency(Latency(self)),
} else if type_ == ffi::GST_QUERY_LATENCY { ffi::GST_QUERY_JITTER => QueryView::Jitter(Jitter(self)),
QueryView::Latency(Latency(self)) ffi::GST_QUERY_RATE => QueryView::Rate(Rate(self)),
} else if type_ == ffi::GST_QUERY_JITTER { ffi::GST_QUERY_SEEKING => QueryView::Seeking(Seeking(self)),
QueryView::Jitter(Jitter(self)) ffi::GST_QUERY_SEGMENT => QueryView::Segment(Segment(self)),
} else if type_ == ffi::GST_QUERY_RATE { ffi::GST_QUERY_CONVERT => QueryView::Convert(Convert(self)),
QueryView::Rate(Rate(self)) ffi::GST_QUERY_FORMATS => QueryView::Formats(Formats(self)),
} else if type_ == ffi::GST_QUERY_SEEKING { ffi::GST_QUERY_BUFFERING => QueryView::Buffering(Buffering(self)),
QueryView::Seeking(Seeking(self)) ffi::GST_QUERY_CUSTOM => QueryView::Custom(Custom(self)),
} else if type_ == ffi::GST_QUERY_SEGMENT { ffi::GST_QUERY_URI => QueryView::Uri(Uri(self)),
QueryView::Segment(Segment(self)) ffi::GST_QUERY_ALLOCATION => QueryView::Allocation(Allocation(self)),
} else if type_ == ffi::GST_QUERY_CONVERT { ffi::GST_QUERY_SCHEDULING => QueryView::Scheduling(Scheduling(self)),
QueryView::Convert(Convert(self)) ffi::GST_QUERY_ACCEPT_CAPS => QueryView::AcceptCaps(AcceptCaps(self)),
} else if type_ == ffi::GST_QUERY_FORMATS { ffi::GST_QUERY_CAPS => QueryView::Caps(Caps(self)),
QueryView::Formats(Formats(self)) ffi::GST_QUERY_DRAIN => QueryView::Drain(Drain(self)),
} else if type_ == ffi::GST_QUERY_BUFFERING { ffi::GST_QUERY_CONTEXT => QueryView::Context(Context(self)),
QueryView::Buffering(Buffering(self)) _ => QueryView::Other(Other(self)),
} else if type_ == ffi::GST_QUERY_CUSTOM {
QueryView::Custom(Custom(self))
} else if type_ == ffi::GST_QUERY_URI {
QueryView::Uri(Uri(self))
} else if type_ == ffi::GST_QUERY_ALLOCATION {
QueryView::Allocation(Allocation(self))
} else if type_ == ffi::GST_QUERY_SCHEDULING {
QueryView::Scheduling(Scheduling(self))
} else if type_ == ffi::GST_QUERY_ACCEPT_CAPS {
QueryView::AcceptCaps(AcceptCaps(self))
} else if type_ == ffi::GST_QUERY_CAPS {
QueryView::Caps(Caps(self))
} else if type_ == ffi::GST_QUERY_DRAIN {
QueryView::Drain(Drain(self))
} else if type_ == ffi::GST_QUERY_CONTEXT {
QueryView::Context(Context(self))
} else {
QueryView::Other(Other(self))
} }
} }

View file

@ -51,6 +51,7 @@ impl Segment {
} }
} }
#[cfg_attr(feature = "cargo-clippy", allow(too_many_arguments))]
pub fn do_seek( pub fn do_seek(
&mut self, &mut self,
rate: f64, rate: f64,
@ -320,6 +321,12 @@ impl glib::types::StaticType for Segment {
} }
} }
impl Default for Segment {
fn default() -> Self {
Self::new()
}
}
#[doc(hidden)] #[doc(hidden)]
impl<'a> glib::value::FromValueOptional<'a> for Segment { impl<'a> glib::value::FromValueOptional<'a> for Segment {
unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> { unsafe fn from_value_optional(value: &glib::Value) -> Option<Self> {

View file

@ -244,6 +244,12 @@ impl GstRc<TagListRef> {
} }
} }
impl Default for GstRc<TagListRef> {
fn default() -> Self {
Self::new()
}
}
impl TagListRef { impl TagListRef {
pub fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode) pub fn add<'a, T: Tag<'a>>(&mut self, value: T::TagType, mode: TagMergeMode)
where where