From d7baadee222b7bd22f84b52327f57337f2eace12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 2 Aug 2017 20:09:00 +0300 Subject: [PATCH] Fix various other compiler/clippy warnings --- gstreamer-app/src/app_sink.rs | 7 +++---- gstreamer-app/src/app_src.rs | 7 +++---- gstreamer/src/event.rs | 8 ++++++-- gstreamer/src/message.rs | 11 +++++++++-- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/gstreamer-app/src/app_sink.rs b/gstreamer-app/src/app_sink.rs index b4f3770e6..40823cf15 100644 --- a/gstreamer-app/src/app_sink.rs +++ b/gstreamer-app/src/app_sink.rs @@ -11,7 +11,6 @@ use ffi; use gst_ffi; use glib::translate::*; use gst; -use std::mem::transmute; use glib::source::CallbackGuard; use glib_ffi::gpointer; use std::ptr; @@ -51,7 +50,7 @@ impl AppSinkCallbacks { unsafe extern "C" fn trampoline_eos(appsink: *mut ffi::GstAppSink, callbacks: gpointer) { let _guard = CallbackGuard::new(); - let callbacks: &AppSinkCallbacks = transmute(callbacks); + let callbacks = &*(callbacks as *const AppSinkCallbacks); (callbacks.eos)(&from_glib_none(appsink)); } @@ -61,7 +60,7 @@ unsafe extern "C" fn trampoline_new_preroll( callbacks: gpointer, ) -> gst_ffi::GstFlowReturn { let _guard = CallbackGuard::new(); - let callbacks: &AppSinkCallbacks = transmute(callbacks); + let callbacks = &*(callbacks as *const AppSinkCallbacks); (callbacks.new_preroll)(&from_glib_none(appsink)).to_glib() } @@ -71,7 +70,7 @@ unsafe extern "C" fn trampoline_new_sample( callbacks: gpointer, ) -> gst_ffi::GstFlowReturn { let _guard = CallbackGuard::new(); - let callbacks: &AppSinkCallbacks = transmute(callbacks); + let callbacks = &*(callbacks as *const AppSinkCallbacks); (callbacks.new_sample)(&from_glib_none(appsink)).to_glib() } diff --git a/gstreamer-app/src/app_src.rs b/gstreamer-app/src/app_src.rs index 9bb7a6e81..292745127 100644 --- a/gstreamer-app/src/app_src.rs +++ b/gstreamer-app/src/app_src.rs @@ -10,7 +10,6 @@ use AppSrc; use ffi; use glib::translate::*; use gst; -use std::mem::transmute; use glib::source::CallbackGuard; use glib_ffi::{gboolean, gpointer}; use std::ptr; @@ -54,14 +53,14 @@ unsafe extern "C" fn trampoline_need_data( callbacks: gpointer, ) { let _guard = CallbackGuard::new(); - let callbacks: &AppSrcCallbacks = transmute(callbacks); + let callbacks = &*(callbacks as *const AppSrcCallbacks); (callbacks.need_data)(&from_glib_none(appsrc), length); } unsafe extern "C" fn trampoline_enough_data(appsrc: *mut ffi::GstAppSrc, callbacks: gpointer) { let _guard = CallbackGuard::new(); - let callbacks: &AppSrcCallbacks = transmute(callbacks); + let callbacks = &*(callbacks as *const AppSrcCallbacks); (callbacks.enough_data)(&from_glib_none(appsrc)); } @@ -72,7 +71,7 @@ unsafe extern "C" fn trampoline_seek_data( callbacks: gpointer, ) -> gboolean { let _guard = CallbackGuard::new(); - let callbacks: &AppSrcCallbacks = transmute(callbacks); + let callbacks = &*(callbacks as *const AppSrcCallbacks); (callbacks.seek_data)(&from_glib_none(appsrc), offset).to_glib() } diff --git a/gstreamer/src/event.rs b/gstreamer/src/event.rs index 05aee4914..2986c7f08 100644 --- a/gstreamer/src/event.rs +++ b/gstreamer/src/event.rs @@ -15,8 +15,10 @@ use std::mem; use std::ffi::CStr; use glib; -use glib::translate::{from_glib, from_glib_full, from_glib_none, FromGlibPtrContainer, ToGlib, - ToGlibPtr}; +use glib::translate::{from_glib, from_glib_full, from_glib_none, ToGlib, ToGlibPtr}; + +#[cfg(feature = "v1_10")] +use glib::translate::FromGlibPtrContainer; #[repr(C)] pub struct EventRef(ffi::GstEvent); @@ -930,9 +932,11 @@ impl EosBuilder { event_builder_generic_impl!(|_| ffi::gst_event_new_eos()); } +// TODO Toc pub struct TocBuilder { seqnum: Option, running_time_offset: Option, + #[allow(unused)] toc: (), updated: bool, } diff --git a/gstreamer/src/message.rs b/gstreamer/src/message.rs index 6d90fe2a4..b4146fd5a 100644 --- a/gstreamer/src/message.rs +++ b/gstreamer/src/message.rs @@ -1122,6 +1122,7 @@ pub struct ErrorBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, + #[allow(unused)] details: Option, } impl<'a> ErrorBuilder<'a> { @@ -1181,6 +1182,7 @@ pub struct WarningBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, + #[allow(unused)] details: Option, } impl<'a> WarningBuilder<'a> { @@ -1240,6 +1242,7 @@ pub struct InfoBuilder<'a> { seqnum: Option, error: &'a glib::Error, debug: Option<&'a str>, + #[allow(unused)] details: Option, } impl<'a> InfoBuilder<'a> { @@ -1890,6 +1893,7 @@ impl<'a> ProgressBuilder<'a> { pub struct TocBuilder { src: Option, seqnum: Option, + #[allow(unused)] toc: (), updated: bool, } @@ -1984,6 +1988,7 @@ impl<'a> NeedContextBuilder<'a> { pub struct HaveContextBuilder { src: Option, seqnum: Option, + #[allow(unused)] context: (), } impl HaveContextBuilder { @@ -1991,11 +1996,11 @@ impl HaveContextBuilder { Self { src: None, seqnum: None, - context: (), + context: context, } } - message_builder_generic_impl!(|s: &mut Self, src| { + message_builder_generic_impl!(|_, src| { ffi::gst_message_new_have_context(src, ptr::null_mut() /*s.context.to_glib_full().0*/) }); } @@ -2038,6 +2043,7 @@ impl<'a> DeviceRemovedBuilder<'a> { }); } +#[cfg(feature = "v1_10")] pub struct PropertyNotifyBuilder<'a> { src: Option, seqnum: Option, @@ -2123,6 +2129,7 @@ impl<'a> StreamsSelectedBuilder<'a> { }); } +#[cfg(feature = "v1_10")] pub struct RedirectBuilder<'a> { src: Option, seqnum: Option,