Hold the RwLock guard in the process context

This avoids having to constantly acquire a new lock.
This commit is contained in:
Robbert van der Helm
2022-02-04 23:03:11 +01:00
parent ce3da8ea44
commit bbc190c67f
5 changed files with 22 additions and 16 deletions

View File

@@ -111,7 +111,7 @@ impl Plugin for Gain {
&mut self,
_bus_config: &BusConfig,
_buffer_config: &BufferConfig,
_context: &impl ProcessContext,
_context: &mut impl ProcessContext,
) -> bool {
// This plugin doesn't need any special initialization, but if you need to do anything
// expensive then this would be the place. State is kept around while when the host
@@ -119,7 +119,11 @@ impl Plugin for Gain {
true
}
fn process(&mut self, buffer: &mut Buffer, _context: &impl ProcessContext) -> ProcessStatus {
fn process(
&mut self,
buffer: &mut Buffer,
_context: &mut impl ProcessContext,
) -> ProcessStatus {
for samples in buffer.iter_mut() {
// Smoothing is optionally built into the parameters themselves
let gain = self.params.gain.smoothed.next();