Skip to content

Commit 0da7ae1

Browse files
authored
bump ringbuf version in examples (#897)
1 parent 0246442 commit 0da7ae1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ dasp_sample = "0.11"
1919
[dev-dependencies]
2020
anyhow = "1.0"
2121
hound = "3.5"
22-
ringbuf = "0.3"
22+
ringbuf = "0.4.1"
2323
clap = { version = "4.0", features = ["derive"] }
2424

2525
[target.'cfg(target_os = "android")'.dev-dependencies]

examples/feedback.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@
88
99
use clap::Parser;
1010
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
11-
use ringbuf::HeapRb;
11+
use ringbuf::{
12+
traits::{Consumer, Producer, Split},
13+
HeapRb,
14+
};
1215

1316
#[derive(Parser, Debug)]
1417
#[command(version, about = "CPAL feedback example", long_about = None)]
@@ -112,13 +115,13 @@ fn main() -> anyhow::Result<()> {
112115
for _ in 0..latency_samples {
113116
// The ring buffer has twice as much space as necessary to add latency here,
114117
// so this should never fail
115-
producer.push(0.0).unwrap();
118+
producer.try_push(0.0).unwrap();
116119
}
117120

118121
let input_data_fn = move |data: &[f32], _: &cpal::InputCallbackInfo| {
119122
let mut output_fell_behind = false;
120123
for &sample in data {
121-
if producer.push(sample).is_err() {
124+
if producer.try_push(sample).is_err() {
122125
output_fell_behind = true;
123126
}
124127
}
@@ -130,7 +133,7 @@ fn main() -> anyhow::Result<()> {
130133
let output_data_fn = move |data: &mut [f32], _: &cpal::OutputCallbackInfo| {
131134
let mut input_fell_behind = false;
132135
for sample in data {
133-
*sample = match consumer.pop() {
136+
*sample = match consumer.try_pop() {
134137
Some(s) => s,
135138
None => {
136139
input_fell_behind = true;

0 commit comments

Comments
 (0)