mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-02 01:43:49 +00:00
gstreamer: Use from_glib_ptr_borrow()
instead of manual pointer operations
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1749>
This commit is contained in:
parent
04c524a20b
commit
b96e0438ae
4 changed files with 8 additions and 11 deletions
|
@ -8,7 +8,7 @@ use std::{
|
|||
ptr, slice,
|
||||
};
|
||||
|
||||
use glib::translate::*;
|
||||
use glib::{prelude::*, translate::*};
|
||||
|
||||
use crate::{ffi, AllocationParams, Allocator, MemoryFlags};
|
||||
|
||||
|
@ -126,7 +126,7 @@ impl MemoryRef {
|
|||
if self.0.allocator.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&*(&self.0.allocator as *const *mut ffi::GstAllocator as *const Allocator))
|
||||
Some(Allocator::from_glib_ptr_borrow(&self.0.allocator))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -970,7 +970,7 @@ impl MemoryRefTrace {
|
|||
if self.0.allocator.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&*(&self.0.allocator as *const *mut ffi::GstAllocator as *const Allocator))
|
||||
Some(Allocator::from_glib_ptr_borrow(&self.0.allocator))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ impl MessageRef {
|
|||
if (*self.as_ptr()).src.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(&*(&(*self.as_ptr()).src as *const *mut ffi::GstObject as *const Object))
|
||||
Some(Object::from_glib_ptr_borrow(&(*self.as_ptr()).src))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ impl PadTemplate {
|
|||
pub fn caps(&self) -> &Caps {
|
||||
unsafe {
|
||||
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||
&*(&templ.caps as *const *mut ffi::GstCaps as *const Caps)
|
||||
Caps::from_glib_ptr_borrow(&templ.caps)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,9 +41,9 @@ impl PadTemplate {
|
|||
unsafe {
|
||||
let templ = &*(self.as_ptr() as *const ffi::GstPadTemplate);
|
||||
if !templ.ABI.abi.documentation_caps.is_null() {
|
||||
&*(&templ.ABI.abi.documentation_caps as *const *mut ffi::GstCaps as *const Caps)
|
||||
Caps::from_glib_ptr_borrow(&templ.ABI.abi.documentation_caps)
|
||||
} else {
|
||||
&*(&templ.caps as *const *mut ffi::GstCaps as *const Caps)
|
||||
self.caps()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -277,10 +277,7 @@ impl ParamSpecArray {
|
|||
if (*ptr).element_spec.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(
|
||||
&*(&(*ptr).element_spec as *const *mut glib::gobject_ffi::GParamSpec
|
||||
as *const glib::ParamSpec),
|
||||
)
|
||||
Some(glib::ParamSpec::from_glib_ptr_borrow(&(*ptr).element_spec))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue