From db3fe694154c697afdaf3efb6ec65332546942e0 Mon Sep 17 00:00:00 2001 From: JohanGoversTech <35530199+JohanGoversTech@users.noreply.github.com> Date: Thu, 14 Jun 2018 14:45:54 +0200 Subject: [PATCH] Change return type of add_probe to support removing (#116) * Change return type of add_probe to support 0 PadProbeId * use from_glib for the conversion of the PadProbeId --- gstreamer/src/pad.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/gstreamer/src/pad.rs b/gstreamer/src/pad.rs index c8869250a..0fefa8763 100644 --- a/gstreamer/src/pad.rs +++ b/gstreamer/src/pad.rs @@ -102,7 +102,7 @@ impl Drop for StreamLock { } pub trait PadExtManual { - fn add_probe(&self, mask: PadProbeType, func: F) -> PadProbeId + fn add_probe(&self, mask: PadProbeType, func: F) -> Option where F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static; fn remove_probe(&self, id: PadProbeId); @@ -225,7 +225,7 @@ pub trait PadExtManual { } impl> PadExtManual for O { - fn add_probe(&self, mask: PadProbeType, func: F) -> PadProbeId + fn add_probe(&self, mask: PadProbeType, func: F) -> Option where F: Fn(&Pad, &mut PadProbeInfo) -> PadProbeReturn + Send + Sync + 'static, { @@ -241,7 +241,11 @@ impl> PadExtManual for O { Some(destroy_closure), ); - from_glib(id) + if id == 0 { + None + } else { + Some(from_glib(id)) + } } }