mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
Fix various minor clippy warnings
This commit is contained in:
parent
0a96e0a80b
commit
95f6844702
23 changed files with 69 additions and 92 deletions
|
@ -128,6 +128,7 @@ fn create_ui(app: >k::Application) {
|
|||
// This is unsafe because the "window handle" we pass here is basically like a raw pointer.
|
||||
// If a wrong value were to be passed here (and you can pass any integer), then the window
|
||||
// system will most likely cause the application to crash.
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
// Here we ask gdk what native window handle we got assigned for
|
||||
// our video region from the window system, and then we will
|
||||
|
@ -151,6 +152,7 @@ fn create_ui(app: >k::Application) {
|
|||
// This is unsafe because the "window handle" we pass here is basically like a raw pointer.
|
||||
// If a wrong value were to be passed here (and you can pass any integer), then the window
|
||||
// system will most likely cause the application to crash.
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
// Here we ask gdk what native window handle we got assigned for
|
||||
// our video region from the windowing system, and then we will
|
||||
|
|
|
@ -226,7 +226,6 @@ fn example_main() -> Result<(), Error> {
|
|||
("Failed to link srcpad"),
|
||||
["{}", err]
|
||||
);
|
||||
()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -154,7 +154,6 @@ fn example_main() -> Result<(), Error> {
|
|||
("Failed to link decodebin srcpad"),
|
||||
["{}", err]
|
||||
);
|
||||
()
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -64,7 +64,7 @@ fn example_main() -> Result<(), Error> {
|
|||
Ok(pipeline) => pipeline,
|
||||
Err(err) => {
|
||||
if let Some(gst::ParseError::NoSuchElement) = err.kind::<gst::ParseError>() {
|
||||
return Err(MissingElement(context.get_missing_elements().join(",".into())).into());
|
||||
return Err(MissingElement(context.get_missing_elements().join(",")).into());
|
||||
} else {
|
||||
return Err(err.into());
|
||||
}
|
||||
|
|
|
@ -216,7 +216,7 @@ unsafe extern "C" fn new_sample_trampoline<
|
|||
this: *mut ffi::GstAppSink,
|
||||
f: glib_ffi::gpointer,
|
||||
) -> gst_ffi::GstFlowReturn {
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
||||
ret.to_glib()
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ unsafe extern "C" fn new_preroll_trampoline<
|
|||
this: *mut ffi::GstAppSink,
|
||||
f: glib_ffi::gpointer,
|
||||
) -> gst_ffi::GstFlowReturn {
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
let ret: gst::FlowReturn = f(&from_glib_borrow(this)).into();
|
||||
ret.to_glib()
|
||||
}
|
||||
|
|
|
@ -704,7 +704,7 @@ impl Harness {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_sink_harness<'a>(&'a self) -> Option<Ref<'a>> {
|
||||
pub fn get_sink_harness(&self) -> Option<Ref> {
|
||||
unsafe {
|
||||
let sink_harness = (*self.0.as_ptr()).sink_harness;
|
||||
if sink_harness.is_null() {
|
||||
|
@ -721,7 +721,7 @@ impl Harness {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_src_harness<'a>(&'a self) -> Option<Ref<'a>> {
|
||||
pub fn get_src_harness(&self) -> Option<Ref> {
|
||||
unsafe {
|
||||
let src_harness = (*self.0.as_ptr()).src_harness;
|
||||
if src_harness.is_null() {
|
||||
|
@ -738,7 +738,7 @@ impl Harness {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_mut_sink_harness<'a>(&'a mut self) -> Option<RefMut<'a>> {
|
||||
pub fn get_mut_sink_harness(&mut self) -> Option<RefMut> {
|
||||
unsafe {
|
||||
let sink_harness = (*self.0.as_ptr()).sink_harness;
|
||||
if sink_harness.is_null() {
|
||||
|
@ -755,7 +755,7 @@ impl Harness {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_mut_src_harness<'a>(&'a mut self) -> Option<RefMut<'a>> {
|
||||
pub fn get_mut_src_harness(&mut self) -> Option<RefMut> {
|
||||
unsafe {
|
||||
let src_harness = (*self.0.as_ptr()).src_harness;
|
||||
if src_harness.is_null() {
|
||||
|
|
|
@ -71,7 +71,6 @@ unsafe extern "C" fn notify_timeout_trampoline<P, F: Fn(&P) + Send + Sync + 'sta
|
|||
) where
|
||||
P: IsA<Discoverer>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
f(&Discoverer::from_glib_borrow(this).unsafe_cast())
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ pub use glib::{Cast, Continue, Error, IsA, StaticType, ToValue, Type, TypedValue
|
|||
#[cfg_attr(feature = "cargo-clippy", allow(match_same_arms))]
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(type_complexity))]
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(useless_transmute))]
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
#[rustfmt::skip]
|
||||
mod auto;
|
||||
pub use auto::*;
|
||||
|
|
|
@ -56,6 +56,7 @@ impl Player {
|
|||
&self,
|
||||
f: F,
|
||||
) -> SignalHandlerId {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
let f: Box_<F> = Box_::new(f);
|
||||
connect_raw(
|
||||
|
@ -71,6 +72,7 @@ impl Player {
|
|||
&self,
|
||||
f: F,
|
||||
) -> SignalHandlerId {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
let f: Box_<F> = Box_::new(f);
|
||||
connect_raw(
|
||||
|
@ -86,6 +88,7 @@ impl Player {
|
|||
&self,
|
||||
f: F,
|
||||
) -> SignalHandlerId {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
let f: Box_<F> = Box_::new(f);
|
||||
connect_raw(
|
||||
|
@ -105,8 +108,7 @@ unsafe extern "C" fn duration_changed_trampoline<
|
|||
object: u64,
|
||||
f: glib_ffi::gpointer,
|
||||
) {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
|
||||
}
|
||||
|
||||
|
@ -117,8 +119,7 @@ unsafe extern "C" fn position_updated_trampoline<
|
|||
object: u64,
|
||||
f: glib_ffi::gpointer,
|
||||
) {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,6 @@ unsafe extern "C" fn seek_done_trampoline<F: Fn(&Player, gst::ClockTime) + Send
|
|||
object: u64,
|
||||
f: glib_ffi::gpointer,
|
||||
) {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
f(&from_glib_borrow(this), gst::ClockTime(Some(object)))
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ unsafe extern "C" fn accept_certificate_trampoline<
|
|||
where
|
||||
P: IsA<RTSPAuth>,
|
||||
{
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
match f(
|
||||
&RTSPAuth::from_glib_borrow(this).unsafe_cast(),
|
||||
&from_glib_borrow(connection),
|
||||
|
|
|
@ -13,8 +13,7 @@ unsafe extern "C" fn trampoline_watch<F: FnMut(&RTSPSessionPool) -> Continue + S
|
|||
pool: *mut ffi::GstRTSPSessionPool,
|
||||
func: gpointer,
|
||||
) -> gboolean {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &RefCell<F> = transmute(func);
|
||||
let func: &RefCell<F> = &*(func as *const RefCell<F>);
|
||||
(&mut *func.borrow_mut())(&from_glib_borrow(pool)).to_glib()
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ unsafe fn convert_sample_async_unsafe<F>(
|
|||
) where
|
||||
F: FnOnce(Result<gst::Sample, glib::Error>) + 'static,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let callback: &mut Option<F> = &mut *(user_data as *mut Option<F>);
|
||||
let callback = callback.take().unwrap();
|
||||
|
||||
|
|
|
@ -449,9 +449,9 @@ impl VideoInfo {
|
|||
#[cfg(not(any(feature = "v1_12", feature = "dox")))]
|
||||
{
|
||||
VideoInfoBuilder {
|
||||
format: format,
|
||||
width: width,
|
||||
height: height,
|
||||
format,
|
||||
width,
|
||||
height,
|
||||
interlace_mode: None,
|
||||
flags: None,
|
||||
size: None,
|
||||
|
|
|
@ -163,7 +163,7 @@ unsafe extern "C" fn do_latency_trampoline<
|
|||
where
|
||||
P: IsA<Bin>,
|
||||
{
|
||||
let f: &F = transmute(f);
|
||||
let f: &F = &*(f as *const F);
|
||||
match f(&Bin::from_glib_borrow(this).unsafe_cast()) {
|
||||
Ok(()) => true,
|
||||
Err(err) => {
|
||||
|
|
|
@ -17,11 +17,11 @@ use BufferListRef;
|
|||
|
||||
impl Serialize for BufferListRef {
|
||||
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {
|
||||
let mut iter = self.iter();
|
||||
let iter = self.iter();
|
||||
let (remaining, _) = iter.size_hint();
|
||||
if remaining > 0 {
|
||||
let mut seq = serializer.serialize_seq(Some(remaining))?;
|
||||
while let Some(ref buffer) = iter.next() {
|
||||
for buffer in iter {
|
||||
seq.serialize_element(buffer)?;
|
||||
}
|
||||
seq.end()
|
||||
|
|
|
@ -25,7 +25,6 @@ unsafe extern "C" fn trampoline_watch<F: FnMut(&Bus, &Message) -> Continue + 'st
|
|||
msg: *mut ffi::GstMessage,
|
||||
func: gpointer,
|
||||
) -> gboolean {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &RefCell<F> = &*(func as *const RefCell<F>);
|
||||
(&mut *func.borrow_mut())(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib()
|
||||
}
|
||||
|
@ -49,7 +48,6 @@ unsafe extern "C" fn trampoline_sync<
|
|||
msg: *mut ffi::GstMessage,
|
||||
func: gpointer,
|
||||
) -> ffi::GstBusSyncReply {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let f: &F = &*(func as *const F);
|
||||
let res = f(&from_glib_borrow(bus), &Message::from_glib_borrow(msg)).to_glib();
|
||||
|
||||
|
|
|
@ -14,7 +14,6 @@ use glib_ffi::{gboolean, gpointer};
|
|||
use libc::c_void;
|
||||
use std::cmp;
|
||||
use std::mem;
|
||||
use std::mem::transmute;
|
||||
use std::ptr;
|
||||
use Clock;
|
||||
use ClockError;
|
||||
|
@ -39,8 +38,7 @@ unsafe extern "C" fn trampoline_wait_async<F: Fn(&Clock, ClockTime, &ClockId) +
|
|||
id: gpointer,
|
||||
func: gpointer,
|
||||
) -> gboolean {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let f: &F = transmute(func);
|
||||
let f: &F = &*(func as *const F);
|
||||
f(
|
||||
&from_glib_borrow(clock),
|
||||
from_glib(time),
|
||||
|
|
|
@ -31,7 +31,6 @@ use StaticPadTemplate;
|
|||
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
use std::mem::transmute;
|
||||
use std::ptr;
|
||||
|
||||
use glib;
|
||||
|
@ -1009,8 +1008,7 @@ unsafe extern "C" fn trampoline_pad_probe<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute(func);
|
||||
let func: &F = &*(func as *const F);
|
||||
let mut data_type = None;
|
||||
|
||||
let mut probe_info = PadProbeInfo {
|
||||
|
@ -1089,8 +1087,7 @@ unsafe extern "C" fn trampoline_activate_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).activatedata);
|
||||
let func: &F = &*((*pad).activatedata as *const F);
|
||||
|
||||
match func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1117,8 +1114,7 @@ unsafe extern "C" fn trampoline_activatemode_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).activatemodedata);
|
||||
let func: &F = &*((*pad).activatemodedata as *const F);
|
||||
|
||||
match func(
|
||||
&&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1146,8 +1142,7 @@ unsafe extern "C" fn trampoline_chain_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).chaindata);
|
||||
let func: &F = &*((*pad).chaindata as *const F);
|
||||
|
||||
let res: FlowReturn = func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1172,8 +1167,7 @@ unsafe extern "C" fn trampoline_chain_list_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).chainlistdata);
|
||||
let func: &F = &*((*pad).chainlistdata as *const F);
|
||||
|
||||
let res: FlowReturn = func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1195,8 +1189,7 @@ unsafe extern "C" fn trampoline_event_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).eventdata);
|
||||
let func: &F = &*((*pad).eventdata as *const F);
|
||||
|
||||
func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1217,8 +1210,7 @@ unsafe extern "C" fn trampoline_event_full_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).eventdata);
|
||||
let func: &F = &*((*pad).eventdata as *const F);
|
||||
|
||||
let res: FlowReturn = func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1242,8 +1234,7 @@ unsafe extern "C" fn trampoline_getrange_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).getrangedata);
|
||||
let func: &F = &*((*pad).getrangedata as *const F);
|
||||
|
||||
match func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1269,8 +1260,7 @@ unsafe extern "C" fn trampoline_iterate_internal_links_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).iterintlinkdata);
|
||||
let func: &F = &*((*pad).iterintlinkdata as *const F);
|
||||
|
||||
// Steal the iterator and return it
|
||||
let ret = func(
|
||||
|
@ -1297,8 +1287,7 @@ unsafe extern "C" fn trampoline_link_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).linkdata);
|
||||
let func: &F = &*((*pad).linkdata as *const F);
|
||||
|
||||
let res: ::PadLinkReturn = func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1320,8 +1309,7 @@ unsafe extern "C" fn trampoline_query_function<
|
|||
where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).querydata);
|
||||
let func: &F = &*((*pad).querydata as *const F);
|
||||
|
||||
func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1340,8 +1328,7 @@ unsafe extern "C" fn trampoline_unlink_function<
|
|||
) where
|
||||
T: IsA<Pad>,
|
||||
{
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = transmute((*pad).unlinkdata);
|
||||
let func: &F = &*((*pad).unlinkdata as *const F);
|
||||
|
||||
func(
|
||||
&Pad::from_glib_borrow(pad).unsafe_cast(),
|
||||
|
@ -1354,8 +1341,7 @@ unsafe extern "C" fn destroy_closure<F>(ptr: gpointer) {
|
|||
}
|
||||
|
||||
unsafe extern "C" fn trampoline_pad_task<F: FnMut() + Send + 'static>(func: gpointer) {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &RefCell<F> = transmute(func);
|
||||
let func: &RefCell<F> = &*(func as *const RefCell<F>);
|
||||
(&mut *func.borrow_mut())()
|
||||
}
|
||||
|
||||
|
|
|
@ -20,24 +20,27 @@ macro_rules! gst_panic_to_error(
|
|||
use std::sync::atomic::Ordering;
|
||||
use $crate::ElementExtManual;
|
||||
|
||||
if $panicked.load(Ordering::Relaxed) {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
$ret
|
||||
} else {
|
||||
let result = panic::catch_unwind(AssertUnwindSafe(|| $code));
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(unused_unit))]
|
||||
{
|
||||
if $panicked.load(Ordering::Relaxed) {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
$ret
|
||||
} else {
|
||||
let result = panic::catch_unwind(AssertUnwindSafe(|| $code));
|
||||
|
||||
match result {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
$panicked.store(true, Ordering::Relaxed);
|
||||
if let Some(cause) = err.downcast_ref::<&str>() {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
} else if let Some(cause) = err.downcast_ref::<String>() {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
} else {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
match result {
|
||||
Ok(result) => result,
|
||||
Err(err) => {
|
||||
$panicked.store(true, Ordering::Relaxed);
|
||||
if let Some(cause) = err.downcast_ref::<&str>() {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
} else if let Some(cause) = err.downcast_ref::<String>() {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked: {}", cause]));
|
||||
} else {
|
||||
$element.post_error_message(&gst_error_msg!($crate::LibraryError::Failed, ["Panicked"]));
|
||||
}
|
||||
$ret
|
||||
}
|
||||
$ret
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use glib;
|
|||
use glib::translate::*;
|
||||
use glib_ffi;
|
||||
use std::marker::PhantomData;
|
||||
use std::mem;
|
||||
use std::ptr;
|
||||
use std::slice;
|
||||
|
||||
|
@ -119,8 +118,7 @@ unsafe extern "C" fn type_find_trampoline<F: Fn(&mut TypeFind) + Send + Sync + '
|
|||
find: *mut ffi::GstTypeFind,
|
||||
user_data: glib_ffi::gpointer,
|
||||
) {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(transmute_ptr_to_ref))]
|
||||
let func: &F = mem::transmute(user_data);
|
||||
let func: &F = &*(user_data as *const F);
|
||||
func(&mut *(find as *mut TypeFind));
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ fn tutorial_main() {
|
|||
}
|
||||
|
||||
let res = src_pad.link(&sink_pad);
|
||||
if !res.is_ok() {
|
||||
if res.is_err() {
|
||||
println!("Type is {} but link failed.", new_pad_type);
|
||||
} else {
|
||||
println!("Link succeeded (type {}).", new_pad_type);
|
||||
|
|
|
@ -112,10 +112,8 @@ mod tutorial5 {
|
|||
Inhibit(false)
|
||||
});
|
||||
|
||||
let play_button = gtk::Button::new_from_icon_name(
|
||||
"media-playback-start",
|
||||
gtk::IconSize::SmallToolbar.into(),
|
||||
);
|
||||
let play_button =
|
||||
gtk::Button::new_from_icon_name("media-playback-start", gtk::IconSize::SmallToolbar);
|
||||
let pipeline = playbin.clone();
|
||||
play_button.connect_clicked(move |_| {
|
||||
let pipeline = &pipeline;
|
||||
|
@ -124,10 +122,8 @@ mod tutorial5 {
|
|||
.expect("Unable to set the pipeline to the `Playing` state");
|
||||
});
|
||||
|
||||
let pause_button = gtk::Button::new_from_icon_name(
|
||||
"media-playback-pause",
|
||||
gtk::IconSize::SmallToolbar.into(),
|
||||
);
|
||||
let pause_button =
|
||||
gtk::Button::new_from_icon_name("media-playback-pause", gtk::IconSize::SmallToolbar);
|
||||
let pipeline = playbin.clone();
|
||||
pause_button.connect_clicked(move |_| {
|
||||
let pipeline = &pipeline;
|
||||
|
@ -136,10 +132,8 @@ mod tutorial5 {
|
|||
.expect("Unable to set the pipeline to the `Paused` state");
|
||||
});
|
||||
|
||||
let stop_button = gtk::Button::new_from_icon_name(
|
||||
"media-playback-stop",
|
||||
gtk::IconSize::SmallToolbar.into(),
|
||||
);
|
||||
let stop_button =
|
||||
gtk::Button::new_from_icon_name("media-playback-stop", gtk::IconSize::SmallToolbar);
|
||||
let pipeline = playbin.clone();
|
||||
stop_button.connect_clicked(move |_| {
|
||||
let pipeline = &pipeline;
|
||||
|
@ -221,6 +215,7 @@ mod tutorial5 {
|
|||
) -> *mut c_void;
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
let xid = gdk_x11_window_get_xid(gdk_window.as_ptr() as *mut _);
|
||||
video_overlay.set_window_handle(xid as usize);
|
||||
|
@ -237,6 +232,7 @@ mod tutorial5 {
|
|||
) -> *mut c_void;
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(cast_ptr_alignment))]
|
||||
unsafe {
|
||||
let window = gdk_quartz_window_get_nsview(gdk_window.as_ptr() as *mut _);
|
||||
video_overlay.set_window_handle(window as usize);
|
||||
|
|
|
@ -18,7 +18,7 @@ fn send_value_as_str(v: &glib::SendValue) -> Option<String> {
|
|||
if let Some(s) = v.get::<&str>() {
|
||||
Some(s.to_string())
|
||||
} else if let Some(serialized) = v.serialize() {
|
||||
Some(serialized.into())
|
||||
Some(serialized)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue