Skip to content

Commit

Permalink
Replace Lazy statics with LazyLock statics, needs Rust 1.80 or later
Browse files Browse the repository at this point in the history
  • Loading branch information
dheijl committed Oct 16, 2024
1 parent 033a36e commit d2ee6af
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 16 deletions.
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- 1.12.0 (unreleased)
- Github CI added by @theavege, thanks!
- replace ```once_cell::sync::Lazy``` with ```std::sync::LazyLock```, so now swyh-rs requires Rustc version __1.80__ or later!!

- 1.11.6 (Sep 30 2024 dheijl)
- CLI: optimize player argument parsing (-o)
Expand Down Expand Up @@ -53,7 +54,7 @@

- 1.10.9 (May 25 2024 dheijl)
- optimize flac near silence injection when no sound is being captured
- GUI: you can now **disable ssdp discovery** by setting the ssdp interval to 0.0. Note that the minimum ssdp interval if enabled stays at 0.5 (half a minute). This is equivalent to the "-x" (serve only) option in the CLI.
- GUI: you can now __disable ssdp discovery__ by setting the ssdp interval to 0.0. Note that the minimum ssdp interval if enabled stays at 0.5 (half a minute). This is equivalent to the "-x" (serve only) option in the CLI.

- 1.10.8 (May 23 2024 dheijl)
- some code cleanup:
Expand All @@ -71,7 +72,7 @@

- 1.10.6 (May 18 2024 dheijl)
- make the default streamsize for FLAC NoneChunked
- remove the NOISE feature flag: this enables the white noise injection for FLAC if no sound while streaming. Only works if you do **NOT**** enable "Inject Silence".
- remove the NOISE feature flag: this enables the white noise injection for FLAC if no sound while streaming. Only works if you do __NOT__** enable "Inject Silence".
- switch to dasp_sample for FLAC and i24

- 1.10.5 (May 9 2024 dheijl)
Expand Down Expand Up @@ -140,7 +141,7 @@

- 1.9.2 (Nov 3 2023 dheijl)
- some optimizations, use more iterators instead of loops, ...
- cli argument "autoreconnect" removed, it's de facto **ON**
- cli argument "autoreconnect" removed, it's de facto __ON__
- correct RMS value calculation
- issue #111: introduce a new -x (--serve_only) commandline switch for the cli. If -x is present no SSDP discovery is run and playing is not started. swyh-rs-cli just sits there waiting for play requests from renderers. Some other useful options in this use case are: -f (format), -b (bits) and -s (sound source).
- CLI: boolean options no longer need an argument, absent means false, present means true. You can still use false to disable options stored in the config. The options -h, -n and -x are not stored in the config file.
Expand All @@ -152,7 +153,7 @@

- 1.9.0 (Oct 18 2023 dheijl)
- some small fixes (cli and WAV format)
- add support for **RF64** format, as it removes the 4 GB WAV limitation. All formats except WAV no longer have limits on the stream size.
- add support for __RF64__ format, as it removes the 4 GB WAV limitation. All formats except WAV no longer have limits on the stream size.

- 1.8.7 (Oct 14 2023 dheijl)
- a fix for LPCM (raw) audio format on Moode Audio Player by letting the URL file extension reflect the audio type.
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ log = { version = "0.4.22", features = [
"release_max_level_debug",
"serde",
] }
once_cell = "1.20.2"
parking_lot = "0.12.3"
serde = { version = "1.0.210", features = ["derive"] }
simplelog = "0.12.2"
Expand Down
15 changes: 7 additions & 8 deletions src/globals/statics.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::atomic::AtomicBool;
use std::sync::{atomic::AtomicBool, LazyLock};

use crate::{
enums::messages::MessageType,
Expand All @@ -7,7 +7,6 @@ use crate::{

use crossbeam_channel::{unbounded, Receiver, Sender};
use hashbrown::HashMap;
use once_cell::sync::Lazy;
use parking_lot::RwLock;

/// app version
Expand All @@ -17,14 +16,14 @@ pub const APP_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const SERVER_PORT: u16 = 5901;

// streaming clients of the webserver
pub static CLIENTS: Lazy<RwLock<HashMap<String, ChannelStream>>> =
Lazy::new(|| RwLock::new(HashMap::new()));
pub static CLIENTS: LazyLock<RwLock<HashMap<String, ChannelStream>>> =
LazyLock::new(|| RwLock::new(HashMap::new()));
// the global GUI logger textbox channel used by all threads
pub static MSGCHANNEL: Lazy<RwLock<(Sender<MessageType>, Receiver<MessageType>)>> =
Lazy::new(|| RwLock::new(unbounded()));
pub static MSGCHANNEL: LazyLock<RwLock<(Sender<MessageType>, Receiver<MessageType>)>> =
LazyLock::new(|| RwLock::new(unbounded()));
// the global configuration state
pub static CONFIG: Lazy<RwLock<Configuration>> =
Lazy::new(|| RwLock::new(Configuration::read_config()));
pub static CONFIG: LazyLock<RwLock<Configuration>> =
LazyLock::new(|| RwLock::new(Configuration::read_config()));
// the list of known fltk theme naes
pub static THEMES: [&str; 6] = ["Shake", "Gray", "Tan", "Dark", "Black", "None"];
// the global "enable rms monitor" flag
Expand Down
4 changes: 2 additions & 2 deletions src/utils/audiodevices.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ fn wave_reader<T>(samples: &[T], f32_samples: &mut Vec<f32>, rms_sender: &Sender
where
T: Sample + ToSample<f32>,
{
static INITIALIZER: Once = Once::new();
INITIALIZER.call_once(|| {
static ONFIRSTCALL: Once = Once::new();
ONFIRSTCALL.call_once(|| {
ui_log("The wave_reader is now receiving samples");
if CONFIG.read().monitor_rms {
RUN_RMS_MONITOR.store(true, Ordering::Relaxed);
Expand Down

0 comments on commit d2ee6af

Please sign in to comment.