forked from mirrors/gstreamer-rs
allocators: Reduce number of initialization check macros
This commit is contained in:
parent
310ff531fb
commit
7754b8dd70
3 changed files with 4 additions and 11 deletions
|
@ -46,7 +46,7 @@ impl DmaBufMemoryRef {
|
||||||
impl DmaBufAllocator {
|
impl DmaBufAllocator {
|
||||||
#[doc(alias = "gst_dmabuf_allocator_alloc")]
|
#[doc(alias = "gst_dmabuf_allocator_alloc")]
|
||||||
pub unsafe fn alloc<A: IntoRawFd>(&self, fd: A, size: usize) -> gst::Memory {
|
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(
|
from_glib_full(ffi::gst_dmabuf_allocator_alloc(
|
||||||
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
||||||
fd.into_raw_fd(),
|
fd.into_raw_fd(),
|
||||||
|
@ -63,7 +63,7 @@ impl DmaBufAllocator {
|
||||||
size: usize,
|
size: usize,
|
||||||
flags: FdMemoryFlags,
|
flags: FdMemoryFlags,
|
||||||
) -> gst::Memory {
|
) -> gst::Memory {
|
||||||
assert_initialized_main_thread_unsafe!();
|
assert_initialized_main_thread!();
|
||||||
from_glib_full(ffi::gst_dmabuf_allocator_alloc_with_flags(
|
from_glib_full(ffi::gst_dmabuf_allocator_alloc_with_flags(
|
||||||
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
||||||
fd,
|
fd,
|
||||||
|
|
|
@ -48,7 +48,7 @@ impl FdMemoryRef {
|
||||||
impl FdAllocator {
|
impl FdAllocator {
|
||||||
#[doc(alias = "gst_fd_allocator_alloc")]
|
#[doc(alias = "gst_fd_allocator_alloc")]
|
||||||
pub unsafe fn alloc(&self, fd: RawFd, size: usize, flags: FdMemoryFlags) -> gst::Memory {
|
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(
|
from_glib_full(ffi::gst_fd_allocator_alloc(
|
||||||
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
self.unsafe_cast_ref::<gst::Allocator>().to_glib_none().0,
|
||||||
fd,
|
fd,
|
||||||
|
|
|
@ -11,20 +11,13 @@ pub use gst;
|
||||||
|
|
||||||
macro_rules! assert_initialized_main_thread {
|
macro_rules! assert_initialized_main_thread {
|
||||||
() => {
|
() => {
|
||||||
|
#[allow(unused_unsafe)]
|
||||||
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
|
if unsafe { gst::ffi::gst_is_initialized() } != glib::ffi::GTRUE {
|
||||||
panic!("GStreamer has not been initialized. Call `gst::init` first.");
|
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 {
|
macro_rules! skip_assert_initialized {
|
||||||
() => {};
|
() => {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue