Update to byte-slice-cast 1.0 and switch from lazy_static to once_cell

This commit is contained in:
Sebastian Dröge 2021-02-23 12:29:04 +02:00
parent c1d9c0e958
commit eee4a65d19
3 changed files with 21 additions and 23 deletions

View file

@ -14,8 +14,7 @@ gstreamer = { version = "0.16", features = ["v1_12"] }
gstreamer-base = "0.16"
gstreamer-audio = "0.16"
gstreamer-video = { version = "0.16", features = ["v1_12"] }
lazy_static = "1.1.0"
byte-slice-cast = "0.3.0"
byte-slice-cast = "1"
once_cell = "1.0"
[build-dependencies]

View file

@ -7,8 +7,6 @@ extern crate gstreamer_audio as gst_audio;
extern crate gstreamer_base as gst_base;
extern crate gstreamer_video as gst_video;
#[macro_use]
extern crate lazy_static;
extern crate byte_slice_cast;
mod device_provider;
@ -25,6 +23,8 @@ use crate::receiver::*;
use std::collections::HashMap;
use std::time;
use once_cell::sync::Lazy;
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[repr(u32)]
pub enum TimestampMode {
@ -44,21 +44,20 @@ fn plugin_init(plugin: &gst::Plugin) -> Result<(), glib::BoolError> {
Ok(())
}
lazy_static! {
static ref DEFAULT_RECEIVER_NDI_NAME: String = {
format!(
"GStreamer NDI Source {}-{}",
env!("CARGO_PKG_VERSION"),
env!("COMMIT_ID")
)
};
}
static DEFAULT_RECEIVER_NDI_NAME: Lazy<String> = Lazy::new(|| {
format!(
"GStreamer NDI Source {}-{}",
env!("CARGO_PKG_VERSION"),
env!("COMMIT_ID")
)
});
#[cfg(feature = "reference-timestamps")]
lazy_static! {
static ref TIMECODE_CAPS: gst::Caps = gst::Caps::new_simple("timestamp/x-ndi-timecode", &[]);
static ref TIMESTAMP_CAPS: gst::Caps = gst::Caps::new_simple("timestamp/x-ndi-timestamp", &[]);
}
static TIMECODE_CAPS: Lazy<gst::Caps> =
Lazy::new(|| gst::Caps::new_simple("timestamp/x-ndi-timecode", &[]));
#[cfg(feature = "reference-timestamps")]
static TIMESTAMP_CAPS: Lazy<gst::Caps> =
Lazy::new(|| gst::Caps::new_simple("timestamp/x-ndi-timestamp", &[]));
impl glib::translate::ToGlib for TimestampMode {
type GlibType = i32;

View file

@ -13,6 +13,8 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use std::sync::{Arc, Condvar, Mutex, Weak};
use std::thread;
use once_cell::sync::Lazy;
use super::*;
pub struct ReceiverInfo {
@ -25,12 +27,10 @@ pub struct ReceiverInfo {
observations: Observations,
}
lazy_static! {
static ref HASHMAP_RECEIVERS: Mutex<HashMap<usize, ReceiverInfo>> = {
let m = HashMap::new();
Mutex::new(m)
};
}
static HASHMAP_RECEIVERS: Lazy<Mutex<HashMap<usize, ReceiverInfo>>> = Lazy::new(|| {
let m = HashMap::new();
Mutex::new(m)
});
static ID_RECEIVER: AtomicUsize = AtomicUsize::new(0);