Remove once_cell dependency

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1567>
This commit is contained in:
Sebastian Dröge 2024-10-21 20:49:40 +03:00 committed by GStreamer Marge Bot
parent 38aeec4ec5
commit 048f3e1be5
21 changed files with 60 additions and 71 deletions

7
Cargo.lock generated
View file

@ -539,7 +539,6 @@ dependencies = [
"memfd",
"memmap2",
"objc",
"once_cell",
"pango",
"pangocairo",
"raw-window-handle",
@ -890,7 +889,6 @@ dependencies = [
"muldiv",
"num-integer",
"num-rational",
"once_cell",
"option-operations",
"paste",
"pin-project-lite",
@ -911,7 +909,6 @@ dependencies = [
"gstreamer",
"gstreamer-allocators-sys",
"libc",
"once_cell",
]
[[package]]
@ -991,7 +988,6 @@ dependencies = [
"gstreamer-base",
"itertools",
"libc",
"once_cell",
"serde",
"serde_json",
"smallvec",
@ -1126,7 +1122,6 @@ dependencies = [
"gstreamer-gl-sys",
"gstreamer-video",
"libc",
"once_cell",
"serde",
"serde_json",
]
@ -1502,7 +1497,6 @@ dependencies = [
"gstreamer",
"gstreamer-app",
"gstreamer-video",
"once_cell",
"thiserror",
]
@ -1546,7 +1540,6 @@ dependencies = [
"gstreamer-video-sys",
"itertools",
"libc",
"once_cell",
"serde",
"serde_json",
"thiserror",

View file

@ -43,7 +43,6 @@ uds = { version = "0.4", optional = true }
winit = { version = "0.29", optional = true, default-features = false, features = ["rwh_05"] }
atomic_refcell = "0.1"
data-encoding = "2.0"
once_cell = "1"
[target.'cfg(windows)'.dependencies]
windows = { version = "0.58", features=["Win32_Graphics_Direct3D11",

View file

@ -365,9 +365,9 @@ mod video_filter {
use gst_app::gst_base::subclass::BaseTransformMode;
use gst_video::{prelude::*, subclass::prelude::*, VideoFrameRef};
use memmap2::MmapMut;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new(
"fdmemoryfilter",
gst::DebugColorFlags::empty(),

View file

@ -38,11 +38,11 @@ mod mirror {
subclass::{prelude::*, GLFilterMode},
*,
};
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use super::{gl, FRAGMENT_SHADER};
pub static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
pub static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new(
"rsglmirrorfilter",
gst::DebugColorFlags::empty(),

View file

@ -18,10 +18,10 @@ mod examples_common;
mod fir_filter {
use byte_slice_cast::*;
use gst_base::subclass::prelude::*;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
// The debug category we use below for our filter
pub static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
pub static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new(
"rsfirfilter",
gst::DebugColorFlags::empty(),

View file

@ -4,14 +4,14 @@ use std::{collections::VecDeque, sync::Mutex};
use glib::prelude::*;
use gst_audio::subclass::prelude::*;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use byte_slice_cast::*;
use atomic_refcell::AtomicRefCell;
// The debug category we use below for our filter
pub static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
pub static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new(
"rsiirfilter",
gst::DebugColorFlags::empty(),

View file

@ -18,7 +18,6 @@ libc = "0.2"
gstreamer-allocators-sys.workspace = true
glib.workspace = true
gst.workspace = true
once_cell = "1"
[dev-dependencies]
gir-format-check = "0.1"

View file

@ -1,7 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use gst::CapsFeatures;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
pub static CAPS_FEATURES_MEMORY_DMABUF: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([crate::CAPS_FEATURE_MEMORY_DMABUF]));
pub static CAPS_FEATURES_MEMORY_DMABUF: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([crate::CAPS_FEATURE_MEMORY_DMABUF]));

View file

@ -22,7 +22,6 @@ gst.workspace = true
gst-base.workspace = true
serde = { version = "1.0", optional = true }
smallvec = "1.0"
once_cell = "1"
[dev-dependencies]
itertools = "0.13"

View file

@ -4,10 +4,10 @@ use std::str;
use crate::ffi;
use glib::translate::{from_glib, IntoGlib};
use once_cell::sync::Lazy;
use std::sync::LazyLock;
#[cfg(feature = "v1_18")]
pub static AUDIO_FORMATS_ALL: Lazy<Box<[crate::AudioFormat]>> = Lazy::new(|| unsafe {
pub static AUDIO_FORMATS_ALL: LazyLock<Box<[crate::AudioFormat]>> = LazyLock::new(|| unsafe {
let mut len: u32 = 0;
let mut res = Vec::with_capacity(len as usize);
let formats = ffi::gst_audio_formats_raw(&mut len);
@ -19,7 +19,7 @@ pub static AUDIO_FORMATS_ALL: Lazy<Box<[crate::AudioFormat]>> = Lazy::new(|| uns
});
#[cfg(not(feature = "v1_18"))]
pub static AUDIO_FORMATS_ALL: Lazy<Box<[crate::AudioFormat]>> = Lazy::new(|| {
pub static AUDIO_FORMATS_ALL: LazyLock<Box<[crate::AudioFormat]>> = LazyLock::new(|| {
#[cfg(target_endian = "little")]
{
Box::new([

View file

@ -24,7 +24,6 @@ gst.workspace = true
gst-base.workspace = true
gst-video.workspace = true
serde = { version = "1.0", optional = true }
once_cell = "1"
[dev-dependencies]
gir-format-check = "0.1"

View file

@ -1,7 +1,7 @@
// Take a look at the license at the top of the repository in the LICENSE file.
use gst::CapsFeatures;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
pub static CAPS_FEATURES_MEMORY_GL_MEMORY: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([crate::CAPS_FEATURE_MEMORY_GL_MEMORY]));
pub static CAPS_FEATURES_MEMORY_GL_MEMORY: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([crate::CAPS_FEATURE_MEMORY_GL_MEMORY]));

View file

@ -19,7 +19,6 @@ rust-version.workspace = true
gst = { workspace = true, features = ["v1_20"] }
gst-app = { workspace = true, features = ["v1_20"] }
gst-video = { workspace = true, features = ["v1_20"] }
once_cell = "1"
thiserror = "1"
[dev-dependencies]

View file

@ -5,7 +5,7 @@ use std::{
};
use gst::{glib, prelude::*};
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use thiserror::Error;
// Small wrapper around AtomicU64 and a Mutex, to allow it to run regular AtomicU64
@ -59,7 +59,7 @@ impl WrappedAtomicU64 {
}
}
static CAT: Lazy<gst::DebugCategory> = Lazy::new(|| {
static CAT: LazyLock<gst::DebugCategory> = LazyLock::new(|| {
gst::DebugCategory::new(
"utilsrs-stream-producer",
gst::DebugColorFlags::empty(),

View file

@ -24,7 +24,6 @@ gst-base.workspace = true
futures-channel = "0.3"
serde = { version = "1.0", optional = true, features = ["derive"] }
thiserror = "1.0.49"
once_cell = "1"
[dev-dependencies]
itertools = "0.13"

View file

@ -2,7 +2,7 @@
use crate::ffi;
use gst::CapsFeatures;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
@ -10,34 +10,34 @@ pub static CAPS_FEATURE_FORMAT_INTERLACED: &glib::GStr =
unsafe { glib::GStr::from_utf8_with_nul_unchecked(ffi::GST_CAPS_FEATURE_FORMAT_INTERLACED) };
#[cfg(feature = "v1_16")]
#[cfg_attr(docsrs, doc(cfg(feature = "v1_16")))]
pub static CAPS_FEATURES_FORMAT_INTERLACED: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_FORMAT_INTERLACED]));
pub static CAPS_FEATURES_FORMAT_INTERLACED: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([CAPS_FEATURE_FORMAT_INTERLACED]));
pub static CAPS_FEATURE_META_GST_VIDEO_AFFINE_TRANSFORMATION_META: &glib::GStr = unsafe {
glib::GStr::from_utf8_with_nul_unchecked(
ffi::GST_CAPS_FEATURE_META_GST_VIDEO_AFFINE_TRANSFORMATION_META,
)
};
pub static CAPS_FEATURES_META_GST_VIDEO_AFFINE_TRANSFORMATION_META: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_AFFINE_TRANSFORMATION_META]));
pub static CAPS_FEATURES_META_GST_VIDEO_AFFINE_TRANSFORMATION_META: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_AFFINE_TRANSFORMATION_META]));
pub static CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META: &glib::GStr = unsafe {
glib::GStr::from_utf8_with_nul_unchecked(
ffi::GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META,
)
};
pub static CAPS_FEATURES_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META]));
pub static CAPS_FEATURES_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META]));
pub static CAPS_FEATURE_META_GST_VIDEO_META: &glib::GStr =
unsafe { glib::GStr::from_utf8_with_nul_unchecked(ffi::GST_CAPS_FEATURE_META_GST_VIDEO_META) };
pub static CAPS_FEATURES_META_GST_VIDEO_META: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_META]));
pub static CAPS_FEATURES_META_GST_VIDEO_META: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_META]));
pub static CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION: &glib::GStr = unsafe {
glib::GStr::from_utf8_with_nul_unchecked(
ffi::GST_CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION,
)
};
pub static CAPS_FEATURES_META_GST_VIDEO_OVERLAY_COMPOSITION: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION]));
pub static CAPS_FEATURES_META_GST_VIDEO_OVERLAY_COMPOSITION: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([CAPS_FEATURE_META_GST_VIDEO_OVERLAY_COMPOSITION]));

