1
0
Fork 0

Fix new Clippy lints

This commit is contained in:
Robbert van der Helm 2023-09-03 16:35:57 +02:00
parent 19988db139
commit c0a72661e1
6 changed files with 33 additions and 9 deletions

View file

@ -173,7 +173,7 @@ impl<'a, P: Param> ParamSlider<'a, P> {
ui.memory_mut(|mem| mem.data.insert_temp(*DRAG_AMOUNT_MEMORY_ID, amount)); ui.memory_mut(|mem| mem.data.insert_temp(*DRAG_AMOUNT_MEMORY_ID, amount));
} }
fn slider_ui(&self, ui: &mut Ui, response: &mut Response) { fn slider_ui(&self, ui: &Ui, response: &mut Response) {
// Handle user input // Handle user input
// TODO: Optionally (since it can be annoying) add scrolling behind a builder option // TODO: Optionally (since it can be annoying) add scrolling behind a builder option
if response.drag_started() { if response.drag_started() {

View file

@ -95,7 +95,9 @@ use crossbeam::channel;
use nih_plug::params::persist::PersistentField; use nih_plug::params::persist::PersistentField;
use nih_plug::prelude::{Editor, GuiContext}; use nih_plug::prelude::{Editor, GuiContext};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::fmt::Debug; // This doesn't need to be re-export but otherwise the compiler complains about
// `hidden_glob_reexports`
pub use std::fmt::Debug;
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;

View file

@ -98,7 +98,7 @@ impl ParamWidgetBase {
/// `Params` object to the parameter you want to display a widget for. Parameter changes are /// `Params` object to the parameter you want to display a widget for. Parameter changes are
/// handled by emitting [`ParamEvent`][super::ParamEvent]s which are automatically handled by /// handled by emitting [`ParamEvent`][super::ParamEvent]s which are automatically handled by
/// the VIZIA wrapper. /// the VIZIA wrapper.
pub fn new<L, Params, P, FMap>(cx: &mut Context, params: L, params_to_param: FMap) -> Self pub fn new<L, Params, P, FMap>(cx: &Context, params: L, params_to_param: FMap) -> Self
where where
L: Lens<Target = Params> + Clone, L: Lens<Target = Params> + Clone,
Params: 'static, Params: 'static,

View file

@ -675,7 +675,7 @@ impl CompressorBank {
/// Set the sidechain frequency spectrum magnitudes just before a [`process()`][Self::process()] /// Set the sidechain frequency spectrum magnitudes just before a [`process()`][Self::process()]
/// call. These will be multiplied with the existing compressor thresholds and knee values to /// call. These will be multiplied with the existing compressor thresholds and knee values to
/// get the effective values for use with sidechaining. /// get the effective values for use with sidechaining.
pub fn process_sidechain(&mut self, sc_buffer: &mut [Complex32], channel_idx: usize) { pub fn process_sidechain(&mut self, sc_buffer: &[Complex32], channel_idx: usize) {
nih_debug_assert_eq!(sc_buffer.len(), self.ln_freqs.len()); nih_debug_assert_eq!(sc_buffer.len(), self.ln_freqs.len());
self.update_sidechain_spectra(sc_buffer, channel_idx); self.update_sidechain_spectra(sc_buffer, channel_idx);
@ -684,7 +684,7 @@ impl CompressorBank {
/// Update the envelope followers based on the bin magnitudes. /// Update the envelope followers based on the bin magnitudes.
fn update_envelopes( fn update_envelopes(
&mut self, &mut self,
buffer: &mut [Complex32], buffer: &[Complex32],
channel_idx: usize, channel_idx: usize,
params: &SpectralCompressorParams, params: &SpectralCompressorParams,
overlap_times: usize, overlap_times: usize,
@ -815,7 +815,7 @@ impl CompressorBank {
} }
/// Update the spectral data using the sidechain input /// Update the spectral data using the sidechain input
fn update_sidechain_spectra(&mut self, sc_buffer: &mut [Complex32], channel_idx: usize) { fn update_sidechain_spectra(&mut self, sc_buffer: &[Complex32], channel_idx: usize) {
nih_debug_assert!(channel_idx < self.sidechain_spectrum_magnitudes.len()); nih_debug_assert!(channel_idx < self.sidechain_spectrum_magnitudes.len());
for (bin, magnitude) in sc_buffer for (bin, magnitude) in sc_buffer

View file

@ -547,7 +547,7 @@ fn process_stft_main(
channel_idx: usize, channel_idx: usize,
real_fft_buffer: &mut [f32], real_fft_buffer: &mut [f32],
complex_fft_buffer: &mut [Complex32], complex_fft_buffer: &mut [Complex32],
fft_plan: &mut Plan, fft_plan: &Plan,
window_function: &[f32], window_function: &[f32],
params: &SpectralCompressorParams, params: &SpectralCompressorParams,
compressor_bank: &mut compressor_bank::CompressorBank, compressor_bank: &mut compressor_bank::CompressorBank,
@ -601,7 +601,7 @@ fn process_stft_sidechain(
channel_idx: usize, channel_idx: usize,
real_fft_buffer: &mut [f32], real_fft_buffer: &mut [f32],
complex_fft_buffer: &mut [Complex32], complex_fft_buffer: &mut [Complex32],
fft_plan: &mut Plan, fft_plan: &Plan,
window_function: &[f32], window_function: &[f32],
compressor_bank: &mut compressor_bank::CompressorBank, compressor_bank: &mut compressor_bank::CompressorBank,
input_gain: f32, input_gain: f32,

View file

@ -425,7 +425,10 @@ impl<P: ClapPlugin> MainThreadExecutor<Task<P>> for Wrapper<P> {
} }
impl<P: ClapPlugin> Wrapper<P> { impl<P: ClapPlugin> Wrapper<P> {
pub fn new(host_callback: *const clap_host) -> Arc<Self> { /// # Safety
///
/// `host_callback` needs to outlive the returned object.
pub unsafe fn new(host_callback: *const clap_host) -> Arc<Self> {
let mut plugin = P::default(); let mut plugin = P::default();
let task_executor = Mutex::new(plugin.task_executor()); let task_executor = Mutex::new(plugin.task_executor());
@ -878,6 +881,11 @@ impl<P: ClapPlugin> Wrapper<P> {
} }
/// Handle all incoming events from an event queue. This will clear `self.input_events` first. /// Handle all incoming events from an event queue. This will clear `self.input_events` first.
///
/// # Safety
///
/// `in_` must contain only pointers to valid data (Clippy insists on there being a safety
/// section here).
pub unsafe fn handle_in_events( pub unsafe fn handle_in_events(
&self, &self,
in_: &clap_input_events, in_: &clap_input_events,
@ -909,6 +917,11 @@ impl<P: ClapPlugin> Wrapper<P> {
/// `(sample_idx, event_idx)` tuple. This allows for splitting the audio buffer into segments /// `(sample_idx, event_idx)` tuple. This allows for splitting the audio buffer into segments
/// with distinct sample values to enable sample accurate automation without modifications to the /// with distinct sample values to enable sample accurate automation without modifications to the
/// wrapped plugin. /// wrapped plugin.
///
/// # Safety
///
/// `in_` must contain only pointers to valid data (Clippy insists on there being a safety
/// section here).
pub unsafe fn handle_in_events_until( pub unsafe fn handle_in_events_until(
&self, &self,
in_: &clap_input_events, in_: &clap_input_events,
@ -966,6 +979,10 @@ impl<P: ClapPlugin> Wrapper<P> {
/// plugin is not actually processing audio. /// plugin is not actually processing audio.
/// ///
/// The `total_buffer_len` argument is used to clamp out of bounds events to the buffer's length. /// The `total_buffer_len` argument is used to clamp out of bounds events to the buffer's length.
///
/// # Safety
///
/// `out` must be a valid object (Clippy insists on there being a safety section here).
pub unsafe fn handle_out_events( pub unsafe fn handle_out_events(
&self, &self,
out: &clap_output_events, out: &clap_output_events,
@ -1374,6 +1391,11 @@ impl<P: ClapPlugin> Wrapper<P> {
/// ///
/// If the event was a transport event and the `transport_info` argument is not `None`, then the /// If the event was a transport event and the `transport_info` argument is not `None`, then the
/// pointer will be changed to point to the transport information from this event. /// pointer will be changed to point to the transport information from this event.
///
/// # Safety
///
/// `in_` must contain only pointers to valid data (Clippy insists on there being a safety
/// section here).
pub unsafe fn handle_in_event( pub unsafe fn handle_in_event(
&self, &self,
event: *const clap_event_header, event: *const clap_event_header,