mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-22 01:21:05 +00:00
all: fix userdata mutability for FnMut callbacks
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1585>
This commit is contained in:
parent
2a1473d69d
commit
33781c5e65
5 changed files with 23 additions and 19 deletions
|
@ -48,9 +48,9 @@ pub trait RTSPSessionPoolExtManual: IsA<RTSPSessionPool> + 'static {
|
|||
glib::ffi::g_source_set_callback(
|
||||
source,
|
||||
Some(transmute::<
|
||||
*const (),
|
||||
*mut (),
|
||||
unsafe extern "C" fn(glib::ffi::gpointer) -> i32,
|
||||
>(trampoline_watch::<F> as *const ())),
|
||||
>(trampoline_watch::<F> as *mut ())),
|
||||
into_raw_watch(func),
|
||||
Some(destroy_closure_watch::<F>),
|
||||
);
|
||||
|
|
|
@ -599,12 +599,13 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let func_ptr: &F = &func;
|
||||
let mut func = func;
|
||||
let func_ptr: &mut F = &mut func;
|
||||
|
||||
from_glib(ffi::gst_buffer_foreach_meta(
|
||||
mut_override(self.as_ptr()),
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as *mut _,
|
||||
func_ptr as *mut _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -643,12 +644,13 @@ impl BufferRef {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let func_ptr: &F = &func;
|
||||
let mut func = func;
|
||||
let func_ptr: &mut F = &mut func;
|
||||
|
||||
from_glib(ffi::gst_buffer_foreach_meta(
|
||||
mut_override(self.as_ptr()),
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as *mut _,
|
||||
func_ptr as *mut _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -149,12 +149,13 @@ impl BufferListRef {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let func_ptr: &F = &func;
|
||||
let mut func = func;
|
||||
let func_ptr: &mut F = &mut func;
|
||||
|
||||
from_glib(ffi::gst_buffer_list_foreach(
|
||||
self.as_ptr() as *mut _,
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as *mut _,
|
||||
func_ptr as *mut _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -198,12 +199,13 @@ impl BufferListRef {
|
|||
}
|
||||
|
||||
unsafe {
|
||||
let func_ptr: &F = &func;
|
||||
let mut func = func;
|
||||
let func_ptr: &mut F = &mut func;
|
||||
|
||||
from_glib(ffi::gst_buffer_list_foreach(
|
||||
self.as_ptr() as *mut _,
|
||||
Some(trampoline::<F>),
|
||||
func_ptr as *const _ as *mut _,
|
||||
func_ptr as *mut _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,9 +120,9 @@ impl Bus {
|
|||
glib::ffi::g_source_set_callback(
|
||||
source,
|
||||
Some(transmute::<
|
||||
*const (),
|
||||
*mut (),
|
||||
unsafe extern "C" fn(glib::ffi::gpointer) -> i32,
|
||||
>(trampoline_watch::<F> as *const ())),
|
||||
>(trampoline_watch::<F> as *mut ())),
|
||||
into_raw_watch(func),
|
||||
Some(destroy_closure_watch::<F>),
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ impl Registry {
|
|||
filter: P,
|
||||
first: bool,
|
||||
) -> glib::List<PluginFeature> {
|
||||
let filter_data: P = filter;
|
||||
let mut filter_data: P = filter;
|
||||
unsafe extern "C" fn filter_func<P: FnMut(&PluginFeature) -> bool>(
|
||||
feature: *mut ffi::GstPluginFeature,
|
||||
user_data: glib::ffi::gpointer,
|
||||
|
@ -27,13 +27,13 @@ impl Registry {
|
|||
res.into_glib()
|
||||
}
|
||||
let filter = Some(filter_func::<P> as _);
|
||||
let super_callback0: &P = &filter_data;
|
||||
let super_callback0: &mut P = &mut filter_data;
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_feature_filter(
|
||||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as *mut _,
|
||||
super_callback0 as *mut _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -76,24 +76,24 @@ impl Registry {
|
|||
filter: P,
|
||||
first: bool,
|
||||
) -> glib::List<Plugin> {
|
||||
let filter_data: P = filter;
|
||||
let mut filter_data: P = filter;
|
||||
unsafe extern "C" fn filter_func<P: FnMut(&Plugin) -> bool>(
|
||||
plugin: *mut ffi::GstPlugin,
|
||||
user_data: glib::ffi::gpointer,
|
||||
) -> glib::ffi::gboolean {
|
||||
let plugin = from_glib_borrow(plugin);
|
||||
let callback = user_data as *const _ as *mut P;
|
||||
let callback = user_data as *mut P;
|
||||
let res = (*callback)(&plugin);
|
||||
res.into_glib()
|
||||
}
|
||||
let filter = Some(filter_func::<P> as _);
|
||||
let super_callback0: &P = &filter_data;
|
||||
let super_callback0: &mut P = &mut filter_data;
|
||||
unsafe {
|
||||
FromGlibPtrContainer::from_glib_full(ffi::gst_registry_plugin_filter(
|
||||
self.to_glib_none().0,
|
||||
filter,
|
||||
first.into_glib(),
|
||||
super_callback0 as *const _ as *mut _,
|
||||
super_callback0 as *mut _ as *mut _,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue