mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-26 11:31:06 +00:00
gstreamer: Fix some clippy::use_self warnings
This commit is contained in:
parent
41f8d00620
commit
1eb0c483fe
3 changed files with 25 additions and 30 deletions
|
@ -78,55 +78,53 @@ impl GenericFormattedValue {
|
||||||
pub fn new(format: Format, value: i64) -> Self {
|
pub fn new(format: Format, value: i64) -> Self {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
match format {
|
match format {
|
||||||
Format::Undefined => GenericFormattedValue::Undefined(Undefined(value)),
|
Format::Undefined => Self::Undefined(Undefined(value)),
|
||||||
Format::Default => GenericFormattedValue::Default(if value == -1 {
|
Format::Default => Self::Default(if value == -1 {
|
||||||
Default(None)
|
Default(None)
|
||||||
} else {
|
} else {
|
||||||
Default(Some(value as u64))
|
Default(Some(value as u64))
|
||||||
}),
|
}),
|
||||||
Format::Bytes => GenericFormattedValue::Bytes(if value == -1 {
|
Format::Bytes => Self::Bytes(if value == -1 {
|
||||||
Bytes(None)
|
Bytes(None)
|
||||||
} else {
|
} else {
|
||||||
Bytes(Some(value as u64))
|
Bytes(Some(value as u64))
|
||||||
}),
|
}),
|
||||||
Format::Time => GenericFormattedValue::Time(if value == -1 {
|
Format::Time => Self::Time(if value == -1 {
|
||||||
ClockTime::none()
|
ClockTime::none()
|
||||||
} else {
|
} else {
|
||||||
ClockTime::from_nseconds(value as u64)
|
ClockTime::from_nseconds(value as u64)
|
||||||
}),
|
}),
|
||||||
Format::Buffers => GenericFormattedValue::Buffers(if value == -1 {
|
Format::Buffers => Self::Buffers(if value == -1 {
|
||||||
Buffers(None)
|
Buffers(None)
|
||||||
} else {
|
} else {
|
||||||
Buffers(Some(value as u64))
|
Buffers(Some(value as u64))
|
||||||
}),
|
}),
|
||||||
Format::Percent => {
|
Format::Percent => Self::Percent(unsafe { Percent::from_raw(format, value) }),
|
||||||
GenericFormattedValue::Percent(unsafe { Percent::from_raw(format, value) })
|
Format::__Unknown(_) => Self::Other(format, value),
|
||||||
}
|
|
||||||
Format::__Unknown(_) => GenericFormattedValue::Other(format, value),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn format(&self) -> Format {
|
pub fn format(&self) -> Format {
|
||||||
match *self {
|
match *self {
|
||||||
GenericFormattedValue::Undefined(_) => Format::Undefined,
|
Self::Undefined(_) => Format::Undefined,
|
||||||
GenericFormattedValue::Default(_) => Format::Default,
|
Self::Default(_) => Format::Default,
|
||||||
GenericFormattedValue::Bytes(_) => Format::Bytes,
|
Self::Bytes(_) => Format::Bytes,
|
||||||
GenericFormattedValue::Time(_) => Format::Time,
|
Self::Time(_) => Format::Time,
|
||||||
GenericFormattedValue::Buffers(_) => Format::Buffers,
|
Self::Buffers(_) => Format::Buffers,
|
||||||
GenericFormattedValue::Percent(_) => Format::Percent,
|
Self::Percent(_) => Format::Percent,
|
||||||
GenericFormattedValue::Other(f, _) => f,
|
Self::Other(f, _) => f,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn value(&self) -> i64 {
|
pub fn value(&self) -> i64 {
|
||||||
match *self {
|
match *self {
|
||||||
GenericFormattedValue::Undefined(v) => v.0,
|
Self::Undefined(v) => v.0,
|
||||||
GenericFormattedValue::Default(v) => v.map(|v| v as i64).unwrap_or(-1),
|
Self::Default(v) => v.map(|v| v as i64).unwrap_or(-1),
|
||||||
GenericFormattedValue::Bytes(v) => v.map(|v| v as i64).unwrap_or(-1),
|
Self::Bytes(v) => v.map(|v| v as i64).unwrap_or(-1),
|
||||||
GenericFormattedValue::Time(v) => v.map(|v| v as i64).unwrap_or(-1),
|
Self::Time(v) => v.map(|v| v as i64).unwrap_or(-1),
|
||||||
GenericFormattedValue::Buffers(v) => v.map(|v| v as i64).unwrap_or(-1),
|
Self::Buffers(v) => v.map(|v| v as i64).unwrap_or(-1),
|
||||||
GenericFormattedValue::Percent(v) => v.map(i64::from).unwrap_or(-1),
|
Self::Percent(v) => v.map(i64::from).unwrap_or(-1),
|
||||||
GenericFormattedValue::Other(_, v) => v,
|
Self::Other(_, v) => v,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -344,9 +344,9 @@ impl<T: ElementImpl> ElementImplExt for T {
|
||||||
) -> R {
|
) -> R {
|
||||||
unsafe {
|
unsafe {
|
||||||
let wrap = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
|
let wrap = parent.as_ref().unwrap().downcast_ref::<Element>().unwrap();
|
||||||
assert!(wrap.type_().is_a(T::type_()));
|
assert!(wrap.type_().is_a(Self::type_()));
|
||||||
let ptr: *mut ffi::GstElement = wrap.to_glib_none().0;
|
let ptr: *mut ffi::GstElement = wrap.to_glib_none().0;
|
||||||
let instance = &*(ptr as *mut T::Instance);
|
let instance = &*(ptr as *mut Self::Instance);
|
||||||
let imp = instance.impl_();
|
let imp = instance.impl_();
|
||||||
|
|
||||||
panic_to_error!(wrap, &imp.panicked(), fallback(), {
|
panic_to_error!(wrap, &imp.panicked(), fallback(), {
|
||||||
|
@ -399,10 +399,7 @@ unsafe impl<T: ElementImpl> IsSubclassable<T> for Element {
|
||||||
fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
|
fn instance_init(instance: &mut glib::subclass::InitializingObject<T>) {
|
||||||
<glib::Object as IsSubclassable<T>>::instance_init(instance);
|
<glib::Object as IsSubclassable<T>>::instance_init(instance);
|
||||||
|
|
||||||
instance.set_instance_data(
|
instance.set_instance_data(Self::static_type(), atomic::AtomicBool::new(false));
|
||||||
crate::Element::static_type(),
|
|
||||||
atomic::AtomicBool::new(false),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@ unsafe impl<T: URIHandlerImpl> IsImplementable<T> for URIHandler {
|
||||||
let protocols = protocols.to_glib_full();
|
let protocols = protocols.to_glib_full();
|
||||||
let data = data.as_mut();
|
let data = data.as_mut();
|
||||||
|
|
||||||
data.set_class_data(URIHandler::static_type(), CStrV(protocols));
|
data.set_class_data(Self::static_type(), CStrV(protocols));
|
||||||
}
|
}
|
||||||
|
|
||||||
iface.get_type = Some(uri_handler_get_type::<T>);
|
iface.get_type = Some(uri_handler_get_type::<T>);
|
||||||
|
|
Loading…
Reference in a new issue