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