2018-03-19 10:53:01 +00:00
|
|
|
// Copyright (C) 2016-2018 Sebastian Dröge <sebastian@centricular.com>
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
#[macro_use]
|
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-25 14:54:02 +00:00
|
|
|
} else if #[cfg(all(not(doctest), doc))] {
|
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 {
|
2018-03-19 10:53:01 +00:00
|
|
|
fn get_pollfd(&self) -> unix::io::RawFd;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl UnixBusExtManual for Bus {
|
|
|
|
fn get_pollfd(&self) -> unix::io::RawFd {
|
|
|
|
#[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-25 14:54:02 +00:00
|
|
|
#[cfg(all(not(unix), all(not(doctest), doc)))]
|
2018-03-19 10:53:01 +00:00
|
|
|
unix::io::RawFd {}
|
|
|
|
}
|
|
|
|
}
|