View file

@ -4,10 +4,10 @@ use std::str;
use crate::ffi;
use glib::translate::{from_glib, FromGlib, IntoGlib};
use once_cell::sync::Lazy;
use std::sync::LazyLock;
#[cfg(feature = "v1_18")]
pub static VIDEO_FORMATS_ALL: Lazy<Box<[crate::VideoFormat]>> = Lazy::new(|| unsafe {
pub static VIDEO_FORMATS_ALL: LazyLock<Box<[crate::VideoFormat]>> = LazyLock::new(|| unsafe {
let mut len: u32 = 0;
let mut res = Vec::with_capacity(len as usize);
let formats = ffi::gst_video_formats_raw(&mut len);
@ -19,7 +19,7 @@ pub static VIDEO_FORMATS_ALL: Lazy<Box<[crate::VideoFormat]>> = Lazy::new(|| uns
});
#[cfg(not(feature = "v1_18"))]
pub static VIDEO_FORMATS_ALL: Lazy<Box<[crate::VideoFormat]>> = Lazy::new(|| {
pub static VIDEO_FORMATS_ALL: LazyLock<Box<[crate::VideoFormat]>> = LazyLock::new(|| {
#[cfg(target_endian = "little")]
{
Box::new([
@ -211,7 +211,7 @@ pub static VIDEO_FORMATS_ALL: Lazy<Box<[crate::VideoFormat]>> = Lazy::new(|| {
});
#[cfg(feature = "v1_24")]
pub static VIDEO_FORMATS_ANY: Lazy<Box<[crate::VideoFormat]>> = Lazy::new(|| unsafe {
pub static VIDEO_FORMATS_ANY: LazyLock<Box<[crate::VideoFormat]>> = LazyLock::new(|| unsafe {
let mut len: u32 = 0;
let mut res = Vec::with_capacity(len as usize);
let formats = ffi::gst_video_formats_any(&mut len);

View file

@ -33,7 +33,6 @@ thiserror = "1"
smallvec = { version = "1.0", features = ["write"] }
itertools = "0.13"
pin-project-lite = "0.2"
once_cell = "1"
[dev-dependencies]
ron = "0.8"

View file

@ -11,7 +11,7 @@ use std::{
use crate::ffi;
use glib::{prelude::*, translate::*};
use once_cell::sync::Lazy;
use std::sync::LazyLock;
#[doc(alias = "GstCapsFeatures")]
#[repr(transparent)]
@ -860,8 +860,8 @@ unsafe impl Send for CapsFeaturesRef {}
pub static CAPS_FEATURE_MEMORY_SYSTEM_MEMORY: &glib::GStr =
unsafe { glib::GStr::from_utf8_with_nul_unchecked(ffi::GST_CAPS_FEATURE_MEMORY_SYSTEM_MEMORY) };
pub static CAPS_FEATURES_MEMORY_SYSTEM_MEMORY: Lazy<CapsFeatures> =
Lazy::new(|| CapsFeatures::new([CAPS_FEATURE_MEMORY_SYSTEM_MEMORY]));
pub static CAPS_FEATURES_MEMORY_SYSTEM_MEMORY: LazyLock<CapsFeatures> =
LazyLock::new(|| CapsFeatures::new([CAPS_FEATURE_MEMORY_SYSTEM_MEMORY]));
#[cfg(test)]
mod tests {

View file

@ -6,7 +6,7 @@ use glib::{ffi::gpointer, prelude::*, translate::*};
use libc::c_char;
#[cfg(feature = "log")]
use log;
use once_cell::sync::Lazy;
use std::sync::LazyLock;
use crate::{ffi, DebugLevel};
@ -563,7 +563,7 @@ impl FromGlibPtrFull<*mut ffi::GstDebugCategory> for DebugCategory {
}
}
pub static CAT_RUST: Lazy<DebugCategory> = Lazy::new(|| {
pub static CAT_RUST: LazyLock<DebugCategory> = LazyLock::new(|| {
DebugCategory::new(
"GST_RUST",
crate::DebugColorFlags::UNDERLINE,
@ -573,7 +573,7 @@ pub static CAT_RUST: Lazy<DebugCategory> = Lazy::new(|| {
macro_rules! declare_debug_category_from_name(
($cat:ident, $cat_name:expr) => (
pub static $cat: Lazy<DebugCategory> = Lazy::new(|| DebugCategory::get($cat_name)
pub static $cat: LazyLock<DebugCategory> = LazyLock::new(|| DebugCategory::get($cat_name)
.expect(&format!("Unable to find `DebugCategory` with name {}", $cat_name)));
);
);
@ -1365,7 +1365,7 @@ mod tests {
}
#[cfg(feature = "log")]
static LOGGER: Lazy<DebugCategoryLogger> = Lazy::new(|| {
static LOGGER: LazyLock<DebugCategoryLogger> = LazyLock::new(|| {
DebugCategoryLogger::new(DebugCategory::new(
"Log_trait",
crate::DebugColorFlags::empty(),

View file

@ -6,31 +6,34 @@ use std::{fmt, mem};
use glib::{prelude::*, Date};
use num_rational::Rational32;
use once_cell::sync::Lazy;
use serde::{
de,
de::{Deserialize, Deserializer, SeqAccess, Visitor},
ser,
ser::{Serialize, SerializeTuple, Serializer},
};
use std::sync::LazyLock;
use crate::{date_time_serde, value::*, Buffer, DateTime, List, Sample, Structure};
pub(crate) static ARRAY_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Array::static_type);
pub(crate) static BITMASK_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Bitmask::static_type);
pub(crate) static DATE_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Date::static_type);
pub(crate) static DATE_TIME_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(DateTime::static_type);
pub(crate) static FRACTION_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Fraction::static_type);
pub(crate) static FRACTION_RANGE_OTHER_TYPE_ID: Lazy<glib::Type> =
Lazy::new(FractionRange::static_type);
pub(crate) static INT_RANGE_I32_OTHER_TYPE_ID: Lazy<glib::Type> =
Lazy::new(IntRange::<i32>::static_type);
pub(crate) static INT_RANGE_I64_OTHER_TYPE_ID: Lazy<glib::Type> =
Lazy::new(IntRange::<i64>::static_type);
pub(crate) static LIST_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(List::static_type);
pub(crate) static SAMPLE_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Sample::static_type);
pub(crate) static BUFFER_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Buffer::static_type);
pub(crate) static STRUCTURE_OTHER_TYPE_ID: Lazy<glib::Type> = Lazy::new(Structure::static_type);
pub(crate) static ARRAY_OTHER_TYPE_ID: LazyLock<glib::Type> = LazyLock::new(Array::static_type);
pub(crate) static BITMASK_OTHER_TYPE_ID: LazyLock<glib::Type> = LazyLock::new(Bitmask::static_type);
pub(crate) static DATE_OTHER_TYPE_ID: LazyLock<glib::Type> = LazyLock::new(Date::static_type);
pub(crate) static DATE_TIME_OTHER_TYPE_ID: LazyLock<glib::Type> =
LazyLock::new(DateTime::static_type);
pub(crate) static FRACTION_OTHER_TYPE_ID: LazyLock<glib::Type> =
LazyLock::new(Fraction::static_type);
pub(crate) static FRACTION_RANGE_OTHER_TYPE_ID: LazyLock<glib::Type> =
LazyLock::new(FractionRange::static_type);
pub(crate) static INT_RANGE_I32_OTHER_TYPE_ID: LazyLock<glib::Type> =
LazyLock::new(IntRange::<i32>::static_type);
pub(crate) static INT_RANGE_I64_OTHER_TYPE_ID: LazyLock<glib::Type> =
LazyLock::new(IntRange::<i64>::static_type);
pub(crate) static LIST_OTHER_TYPE_ID: LazyLock<glib::Type> = LazyLock::new(List::static_type);
pub(crate) static SAMPLE_OTHER_TYPE_ID: LazyLock<glib::Type> = LazyLock::new(Sample::static_type);
pub(crate) static BUFFER_OTHER_TYPE_ID: LazyLock<glib::Type> = LazyLock::new(Buffer::static_type);
pub(crate) static STRUCTURE_OTHER_TYPE_ID: LazyLock<glib::Type> =
LazyLock::new(Structure::static_type);
impl Serialize for Fraction {
fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error> {