2020-12-15 10:53:31 +00:00
|
|
|
// Take a look at the license at the top of the repository in the LICENSE file.
|
2018-03-19 10:53:01 +00:00
|
|
|
|
2020-11-21 13:46:48 +00:00
|
|
|
cfg_if::cfg_if! {
|
2018-03-19 10:53:01 +00:00
|
|
|
if #[cfg(unix)] {
|
|
|
|
use glib::translate::ToGlibPtr;
|
|
|
|
|
|
|
|
use std::mem;
|
|
|
|
use std::os::unix;
|
2020-11-27 13:37:49 +00:00
|
|
|
} else if #[cfg(feature = "dox")] {
|
2018-03-19 10:53:01 +00:00
|
|
|
// Declare a fake RawFd for doc generation on windows
|
|
|
|
pub mod unix {
|
|
|
|
pub mod io {
|
|
|
|
pub struct RawFd{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
use super::Bus;
|
|
|
|
|
2018-12-08 09:22:42 +00:00
|
|
|
pub trait UnixBusExtManual: 'static {
|
2021-05-02 09:41:18 +00:00
|
|
|
#[doc(alias = "get_pollfd")]
|
2021-05-19 20:35:47 +00:00
|
|
|
#[doc(alias = "gst_bus_get_pollfd")]
|
2021-04-11 19:39:50 +00:00
|
|
|
fn pollfd(&self) -> unix::io::RawFd;
|
2018-03-19 10:53:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl UnixBusExtManual for Bus {
|
2021-04-11 19:39:50 +00:00
|
|
|
fn pollfd(&self) -> unix::io::RawFd {
|
2018-03-19 10:53:01 +00:00
|
|
|
#[cfg(unix)]
|
|
|
|
unsafe {
|
2019-07-11 13:02:46 +00:00
|
|
|
let mut pollfd = mem::MaybeUninit::zeroed();
|
2020-11-21 13:46:48 +00:00
|
|
|
ffi::gst_bus_get_pollfd(self.to_glib_none().0, pollfd.as_mut_ptr());
|
2019-07-11 13:02:46 +00:00
|
|
|
let pollfd = pollfd.assume_init();
|
2018-03-19 10:53:01 +00:00
|
|
|
pollfd.fd
|
|
|
|
}
|
|
|
|
|
2020-11-27 13:37:49 +00:00
|
|
|
#[cfg(all(not(unix), feature = "dox"))]
|
2018-03-19 10:53:01 +00:00
|
|
|
unix::io::RawFd {}
|
|
|
|
}
|
|
|
|
}
|