forked from mirrors/gstreamer-rs
gstreamer: Manually implement Allocator::register()
Due to a bug it causes use-after-free in versions < 1.20.5, so work around that here. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1147>
This commit is contained in:
parent
dc11c7312a
commit
784c44b947
4 changed files with 28 additions and 8 deletions
|
@ -394,6 +394,10 @@ status = "generate"
|
|||
[[object]]
|
||||
name = "Gst.Allocator"
|
||||
status = "generate"
|
||||
[[object.function]]
|
||||
name = "register"
|
||||
# Steals the string name in < 1.20.5
|
||||
manual = true
|
||||
|
||||
[[object.function]]
|
||||
name = "alloc"
|
||||
|
|
23
gstreamer/src/allocator.rs
Normal file
23
gstreamer/src/allocator.rs
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Take a look at the license at the top of the repository in the LICENSE file.
|
||||
|
||||
use crate::Allocator;
|
||||
use glib::translate::*;
|
||||
use glib::IsA;
|
||||
|
||||
impl Allocator {
|
||||
#[doc(alias = "gst_allocator_register")]
|
||||
pub fn register(name: &str, allocator: &impl IsA<Allocator>) {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
// See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3364
|
||||
if crate::version() < (1, 20, 5, 0) {
|
||||
ffi::gst_allocator_register(name.to_glib_full(), allocator.as_ref().to_glib_full());
|
||||
} else {
|
||||
ffi::gst_allocator_register(
|
||||
name.to_glib_none().0,
|
||||
allocator.as_ref().to_glib_full(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,14 +26,6 @@ impl Allocator {
|
|||
assert_initialized_main_thread!();
|
||||
unsafe { from_glib_full(ffi::gst_allocator_find(name.to_glib_none().0)) }
|
||||
}
|
||||
|
||||
#[doc(alias = "gst_allocator_register")]
|
||||
pub fn register(name: &str, allocator: &impl IsA<Allocator>) {
|
||||
skip_assert_initialized!();
|
||||
unsafe {
|
||||
ffi::gst_allocator_register(name.to_glib_none().0, allocator.as_ref().to_glib_full());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for Allocator {}
|
||||
|
|
|
@ -153,6 +153,7 @@ mod pipeline;
|
|||
|
||||
mod allocation_params;
|
||||
pub use self::allocation_params::AllocationParams;
|
||||
mod allocator;
|
||||
|
||||
mod element_factory_type;
|
||||
pub use element_factory_type::*;
|
||||
|
|
Loading…
Reference in a new issue