Merge branch 'jwq_cpal-buffer-fix'
Fix CPAL buffer bug (standalone) https://github.com/robbert-vdh/nih-plug/pull/142
This commit is contained in:
commit
1c03d4adc6
|
@ -824,8 +824,10 @@ impl CpalMidir {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
let sample_count = data.len() / num_output_channels;
|
||||||
|
assert!(sample_count <= buffer_size);
|
||||||
let buffers = unsafe {
|
let buffers = unsafe {
|
||||||
buffer_manager.create_buffers(0, buffer_size, |buffer_sources| {
|
buffer_manager.create_buffers(0, sample_count, |buffer_sources| {
|
||||||
*buffer_sources.main_output_channel_pointers = Some(ChannelPointers {
|
*buffer_sources.main_output_channel_pointers = Some(ChannelPointers {
|
||||||
ptrs: NonNull::new(main_io_channel_pointers.get().as_mut_ptr())
|
ptrs: NonNull::new(main_io_channel_pointers.get().as_mut_ptr())
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
|
@ -893,11 +895,10 @@ impl CpalMidir {
|
||||||
|
|
||||||
// The buffer's samples need to be written to `data` in an interlaced format
|
// The buffer's samples need to be written to `data` in an interlaced format
|
||||||
// SAFETY: Dropping `buffers` allows us to borrow `main_io_storage` again
|
// SAFETY: Dropping `buffers` allows us to borrow `main_io_storage` again
|
||||||
for (output_sample, buffer_sample) in data
|
for (i, output_sample) in data.iter_mut().enumerate() {
|
||||||
.iter_mut()
|
let ch = i % num_output_channels;
|
||||||
.zip(main_io_storage.iter().flat_map(|channels| channels.iter()))
|
let n = i / num_output_channels;
|
||||||
{
|
*output_sample = T::from_sample(main_io_storage[ch][n]);
|
||||||
*output_sample = T::from_sample(*buffer_sample);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(output_event_rb_producer) = &mut output_event_rb_producer {
|
if let Some(output_event_rb_producer) = &mut output_event_rb_producer {
|
||||||
|
|
Loading…
Reference in a new issue