Deps: Replace OnceCell with std::sync::OnceLock (#207)

This commit is contained in:
Gnome!
2023-12-02 17:22:00 +00:00
committed by Kyle Simpson
parent 2146846df4
commit 743a1d262e
11 changed files with 59 additions and 58 deletions

View File

@@ -31,12 +31,12 @@ pub(crate) use crypto::CryptoState;
pub use decode_mode::*;
pub use mix_mode::MixMode;
pub use scheduler::{
get_default_scheduler,
Config as SchedulerConfig,
Error as SchedulerError,
LiveStatBlock,
Mode as SchedulerMode,
Scheduler,
DEFAULT_SCHEDULER,
};
#[cfg(test)]
pub use test_config::*;

View File

@@ -1,11 +1,14 @@
use std::{error::Error as StdError, fmt::Display, num::NonZeroUsize, sync::Arc};
use std::{
error::Error as StdError,
fmt::Display,
num::NonZeroUsize,
sync::{Arc, OnceLock},
};
use flume::{Receiver, RecvError, Sender};
use once_cell::sync::Lazy;
use crate::{constants::TIMESTEP_LENGTH, Config as DriverConfig};
use super::tasks::message::{Interconnect, MixerMessage};
use crate::{constants::TIMESTEP_LENGTH, Config as DriverConfig};
mod config;
mod idle;
@@ -34,7 +37,10 @@ const DEFAULT_MIXERS_PER_THREAD: NonZeroUsize = match NonZeroUsize::new(16) {
///
/// [`Config::default`]: crate::Config::default
/// [`ScheduleMode`]: Mode
pub static DEFAULT_SCHEDULER: Lazy<Scheduler> = Lazy::new(Scheduler::default);
pub fn get_default_scheduler() -> &'static Scheduler {
static DEFAULT_SCHEDULER: OnceLock<Scheduler> = OnceLock::new();
DEFAULT_SCHEDULER.get_or_init(Scheduler::default)
}
/// A reference to a shared group of threads used for running idle and active
/// audio threads.

View File

@@ -9,7 +9,7 @@ use crate::{
constants::*,
input::{
cached::Compressed,
codecs::{CODEC_REGISTRY, PROBE},
codecs::{get_codec_registry, get_probe},
RawAdapter,
},
test_utils,
@@ -103,7 +103,7 @@ impl Mixer {
for _ in 0..num_tracks {
let input: Input = RawAdapter::new(Cursor::new(floats.clone()), 48_000, 2).into();
let promoted = match input {
Input::Live(l, _) => l.promote(&CODEC_REGISTRY, &PROBE),
Input::Live(l, _) => l.promote(get_codec_registry(), get_probe()),
Input::Lazy(_) => panic!("Failed to create a guaranteed source."),
};
let (_, ctx) = Track::from(Input::Live(promoted.unwrap(), None)).into_context();
@@ -121,7 +121,7 @@ impl Mixer {
let input: Input = RawAdapter::new(Cursor::new(floats.clone()), 48_000, 2).into();
let promoted = match input {
Input::Live(l, _) => l.promote(&CODEC_REGISTRY, &PROBE),
Input::Live(l, _) => l.promote(get_codec_registry(), get_probe()),
Input::Lazy(_) => panic!("Failed to create a guaranteed source."),
};
let mut track = Track::from(Input::Live(promoted.unwrap(), None));
@@ -141,7 +141,7 @@ impl Mixer {
let floats = test_utils::make_sine((i / 5) * STEREO_FRAME_SIZE, true);
let input: Input = RawAdapter::new(Cursor::new(floats.clone()), 48_000, 2).into();
let promoted = match input {
Input::Live(l, _) => l.promote(&CODEC_REGISTRY, &PROBE),
Input::Live(l, _) => l.promote(get_codec_registry(), get_probe()),
Input::Lazy(_) => panic!("Failed to create a guaranteed source."),
};
let (_, ctx) = Track::from(Input::Live(promoted.unwrap(), None)).into_context();
@@ -170,7 +170,7 @@ impl Mixer {
src.raw.load_all();
let promoted = match src.into() {
Input::Live(l, _) => l.promote(&CODEC_REGISTRY, &PROBE),
Input::Live(l, _) => l.promote(get_codec_registry(), get_probe()),
Input::Lazy(_) => panic!("Failed to create a guaranteed source."),
};
let (_, ctx) = Track::from(Input::Live(promoted.unwrap(), None)).into_context();