From 7754b8dd70afb7b6a657a163717aff2ee329258c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 27 Jun 2022 10:07:12 +0300 Subject: [PATCH] allocators: Reduce number of initialization check macros --- gstreamer-allocators/src/dma_buf_allocator.rs | 4 ++-- gstreamer-allocators/src/fd_allocator.rs | 2 +- gstreamer-allocators/src/lib.rs | 9 +-------- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/gstreamer-allocators/src/dma_buf_allocator.rs b/gstreamer-allocators/src/dma_buf_allocator.rs index 8a40614b9..af115d646 100644 --- a/gstreamer-allocators/src/dma_buf_allocator.rs +++ b/gstreamer-allocators/src/dma_buf_allocator.rs @@ -46,7 +46,7 @@ impl DmaBufMemoryRef { impl DmaBufAllocator { #[doc(alias = "gst_dmabuf_allocator_alloc")] pub unsafe fn alloc(&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::().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::().to_glib_none().0, fd, diff --git a/gstreamer-allocators/src/fd_allocator.rs b/gstreamer-allocators/src/fd_allocator.rs index 63f53cb6b..72d4207a5 100644 --- a/gstreamer-allocators/src/fd_allocator.rs +++ b/gstreamer-allocators/src/fd_allocator.rs @@ -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::().to_glib_none().0, fd, diff --git a/gstreamer-allocators/src/lib.rs b/gstreamer-allocators/src/lib.rs index 9feae2a5d..8f42f72f1 100644 --- a/gstreamer-allocators/src/lib.rs +++ b/gstreamer-allocators/src/lib.rs @@ -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 { () => {}; }