mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-12-22 08:07:07 +00:00
Use MaybeUninit::zeroed() everywhere possible instead of mem::zeroed()
This commit is contained in:
parent
3a8d05075d
commit
424a87efbf
19 changed files with 229 additions and 202 deletions
|
@ -74,9 +74,9 @@ impl<'a> VideoFrameGLExt for VideoFrameRef<&'a gst::BufferRef> {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
|
||||
|
@ -87,7 +87,7 @@ impl<'a> VideoFrameGLExt for VideoFrameRef<&'a gst::BufferRef> {
|
|||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
Ok(VideoFrame::from_glib_full(frame))
|
||||
Ok(VideoFrame::from_glib_full(frame.assume_init()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -111,9 +111,9 @@ impl<'a> VideoFrameGLExt for VideoFrameRef<&'a gst::BufferRef> {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
|
||||
|
@ -124,7 +124,7 @@ impl<'a> VideoFrameGLExt for VideoFrameRef<&'a gst::BufferRef> {
|
|||
if !res {
|
||||
None
|
||||
} else {
|
||||
Some(VideoFrameRef::from_glib_borrow(&frame))
|
||||
Some(VideoFrameRef::from_glib_borrow(&frame.assume_init()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,13 +20,13 @@ impl SDPAttribute {
|
|||
pub fn new(key: &str, value: Option<&str>) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut attr = mem::zeroed();
|
||||
let mut attr = mem::MaybeUninit::zeroed();
|
||||
gst_sdp_sys::gst_sdp_attribute_set(
|
||||
&mut attr,
|
||||
attr.as_mut_ptr(),
|
||||
key.to_glib_none().0,
|
||||
value.to_glib_none().0,
|
||||
);
|
||||
SDPAttribute(attr)
|
||||
SDPAttribute(attr.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,9 +20,9 @@ impl SDPBandwidth {
|
|||
pub fn new(bwtype: &str, bandwidth: u32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut bw = mem::zeroed();
|
||||
gst_sdp_sys::gst_sdp_bandwidth_set(&mut bw, bwtype.to_glib_none().0, bandwidth);
|
||||
SDPBandwidth(bw)
|
||||
let mut bw = mem::MaybeUninit::zeroed();
|
||||
gst_sdp_sys::gst_sdp_bandwidth_set(bw.as_mut_ptr(), bwtype.to_glib_none().0, bandwidth);
|
||||
SDPBandwidth(bw.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,16 +20,16 @@ impl SDPConnection {
|
|||
pub fn new(nettype: &str, addrtype: &str, address: &str, ttl: u32, addr_number: u32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut conn = mem::zeroed();
|
||||
let mut conn = mem::MaybeUninit::zeroed();
|
||||
gst_sdp_sys::gst_sdp_connection_set(
|
||||
&mut conn,
|
||||
conn.as_mut_ptr(),
|
||||
nettype.to_glib_none().0,
|
||||
addrtype.to_glib_none().0,
|
||||
address.to_glib_none().0,
|
||||
ttl,
|
||||
addr_number,
|
||||
);
|
||||
SDPConnection(conn)
|
||||
SDPConnection(conn.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ impl SDPMessage {
|
|||
pub fn new() -> SDPMessage {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut msg = mem::zeroed();
|
||||
let mut msg = ptr::null_mut();
|
||||
gst_sdp_sys::gst_sdp_message_new(&mut msg);
|
||||
from_glib_full(msg)
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ impl SDPMessage {
|
|||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let size = data.len() as u32;
|
||||
let mut msg = mem::zeroed();
|
||||
let mut msg = ptr::null_mut();
|
||||
gst_sdp_sys::gst_sdp_message_new(&mut msg);
|
||||
let result =
|
||||
gst_sdp_sys::gst_sdp_message_parse_buffer(data.to_glib_none().0, size, msg);
|
||||
|
@ -106,7 +106,7 @@ impl SDPMessage {
|
|||
pub fn parse_uri(uri: &str) -> Result<Self, ()> {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut msg = mem::zeroed();
|
||||
let mut msg = ptr::null_mut();
|
||||
gst_sdp_sys::gst_sdp_message_new(&mut msg);
|
||||
let result = gst_sdp_sys::gst_sdp_message_parse_uri(uri.to_glib_none().0, msg);
|
||||
match result {
|
||||
|
|
|
@ -21,14 +21,14 @@ impl SDPTime {
|
|||
pub fn new(start: &str, stop: &str, repeat: &[&str]) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut time = mem::zeroed();
|
||||
let mut time = mem::MaybeUninit::zeroed();
|
||||
gst_sdp_sys::gst_sdp_time_set(
|
||||
&mut time,
|
||||
time.as_mut_ptr(),
|
||||
start.to_glib_none().0,
|
||||
stop.to_glib_none().0,
|
||||
repeat.to_glib_none().0,
|
||||
);
|
||||
SDPTime(time)
|
||||
SDPTime(time.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,13 +20,13 @@ impl SDPZone {
|
|||
pub fn new(time: &str, typed_time: &str) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut zone = mem::zeroed();
|
||||
let mut zone = mem::MaybeUninit::zeroed();
|
||||
gst_sdp_sys::gst_sdp_zone_set(
|
||||
&mut zone,
|
||||
zone.as_mut_ptr(),
|
||||
time.to_glib_none().0,
|
||||
typed_time.to_glib_none().0,
|
||||
);
|
||||
SDPZone(zone)
|
||||
SDPZone(zone.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -89,13 +89,13 @@ pub trait VideoBufferPoolConfig {
|
|||
impl VideoBufferPoolConfig for gst::BufferPoolConfig {
|
||||
fn get_video_alignment(&self) -> Option<VideoAlignment> {
|
||||
unsafe {
|
||||
let mut alignment: VideoAlignment = mem::zeroed();
|
||||
let mut alignment = mem::MaybeUninit::zeroed();
|
||||
let ret = from_glib(gst_video_sys::gst_buffer_pool_config_get_video_alignment(
|
||||
self.as_ref().as_mut_ptr(),
|
||||
&mut alignment.0,
|
||||
alignment.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
Some(alignment)
|
||||
Some(VideoAlignment(alignment.assume_init()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -189,9 +189,9 @@ impl VideoFrame<Readable> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_sys::GST_MAP_READ,
|
||||
|
@ -200,6 +200,7 @@ impl VideoFrame<Readable> {
|
|||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame(frame, Some(buffer), info, PhantomData))
|
||||
}
|
||||
|
@ -214,9 +215,9 @@ impl VideoFrame<Readable> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map_id(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
id,
|
||||
|
@ -226,6 +227,7 @@ impl VideoFrame<Readable> {
|
|||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame(frame, Some(buffer), info, PhantomData))
|
||||
}
|
||||
|
@ -251,9 +253,9 @@ impl VideoFrame<Writable> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
|
||||
|
@ -264,6 +266,7 @@ impl VideoFrame<Writable> {
|
|||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame(frame, Some(buffer), info, PhantomData))
|
||||
}
|
||||
|
@ -278,9 +281,9 @@ impl VideoFrame<Writable> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map_id(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.to_glib_none().0,
|
||||
id,
|
||||
|
@ -292,6 +295,7 @@ impl VideoFrame<Writable> {
|
|||
if !res {
|
||||
Err(buffer)
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Ok(VideoFrame(frame, Some(buffer), info, PhantomData))
|
||||
}
|
||||
|
@ -367,9 +371,9 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF | gst_sys::GST_MAP_READ,
|
||||
|
@ -378,6 +382,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
if !res {
|
||||
None
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Some(VideoFrameRef(frame, Some(buffer), info, false))
|
||||
}
|
||||
|
@ -392,9 +397,9 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map_id(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
id,
|
||||
|
@ -404,6 +409,7 @@ impl<'a> VideoFrameRef<&'a gst::BufferRef> {
|
|||
if !res {
|
||||
None
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Some(VideoFrameRef(frame, Some(buffer), info, false))
|
||||
}
|
||||
|
@ -558,9 +564,9 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
gst_video_sys::GST_VIDEO_FRAME_MAP_FLAG_NO_REF
|
||||
|
@ -571,6 +577,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
if !res {
|
||||
None
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Some(VideoFrameRef(frame, Some(buffer), info, false))
|
||||
}
|
||||
|
@ -585,9 +592,9 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
skip_assert_initialized!();
|
||||
|
||||
unsafe {
|
||||
let mut frame = mem::zeroed();
|
||||
let mut frame = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_video_sys::gst_video_frame_map_id(
|
||||
&mut frame,
|
||||
frame.as_mut_ptr(),
|
||||
info.to_glib_none().0 as *mut _,
|
||||
buffer.as_mut_ptr(),
|
||||
id,
|
||||
|
@ -599,6 +606,7 @@ impl<'a> VideoFrameRef<&'a mut gst::BufferRef> {
|
|||
if !res {
|
||||
None
|
||||
} else {
|
||||
let frame = frame.assume_init();
|
||||
let info = ::VideoInfo(ptr::read(&frame.info));
|
||||
Some(VideoFrameRef(frame, Some(buffer), info, false))
|
||||
}
|
||||
|
|
|
@ -118,13 +118,13 @@ impl VideoColorimetry {
|
|||
assert_initialized_main_thread!();
|
||||
|
||||
unsafe {
|
||||
let mut colorimetry = mem::zeroed();
|
||||
let mut colorimetry = mem::MaybeUninit::zeroed();
|
||||
let valid: bool = from_glib(gst_video_sys::gst_video_colorimetry_from_string(
|
||||
&mut colorimetry,
|
||||
colorimetry.as_mut_ptr(),
|
||||
s.to_glib_none().0,
|
||||
));
|
||||
if valid {
|
||||
Some(VideoColorimetry(colorimetry))
|
||||
Some(VideoColorimetry(colorimetry.assume_init()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -34,9 +34,9 @@ impl VideoTimeCode {
|
|||
pub fn new_empty() -> VideoTimeCode {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut v = mem::zeroed();
|
||||
gst_video_sys::gst_video_time_code_clear(&mut v);
|
||||
VideoTimeCode(v)
|
||||
let mut v = mem::MaybeUninit::zeroed();
|
||||
gst_video_sys::gst_video_time_code_clear(v.as_mut_ptr());
|
||||
VideoTimeCode(v.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,9 @@ impl VideoTimeCode {
|
|||
) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut v = mem::zeroed();
|
||||
let mut v = mem::MaybeUninit::zeroed();
|
||||
gst_video_sys::gst_video_time_code_init(
|
||||
&mut v,
|
||||
v.as_mut_ptr(),
|
||||
*fps.numer() as u32,
|
||||
*fps.denom() as u32,
|
||||
latest_daily_jam.to_glib_none().0,
|
||||
|
@ -67,37 +67,37 @@ impl VideoTimeCode {
|
|||
field_count,
|
||||
);
|
||||
|
||||
VideoTimeCode(v)
|
||||
VideoTimeCode(v.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
// #[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
// pub fn new_from_date_time(
|
||||
// fps: gst::Fraction,
|
||||
// dt: &glib::DateTime,
|
||||
// flags: VideoTimeCodeFlags,
|
||||
// field_count: u32,
|
||||
// ) -> Option<VideoTimeCode> {
|
||||
// assert_initialized_main_thread!();
|
||||
// assert!(fps_d > 0);
|
||||
// unsafe {
|
||||
// let mut v = mem::zeroed();
|
||||
// let res = gst_video_sys::gst_video_time_code_init_from_date_time_full(
|
||||
// &mut v,
|
||||
// *fps.numer() as u32,
|
||||
// *fps.denom() as u32,
|
||||
// dt.to_glib_none().0,
|
||||
// flags.to_glib(),
|
||||
// field_count,
|
||||
// );
|
||||
//
|
||||
// if res == glib_sys::GFALSE {
|
||||
// None
|
||||
// } else {
|
||||
// Some(VideoTimeCode(v))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
#[cfg(any(feature = "v1_16", feature = "dox"))]
|
||||
pub fn new_from_date_time(
|
||||
fps: gst::Fraction,
|
||||
dt: &glib::DateTime,
|
||||
flags: VideoTimeCodeFlags,
|
||||
field_count: u32,
|
||||
) -> Option<VideoTimeCode> {
|
||||
assert_initialized_main_thread!();
|
||||
assert!(*fps.denom() > 0);
|
||||
unsafe {
|
||||
let mut v = mem::MaybeUninit::zeroed();
|
||||
let res = gst_video_sys::gst_video_time_code_init_from_date_time_full(
|
||||
v.as_mut_ptr(),
|
||||
*fps.numer() as u32,
|
||||
*fps.denom() as u32,
|
||||
dt.to_glib_none().0,
|
||||
flags.to_glib(),
|
||||
field_count,
|
||||
);
|
||||
|
||||
if res == glib_sys::GFALSE {
|
||||
None
|
||||
} else {
|
||||
Some(VideoTimeCode(v.assume_init()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(feature = "v1_12", feature = "dox"))]
|
||||
pub fn from_string(tc_str: &str) -> Option<VideoTimeCode> {
|
||||
|
|
|
@ -34,11 +34,15 @@ impl VideoTimeCodeInterval {
|
|||
pub fn new(hours: u32, minutes: u32, seconds: u32, frames: u32) -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
unsafe {
|
||||
let mut v = mem::zeroed();
|
||||
let mut v = mem::MaybeUninit::zeroed();
|
||||
gst_video_sys::gst_video_time_code_interval_init(
|
||||
&mut v, hours, minutes, seconds, frames,
|
||||
v.as_mut_ptr(),
|
||||
hours,
|
||||
minutes,
|
||||
seconds,
|
||||
frames,
|
||||
);
|
||||
VideoTimeCodeInterval(v)
|
||||
VideoTimeCodeInterval(v.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -119,42 +119,42 @@ impl Buffer {
|
|||
}
|
||||
|
||||
pub fn into_mapped_buffer_readable(self) -> Result<MappedBuffer<Readable>, Self> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res: bool = unsafe {
|
||||
from_glib(gst_sys::gst_buffer_map(
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_sys::gst_buffer_map(
|
||||
self.as_mut_ptr(),
|
||||
&mut map_info,
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READ,
|
||||
))
|
||||
};
|
||||
if res {
|
||||
Ok(MappedBuffer {
|
||||
buffer: Some(self),
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
));
|
||||
if res {
|
||||
Ok(MappedBuffer {
|
||||
buffer: Some(self),
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_mapped_buffer_writable(self) -> Result<MappedBuffer<Writable>, Self> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res: bool = unsafe {
|
||||
from_glib(gst_sys::gst_buffer_map(
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_sys::gst_buffer_map(
|
||||
self.as_mut_ptr(),
|
||||
&mut map_info,
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READWRITE,
|
||||
))
|
||||
};
|
||||
if res {
|
||||
Ok(MappedBuffer {
|
||||
buffer: Some(self),
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
));
|
||||
if res {
|
||||
Ok(MappedBuffer {
|
||||
buffer: Some(self),
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -177,34 +177,42 @@ impl Default for Buffer {
|
|||
|
||||
impl BufferRef {
|
||||
pub fn map_readable(&self) -> Option<BufferMap<Readable>> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res = unsafe {
|
||||
gst_sys::gst_buffer_map(self.as_mut_ptr(), &mut map_info, gst_sys::GST_MAP_READ)
|
||||
};
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(BufferMap {
|
||||
buffer: self,
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res = gst_sys::gst_buffer_map(
|
||||
self.as_mut_ptr(),
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READ,
|
||||
);
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(BufferMap {
|
||||
buffer: self,
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_writable(&mut self) -> Option<BufferMap<Writable>> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res = unsafe {
|
||||
gst_sys::gst_buffer_map(self.as_mut_ptr(), &mut map_info, gst_sys::GST_MAP_READWRITE)
|
||||
};
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(BufferMap {
|
||||
buffer: self,
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res = gst_sys::gst_buffer_map(
|
||||
self.as_mut_ptr(),
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READWRITE,
|
||||
);
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(BufferMap {
|
||||
buffer: self,
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -154,14 +154,14 @@ impl BufferPoolConfig {
|
|||
pub fn get_allocator(&self) -> Option<(Option<Allocator>, AllocationParams)> {
|
||||
unsafe {
|
||||
let mut allocator = ptr::null_mut();
|
||||
let mut params = mem::zeroed();
|
||||
let mut params = mem::MaybeUninit::zeroed();
|
||||
let ret = from_glib(gst_sys::gst_buffer_pool_config_get_allocator(
|
||||
self.0.to_glib_none().0,
|
||||
&mut allocator,
|
||||
&mut params,
|
||||
params.as_mut_ptr(),
|
||||
));
|
||||
if ret {
|
||||
Some((from_glib_none(allocator), params.into()))
|
||||
Some((from_glib_none(allocator), params.assume_init().into()))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
cfg_if! {
|
||||
if #[cfg(unix)] {
|
||||
use gst_sys;
|
||||
use glib_sys;
|
||||
use glib::translate::ToGlibPtr;
|
||||
|
||||
use std::mem;
|
||||
|
@ -36,9 +35,9 @@ impl UnixBusExtManual for Bus {
|
|||
fn get_pollfd(&self) -> unix::io::RawFd {
|
||||
#[cfg(unix)]
|
||||
unsafe {
|
||||
let mut pollfd: glib_sys::GPollFD = mem::zeroed();
|
||||
gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, &mut pollfd);
|
||||
|
||||
let mut pollfd = mem::MaybeUninit::zeroed();
|
||||
gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr());
|
||||
let pollfd = pollfd.assume_init();
|
||||
pollfd.fd
|
||||
}
|
||||
|
||||
|
|
|
@ -36,9 +36,9 @@ impl WindowsBusExtManual for Bus {
|
|||
fn get_pollfd(&self) -> windows::io::RawHandle {
|
||||
#[cfg(windows)]
|
||||
unsafe {
|
||||
let mut pollfd: glib_sys::GPollFD = mem::zeroed();
|
||||
gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, &mut pollfd);
|
||||
|
||||
let mut pollfd = mem::MaybeUninit::zeroed();
|
||||
gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.assume_init());
|
||||
let pollfd = pollfd.assume_init();
|
||||
pollfd.fd as *mut _
|
||||
}
|
||||
|
||||
|
|
|
@ -128,42 +128,42 @@ impl Memory {
|
|||
}
|
||||
|
||||
pub fn into_mapped_memory_readable(self) -> Result<MappedMemory<Readable>, Self> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res: bool = unsafe {
|
||||
from_glib(gst_sys::gst_memory_map(
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_sys::gst_memory_map(
|
||||
self.as_mut_ptr(),
|
||||
&mut map_info,
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READ,
|
||||
))
|
||||
};
|
||||
if res {
|
||||
Ok(MappedMemory {
|
||||
memory: Some(self),
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
));
|
||||
if res {
|
||||
Ok(MappedMemory {
|
||||
memory: Some(self),
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn into_mapped_memory_writable(self) -> Result<MappedMemory<Writable>, Self> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res: bool = unsafe {
|
||||
from_glib(gst_sys::gst_memory_map(
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res: bool = from_glib(gst_sys::gst_memory_map(
|
||||
self.as_mut_ptr(),
|
||||
&mut map_info,
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READWRITE,
|
||||
))
|
||||
};
|
||||
if res {
|
||||
Ok(MappedMemory {
|
||||
memory: Some(self),
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
));
|
||||
if res {
|
||||
Ok(MappedMemory {
|
||||
memory: Some(self),
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
Err(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -247,34 +247,42 @@ impl MemoryRef {
|
|||
}
|
||||
|
||||
pub fn map_readable(&self) -> Option<MemoryMap<Readable>> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res = unsafe {
|
||||
gst_sys::gst_memory_map(self.as_mut_ptr(), &mut map_info, gst_sys::GST_MAP_READ)
|
||||
};
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(MemoryMap {
|
||||
memory: self,
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res = gst_sys::gst_memory_map(
|
||||
self.as_mut_ptr(),
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READ,
|
||||
);
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(MemoryMap {
|
||||
memory: self,
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_writable(&mut self) -> Option<MemoryMap<Writable>> {
|
||||
let mut map_info: gst_sys::GstMapInfo = unsafe { mem::zeroed() };
|
||||
let res = unsafe {
|
||||
gst_sys::gst_memory_map(self.as_mut_ptr(), &mut map_info, gst_sys::GST_MAP_READWRITE)
|
||||
};
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(MemoryMap {
|
||||
memory: self,
|
||||
map_info,
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
unsafe {
|
||||
let mut map_info = mem::MaybeUninit::zeroed();
|
||||
let res = gst_sys::gst_memory_map(
|
||||
self.as_mut_ptr(),
|
||||
map_info.as_mut_ptr(),
|
||||
gst_sys::GST_MAP_READWRITE,
|
||||
);
|
||||
if res == glib_sys::GTRUE {
|
||||
Some(MemoryMap {
|
||||
memory: self,
|
||||
map_info: map_info.assume_init(),
|
||||
phantom: PhantomData,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ impl<T: FormattedValue> FormattedSegment<T> {
|
|||
pub fn new() -> Self {
|
||||
assert_initialized_main_thread!();
|
||||
let segment = unsafe {
|
||||
let mut segment = mem::zeroed();
|
||||
gst_sys::gst_segment_init(&mut segment, T::get_default_format().to_glib());
|
||||
segment
|
||||
let mut segment = mem::MaybeUninit::zeroed();
|
||||
gst_sys::gst_segment_init(segment.as_mut_ptr(), T::get_default_format().to_glib());
|
||||
segment.assume_init()
|
||||
};
|
||||
FormattedSegment(segment, PhantomData)
|
||||
}
|
||||
|
|
|
@ -412,10 +412,10 @@ impl TagListRef {
|
|||
|
||||
pub fn get_generic(&self, tag_name: &str) -> Option<SendValue> {
|
||||
unsafe {
|
||||
let mut value: SendValue = mem::zeroed();
|
||||
let mut value: mem::MaybeUninit<SendValue> = mem::MaybeUninit::zeroed();
|
||||
|
||||
let found: bool = from_glib(gst_sys::gst_tag_list_copy_value(
|
||||
value.to_glib_none_mut().0,
|
||||
(*value.as_mut_ptr()).to_glib_none_mut().0,
|
||||
self.as_ptr(),
|
||||
tag_name.to_glib_none().0,
|
||||
));
|
||||
|
@ -424,7 +424,7 @@ impl TagListRef {
|
|||
return None;
|
||||
}
|
||||
|
||||
Some(value)
|
||||
Some(value.assume_init())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue