mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 11:01:10 +00:00
Simplify various raw pointer casts everywhere
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1353>
This commit is contained in:
parent
897c7dfd39
commit
ca8309a5dd
15 changed files with 36 additions and 50 deletions
|
@ -180,7 +180,7 @@ impl AudioMeta {
|
|||
#[doc(alias = "get_info")]
|
||||
#[inline]
|
||||
pub fn info(&self) -> crate::AudioInfo {
|
||||
unsafe { from_glib_none(&self.0.info as *const _ as *mut ffi::GstAudioInfo) }
|
||||
unsafe { from_glib_none(&self.0.info as *const _) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_samples")]
|
||||
|
|
|
@ -31,7 +31,7 @@ impl AudioRingBufferSpec {
|
|||
#[doc(alias = "get_audio_info")]
|
||||
#[inline]
|
||||
pub fn audio_info(&self) -> AudioInfo {
|
||||
unsafe { AudioInfo::from_glib_none(mut_override(&self.0.info)) }
|
||||
unsafe { AudioInfo::from_glib_none(&self.0.info as *const ffi::GstAudioInfo) }
|
||||
}
|
||||
|
||||
#[doc(alias = "get_latency_time")]
|
||||
|
|
|
@ -135,7 +135,7 @@ pub trait AudioSinkImplExt: sealed::Sealed + ObjectSubclass {
|
|||
Some(f) => f,
|
||||
None => return Ok(-1),
|
||||
};
|
||||
let buffer_ptr = buffer.as_ptr() as *const _ as *mut _;
|
||||
let buffer_ptr = buffer.as_ptr() as glib::ffi::gpointer;
|
||||
let ret = f(
|
||||
self.obj().unsafe_cast_ref::<AudioSink>().to_glib_none().0,
|
||||
buffer_ptr,
|
||||
|
|
|
@ -40,7 +40,7 @@ impl GLSyncMeta {
|
|||
pub fn set_sync_point(&self, context: &impl IsA<GLContext>) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_set_sync_point(
|
||||
&self.0 as *const _ as *mut _,
|
||||
mut_override(&self.0),
|
||||
context.as_ref().to_glib_none().0,
|
||||
);
|
||||
}
|
||||
|
@ -49,10 +49,7 @@ impl GLSyncMeta {
|
|||
#[doc(alias = "gst_gl_sync_meta_wait")]
|
||||
pub fn wait(&self, context: &impl IsA<GLContext>) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_wait(
|
||||
&self.0 as *const _ as *mut _,
|
||||
context.as_ref().to_glib_none().0,
|
||||
);
|
||||
ffi::gst_gl_sync_meta_wait(mut_override(&self.0), context.as_ref().to_glib_none().0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,7 +57,7 @@ impl GLSyncMeta {
|
|||
pub fn wait_cpu(&self, context: &impl IsA<GLContext>) {
|
||||
unsafe {
|
||||
ffi::gst_gl_sync_meta_wait_cpu(
|
||||
&self.0 as *const _ as *mut _,
|
||||
mut_override(&self.0),
|
||||
context.as_ref().to_glib_none().0,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ pub trait VideoAggregatorImplExt: sealed::Sealed + ObjectSubclass {
|
|||
None
|
||||
} else {
|
||||
Some((
|
||||
from_glib_none(mut_override(&info as *const ffi::GstVideoInfo)),
|
||||
from_glib_none(&info as *const ffi::GstVideoInfo),
|
||||
from_glib(at_least_one_alpha),
|
||||
))
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ impl VideoBufferPoolConfig for gst::BufferPoolConfigRef {
|
|||
unsafe {
|
||||
ffi::gst_buffer_pool_config_set_video_alignment(
|
||||
self.as_mut().as_mut_ptr(),
|
||||
&align.0 as *const _ as *mut _,
|
||||
mut_override(&align.0),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -97,8 +97,7 @@ impl<'a, T: VideoCodecStateContext<'a>> VideoCodecState<'a, T> {
|
|||
#[inline]
|
||||
pub fn info(&self) -> VideoInfo {
|
||||
unsafe {
|
||||
let ptr = &((*self.as_mut_ptr()).info) as *const _ as usize as *mut _;
|
||||
VideoInfo::from_glib_none(ptr)
|
||||
VideoInfo::from_glib_none(&((*self.as_mut_ptr()).info) as *const ffi::GstVideoInfo)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -288,12 +288,11 @@ impl<O: IsA<VideoDecoder>> VideoDecoderExtManual for O {}
|
|||
impl HasStreamLock for VideoDecoder {
|
||||
fn stream_lock(&self) -> *mut glib::ffi::GRecMutex {
|
||||
let decoder_sys: *const ffi::GstVideoDecoder = self.to_glib_none().0;
|
||||
unsafe { &(*decoder_sys).stream_lock as *const _ as usize as *mut _ }
|
||||
unsafe { mut_override(&(*decoder_sys).stream_lock) }
|
||||
}
|
||||
|
||||
fn element_as_ptr(&self) -> *const gst::ffi::GstElement {
|
||||
let decoder_sys: *const ffi::GstVideoDecoder = self.to_glib_none().0;
|
||||
decoder_sys as *const gst::ffi::GstElement
|
||||
self.as_ptr() as *mut gst::ffi::GstElement
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -231,11 +231,10 @@ impl<O: IsA<VideoEncoder>> VideoEncoderExtManual for O {}
|
|||
impl HasStreamLock for VideoEncoder {
|
||||
fn stream_lock(&self) -> *mut glib::ffi::GRecMutex {
|
||||
let encoder_sys: *const ffi::GstVideoEncoder = self.to_glib_none().0;
|
||||
unsafe { &(*encoder_sys).stream_lock as *const _ as usize as *mut _ }
|
||||
unsafe { mut_override(&(*encoder_sys).stream_lock) }
|
||||
}
|
||||
|
||||
fn element_as_ptr(&self) -> *const gst::ffi::GstElement {
|
||||
let encoder_sys: *const ffi::GstVideoEncoder = self.to_glib_none().0;
|
||||
encoder_sys as *const gst::ffi::GstElement
|
||||
self.as_ptr() as *const gst::ffi::GstElement
|
||||
}
|
||||
}
|
||||
|
|
|
@ -584,7 +584,7 @@ impl VideoInfo {
|
|||
#[doc(alias = "gst_video_info_to_caps")]
|
||||
pub fn to_caps(&self) -> Result<gst::Caps, glib::error::BoolError> {
|
||||
unsafe {
|
||||
let result = from_glib_full(ffi::gst_video_info_to_caps(&self.0 as *const _ as *mut _));
|
||||
let result = from_glib_full(ffi::gst_video_info_to_caps(mut_override(&self.0)));
|
||||
match result {
|
||||
Some(c) => Ok(c),
|
||||
None => Err(glib::bool_error!("Failed to create caps from VideoInfo")),
|
||||
|
@ -802,7 +802,7 @@ impl VideoInfo {
|
|||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(ffi::gst_video_info_convert(
|
||||
&self.0 as *const _ as *mut _,
|
||||
mut_override(&self.0),
|
||||
src_val.format().into_glib(),
|
||||
src_val.into_raw_value(),
|
||||
U::default_format().into_glib(),
|
||||
|
@ -824,7 +824,7 @@ impl VideoInfo {
|
|||
unsafe {
|
||||
let mut dest_val = mem::MaybeUninit::uninit();
|
||||
if from_glib(ffi::gst_video_info_convert(
|
||||
&self.0 as *const _ as *mut _,
|
||||
mut_override(&self.0),
|
||||
src_val.format().into_glib(),
|
||||
src_val.into_raw_value(),
|
||||
dest_fmt.into_glib(),
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::{fmt, ptr};
|
||||
|
||||
use glib::translate::{from_glib, from_glib_none, FromGlib, IntoGlib, IntoGlibPtr, ToGlibPtr};
|
||||
use glib::translate::*;
|
||||
use gst::prelude::*;
|
||||
|
||||
#[repr(transparent)]
|
||||
|
@ -182,10 +182,7 @@ impl VideoMeta {
|
|||
|
||||
unsafe {
|
||||
glib::result_from_gboolean!(
|
||||
ffi::gst_video_meta_get_plane_size(
|
||||
&self.0 as *const _ as usize as *mut _,
|
||||
&mut plane_size,
|
||||
),
|
||||
ffi::gst_video_meta_get_plane_size(mut_override(&self.0), &mut plane_size,),
|
||||
"Failed to get plane size"
|
||||
)?;
|
||||
}
|
||||
|
@ -202,10 +199,7 @@ impl VideoMeta {
|
|||
|
||||
unsafe {
|
||||
glib::result_from_gboolean!(
|
||||
ffi::gst_video_meta_get_plane_height(
|
||||
&self.0 as *const _ as usize as *mut _,
|
||||
&mut plane_height,
|
||||
),
|
||||
ffi::gst_video_meta_get_plane_height(mut_override(&self.0), &mut plane_height,),
|
||||
"Failed to get plane height"
|
||||
)?;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
use std::{fmt, marker::PhantomData, mem, ops, ops::ControlFlow, ptr, slice, u64, usize};
|
||||
|
||||
use glib::translate::{
|
||||
from_glib, from_glib_full, FromGlib, FromGlibPtrFull, IntoGlib, IntoGlibPtr,
|
||||
};
|
||||
use glib::translate::*;
|
||||
|
||||
use crate::{meta::*, BufferCursor, BufferFlags, BufferRefCursor, ClockTime, Memory, MemoryRef};
|
||||
|
||||
|
@ -475,7 +473,7 @@ impl BufferRef {
|
|||
meta: *mut *mut ffi::GstMeta,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let func = user_data as *const _ as usize as *mut F;
|
||||
let func = user_data as *mut F;
|
||||
let res = (*func)(Meta::from_ptr(BufferRef::from_ptr(buffer), *meta));
|
||||
|
||||
matches!(res, ControlFlow::Continue(_)).into_glib()
|
||||
|
@ -485,9 +483,9 @@ impl BufferRef {
|
|||
let func_ptr: &F = &func;
|
||||
|
||||
from_glib(ffi::gst_buffer_foreach_meta(
|
||||
self.as_ptr() as *mut _,
|
||||
mut_override(self.as_ptr()),
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as usize as *mut _,
|
||||
func_ptr as *const _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -510,7 +508,7 @@ impl BufferRef {
|
|||
meta: *mut *mut ffi::GstMeta,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let func = user_data as *const _ as usize as *mut F;
|
||||
let func = user_data as *mut F;
|
||||
let res = (*func)(Meta::from_mut_ptr(BufferRef::from_mut_ptr(buffer), *meta));
|
||||
|
||||
let (cont, action) = match res {
|
||||
|
@ -529,9 +527,9 @@ impl BufferRef {
|
|||
let func_ptr: &F = &func;
|
||||
|
||||
from_glib(ffi::gst_buffer_foreach_meta(
|
||||
self.as_ptr() as *mut _,
|
||||
mut_override(self.as_ptr()),
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as usize as *mut _,
|
||||
func_ptr as *const _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ impl BufferListRef {
|
|||
idx: u32,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let func = user_data as *const _ as usize as *mut F;
|
||||
let func = user_data as *mut F;
|
||||
let res = (*func)(&Buffer::from_glib_borrow(*buffer), idx);
|
||||
|
||||
matches!(res, ControlFlow::Continue(_)).into_glib()
|
||||
|
@ -121,7 +121,7 @@ impl BufferListRef {
|
|||
from_glib(ffi::gst_buffer_list_foreach(
|
||||
self.as_ptr() as *mut _,
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as usize as *mut _,
|
||||
func_ptr as *const _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ impl BufferListRef {
|
|||
idx: u32,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let func = user_data as *const _ as usize as *mut F;
|
||||
let func = user_data as *mut F;
|
||||
let res = (*func)(
|
||||
Buffer::from_glib_full(ptr::replace(
|
||||
buffer as *mut *const ffi::GstBuffer,
|
||||
|
@ -170,7 +170,7 @@ impl BufferListRef {
|
|||
from_glib(ffi::gst_buffer_list_foreach(
|
||||
self.as_ptr() as *mut _,
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as usize as *mut _,
|
||||
func_ptr as *const _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ impl Registry {
|
|||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let feature = from_glib_borrow(feature);
|
||||
let callback: *mut P = user_data as *const _ as usize as *mut P;
|
||||
let callback = user_data as *mut P;
|
||||
let res = (*callback)(&feature);
|
||||
res.into_glib()
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ impl Registry {
|
|||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as usize as *mut _,
|
||||
super_callback0 as *const _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ impl Registry {
|
|||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let plugin = from_glib_borrow(plugin);
|
||||
let callback: *mut P = user_data as *const _ as usize as *mut P;
|
||||
let callback = user_data as *const _ as *mut P;
|
||||
let res = (*callback)(&plugin);
|
||||
res.into_glib()
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ impl Registry {
|
|||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as usize as *mut _,
|
||||
super_callback0 as *const _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::{fmt, ptr};
|
||||
|
||||
use glib::translate::{from_glib_full, from_glib_none, mut_override, IntoGlibPtr, ToGlibPtr};
|
||||
use glib::translate::{from_glib_full, from_glib_none, IntoGlibPtr, ToGlibPtr};
|
||||
|
||||
use crate::{
|
||||
format::FormattedValueIntrinsic, Buffer, BufferList, BufferListRef, BufferRef, Caps, CapsRef,
|
||||
|
@ -73,7 +73,7 @@ impl<'a> SampleBuilder<'a> {
|
|||
self.buffer.to_glib_none().0,
|
||||
self.caps.to_glib_none().0,
|
||||
self.segment.to_glib_none().0,
|
||||
mut_override(info),
|
||||
info,
|
||||
));
|
||||
|
||||
if let Some(buffer_list) = self.buffer_list {
|
||||
|
|
Loading…
Reference in a new issue