mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2025-01-07 07:45:27 +00:00
gstreamer/clock: Add ClockID::wait_async_stream()
This provides an async stream with the values of each timeout.
This commit is contained in:
parent
f65efb41e8
commit
5d80372dd3
1 changed files with 21 additions and 0 deletions
|
@ -25,6 +25,9 @@ use ClockSuccess;
|
|||
use ClockTime;
|
||||
use ClockTimeDiff;
|
||||
|
||||
use futures_core::Stream;
|
||||
use std::marker::Unpin;
|
||||
use std::pin::Pin;
|
||||
use std::sync::atomic;
|
||||
use std::sync::atomic::AtomicI32;
|
||||
|
||||
|
@ -102,6 +105,24 @@ impl ClockId {
|
|||
ret.into_result()
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn wait_async_stream(
|
||||
&self,
|
||||
) -> Result<
|
||||
Pin<Box<dyn Stream<Item = (ClockTime, ClockId)> + Unpin + Send + 'static>>,
|
||||
ClockError,
|
||||
> {
|
||||
use futures_channel::mpsc;
|
||||
|
||||
let (sender, receiver) = mpsc::unbounded();
|
||||
|
||||
self.wait_async(move |_clock, jitter, id| {
|
||||
let _ = sender.unbounded_send((jitter, id.clone()));
|
||||
})?;
|
||||
|
||||
Ok(Box::pin(receiver))
|
||||
}
|
||||
|
||||
pub fn compare_by_time(&self, other: &Self) -> cmp::Ordering {
|
||||
unsafe {
|
||||
let res =
|
||||
|
|
Loading…
Reference in a new issue