Pass events by value instead of reference

This commit is contained in:
Sebastian Dröge 2017-08-01 13:58:50 +01:00
parent 484cf56890
commit 38496eca7d
32 changed files with 82 additions and 64 deletions

View file

@ -227,6 +227,11 @@ status = "generate"
# correct mutability # correct mutability
ignore = true ignore = true
[[object.function]]
name = "send_event"
# Pass by value
ignore = true
[[object]] [[object]]
name = "Gst.ElementFactory" name = "Gst.ElementFactory"
status = "generate" status = "generate"
@ -385,6 +390,21 @@ status = "generate"
# Correct mutability # Correct mutability
ignore = true ignore = true
[[object.function]]
name = "event_default"
# Pass by value
ignore = true
[[object.function]]
name = "push_event"
# Pass by value
ignore = true
[[object.function]]
name = "send_event"
# Pass by value
ignore = true
[[object]] [[object]]
name = "Gst.GhostPad" name = "Gst.GhostPad"
status = "generate" status = "generate"

View file

@ -24,7 +24,7 @@ fn main() {
println!("sending eos"); println!("sending eos");
let ev = Event::new_eos().build(); let ev = Event::new_eos().build();
pipeline.send_event(&ev); pipeline.send_event(ev);
glib::Continue(false) glib::Continue(false)
}); });

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
#[allow(unused_imports)] #[allow(unused_imports)]

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ChildProxy; use ChildProxy;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ClockTime; use ClockTime;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ffi; use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ClockTime; use ClockTime;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ffi; use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Caps; use Caps;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Bus; use Bus;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Bus; use Bus;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use DeviceProvider; use DeviceProvider;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Bus; use Bus;
@ -7,7 +7,6 @@ use Clock;
use ClockTime; use ClockTime;
use ElementFactory; use ElementFactory;
use Error; use Error;
use Event;
use Format; use Format;
use Iterator; use Iterator;
use Message; use Message;
@ -181,8 +180,6 @@ pub trait ElementExt {
fn seek_simple(&self, format: Format, seek_flags: SeekFlags, seek_pos: i64) -> Result<(), glib::error::BoolError>; fn seek_simple(&self, format: Format, seek_flags: SeekFlags, seek_pos: i64) -> Result<(), glib::error::BoolError>;
fn send_event(&self, event: &Event) -> bool;
fn set_base_time(&self, time: ClockTime); fn set_base_time(&self, time: ClockTime);
fn set_bus(&self, bus: &Bus); fn set_bus(&self, bus: &Bus);
@ -509,12 +506,6 @@ impl<O: IsA<Element> + IsA<glib::object::Object>> ElementExt for O {
} }
} }
fn send_event(&self, event: &Event) -> bool {
unsafe {
from_glib(ffi::gst_element_send_event(self.to_glib_none().0, event.to_glib_full()))
}
}
fn set_base_time(&self, time: ClockTime) { fn set_base_time(&self, time: ClockTime) {
unsafe { unsafe {
ffi::gst_element_set_base_time(self.to_glib_none().0, time); ffi::gst_element_set_base_time(self.to_glib_none().0, time);

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Caps; use Caps;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ffi; use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ffi; use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Bin; use Bin;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Object; use Object;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
mod bin; mod bin;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ClockTime; use ClockTime;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Caps; use Caps;
@ -87,8 +87,6 @@ pub trait PadExt {
//fn create_stream_id_printf_valist<'a, P: IsA<Element>, Q: Into<Option<&'a str>>>(&self, parent: &P, stream_id: Q, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<String>; //fn create_stream_id_printf_valist<'a, P: IsA<Element>, Q: Into<Option<&'a str>>>(&self, parent: &P, stream_id: Q, var_args: /*Unknown conversion*//*Unimplemented*/Unsupported) -> Option<String>;
fn event_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: &Event) -> bool;
//fn forward<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool; //fn forward<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool;
fn get_allowed_caps(&self) -> Option<Caps>; fn get_allowed_caps(&self) -> Option<Caps>;
@ -161,8 +159,6 @@ pub trait PadExt {
fn peer_query_position(&self, format: Format) -> Option<i64>; fn peer_query_position(&self, format: Format) -> Option<i64>;
fn push_event(&self, event: &Event) -> bool;
//fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn; //fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn;
fn query_accept_caps(&self, caps: &Caps) -> bool; fn query_accept_caps(&self, caps: &Caps) -> bool;
@ -175,8 +171,6 @@ pub trait PadExt {
fn query_position(&self, format: Format) -> Option<i64>; fn query_position(&self, format: Format) -> Option<i64>;
fn send_event(&self, event: &Event) -> bool;
//fn set_activate_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, activate: /*Unknown conversion*//*Unimplemented*/PadActivateFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify); //fn set_activate_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, activate: /*Unknown conversion*//*Unimplemented*/PadActivateFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify);
//fn set_activatemode_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, activatemode: /*Unknown conversion*//*Unimplemented*/PadActivateModeFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify); //fn set_activatemode_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, activatemode: /*Unknown conversion*//*Unimplemented*/PadActivateModeFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify);
@ -265,14 +259,6 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
// unsafe { TODO: call ffi::gst_pad_create_stream_id_printf_valist() } // unsafe { TODO: call ffi::gst_pad_create_stream_id_printf_valist() }
//} //}
fn event_default<'a, P: IsA<Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: &Event) -> bool {
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_pad_event_default(self.to_glib_none().0, parent.0, event.to_glib_full()))
}
}
//fn forward<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool { //fn forward<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, forward: /*Unknown conversion*//*Unimplemented*/PadForwardFunction, user_data: P) -> bool {
// unsafe { TODO: call ffi::gst_pad_forward() } // unsafe { TODO: call ffi::gst_pad_forward() }
//} //}
@ -481,12 +467,6 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
} }
} }
fn push_event(&self, event: &Event) -> bool {
unsafe {
from_glib(ffi::gst_pad_push_event(self.to_glib_none().0, event.to_glib_full()))
}
}
//fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn { //fn push_list(&self, list: /*Ignored*/&mut BufferList) -> FlowReturn {
// unsafe { TODO: call ffi::gst_pad_push_list() } // unsafe { TODO: call ffi::gst_pad_push_list() }
//} //}
@ -529,12 +509,6 @@ impl<O: IsA<Pad> + IsA<glib::object::Object>> PadExt for O {
} }
} }
fn send_event(&self, event: &Event) -> bool {
unsafe {
from_glib(ffi::gst_pad_send_event(self.to_glib_none().0, event.to_glib_full()))
}
}
//fn set_activate_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, activate: /*Unknown conversion*//*Unimplemented*/PadActivateFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) { //fn set_activate_function_full<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, activate: /*Unknown conversion*//*Unimplemented*/PadActivateFunction, user_data: P, notify: /*Unknown conversion*//*Unimplemented*/DestroyNotify) {
// unsafe { TODO: call ffi::gst_pad_set_activate_function_full() } // unsafe { TODO: call ffi::gst_pad_set_activate_function_full() }
//} //}

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Caps; use Caps;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Bin; use Bin;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Error; use Error;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use ffi; use ffi;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Iterator; use Iterator;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
#[cfg(feature = "v1_10")] #[cfg(feature = "v1_10")]

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Object; use Object;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Element; use Element;

