mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2025-09-02 17:53:48 +00:00
transcriberbin: Don't keep state locked while querying upstream latency
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/2463>
This commit is contained in:
parent
357336cd56
commit
9710476c96
1 changed files with 20 additions and 16 deletions
|
@ -16,6 +16,7 @@ use std::collections::{HashMap, HashSet};
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use std::sync::LazyLock;
|
use std::sync::LazyLock;
|
||||||
|
use std::sync::MutexGuard;
|
||||||
|
|
||||||
use super::{CaptionSource, MuxMethod};
|
use super::{CaptionSource, MuxMethod};
|
||||||
|
|
||||||
|
@ -2175,19 +2176,21 @@ impl TranscriberBin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_upstream_latency(&self, state: &State) -> gst::ClockTime {
|
fn query_upstream_latency(&self, state_guard: MutexGuard<Option<State>>) -> gst::ClockTime {
|
||||||
|
let state = state_guard.as_ref().unwrap();
|
||||||
let mut min = gst::ClockTime::from_seconds(0);
|
let mut min = gst::ClockTime::from_seconds(0);
|
||||||
|
|
||||||
for pad in state
|
let pads = Iterator::chain(
|
||||||
.audio_sink_pads
|
state
|
||||||
.values()
|
.audio_sink_pads
|
||||||
.map(|p| p.upcast_ref::<gst::Pad>())
|
.values()
|
||||||
.chain(
|
.map(|p| p.clone().upcast::<gst::Pad>()),
|
||||||
[&self.video_sinkpad]
|
std::iter::once(&self.video_sinkpad).map(|p| p.clone().upcast::<gst::Pad>()),
|
||||||
.iter()
|
)
|
||||||
.map(|p| p.upcast_ref::<gst::Pad>()),
|
.collect::<Vec<_>>();
|
||||||
)
|
drop(state_guard);
|
||||||
{
|
|
||||||
|
for pad in pads {
|
||||||
let mut upstream_query = gst::query::Latency::new();
|
let mut upstream_query = gst::query::Latency::new();
|
||||||
|
|
||||||
if pad.peer_query(&mut upstream_query) {
|
if pad.peer_query(&mut upstream_query) {
|
||||||
|
@ -2270,11 +2273,12 @@ impl TranscriberBin {
|
||||||
|
|
||||||
match query.view_mut() {
|
match query.view_mut() {
|
||||||
QueryViewMut::Latency(q) => {
|
QueryViewMut::Latency(q) => {
|
||||||
let state = self.state.lock().unwrap();
|
let state_guard = self.state.lock().unwrap();
|
||||||
if let Some(state) = state.as_ref() {
|
if let Some(ref state) = &*state_guard {
|
||||||
let upstream_min = self.query_upstream_latency(state);
|
let our_latency = self.our_latency(state, &self.settings.lock().unwrap());
|
||||||
let min =
|
let upstream_min = self.query_upstream_latency(state_guard);
|
||||||
upstream_min + self.our_latency(state, &self.settings.lock().unwrap());
|
|
||||||
|
let min = upstream_min + our_latency;
|
||||||
|
|
||||||
gst::debug!(CAT, imp = self, "calculated latency: {}", min);
|
gst::debug!(CAT, imp = self, "calculated latency: {}", min);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue