threadshare/inputselector: Port to latest API

This commit is contained in:
Sebastian Dröge 2020-02-19 21:42:19 +02:00
parent b3becb01c3
commit 575efcab7e

View file

@ -17,7 +17,6 @@
use either::Either; use either::Either;
use futures::channel::oneshot;
use futures::executor::block_on; use futures::executor::block_on;
use futures::future::BoxFuture; use futures::future::BoxFuture;
use futures::future::{abortable, AbortHandle}; use futures::future::{abortable, AbortHandle};
@ -43,7 +42,7 @@ use std::time::Duration;
use std::u32; use std::u32;
use crate::runtime::prelude::*; use crate::runtime::prelude::*;
use crate::runtime::{Context, PadSink, PadSinkRef, PadSrc}; use crate::runtime::{self, Context, PadSink, PadSinkRef, PadSrc};
fn get_current_running_time(element: &gst::Element) -> gst::ClockTime { fn get_current_running_time(element: &gst::Element) -> gst::ClockTime {
if let Some(clock) = element.get_clock() { if let Some(clock) = element.get_clock() {
@ -139,22 +138,11 @@ impl InputSelectorPadSinkHandler {
/* Wait until specified time */ /* Wait until specified time */
async fn sync(&self, element: &gst::Element, running_time: gst::ClockTime) { async fn sync(&self, element: &gst::Element, running_time: gst::ClockTime) {
let inputselector = InputSelector::from_instance(element);
let now = get_current_running_time(&element); let now = get_current_running_time(&element);
if now.is_some() && now < running_time { if now.is_some() && now < running_time {
let pad_src_state = inputselector.src_pad.lock_state().await;
let context = pad_src_state.pad_context().unwrap();
let (sender, receiver) = oneshot::channel();
let delay = running_time - now; let delay = running_time - now;
let delay_for_fut = runtime::time::delay_for(Duration::from_nanos(delay.nseconds().unwrap())).await;
context.delay_for(Duration::from_nanos(delay.nseconds().unwrap()), move || {
async {
let _ = sender.send(());
}
});
context.spawn(delay_for_fut);
let _ = receiver.await;
} }
} }
@ -222,7 +210,7 @@ impl PadSinkHandler for InputSelectorPadSinkHandler {
fn sink_chain( fn sink_chain(
&self, &self,
pad: PadSinkRef, pad: &PadSinkRef,
_inputselector: &InputSelector, _inputselector: &InputSelector,
element: &gst::Element, element: &gst::Element,
buffer: gst::Buffer, buffer: gst::Buffer,
@ -239,7 +227,7 @@ impl PadSinkHandler for InputSelectorPadSinkHandler {
fn sink_chain_list( fn sink_chain_list(
&self, &self,
pad: PadSinkRef, pad: &PadSinkRef,
_inputselector: &InputSelector, _inputselector: &InputSelector,
element: &gst::Element, element: &gst::Element,
list: gst::BufferList, list: gst::BufferList,
@ -257,7 +245,7 @@ impl PadSinkHandler for InputSelectorPadSinkHandler {
fn sink_event( fn sink_event(
&self, &self,
_pad: PadSinkRef, _pad: &PadSinkRef,
inputselector: &InputSelector, inputselector: &InputSelector,
_element: &gst::Element, _element: &gst::Element,
event: gst::Event, event: gst::Event,
@ -298,7 +286,7 @@ impl PadSinkHandler for InputSelectorPadSinkHandler {
fn sink_query( fn sink_query(
&self, &self,
pad: PadSinkRef, pad: &PadSinkRef,
inputselector: &InputSelector, inputselector: &InputSelector,
_element: &gst::Element, _element: &gst::Element,
query: &mut gst::QueryRef, query: &mut gst::QueryRef,