diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index 4587c9a4d..c75d17c87 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -17,7 +17,6 @@ use gst_app_sys; use gst_sys; use std::boxed::Box as Box_; use std::cell::RefCell; -use std::mem::transmute; use std::panic; use std::ptr; use std::sync::atomic::{AtomicBool, Ordering}; @@ -295,7 +294,7 @@ impl AppSink { connect_raw( self.as_ptr() as *mut _, b"new-sample\0".as_ptr() as *const _, - Some(transmute(new_sample_trampoline:: as usize)), + Some(*(&new_sample_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } @@ -312,7 +311,7 @@ impl AppSink { connect_raw( self.as_ptr() as *mut _, b"new-preroll\0".as_ptr() as *const _, - Some(transmute(new_preroll_trampoline:: as usize)), + Some(*(&new_preroll_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } diff --git a/gstreamer-audio/src/audio_channel_position.rs b/gstreamer-audio/src/audio_channel_position.rs index 97f3ca8e9..d004960cb 100644 --- a/gstreamer-audio/src/audio_channel_position.rs +++ b/gstreamer-audio/src/audio_channel_position.rs @@ -24,10 +24,8 @@ impl AudioChannelPosition { if pos < 0 { return 0; } - unsafe { - let val = mem::transmute::(pos); - 1 << val - } + + 1 << (pos as u32) } pub fn positions_to_mask( diff --git a/gstreamer-base/src/aggregator.rs b/gstreamer-base/src/aggregator.rs index ef0da9335..66aa4fa74 100644 --- a/gstreamer-base/src/aggregator.rs +++ b/gstreamer-base/src/aggregator.rs @@ -100,9 +100,7 @@ impl> AggregatorExtManual for O { connect_raw( self.as_ptr() as *mut _, b"notify::min-upstream-latency\0".as_ptr() as *const _, - Some(mem::transmute( - notify_min_upstream_latency_trampoline:: as usize, - )), + Some(*(¬ify_min_upstream_latency_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } diff --git a/gstreamer-pbutils/src/discoverer.rs b/gstreamer-pbutils/src/discoverer.rs index ae8d55e10..acb9c947e 100644 --- a/gstreamer-pbutils/src/discoverer.rs +++ b/gstreamer-pbutils/src/discoverer.rs @@ -23,7 +23,6 @@ use gobject_sys; use gst_pbutils_sys; use std::boxed::Box as Box_; -use std::mem::transmute; impl Discoverer { pub fn set_property_timeout(&self, timeout: gst::ClockTime) { @@ -60,7 +59,7 @@ impl Discoverer { connect_raw( self.as_ptr() as *mut _, b"notify::timeout\0".as_ptr() as *const _, - Some(transmute(notify_timeout_trampoline:: as usize)), + Some(*(¬ify_timeout_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } diff --git a/gstreamer-player/src/player.rs b/gstreamer-player/src/player.rs index ab009e993..d6587c511 100644 --- a/gstreamer-player/src/player.rs +++ b/gstreamer-player/src/player.rs @@ -15,7 +15,6 @@ use glib_sys; use gst; use gst_player_sys; use std::boxed::Box as Box_; -use std::mem::transmute; use Player; use PlayerSignalDispatcher; use PlayerVideoRenderer; @@ -72,7 +71,7 @@ impl Player { connect_raw( self.as_ptr() as *mut _, b"duration-changed\0".as_ptr() as *const _, - Some(transmute(duration_changed_trampoline:: as usize)), + Some(*(&duration_changed_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } @@ -88,7 +87,7 @@ impl Player { connect_raw( self.as_ptr() as *mut _, b"position-updated\0".as_ptr() as *const _, - Some(transmute(position_updated_trampoline:: as usize)), + Some(*(&position_updated_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } @@ -104,7 +103,7 @@ impl Player { connect_raw( self.as_ptr() as *mut _, b"seek-done\0".as_ptr() as *const _, - Some(transmute(seek_done_trampoline:: as usize)), + Some(*(&seek_done_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } diff --git a/gstreamer-rtsp-server/src/rtsp_auth.rs b/gstreamer-rtsp-server/src/rtsp_auth.rs index 1a3d0ddde..100c67bac 100644 --- a/gstreamer-rtsp-server/src/rtsp_auth.rs +++ b/gstreamer-rtsp-server/src/rtsp_auth.rs @@ -6,7 +6,6 @@ use glib::translate::*; use gst_rtsp_server_sys; use std::boxed::Box as Box_; -use std::mem::transmute; use RTSPAuth; use RTSPToken; @@ -59,7 +58,7 @@ impl> RTSPAuthExtManual for O { connect_raw( self.as_ptr() as *mut _, b"accept-certificate\0".as_ptr() as *const _, - Some(transmute(accept_certificate_trampoline:: as usize)), + Some(*(&accept_certificate_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } diff --git a/gstreamer-rtsp-server/src/rtsp_session_pool.rs b/gstreamer-rtsp-server/src/rtsp_session_pool.rs index 2a83f0321..d51d23e23 100644 --- a/gstreamer-rtsp-server/src/rtsp_session_pool.rs +++ b/gstreamer-rtsp-server/src/rtsp_session_pool.rs @@ -6,7 +6,6 @@ use glib_sys; use glib_sys::{gboolean, gpointer}; use gst_rtsp_server_sys; use std::cell::RefCell; -use std::mem::transmute; use RTSPSessionPool; unsafe extern "C" fn trampoline_watch Continue + Send + 'static>( @@ -49,7 +48,7 @@ impl> RTSPSessionPoolExtManual for O { ); glib_sys::g_source_set_callback( source, - Some(transmute(trampoline_watch:: as usize)), + Some(*(&trampoline_watch:: as *const _ as *const _)), into_raw_watch(func), Some(destroy_closure_watch::), ); diff --git a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs index 395fc6a7f..b2de19d70 100644 --- a/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs +++ b/gstreamer-rtsp-server/src/subclass/rtsp_media_factory.rs @@ -273,7 +273,6 @@ where T: RTSPMediaFactoryImpl, { use once_cell::sync::Lazy; - use std::mem; static PIPELINE_QUARK: Lazy = Lazy::new(|| glib::Quark::from_string("gstreamer-rs-rtsp-media-pipeline")); @@ -291,7 +290,7 @@ where media as *mut _, PIPELINE_QUARK.to_glib(), pipeline as *mut _, - Some(mem::transmute(gobject_sys::g_object_unref as usize)), + Some(*(&gobject_sys::g_object_unref as *const _ as *const _)), ); pipeline as *mut _ diff --git a/gstreamer-video/src/functions.rs b/gstreamer-video/src/functions.rs index ca86a9a44..a22763be7 100644 --- a/gstreamer-video/src/functions.rs +++ b/gstreamer-video/src/functions.rs @@ -14,7 +14,6 @@ use glib; use glib::translate::{from_glib_full, ToGlib, ToGlibPtr}; use gst; -use std::mem; use std::ptr; pub fn convert_sample( @@ -106,7 +105,7 @@ unsafe fn convert_sample_async_unsafe( timeout.to_glib(), Some(convert_sample_async_trampoline::), Box::into_raw(user_data) as glib_sys::gpointer, - Some(mem::transmute(convert_sample_async_free:: as usize)), + Some(convert_sample_async_free::), ); } diff --git a/gstreamer/src/bin.rs b/gstreamer/src/bin.rs index 60d52c5d4..1406e7cce 100644 --- a/gstreamer/src/bin.rs +++ b/gstreamer/src/bin.rs @@ -22,7 +22,6 @@ use glib::GString; use gst_sys; use std::boxed::Box as Box_; -use std::mem::transmute; use std::path; pub trait GstBinExtManual: 'static { @@ -99,7 +98,7 @@ impl> GstBinExtManual for O { connect_raw( self.as_ptr() as *mut _, b"do-latency\0".as_ptr() as *const _, - Some(transmute(do_latency_trampoline:: as usize)), + Some(*(&do_latency_trampoline:: as *const _ as *const _)), Box_::into_raw(f), ) } diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index 1ad20e34d..1a17a5cb9 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -16,7 +16,6 @@ use glib_sys; use glib_sys::{gboolean, gpointer}; use gst_sys; use std::cell::RefCell; -use std::mem::transmute; use std::pin::Pin; use std::task::{Context, Poll}; @@ -94,7 +93,7 @@ impl Bus { let source = gst_sys::gst_bus_create_watch(self.to_glib_none().0); glib_sys::g_source_set_callback( source, - Some(transmute(trampoline_watch:: as usize)), + Some(*(&trampoline_watch:: as *const _ as *const _)), into_raw_watch(func), Some(destroy_closure_watch::), ); diff --git a/gstreamer/src/iterator.rs b/gstreamer/src/iterator.rs index b1da87f8e..10a1bd675 100644 --- a/gstreamer/src/iterator.rs +++ b/gstreamer/src/iterator.rs @@ -328,8 +328,7 @@ where let func = func as *const gobject_sys::GValue; let func = gobject_sys::g_value_get_boxed(func); - #[allow(clippy::transmute_ptr_to_ref)] - let func: &&(dyn Fn(T) -> bool + Send + Sync + 'static) = mem::transmute(func); + let func = &*(func as *const &(dyn Fn(T) -> bool + Send + Sync + 'static)); let value = &*(value as *const glib::Value); let value = value