1
0
Fork 0

Store the minimum buffer size in BufferConfig

This commit is contained in:
Robbert van der Helm 2022-05-22 13:21:39 +02:00
parent e1d4be2a03
commit ee3b0bf8e6
4 changed files with 8 additions and 2 deletions

View file

@ -294,8 +294,11 @@ pub struct BusConfig {
pub struct BufferConfig {
/// The current sample rate.
pub sample_rate: f32,
/// The minimum buffer size the host will use. This may not be set.
pub min_buffer_size: Option<u32>,
/// The maximum buffer size the host will use. The plugin should be able to accept variable
/// sized buffers up to this size.
/// sized buffers up to this size, or between the minimum and the maximum buffer size if both
/// are set.
pub max_buffer_size: u32,
}

View file

@ -1506,7 +1506,7 @@ impl<P: ClapPlugin> Wrapper<P> {
unsafe extern "C" fn activate(
plugin: *const clap_plugin,
sample_rate: f64,
_min_frames_count: u32,
min_frames_count: u32,
max_frames_count: u32,
) -> bool {
check_null_ptr!(false, plugin);
@ -1515,6 +1515,7 @@ impl<P: ClapPlugin> Wrapper<P> {
let bus_config = wrapper.current_bus_config.load();
let buffer_config = BufferConfig {
sample_rate: sample_rate as f32,
min_buffer_size: Some(min_frames_count),
max_buffer_size: max_frames_count,
};

View file

@ -200,6 +200,7 @@ impl<P: Plugin, B: Backend> Wrapper<P, B> {
},
buffer_config: BufferConfig {
sample_rate: config.sample_rate,
min_buffer_size: None,
max_buffer_size: config.period_size,
},
config,

View file

@ -690,6 +690,7 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
// This is needed when activating the plugin and when restoring state
self.inner.current_buffer_config.store(Some(BufferConfig {
sample_rate: setup.sample_rate as f32,
min_buffer_size: None,
max_buffer_size: setup.max_samples_per_block as u32,
}));