allocators: Reduce number of initialization check macros

This commit is contained in:
Sebastian Dröge 2022-06-27 10:07:12 +03:00
parent 310ff531fb
commit 7754b8dd70
3 changed files with 4 additions and 11 deletions

View file

@ -46,7 +46,7 @@ impl DmaBufMemoryRef {
impl DmaBufAllocator {
#[doc(alias = "gst_dmabuf_allocator_alloc")]
pub unsafe fn alloc<A: IntoRawFd>(&self, fd: A, size: usize) -> gst::Memory {
assert_initialized_main_thread_unsafe!();
assert_initialized_main_thread!();
from_glib_full(ffi::gst_dmabuf_allocator_alloc(
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
fd.into_raw_fd(),
@ -63,7 +63,7 @@ impl DmaBufAllocator {
size: usize,
flags: FdMemoryFlags,
) -> gst::Memory {
assert_initialized_main_thread_unsafe!();
assert_initialized_main_thread!();
from_glib_full(ffi::gst_dmabuf_allocator_alloc_with_flags(
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
fd,

View file

@ -48,7 +48,7 @@ impl FdMemoryRef {
impl FdAllocator {
#[doc(alias = "gst_fd_allocator_alloc")]
pub unsafe fn alloc(&self, fd: RawFd, size: usize, flags: FdMemoryFlags) -> gst::Memory {
assert_initialized_main_thread_unsafe!();
assert_initialized_main_thread!();
from_glib_full(ffi::gst_fd_allocator_alloc(
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
fd,

View file

@ -11,20 +11,13 @@ pub use gst;
macro_rules! assert_initialized_main_thread {
() => {
#[allow(unused_unsafe)]
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
}
macro_rules! assert_initialized_main_thread_unsafe {
() => {
if gst::ffi::gst_is_initialized() != glib::ffi::GTRUE {
panic!("GStreamer has not been initialized. Call `gst::init` first.");
}
};
}
macro_rules! skip_assert_initialized {
() => {};
}