Update atomic variable once per buffer, not once per frame
This commit is contained in:
parent
2d458651e6
commit
05f0144419
|
@ -115,13 +115,16 @@ impl Player {
|
|||
.build_output_stream(
|
||||
config,
|
||||
move |output: &mut [T], _| {
|
||||
let frames = output.chunks_mut(num_channels);
|
||||
let mut idx = idx.fetch_add(frames.len(), Ordering::Relaxed);
|
||||
|
||||
for frame in output.chunks_mut(num_channels) {
|
||||
let i = idx.fetch_add(1, Ordering::Relaxed);
|
||||
for (j, sample) in frame.iter_mut().enumerate() {
|
||||
let buffer = &audio_data.buffers[j];
|
||||
let value: T = Sample::from::<f32>(&buffer[i]);
|
||||
let value: T = Sample::from::<f32>(&buffer[idx]);
|
||||
*sample = value;
|
||||
}
|
||||
idx += 1;
|
||||
}
|
||||
},
|
||||
err_fn,
|
||||
|
|
Loading…
Reference in New Issue