From ec3a3610d34408b800d172895ab3fbbfef7e1daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 10 Nov 2023 16:41:39 +0200 Subject: [PATCH] allocator: Generate new `ShmAllocator` Part-of: --- gstreamer-allocators/Gir.toml | 12 ++++++++ gstreamer-allocators/src/auto/mod.rs | 11 +++++++ .../src/auto/shm_allocator.rs | 29 +++++++++++++++++++ gstreamer-allocators/src/lib.rs | 4 +++ gstreamer-allocators/src/shm_allocator.rs | 14 +++++++++ 5 files changed, 70 insertions(+) create mode 100644 gstreamer-allocators/src/auto/shm_allocator.rs create mode 100644 gstreamer-allocators/src/shm_allocator.rs diff --git a/gstreamer-allocators/Gir.toml b/gstreamer-allocators/Gir.toml index 1a1f504b5..d44072111 100644 --- a/gstreamer-allocators/Gir.toml +++ b/gstreamer-allocators/Gir.toml @@ -94,3 +94,15 @@ status = "generate" [[object.function]] name = "alloc" manual = true + +[[object]] +name = "GstAllocators.ShmAllocator" +status = "generate" +cfg_condition = "unix" + [[object.function]] + name = "get" + manual = true + [[object.function]] + name = "once_init" + manual = true + diff --git a/gstreamer-allocators/src/auto/mod.rs b/gstreamer-allocators/src/auto/mod.rs index 9590ddb8c..bb556d247 100644 --- a/gstreamer-allocators/src/auto/mod.rs +++ b/gstreamer-allocators/src/auto/mod.rs @@ -27,6 +27,17 @@ pub use self::fd_allocator::FdAllocator; mod phys_memory_allocator; pub use self::phys_memory_allocator::PhysMemoryAllocator; +#[cfg(unix)] +#[cfg_attr(docsrs, doc(cfg(unix)))] +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +mod shm_allocator; +#[cfg(unix)] +#[cfg_attr(docsrs, doc(cfg(unix)))] +#[cfg(feature = "v1_24")] +#[cfg_attr(docsrs, doc(cfg(feature = "v1_24")))] +pub use self::shm_allocator::ShmAllocator; + mod flags; pub use self::flags::FdMemoryFlags; diff --git a/gstreamer-allocators/src/auto/shm_allocator.rs b/gstreamer-allocators/src/auto/shm_allocator.rs new file mode 100644 index 000000000..bdf729dd0 --- /dev/null +++ b/gstreamer-allocators/src/auto/shm_allocator.rs @@ -0,0 +1,29 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// from gst-gir-files (https://gitlab.freedesktop.org/gstreamer/gir-files-rs.git) +// DO NOT EDIT + +use crate::FdAllocator; +use glib::translate::*; + +glib::wrapper! { + #[doc(alias = "GstShmAllocator")] + pub struct ShmAllocator(Object) @extends FdAllocator, gst::Allocator; + + match fn { + type_ => || ffi::gst_shm_allocator_get_type(), + } +} + +impl ShmAllocator { + #[doc(alias = "gst_shm_allocator_init_once")] + pub fn init_once() { + assert_initialized_main_thread!(); + unsafe { + ffi::gst_shm_allocator_init_once(); + } + } +} + +unsafe impl Send for ShmAllocator {} +unsafe impl Sync for ShmAllocator {} diff --git a/gstreamer-allocators/src/lib.rs b/gstreamer-allocators/src/lib.rs index 54993aa4c..cc80e99f7 100644 --- a/gstreamer-allocators/src/lib.rs +++ b/gstreamer-allocators/src/lib.rs @@ -44,6 +44,10 @@ mod drm_dumb_allocator; #[cfg_attr(docsrs, doc(cfg(all(feature = "v1_24", target_os = "linux"))))] pub use drm_dumb_allocator::*; +#[cfg(any(all(feature = "v1_24", unix), docsrs))] +#[cfg_attr(docsrs, doc(cfg(all(feature = "v1_24", unix))))] +mod shm_allocator; + mod phys_memory; pub use phys_memory::*; diff --git a/gstreamer-allocators/src/shm_allocator.rs b/gstreamer-allocators/src/shm_allocator.rs new file mode 100644 index 000000000..2ac05c9e2 --- /dev/null +++ b/gstreamer-allocators/src/shm_allocator.rs @@ -0,0 +1,14 @@ +use glib::translate::*; + +use crate::ShmAllocator; + +impl ShmAllocator { + #[doc(alias = "gst_shm_allocator_get")] + pub fn get() -> Option { + assert_initialized_main_thread!(); + unsafe { + ffi::gst_shm_allocator_init_once(); + from_glib_full(ffi::gst_shm_allocator_get()) + } + } +}