1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
use glib::translate::*;

use crate::{ffi, ShmAllocator};

impl ShmAllocator {
    /// Get the [`ShmAllocator`][crate::ShmAllocator] singleton previously registered with
    /// [`init_once()`][Self::init_once()].
    ///
    /// # Returns
    ///
    /// a [`gst::Allocator`][crate::gst::Allocator] or [`None`] if
    /// [`init_once()`][Self::init_once()] has not been previously called.
    #[doc(alias = "gst_shm_allocator_get")]
    pub fn get() -> Option<gst::Allocator> {
        assert_initialized_main_thread!();
        unsafe {
            ffi::gst_shm_allocator_init_once();
            from_glib_full(ffi::gst_shm_allocator_get())
        }
    }
}