Fix various signal handler trampoline usages

This commit is contained in:
Sebastian Dröge 2020-04-13 19:18:57 +03:00
parent 5021994237
commit 185eb188ca
9 changed files with 49 additions and 12 deletions

View file

@ -17,6 +17,7 @@ use gst_app_sys;
use gst_sys; use gst_sys;
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem::transmute;
use std::panic; use std::panic;
use std::ptr; use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
@ -294,7 +295,9 @@ impl AppSink {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"new-sample\0".as_ptr() as *const _, b"new-sample\0".as_ptr() as *const _,
Some(*(&new_sample_trampoline::<F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
new_sample_trampoline::<F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }
@ -311,7 +314,9 @@ impl AppSink {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"new-preroll\0".as_ptr() as *const _, b"new-preroll\0".as_ptr() as *const _,
Some(*(&new_preroll_trampoline::<F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
new_preroll_trampoline::<F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }

View file

@ -19,6 +19,8 @@ use gst_base_sys;
#[cfg(any(feature = "v1_16", feature = "dox"))] #[cfg(any(feature = "v1_16", feature = "dox"))]
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
use std::mem; use std::mem;
#[cfg(any(feature = "v1_16", feature = "dox"))]
use std::mem::transmute;
use std::ptr; use std::ptr;
use Aggregator; use Aggregator;
@ -100,7 +102,9 @@ impl<O: IsA<Aggregator>> AggregatorExtManual for O {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"notify::min-upstream-latency\0".as_ptr() as *const _, b"notify::min-upstream-latency\0".as_ptr() as *const _,
Some(*(&notify_min_upstream_latency_trampoline::<Self, F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
notify_min_upstream_latency_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }

View file

@ -23,6 +23,7 @@ use gobject_sys;
use gst_pbutils_sys; use gst_pbutils_sys;
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
use std::mem::transmute;
impl Discoverer { impl Discoverer {
pub fn set_property_timeout(&self, timeout: gst::ClockTime) { pub fn set_property_timeout(&self, timeout: gst::ClockTime) {
@ -59,7 +60,9 @@ impl Discoverer {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"notify::timeout\0".as_ptr() as *const _, b"notify::timeout\0".as_ptr() as *const _,
Some(*(&notify_timeout_trampoline::<Self, F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
notify_timeout_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }

View file

@ -15,6 +15,7 @@ use glib_sys;
use gst; use gst;
use gst_player_sys; use gst_player_sys;
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
use std::mem::transmute;
use Player; use Player;
use PlayerSignalDispatcher; use PlayerSignalDispatcher;
use PlayerVideoRenderer; use PlayerVideoRenderer;
@ -71,7 +72,9 @@ impl Player {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"duration-changed\0".as_ptr() as *const _, b"duration-changed\0".as_ptr() as *const _,
Some(*(&duration_changed_trampoline::<F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
duration_changed_trampoline::<F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }
@ -87,7 +90,9 @@ impl Player {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"position-updated\0".as_ptr() as *const _, b"position-updated\0".as_ptr() as *const _,
Some(*(&position_updated_trampoline::<F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
position_updated_trampoline::<F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }
@ -103,7 +108,9 @@ impl Player {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"seek-done\0".as_ptr() as *const _, b"seek-done\0".as_ptr() as *const _,
Some(*(&seek_done_trampoline::<F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
seek_done_trampoline::<F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }

View file

@ -6,6 +6,7 @@ use glib::translate::*;
use gst_rtsp_server_sys; use gst_rtsp_server_sys;
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
use std::mem::transmute;
use RTSPAuth; use RTSPAuth;
use RTSPToken; use RTSPToken;
@ -58,7 +59,9 @@ impl<O: IsA<RTSPAuth>> RTSPAuthExtManual for O {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"accept-certificate\0".as_ptr() as *const _, b"accept-certificate\0".as_ptr() as *const _,
Some(*(&accept_certificate_trampoline::<Self, F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
accept_certificate_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }

View file

@ -6,6 +6,7 @@ use glib_sys;
use glib_sys::{gboolean, gpointer}; use glib_sys::{gboolean, gpointer};
use gst_rtsp_server_sys; use gst_rtsp_server_sys;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem::transmute;
use RTSPSessionPool; use RTSPSessionPool;
unsafe extern "C" fn trampoline_watch<F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static>( unsafe extern "C" fn trampoline_watch<F: FnMut(&RTSPSessionPool) -> Continue + Send + 'static>(
@ -48,7 +49,10 @@ impl<O: IsA<RTSPSessionPool>> RTSPSessionPoolExtManual for O {
); );
glib_sys::g_source_set_callback( glib_sys::g_source_set_callback(
source, source,
Some(*(&trampoline_watch::<F> as *const _ as *const _)), Some(transmute::<
_,
unsafe extern "C" fn(glib_sys::gpointer) -> i32,
>(trampoline_watch::<F> as *const ())),
into_raw_watch(func), into_raw_watch(func),
Some(destroy_closure_watch::<F>), Some(destroy_closure_watch::<F>),
); );

View file

@ -16,6 +16,8 @@ use glib::subclass::prelude::*;
use RTSPMediaFactory; use RTSPMediaFactory;
use RTSPMediaFactoryClass; use RTSPMediaFactoryClass;
use std::mem::transmute;
pub trait RTSPMediaFactoryImpl: pub trait RTSPMediaFactoryImpl:
RTSPMediaFactoryImplExt + ObjectImpl + Send + Sync + 'static RTSPMediaFactoryImplExt + ObjectImpl + Send + Sync + 'static
{ {
@ -290,7 +292,9 @@ where
media as *mut _, media as *mut _,
PIPELINE_QUARK.to_glib(), PIPELINE_QUARK.to_glib(),
pipeline as *mut _, pipeline as *mut _,
Some(*(&gobject_sys::g_object_unref as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn(glib_sys::gpointer)>(
gobject_sys::g_object_unref as *const (),
)),
); );
pipeline as *mut _ pipeline as *mut _

View file

@ -22,6 +22,7 @@ use glib::GString;
use gst_sys; use gst_sys;
use std::boxed::Box as Box_; use std::boxed::Box as Box_;
use std::mem::transmute;
use std::path; use std::path;
pub trait GstBinExtManual: 'static { pub trait GstBinExtManual: 'static {
@ -98,7 +99,9 @@ impl<O: IsA<Bin>> GstBinExtManual for O {
connect_raw( connect_raw(
self.as_ptr() as *mut _, self.as_ptr() as *mut _,
b"do-latency\0".as_ptr() as *const _, b"do-latency\0".as_ptr() as *const _,
Some(*(&do_latency_trampoline::<Self, F> as *const _ as *const _)), Some(transmute::<_, unsafe extern "C" fn()>(
do_latency_trampoline::<Self, F> as *const (),
)),
Box_::into_raw(f), Box_::into_raw(f),
) )
} }

View file

@ -16,6 +16,7 @@ use glib_sys;
use glib_sys::{gboolean, gpointer}; use glib_sys::{gboolean, gpointer};
use gst_sys; use gst_sys;
use std::cell::RefCell; use std::cell::RefCell;
use std::mem::transmute;
use std::pin::Pin; use std::pin::Pin;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
@ -93,7 +94,10 @@ impl Bus {
let source = gst_sys::gst_bus_create_watch(self.to_glib_none().0); let source = gst_sys::gst_bus_create_watch(self.to_glib_none().0);
glib_sys::g_source_set_callback( glib_sys::g_source_set_callback(
source, source,
Some(*(&trampoline_watch::<F> as *const _ as *const _)), Some(transmute::<
_,
unsafe extern "C" fn(glib_sys::gpointer) -> i32,
>(trampoline_watch::<F> as *const ())),
into_raw_watch(func), into_raw_watch(func),
Some(destroy_closure_watch::<F>), Some(destroy_closure_watch::<F>),
); );