gstreamer/
bus_unix.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3cfg_if::cfg_if! {
4    if #[cfg(unix)] {
5        use glib::translate::ToGlibPtr;
6
7        use std::mem;
8        use std::os::unix;
9    } else if #[cfg(docsrs)] {
10        // Declare a fake RawFd for doc generation on windows
11        pub mod unix {
12            pub mod io {
13                pub struct RawFd{}
14            }
15        }
16    }
17}
18
19use super::Bus;
20
21pub trait UnixBusExtManual: 'static {
22    #[doc(alias = "get_pollfd")]
23    #[doc(alias = "gst_bus_get_pollfd")]
24    fn pollfd(&self) -> unix::io::RawFd;
25}
26
27impl UnixBusExtManual for Bus {
28    fn pollfd(&self) -> unix::io::RawFd {
29        #[cfg(unix)]
30        unsafe {
31            let mut pollfd = mem::MaybeUninit::uninit();
32            crate::ffi::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr());
33            let pollfd = pollfd.assume_init();
34            pollfd.fd
35        }
36
37        #[cfg(all(not(unix), docsrs))]
38        unix::io::RawFd {}
39    }
40}