gstreamer_vulkan/
vulkan_queue.rs

1use crate::VulkanQueue;
2
3use glib::{prelude::*, translate::*};
4
5mod sealed {
6    pub trait Sealed {}
7    impl<T: super::IsA<super::VulkanQueue>> Sealed for T {}
8}
9
10// rustdoc-stripper-ignore-next
11/// Represents a locked vulkan queue that can be submitted too. The queue is unlock when this struct is dropped.
12#[derive(Debug)]
13pub struct VulkanQueueSubmitGuard<'a> {
14    obj: &'a VulkanQueue,
15}
16
17impl Drop for VulkanQueueSubmitGuard<'_> {
18    fn drop(&mut self) {
19        unsafe {
20            ffi::gst_vulkan_queue_submit_unlock(self.obj.to_glib_none().0);
21        }
22    }
23}
24impl PartialEq for VulkanQueueSubmitGuard<'_> {
25    fn eq(&self, other: &Self) -> bool {
26        self.obj == other.obj
27    }
28}
29impl Eq for VulkanQueueSubmitGuard<'_> {}
30
31pub trait VulkanQueueExtManual: sealed::Sealed + IsA<VulkanQueue> + 'static {
32    // rustdoc-stripper-ignore-next
33    /// Locks the vulkan queue for submission. A struct similar to `MutexGuard` is retured that unlocks the queue once dropped.
34    // rustdoc-stripper-ignore-next-stop
35    /// Locks the queue for command submission using `vkQueueSubmit()` to meet the
36    /// Vulkan requirements for externally synchronised resources.
37    #[doc(alias = "gst_vulkan_queue_submit_lock")]
38    fn submit_lock<'a>(&'a self) -> VulkanQueueSubmitGuard<'a> {
39        unsafe {
40            ffi::gst_vulkan_queue_submit_lock(self.as_ref().to_glib_none().0);
41        }
42        VulkanQueueSubmitGuard {
43            obj: self.upcast_ref(),
44        }
45    }
46}
47impl<O: IsA<VulkanQueue>> VulkanQueueExtManual for O {}