View file

@ -1,4 +1,4 @@
// This file was generated by gir (a01311c+) from gir-files (???) // This file was generated by gir (f00d658) from gir-files (???)
// DO NOT EDIT // DO NOT EDIT
use Error; use Error;

View file

@ -12,6 +12,7 @@ use glib;
use glib::IsA; use glib::IsA;
use glib::translate::{from_glib, ToGlibPtr}; use glib::translate::{from_glib, ToGlibPtr};
use QueryRef; use QueryRef;
use Event;
use miniobject::MiniObject; use miniobject::MiniObject;
use ffi; use ffi;
@ -44,6 +45,8 @@ impl Element {
pub trait ElementExtManual { pub trait ElementExtManual {
fn query(&self, query: &mut QueryRef) -> bool; fn query(&self, query: &mut QueryRef) -> bool;
fn send_event(&self, event: Event) -> bool;
} }
impl<O: IsA<Element>> ElementExtManual for O { impl<O: IsA<Element>> ElementExtManual for O {
@ -55,4 +58,10 @@ impl<O: IsA<Element>> ElementExtManual for O {
)) ))
} }
} }
fn send_event(&self, event: Event) -> bool {
unsafe {
from_glib(ffi::gst_element_send_event(self.to_glib_none().0, event.into_ptr()))
}
}
} }

View file

@ -86,6 +86,10 @@ pub trait PadExtManual {
) -> bool; ) -> bool;
fn proxy_query_caps(&self, query: &mut QueryRef) -> bool; fn proxy_query_caps(&self, query: &mut QueryRef) -> bool;
fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool; fn proxy_query_accept_caps(&self, query: &mut QueryRef) -> bool;
fn event_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: Event) -> bool;
fn push_event(&self, event: Event) -> bool;
fn send_event(&self, event: Event) -> bool;
} }
impl<O: IsA<Pad>> PadExtManual for O { impl<O: IsA<Pad>> PadExtManual for O {
@ -205,6 +209,26 @@ impl<O: IsA<Pad>> PadExtManual for O {
)) ))
} }
} }
fn event_default<'a, P: IsA<::Object> + 'a, Q: Into<Option<&'a P>>>(&self, parent: Q, event: Event) -> bool {
let parent = parent.into();
let parent = parent.to_glib_none();
unsafe {
from_glib(ffi::gst_pad_event_default(self.to_glib_none().0, parent.0, event.into_ptr()))
}
}
fn push_event(&self, event: Event) -> bool {
unsafe {
from_glib(ffi::gst_pad_push_event(self.to_glib_none().0, event.into_ptr()))
}
}
fn send_event(&self, event: Event) -> bool {
unsafe {
from_glib(ffi::gst_pad_send_event(self.to_glib_none().0, event.into_ptr()))
}
}
} }
unsafe extern "C" fn trampoline_pad_probe( unsafe extern "C" fn trampoline_pad_probe(