From 23ef3c1f08f945b1f3b0863d4742f00743cdf31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 1 Aug 2017 20:52:29 +0300 Subject: [PATCH] Add a function to unset the Bus' current sync handler And use it in the Tokio example to unset the handler once the BusStream is dropped. --- examples/src/bin/tokio.rs | 6 ++++++ gstreamer/src/bus.rs | 12 ++++++++++++ 2 files changed, 18 insertions(+) diff --git a/examples/src/bin/tokio.rs b/examples/src/bin/tokio.rs index a130c6da7..b10f637e7 100644 --- a/examples/src/bin/tokio.rs +++ b/examples/src/bin/tokio.rs @@ -32,6 +32,12 @@ impl BusStream { } } +impl Drop for BusStream { + fn drop(&mut self) { + self.0.unset_sync_handler(); + } +} + impl Stream for BusStream { type Item = Message; type Error = (); diff --git a/gstreamer/src/bus.rs b/gstreamer/src/bus.rs index a0d66332b..14c290548 100644 --- a/gstreamer/src/bus.rs +++ b/gstreamer/src/bus.rs @@ -14,6 +14,7 @@ use glib::translate::*; use glib::source::{CallbackGuard, Continue, Priority, SourceId}; use glib_ffi; use glib_ffi::{gboolean, gpointer}; +use std::ptr; use Bus; use BusSyncReply; @@ -119,4 +120,15 @@ impl Bus { ) } } + + pub fn unset_sync_handler(&self) { + unsafe { + ffi::gst_bus_set_sync_handler( + self.to_glib_none().0, + None, + ptr::null_mut(), + None, + ) + } + } }