mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-09-01 01:13:48 +00:00
vulkan: Replace gst_vulkan_queue_submit_unlock
with drop code in a guard returned from the lock function
This commit is contained in:
parent
594e9d0187
commit
385a99945a
4 changed files with 54 additions and 15 deletions
|
@ -41,7 +41,6 @@ generate = [
|
|||
#"GstVulkan.VulkanMemory",
|
||||
"GstVulkan.VulkanOperation",
|
||||
"GstVulkan.VulkanPhysicalDevice",
|
||||
"GstVulkan.VulkanQueue",
|
||||
# "GstVulkan.VulkanSwapper",
|
||||
"GstVulkan.VulkanTrash",
|
||||
"GstVulkan.VulkanVideoFilter",
|
||||
|
@ -117,6 +116,16 @@ name = "GstVulkan.VulkanHandle"
|
|||
status = "generate"
|
||||
ref_mode = "ref"
|
||||
|
||||
[[object]]
|
||||
name = "GstVulkan.VulkanQueue"
|
||||
status = "generate"
|
||||
[[object.function]]
|
||||
name = "submit_lock"
|
||||
manual = true
|
||||
[[object.function]]
|
||||
name = "submit_unlock"
|
||||
manual = true
|
||||
|
||||
[[object]]
|
||||
name = "GstVulkan.VulkanSwapper"
|
||||
status = "generate"
|
||||
|
|
|
@ -74,20 +74,6 @@ pub trait VulkanQueueExt: IsA<VulkanQueue> + 'static {
|
|||
))
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_vulkan_queue_submit_lock")]
|
||||
fn submit_lock(&self) {
|
||||
unsafe {
|
||||
ffi::gst_vulkan_queue_submit_lock(self.as_ref().to_glib_none().0);
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_vulkan_queue_submit_unlock")]
|
||||
fn submit_unlock(&self) {
|
||||
unsafe {
|
||||
ffi::gst_vulkan_queue_submit_unlock(self.as_ref().to_glib_none().0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<O: IsA<VulkanQueue>> VulkanQueueExt for O {}
|
||||
|
|
|
@ -27,6 +27,7 @@ pub use crate::auto::*;
|
|||
|
||||
mod vulkan_device;
|
||||
mod vulkan_full_screen_quad;
|
||||
mod vulkan_queue;
|
||||
mod vulkan_swapper;
|
||||
|
||||
// Re-export all the traits in a prelude module, so that applications
|
||||
|
@ -37,6 +38,7 @@ pub mod prelude {
|
|||
|
||||
pub use super::vulkan_device::VulkanDeviceExtManual;
|
||||
pub use super::vulkan_full_screen_quad::VulkanFullScreenQuadExtManual;
|
||||
pub use super::vulkan_queue::VulkanQueueExtManual;
|
||||
pub use super::vulkan_swapper::VulkanSwapperExtManual;
|
||||
pub use crate::auto::traits::*;
|
||||
}
|
||||
|
|
42
gstreamer-vulkan/src/vulkan_queue.rs
Normal file
42
gstreamer-vulkan/src/vulkan_queue.rs
Normal file
|
@ -0,0 +1,42 @@
|
|||
use crate::VulkanQueue;
|
||||
|
||||
use glib::{prelude::*, translate::*};
|
||||
|
||||
mod sealed {
|
||||
pub trait Sealed {}
|
||||
impl<T: super::IsA<super::VulkanQueue>> Sealed for T {}
|
||||
}
|
||||
|
||||
/// Represents a locked vulkan queue that can be submitted too. The queue is unlock when this struct is dropped.
|
||||
#[derive(Debug)]
|
||||
pub struct VulkanQueueSubmitGuard<'a> {
|
||||
obj: &'a VulkanQueue,
|
||||
}
|
||||
|
||||
impl Drop for VulkanQueueSubmitGuard<'_> {
|
||||
fn drop(&mut self) {
|
||||
unsafe {
|
||||
ffi::gst_vulkan_queue_submit_unlock(self.obj.to_glib_none().0);
|
||||
}
|
||||
}
|
||||
}
|
||||
impl PartialEq for VulkanQueueSubmitGuard<'_> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.obj == other.obj
|
||||
}
|
||||
}
|
||||
impl Eq for VulkanQueueSubmitGuard<'_> {}
|
||||
|
||||
pub trait VulkanQueueExtManual: sealed::Sealed + IsA<VulkanQueue> + 'static {
|
||||
/// Locks the vulkan queue for submission. A struct similar to `MutexGuard` is retured that unlocks the queue once dropped.
|
||||
#[doc(alias = "gst_vulkan_queue_submit_lock")]
|
||||
fn submit_lock<'a>(&'a self) -> VulkanQueueSubmitGuard<'a> {
|
||||
unsafe {
|
||||
ffi::gst_vulkan_queue_submit_lock(self.as_ref().to_glib_none().0);
|
||||
}
|
||||
VulkanQueueSubmitGuard {
|
||||
obj: self.upcast_ref(),
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<O: IsA<VulkanQueue>> VulkanQueueExtManual for O {}
|
Loading…
Reference in a new issue