Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopyl committed Apr 4, 2024
1 parent bbfa76a commit 33a3e2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
7 changes: 3 additions & 4 deletions extensions/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//! }
//!
//! struct MyHostShared<'a> {
//! state_ext: OnceLock<Option<&'a PluginState>>
//! state_ext: OnceLock<Option<PluginState>>

Check failure on line 34 in extensions/src/state.rs

View workflow job for this annotation

GitHub Actions / miri

lifetime parameter `'a` is never used
//! }
//!
//! impl<'a> HostShared<'a> for MyHostShared<'a> {
Expand All @@ -45,13 +45,12 @@
//!
//! struct MyHostMainThread<'a> {
//! shared: &'a MyHostShared<'a>,
//! plugin: Option<PluginMainThreadHandle<'a>>,
//! is_state_dirty: bool
//! }
//!
//! impl<'a> HostMainThread<'a> for MyHostMainThread<'a> {
//! /* ... */
//! # fn instantiated(&mut self, instance: PluginMainThreadHandle<'a>) { self.plugin = Some(instance); }
//! # fn initialized(&mut self, _instance: InitializedPluginHandle<'a>) {}
//! }
//!
//! // Implement the Host State extension for the plugin to notify us of its dirty save state
Expand Down Expand Up @@ -99,7 +98,7 @@
//! # pub fn main() -> Result<(), Box<dyn Error>> {
//! # mod utils { include!("./__doc_utils.rs"); }
//! let mut plugin_instance: PluginInstance<MyHost> = /* ... */
//! # utils::get_working_instance(|_| MyHostShared { state_ext: OnceLock::new() }, |shared| MyHostMainThread { is_state_dirty: false, shared, plugin: None })?;
//! # utils::get_working_instance(|_| MyHostShared { state_ext: OnceLock::new() }, |shared| MyHostMainThread { is_state_dirty: false, shared })?;
//!
//! // We just loaded our plugin, but we have a preset to initialize it to.
//! let preset_data = b"I'm a totally legit preset.";
Expand Down
12 changes: 6 additions & 6 deletions host/src/process/audio_buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ mod test {
}]);

assert_eq!(buffers.buffers.len(), 1);
assert_eq!(buffers.frames_count, 4);
assert_eq!(buffers.frames_count, Some(4));
}

#[test]
Expand All @@ -611,7 +611,7 @@ mod test {
}]);

assert_eq!(buffers.buffers.len(), 1);
assert_eq!(buffers.frames_count, 4);
assert_eq!(buffers.frames_count, Some(4));

assert_eq!(bufs.len(), 2); // Check borrow still works
assert_eq!(ports.port_count(), 1);
Expand All @@ -634,7 +634,7 @@ mod test {
}]);

assert_eq!(buffers.buffers.len(), 1);
assert_eq!(buffers.frames_count, 4);
assert_eq!(buffers.frames_count, Some(4));
}

#[test]
Expand All @@ -651,7 +651,7 @@ mod test {
}]);

assert_eq!(buffers.buffers.len(), 1);
assert_eq!(buffers.frames_count, 4);
assert_eq!(buffers.frames_count, Some(4));

assert_eq!(bufs.len(), 2); // Check borrow still works
assert_eq!(ports.port_count(), 1);
Expand Down Expand Up @@ -684,9 +684,9 @@ mod test {
}));

assert_eq!(input_buffers.buffers.len(), 2);
assert_eq!(input_buffers.frames_count, 4);
assert_eq!(input_buffers.frames_count, Some(4));
assert_eq!(output_buffers.buffers.len(), 2);
assert_eq!(output_buffers.frames_count, 4);
assert_eq!(output_buffers.frames_count, Some(4));

let raw_input_buffers = input_buffers.as_raw_buffers();
let raw_output_buffers = output_buffers.as_raw_buffers();
Expand Down
10 changes: 7 additions & 3 deletions plugin/src/process/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ pub mod tests {
),
}]);

let frames_count = match (input_buffers.frames_count(), output_buffers.frames_count()) {
(Some(a), Some(b)) => a.min(b),
(Some(a), None) | (None, Some(a)) => a,
(None, None) => 0,
};

Audio {
inputs: input_buffers.as_raw_buffers(),
frames_count: input_buffers
.frames_count()
.min(output_buffers.frames_count()),
frames_count,
outputs: output_buffers.into_raw_buffers(),
}
}
Expand Down

0 comments on commit 33a3e2d

Please sign in to comment.