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.
This commit is contained in:
Sebastian Dröge 2017-08-01 20:52:29 +03:00
parent 7e079e927d
commit 23ef3c1f08
2 changed files with 18 additions and 0 deletions

View file

@ -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 = ();

View file

@ -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,
)
}
}
}