mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-02 01:43:49 +00:00
Use NonZeroU64/U32 for PadProbeId, NotifyId and DeviceMonitorFilterId
This allows for some further optimizations.
This commit is contained in:
parent
c298577139
commit
8aac047af5
3 changed files with 15 additions and 11 deletions
|
@ -15,6 +15,8 @@ use glib::translate::*;
|
||||||
|
|
||||||
use gst_sys;
|
use gst_sys;
|
||||||
|
|
||||||
|
use std::num::NonZeroU32;
|
||||||
|
|
||||||
impl DeviceMonitor {
|
impl DeviceMonitor {
|
||||||
pub fn new() -> DeviceMonitor {
|
pub fn new() -> DeviceMonitor {
|
||||||
assert_initialized_main_thread!();
|
assert_initialized_main_thread!();
|
||||||
|
@ -35,13 +37,13 @@ impl Default for DeviceMonitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct DeviceMonitorFilterId(libc::c_uint);
|
pub struct DeviceMonitorFilterId(NonZeroU32);
|
||||||
|
|
||||||
impl ToGlib for DeviceMonitorFilterId {
|
impl ToGlib for DeviceMonitorFilterId {
|
||||||
type GlibType = libc::c_uint;
|
type GlibType = libc::c_uint;
|
||||||
|
|
||||||
fn to_glib(&self) -> libc::c_uint {
|
fn to_glib(&self) -> libc::c_uint {
|
||||||
self.0
|
self.0.get()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +51,7 @@ impl FromGlib<libc::c_uint> for DeviceMonitorFilterId {
|
||||||
fn from_glib(val: libc::c_uint) -> DeviceMonitorFilterId {
|
fn from_glib(val: libc::c_uint) -> DeviceMonitorFilterId {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
assert_ne!(val, 0);
|
assert_ne!(val, 0);
|
||||||
DeviceMonitorFilterId(val)
|
DeviceMonitorFilterId(unsafe { NonZeroU32::new_unchecked(val) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ use StateChangeSuccess;
|
||||||
|
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::num::NonZeroU64;
|
||||||
|
|
||||||
use libc;
|
use libc;
|
||||||
|
|
||||||
|
@ -106,13 +107,13 @@ pub enum ElementMessageType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct NotifyWatchId(libc::c_ulong);
|
pub struct NotifyWatchId(NonZeroU64);
|
||||||
|
|
||||||
impl ToGlib for NotifyWatchId {
|
impl ToGlib for NotifyWatchId {
|
||||||
type GlibType = libc::c_ulong;
|
type GlibType = libc::c_ulong;
|
||||||
|
|
||||||
fn to_glib(&self) -> libc::c_ulong {
|
fn to_glib(&self) -> libc::c_ulong {
|
||||||
self.0
|
self.0.get() as libc::c_ulong
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +121,7 @@ impl FromGlib<libc::c_ulong> for NotifyWatchId {
|
||||||
fn from_glib(val: libc::c_ulong) -> NotifyWatchId {
|
fn from_glib(val: libc::c_ulong) -> NotifyWatchId {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
assert_ne!(val, 0);
|
assert_ne!(val, 0);
|
||||||
NotifyWatchId(val)
|
NotifyWatchId(unsafe { NonZeroU64::new_unchecked(val as u64) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +570,7 @@ impl<O: IsA<Element>> ElementExtManual for O {
|
||||||
unsafe {
|
unsafe {
|
||||||
gst_sys::gst_element_remove_property_notify_watch(
|
gst_sys::gst_element_remove_property_notify_watch(
|
||||||
self.as_ref().to_glib_none().0,
|
self.as_ref().to_glib_none().0,
|
||||||
watch_id.0,
|
watch_id.to_glib(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ use StaticPadTemplate;
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::RefCell;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
|
use std::num::NonZeroU64;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
|
|
||||||
use glib;
|
use glib;
|
||||||
|
@ -61,13 +62,13 @@ impl Pad {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct PadProbeId(libc::c_ulong);
|
pub struct PadProbeId(NonZeroU64);
|
||||||
|
|
||||||
impl ToGlib for PadProbeId {
|
impl ToGlib for PadProbeId {
|
||||||
type GlibType = libc::c_ulong;
|
type GlibType = libc::c_ulong;
|
||||||
|
|
||||||
fn to_glib(&self) -> libc::c_ulong {
|
fn to_glib(&self) -> libc::c_ulong {
|
||||||
self.0
|
self.0.get() as libc::c_ulong
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ impl FromGlib<libc::c_ulong> for PadProbeId {
|
||||||
fn from_glib(val: libc::c_ulong) -> PadProbeId {
|
fn from_glib(val: libc::c_ulong) -> PadProbeId {
|
||||||
skip_assert_initialized!();
|
skip_assert_initialized!();
|
||||||
assert_ne!(val, 0);
|
assert_ne!(val, 0);
|
||||||
PadProbeId(val)
|
PadProbeId(unsafe { NonZeroU64::new_unchecked(val as u64) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1032,7 +1033,7 @@ where
|
||||||
|
|
||||||
let mut probe_info = PadProbeInfo {
|
let mut probe_info = PadProbeInfo {
|
||||||
mask: from_glib((*info).type_),
|
mask: from_glib((*info).type_),
|
||||||
id: PadProbeId((*info).id),
|
id: PadProbeId(NonZeroU64::new_unchecked((*info).id)),
|
||||||
offset: (*info).offset,
|
offset: (*info).offset,
|
||||||
size: (*info).size,
|
size: (*info).size,
|
||||||
data: if (*info).data.is_null() {
|
data: if (*info).data.is_null() {
|
||||||
|
|
Loading…
Reference in a new issue