mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
Update from_glib calls and put them in unsafe blocks
This commit is contained in:
parent
959568f124
commit
fb56af8d84
27 changed files with 83 additions and 82 deletions
|
@ -25,8 +25,6 @@ use gio::prelude::*;
|
|||
|
||||
use gtk::prelude::*;
|
||||
|
||||
use gdk::prelude::*;
|
||||
|
||||
use std::env;
|
||||
|
||||
use std::os::raw::c_void;
|
||||
|
|
|
@ -82,7 +82,7 @@ impl AudioChannelPosition {
|
|||
|
||||
if valid {
|
||||
for (d, s) in positions.iter_mut().zip(positions_raw.iter()) {
|
||||
*d = from_glib(*s);
|
||||
*d = unsafe { from_glib(*s) };
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
|
@ -119,7 +119,7 @@ impl AudioChannelPosition {
|
|||
|
||||
if valid {
|
||||
for (d, s) in positions.iter_mut().zip(positions_raw.iter()) {
|
||||
*d = from_glib(*s);
|
||||
*d = unsafe { from_glib(*s) };
|
||||
}
|
||||
Ok(())
|
||||
} else {
|
||||
|
|
|
@ -21,7 +21,8 @@ pub enum AudioEndianness {
|
|||
}
|
||||
|
||||
impl FromGlib<i32> for AudioEndianness {
|
||||
fn from_glib(value: i32) -> Self {
|
||||
#[allow(unused_unsafe)]
|
||||
unsafe fn from_glib(value: i32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
|
||||
match value {
|
||||
|
@ -59,7 +60,7 @@ impl AudioFormatInfo {
|
|||
}
|
||||
|
||||
pub fn format(&self) -> crate::AudioFormat {
|
||||
from_glib(self.0.format)
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
pub fn name<'a>(&self) -> &'a str {
|
||||
|
@ -71,11 +72,11 @@ impl AudioFormatInfo {
|
|||
}
|
||||
|
||||
pub fn flags(&self) -> crate::AudioFormatFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn endianness(&self) -> AudioEndianness {
|
||||
from_glib(self.0.endianness)
|
||||
unsafe { from_glib(self.0.endianness) }
|
||||
}
|
||||
|
||||
pub fn width(&self) -> u32 {
|
||||
|
@ -87,7 +88,7 @@ impl AudioFormatInfo {
|
|||
}
|
||||
|
||||
pub fn unpack_format(&self) -> crate::AudioFormat {
|
||||
from_glib(self.0.unpack_format)
|
||||
unsafe { from_glib(self.0.unpack_format) }
|
||||
}
|
||||
|
||||
pub fn silence<'a>(&self) -> &'a [u8] {
|
||||
|
|
|
@ -243,11 +243,11 @@ impl AudioInfo {
|
|||
}
|
||||
|
||||
pub fn layout(&self) -> crate::AudioLayout {
|
||||
from_glib(self.0.layout)
|
||||
unsafe { from_glib(self.0.layout) }
|
||||
}
|
||||
|
||||
pub fn flags(&self) -> crate::AudioFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn rate(&self) -> u32 {
|
||||
|
|
|
@ -50,11 +50,11 @@ impl AudioClippingMeta {
|
|||
}
|
||||
|
||||
pub fn get_start(&self) -> gst::GenericFormattedValue {
|
||||
gst::GenericFormattedValue::new(from_glib(self.0.format), self.0.start as i64)
|
||||
unsafe { gst::GenericFormattedValue::new(from_glib(self.0.format), self.0.start as i64) }
|
||||
}
|
||||
|
||||
pub fn get_end(&self) -> gst::GenericFormattedValue {
|
||||
gst::GenericFormattedValue::new(from_glib(self.0.format), self.0.end as i64)
|
||||
unsafe { gst::GenericFormattedValue::new(from_glib(self.0.format), self.0.end as i64) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ pub struct AudioRingBufferSpec(pub(crate) GstAudioRingBufferSpec);
|
|||
|
||||
impl AudioRingBufferSpec {
|
||||
pub fn get_type(&self) -> AudioRingBufferFormatType {
|
||||
AudioRingBufferFormatType::from_glib(self.0.type_)
|
||||
unsafe { AudioRingBufferFormatType::from_glib(self.0.type_) }
|
||||
}
|
||||
|
||||
pub fn set_type(&mut self, value: AudioRingBufferFormatType) {
|
||||
|
|
|
@ -45,7 +45,7 @@ impl ToGlib for Overhead {
|
|||
|
||||
impl FromGlib<i32> for Overhead {
|
||||
#[inline]
|
||||
fn from_glib(val: i32) -> Overhead {
|
||||
unsafe fn from_glib(val: i32) -> Overhead {
|
||||
skip_assert_initialized!();
|
||||
match val {
|
||||
0 => Overhead::None,
|
||||
|
|
|
@ -264,7 +264,7 @@ pub enum VideoEndianness {
|
|||
}
|
||||
|
||||
impl FromGlib<i32> for VideoEndianness {
|
||||
fn from_glib(value: i32) -> Self {
|
||||
unsafe fn from_glib(value: i32) -> Self {
|
||||
skip_assert_initialized!();
|
||||
|
||||
match value {
|
||||
|
|
|
@ -28,7 +28,7 @@ impl VideoFormatInfo {
|
|||
}
|
||||
|
||||
pub fn format(&self) -> crate::VideoFormat {
|
||||
from_glib(self.0.format)
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
pub fn name<'a>(&self) -> &'a str {
|
||||
|
@ -40,7 +40,7 @@ impl VideoFormatInfo {
|
|||
}
|
||||
|
||||
pub fn flags(&self) -> crate::VideoFormatFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn bits(&self) -> u32 {
|
||||
|
@ -84,7 +84,7 @@ impl VideoFormatInfo {
|
|||
}
|
||||
|
||||
pub fn tile_mode(&self) -> crate::VideoTileMode {
|
||||
from_glib(self.0.tile_mode)
|
||||
unsafe { from_glib(self.0.tile_mode) }
|
||||
}
|
||||
|
||||
pub fn tile_ws(&self) -> u32 {
|
||||
|
@ -96,7 +96,7 @@ impl VideoFormatInfo {
|
|||
}
|
||||
|
||||
pub fn unpack_format(&self) -> crate::VideoFormat {
|
||||
from_glib(self.0.unpack_format)
|
||||
unsafe { from_glib(self.0.unpack_format) }
|
||||
}
|
||||
|
||||
pub fn pack_lines(&self) -> i32 {
|
||||
|
|
|
@ -45,7 +45,7 @@ impl<T> VideoFrame<T> {
|
|||
}
|
||||
|
||||
pub fn flags(&self) -> crate::VideoFrameFlags {
|
||||
from_glib(self.frame.flags)
|
||||
unsafe { from_glib(self.frame.flags) }
|
||||
}
|
||||
|
||||
pub fn id(&self) -> i32 {
|
||||
|
@ -420,7 +420,7 @@ impl<T> VideoFrameRef<T> {
|
|||
}
|
||||
|
||||
pub fn flags(&self) -> crate::VideoFrameFlags {
|
||||
from_glib(self.frame.flags)
|
||||
unsafe { from_glib(self.frame.flags) }
|
||||
}
|
||||
|
||||
pub fn id(&self) -> i32 {
|
||||
|
|
|
@ -48,7 +48,7 @@ impl ToGlib for VideoColorRange {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<ffi::GstVideoColorRange> for VideoColorRange {
|
||||
fn from_glib(value: ffi::GstVideoColorRange) -> Self {
|
||||
unsafe fn from_glib(value: ffi::GstVideoColorRange) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match value as i32 {
|
||||
0 => VideoColorRange::Unknown,
|
||||
|
@ -109,19 +109,19 @@ impl VideoColorimetry {
|
|||
}
|
||||
|
||||
pub fn range(&self) -> crate::VideoColorRange {
|
||||
from_glib(self.0.range)
|
||||
unsafe { from_glib(self.0.range) }
|
||||
}
|
||||
|
||||
pub fn matrix(&self) -> crate::VideoColorMatrix {
|
||||
from_glib(self.0.matrix)
|
||||
unsafe { from_glib(self.0.matrix) }
|
||||
}
|
||||
|
||||
pub fn transfer(&self) -> crate::VideoTransferFunction {
|
||||
from_glib(self.0.transfer)
|
||||
unsafe { from_glib(self.0.transfer) }
|
||||
}
|
||||
|
||||
pub fn primaries(&self) -> crate::VideoColorPrimaries {
|
||||
from_glib(self.0.primaries)
|
||||
unsafe { from_glib(self.0.primaries) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ impl fmt::Display for crate::VideoChromaSite {
|
|||
impl From<crate::VideoMultiviewFramePacking> for crate::VideoMultiviewMode {
|
||||
fn from(v: crate::VideoMultiviewFramePacking) -> Self {
|
||||
skip_assert_initialized!();
|
||||
from_glib(v.to_glib())
|
||||
unsafe { from_glib(v.to_glib()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ impl std::convert::TryFrom<crate::VideoMultiviewMode> for crate::VideoMultiviewF
|
|||
) -> Result<crate::VideoMultiviewFramePacking, glib::BoolError> {
|
||||
skip_assert_initialized!();
|
||||
|
||||
let v2 = from_glib(v.to_glib());
|
||||
let v2 = unsafe { from_glib(v.to_glib()) };
|
||||
|
||||
if let crate::VideoMultiviewFramePacking::__Unknown(_) = v2 {
|
||||
Err(glib::glib_bool_error!("Invalid frame packing mode"))
|
||||
|
@ -647,11 +647,11 @@ impl VideoInfo {
|
|||
}
|
||||
|
||||
pub fn interlace_mode(&self) -> crate::VideoInterlaceMode {
|
||||
from_glib(self.0.interlace_mode)
|
||||
unsafe { from_glib(self.0.interlace_mode) }
|
||||
}
|
||||
|
||||
pub fn flags(&self) -> crate::VideoFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn size(&self) -> usize {
|
||||
|
@ -663,7 +663,7 @@ impl VideoInfo {
|
|||
}
|
||||
|
||||
pub fn chroma_site(&self) -> crate::VideoChromaSite {
|
||||
from_glib(self.0.chroma_site)
|
||||
unsafe { from_glib(self.0.chroma_site) }
|
||||
}
|
||||
|
||||
pub fn colorimetry(&self) -> VideoColorimetry {
|
||||
|
|
|
@ -123,11 +123,11 @@ impl VideoMeta {
|
|||
}
|
||||
|
||||
pub fn get_flags(&self) -> crate::VideoFrameFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn get_format(&self) -> crate::VideoFormat {
|
||||
from_glib(self.0.format)
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
pub fn get_id(&self) -> i32 {
|
||||
|
@ -339,7 +339,7 @@ impl VideoRegionOfInterestMeta {
|
|||
}
|
||||
|
||||
pub fn get_roi_type<'a>(&self) -> &'a str {
|
||||
glib::Quark::from_glib(self.0.roi_type).to_string()
|
||||
unsafe { glib::Quark::from_glib(self.0.roi_type).to_string() }
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1_14")]
|
||||
|
@ -581,7 +581,7 @@ impl VideoCaptionMeta {
|
|||
}
|
||||
|
||||
pub fn get_caption_type(&self) -> crate::VideoCaptionType {
|
||||
from_glib(self.0.caption_type)
|
||||
unsafe { from_glib(self.0.caption_type) }
|
||||
}
|
||||
|
||||
pub fn get_data(&self) -> &[u8] {
|
||||
|
@ -654,11 +654,11 @@ impl VideoAFDMeta {
|
|||
}
|
||||
|
||||
pub fn get_spec(&self) -> crate::VideoAFDSpec {
|
||||
from_glib(self.0.spec)
|
||||
unsafe { from_glib(self.0.spec) }
|
||||
}
|
||||
|
||||
pub fn get_afd(&self) -> crate::VideoAFDValue {
|
||||
from_glib(self.0.afd)
|
||||
unsafe { from_glib(self.0.afd) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -726,7 +726,7 @@ impl VideoBarMeta {
|
|||
}
|
||||
|
||||
pub fn is_letterbox(&self) -> bool {
|
||||
from_glib(self.0.is_letterbox)
|
||||
unsafe { from_glib(self.0.is_letterbox) }
|
||||
}
|
||||
|
||||
pub fn get_bar_data1(&self) -> u32 {
|
||||
|
|
|
@ -272,7 +272,7 @@ macro_rules! generic_impl {
|
|||
}
|
||||
|
||||
pub fn get_flags(&self) -> VideoTimeCodeFlags {
|
||||
from_glib(self.0.config.flags)
|
||||
unsafe { from_glib(self.0.config.flags) }
|
||||
}
|
||||
|
||||
pub fn get_latest_daily_jam(&self) -> Option<glib::DateTime> {
|
||||
|
|
|
@ -20,7 +20,7 @@ unsafe impl Sync for AllocationParams {}
|
|||
|
||||
impl AllocationParams {
|
||||
pub fn get_flags(&self) -> MemoryFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn get_align(&self) -> usize {
|
||||
|
|
|
@ -346,7 +346,7 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
pub fn get_pts(&self) -> ClockTime {
|
||||
from_glib(self.0.pts)
|
||||
unsafe { from_glib(self.0.pts) }
|
||||
}
|
||||
|
||||
pub fn set_pts(&mut self, pts: ClockTime) {
|
||||
|
@ -354,7 +354,7 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
pub fn get_dts(&self) -> ClockTime {
|
||||
from_glib(self.0.dts)
|
||||
unsafe { from_glib(self.0.dts) }
|
||||
}
|
||||
|
||||
pub fn set_dts(&mut self, dts: ClockTime) {
|
||||
|
@ -371,7 +371,7 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
pub fn get_duration(&self) -> ClockTime {
|
||||
from_glib(self.0.duration)
|
||||
unsafe { from_glib(self.0.duration) }
|
||||
}
|
||||
|
||||
pub fn set_duration(&mut self, duration: ClockTime) {
|
||||
|
|
|
@ -217,19 +217,19 @@ impl BufferPoolAcquireParams {
|
|||
}
|
||||
|
||||
pub fn flags(&self) -> crate::BufferPoolAcquireFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn format(&self) -> crate::Format {
|
||||
from_glib(self.0.format)
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
pub fn start(&self) -> crate::GenericFormattedValue {
|
||||
crate::GenericFormattedValue::new(from_glib(self.0.format), self.0.start)
|
||||
unsafe { crate::GenericFormattedValue::new(from_glib(self.0.format), self.0.start) }
|
||||
}
|
||||
|
||||
pub fn stop(&self) -> crate::GenericFormattedValue {
|
||||
crate::GenericFormattedValue::new(from_glib(self.0.format), self.0.stop)
|
||||
unsafe { crate::GenericFormattedValue::new(from_glib(self.0.format), self.0.stop) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ pub struct AtomicClockReturn(AtomicI32);
|
|||
|
||||
impl AtomicClockReturn {
|
||||
pub fn load(&self) -> ClockReturn {
|
||||
from_glib(self.0.load(atomic::Ordering::SeqCst))
|
||||
unsafe { from_glib(self.0.load(atomic::Ordering::SeqCst)) }
|
||||
}
|
||||
|
||||
pub fn store(&self, val: ClockReturn) {
|
||||
|
@ -321,15 +321,17 @@ impl AtomicClockReturn {
|
|||
}
|
||||
|
||||
pub fn swap(&self, val: ClockReturn) -> ClockReturn {
|
||||
from_glib(self.0.swap(val.to_glib(), atomic::Ordering::SeqCst))
|
||||
unsafe { from_glib(self.0.swap(val.to_glib(), atomic::Ordering::SeqCst)) }
|
||||
}
|
||||
|
||||
pub fn compare_and_swap(&self, current: ClockReturn, new: ClockReturn) -> ClockReturn {
|
||||
from_glib(self.0.compare_and_swap(
|
||||
current.to_glib(),
|
||||
new.to_glib(),
|
||||
atomic::Ordering::SeqCst,
|
||||
))
|
||||
unsafe {
|
||||
from_glib(self.0.compare_and_swap(
|
||||
current.to_glib(),
|
||||
new.to_glib(),
|
||||
atomic::Ordering::SeqCst,
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -192,7 +192,7 @@ impl ToGlib for ClockTime {
|
|||
|
||||
#[doc(hidden)]
|
||||
impl FromGlib<ffi::GstClockTime> for ClockTime {
|
||||
fn from_glib(value: ffi::GstClockTime) -> Self {
|
||||
unsafe fn from_glib(value: ffi::GstClockTime) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match value {
|
||||
ffi::GST_CLOCK_TIME_NONE => ClockTime(None),
|
||||
|
@ -205,7 +205,7 @@ impl FromGlib<ffi::GstClockTime> for ClockTime {
|
|||
impl<'a> glib::value::FromValueOptional<'a> for ClockTime {
|
||||
unsafe fn from_value_optional(value: &'a glib::Value) -> Option<Self> {
|
||||
<u64 as glib::value::FromValueOptional>::from_value_optional(value)
|
||||
.map(ClockTime::from_glib)
|
||||
.map(|x| ClockTime::from_glib(x))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ impl TryFrom<DateTimeVariants> for Date {
|
|||
skip_assert_initialized!();
|
||||
match dt_variant {
|
||||
DateTimeVariants::YMD(y, m, d) => {
|
||||
let month = glib::DateMonth::from_glib(m);
|
||||
let month = unsafe { glib::DateMonth::from_glib(m) };
|
||||
if let glib::DateMonth::__Unknown(_) = month {
|
||||
return Err(glib::glib_bool_error!("Out of range `month` for `Date`"));
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ impl ToGlib for DeviceMonitorFilterId {
|
|||
}
|
||||
|
||||
impl FromGlib<libc::c_uint> for DeviceMonitorFilterId {
|
||||
fn from_glib(val: libc::c_uint) -> DeviceMonitorFilterId {
|
||||
unsafe fn from_glib(val: libc::c_uint) -> DeviceMonitorFilterId {
|
||||
skip_assert_initialized!();
|
||||
assert_ne!(val, 0);
|
||||
DeviceMonitorFilterId(unsafe { NonZeroU32::new_unchecked(val) })
|
||||
DeviceMonitorFilterId(NonZeroU32::new_unchecked(val))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ impl<O: IsA<DeviceMonitor>> DeviceMonitorExtManual for O {
|
|||
if id == 0 {
|
||||
None
|
||||
} else {
|
||||
Some(from_glib(id))
|
||||
Some(unsafe { from_glib(id) })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,10 +121,10 @@ impl ToGlib for NotifyWatchId {
|
|||
}
|
||||
|
||||
impl FromGlib<libc::c_ulong> for NotifyWatchId {
|
||||
fn from_glib(val: libc::c_ulong) -> NotifyWatchId {
|
||||
unsafe fn from_glib(val: libc::c_ulong) -> NotifyWatchId {
|
||||
skip_assert_initialized!();
|
||||
assert_ne!(val, 0);
|
||||
NotifyWatchId(unsafe { NonZeroU64::new_unchecked(val as u64) })
|
||||
NotifyWatchId(NonZeroU64::new_unchecked(val as u64))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -377,14 +377,14 @@ impl ops::Add<u32> for crate::TypeFindProbability {
|
|||
|
||||
fn add(self, rhs: u32) -> crate::TypeFindProbability {
|
||||
let res = (self.to_glib() as u32).saturating_add(rhs);
|
||||
from_glib(res as i32)
|
||||
unsafe { from_glib(res as i32) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::AddAssign<u32> for crate::TypeFindProbability {
|
||||
fn add_assign(&mut self, rhs: u32) {
|
||||
let res = (self.to_glib() as u32).saturating_add(rhs);
|
||||
*self = from_glib(res as i32);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -393,14 +393,14 @@ impl ops::Sub<u32> for crate::TypeFindProbability {
|
|||
|
||||
fn sub(self, rhs: u32) -> crate::TypeFindProbability {
|
||||
let res = (self.to_glib() as u32).saturating_sub(rhs);
|
||||
from_glib(res as i32)
|
||||
unsafe { from_glib(res as i32) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::SubAssign<u32> for crate::TypeFindProbability {
|
||||
fn sub_assign(&mut self, rhs: u32) {
|
||||
let res = (self.to_glib() as u32).saturating_sub(rhs);
|
||||
*self = from_glib(res as i32);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -429,14 +429,14 @@ impl ops::Add<u32> for crate::Rank {
|
|||
|
||||
fn add(self, rhs: u32) -> crate::Rank {
|
||||
let res = (self.to_glib() as u32).saturating_add(rhs);
|
||||
from_glib(res as i32)
|
||||
unsafe { from_glib(res as i32) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::AddAssign<u32> for crate::Rank {
|
||||
fn add_assign(&mut self, rhs: u32) {
|
||||
let res = (self.to_glib() as u32).saturating_add(rhs);
|
||||
*self = from_glib(res as i32);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,14 +445,14 @@ impl ops::Sub<u32> for crate::Rank {
|
|||
|
||||
fn sub(self, rhs: u32) -> crate::Rank {
|
||||
let res = (self.to_glib() as u32).saturating_sub(rhs);
|
||||
from_glib(res as i32)
|
||||
unsafe { from_glib(res as i32) }
|
||||
}
|
||||
}
|
||||
|
||||
impl ops::SubAssign<u32> for crate::Rank {
|
||||
fn sub_assign(&mut self, rhs: u32) {
|
||||
let res = (self.to_glib() as u32).saturating_sub(rhs);
|
||||
*self = from_glib(res as i32);
|
||||
*self = unsafe { from_glib(res as i32) };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -563,7 +563,7 @@ impl ToGlib for MessageType {
|
|||
#[doc(hidden)]
|
||||
impl FromGlib<ffi::GstMessageType> for MessageType {
|
||||
#[allow(clippy::unreadable_literal)]
|
||||
fn from_glib(value: ffi::GstMessageType) -> Self {
|
||||
unsafe fn from_glib(value: ffi::GstMessageType) -> Self {
|
||||
skip_assert_initialized!();
|
||||
match value {
|
||||
0 => MessageType::Unknown,
|
||||
|
@ -641,7 +641,7 @@ impl State {
|
|||
|
||||
let sign = (pending - current).signum();
|
||||
|
||||
from_glib(current + sign)
|
||||
unsafe { from_glib(current + sign) }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -650,7 +650,7 @@ impl StateChange {
|
|||
skip_assert_initialized!();
|
||||
let current = current.to_glib();
|
||||
let next = next.to_glib();
|
||||
from_glib((current << 3) | next)
|
||||
unsafe { from_glib((current << 3) | next) }
|
||||
}
|
||||
|
||||
pub fn current(self) -> State {
|
||||
|
|
|
@ -91,7 +91,7 @@ impl DebugCategory {
|
|||
}
|
||||
|
||||
pub fn get_threshold(self) -> crate::DebugLevel {
|
||||
from_glib(unsafe { ffi::gst_debug_category_get_threshold(self.0.as_ptr()) })
|
||||
unsafe { from_glib(ffi::gst_debug_category_get_threshold(self.0.as_ptr())) }
|
||||
}
|
||||
|
||||
pub fn set_threshold(self, threshold: crate::DebugLevel) {
|
||||
|
|
|
@ -203,7 +203,7 @@ impl MemoryRef {
|
|||
}
|
||||
|
||||
pub fn get_flags(&self) -> MemoryFlags {
|
||||
from_glib(self.0.mini_object.flags)
|
||||
unsafe { from_glib(self.0.mini_object.flags) }
|
||||
}
|
||||
|
||||
pub fn copy_part(&self, offset: isize, size: Option<usize>) -> Memory {
|
||||
|
|
|
@ -387,11 +387,11 @@ impl ReferenceTimestampMeta {
|
|||
}
|
||||
|
||||
pub fn get_timestamp(&self) -> ClockTime {
|
||||
from_glib(self.0.timestamp)
|
||||
unsafe { from_glib(self.0.timestamp) }
|
||||
}
|
||||
|
||||
pub fn get_duration(&self) -> ClockTime {
|
||||
from_glib(self.0.duration)
|
||||
unsafe { from_glib(self.0.duration) }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,10 +53,10 @@ impl ToGlib for PadProbeId {
|
|||
}
|
||||
|
||||
impl FromGlib<libc::c_ulong> for PadProbeId {
|
||||
fn from_glib(val: libc::c_ulong) -> PadProbeId {
|
||||
unsafe fn from_glib(val: libc::c_ulong) -> PadProbeId {
|
||||
skip_assert_initialized!();
|
||||
assert_ne!(val, 0);
|
||||
PadProbeId(unsafe { NonZeroU64::new_unchecked(val as u64) })
|
||||
PadProbeId(NonZeroU64::new_unchecked(val as u64))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
pub fn get_flags(&self) -> crate::SegmentFlags {
|
||||
from_glib(self.0.flags)
|
||||
unsafe { from_glib(self.0.flags) }
|
||||
}
|
||||
|
||||
pub fn set_flags(&mut self, flags: crate::SegmentFlags) {
|
||||
|
@ -392,7 +392,7 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
|||
}
|
||||
|
||||
pub fn get_format(&self) -> Format {
|
||||
from_glib(self.0.format)
|
||||
unsafe { from_glib(self.0.format) }
|
||||
}
|
||||
|
||||
pub fn get_base(&self) -> T {
|
||||
|
|
Loading…
Reference in a new issue