mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-28 23:02:13 +00:00
ndisrc: Remove unnecessary Arc around the timestamp observations and use AtomicRefCell instead of Mutex
This commit is contained in:
parent
718734ab18
commit
b82acb9ca9
2 changed files with 6 additions and 4 deletions
|
@ -16,6 +16,7 @@ gst-video = { package = "gstreamer-video", version = "0.18", features = ["v1_12"
|
||||||
byte-slice-cast = "1"
|
byte-slice-cast = "1"
|
||||||
once_cell = "1.0"
|
once_cell = "1.0"
|
||||||
byteorder = "1.0"
|
byteorder = "1.0"
|
||||||
|
atomic_refcell = "0.1"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gst-plugin-version-helper = "0.7"
|
gst-plugin-version-helper = "0.7"
|
||||||
|
|
|
@ -10,6 +10,8 @@ use std::collections::VecDeque;
|
||||||
use std::sync::{Arc, Condvar, Mutex, Weak};
|
use std::sync::{Arc, Condvar, Mutex, Weak};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
|
use atomic_refcell::AtomicRefCell;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
|
||||||
|
@ -225,8 +227,7 @@ struct ReceiverQueueInner {
|
||||||
const WINDOW_LENGTH: u64 = 512;
|
const WINDOW_LENGTH: u64 = 512;
|
||||||
const WINDOW_DURATION: u64 = 2_000_000_000;
|
const WINDOW_DURATION: u64 = 2_000_000_000;
|
||||||
|
|
||||||
#[derive(Clone)]
|
struct Observations(AtomicRefCell<ObservationsInner>);
|
||||||
struct Observations(Arc<Mutex<ObservationsInner>>);
|
|
||||||
|
|
||||||
struct ObservationsInner {
|
struct ObservationsInner {
|
||||||
base_remote_time: Option<u64>,
|
base_remote_time: Option<u64>,
|
||||||
|
@ -254,7 +255,7 @@ impl Default for ObservationsInner {
|
||||||
|
|
||||||
impl Observations {
|
impl Observations {
|
||||||
fn new() -> Self {
|
fn new() -> Self {
|
||||||
Self(Arc::new(Mutex::new(ObservationsInner::default())))
|
Self(AtomicRefCell::new(ObservationsInner::default()))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Based on the algorithm used in GStreamer's rtpjitterbuffer, which comes from
|
// Based on the algorithm used in GStreamer's rtpjitterbuffer, which comes from
|
||||||
|
@ -282,7 +283,7 @@ impl Observations {
|
||||||
gst::ClockTime::from_nseconds(remote_time),
|
gst::ClockTime::from_nseconds(remote_time),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut inner = self.0.lock().unwrap();
|
let mut inner = self.0.borrow_mut();
|
||||||
|
|
||||||
let (base_remote_time, base_local_time) =
|
let (base_remote_time, base_local_time) =
|
||||||
match (inner.base_remote_time, inner.base_local_time) {
|
match (inner.base_remote_time, inner.base_local_time) {
|
||||||
|
|
Loading…
Reference in a new issue