1 // Copyright (C) 2016-2018 Sebastian Dröge <sebastian@centricular.com> 2 // 3 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or 4 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license 5 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your 6 // option. This file may not be copied, modified, or distributed 7 // except according to those terms. 8 9 #[macro_use] 10 cfg_if! { 11 if #[cfg(unix)] { 12 use gst_sys; 13 use glib::translate::ToGlibPtr; 14 15 use std::mem; 16 use std::os::unix; 17 } else if #[cfg(feature = "dox")] { 18 // Declare a fake RawFd for doc generation on windows 19 pub mod unix { 20 pub mod io { 21 pub struct RawFd{} 22 } 23 } 24 } 25 } 26 27 use super::Bus; 28 29 pub trait UnixBusExtManual: 'static { get_pollfd(&self) -> unix::io::RawFd30 fn get_pollfd(&self) -> unix::io::RawFd; 31 } 32 33 impl UnixBusExtManual for Bus { 34 /// This is supported on **Unix** only. get_pollfd(&self) -> unix::io::RawFd35 fn get_pollfd(&self) -> unix::io::RawFd { 36 #[cfg(unix)] 37 unsafe { 38 let mut pollfd = mem::MaybeUninit::zeroed(); 39 gst_sys::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr()); 40 let pollfd = pollfd.assume_init(); 41 pollfd.fd 42 } 43 44 #[cfg(all(not(unix), feature = "dox"))] 45 unix::io::RawFd {} 46 } 47 } 48