Skip to content

Commit d5bff40

Browse files
committed
Add a few comments to clarify examples
1 parent b0932d0 commit d5bff40

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

examples/feedback_interleaved.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ fn main() -> Result<(), coreaudio::Error> {
9898
let Args {
9999
num_frames, data, ..
100100
} = args;
101+
// Print the number of frames the callback requests.
102+
// Included to aid understanding, don't use println and other things
103+
// that may block for an unknown amount of time inside the callback
104+
// of a real application.
101105
println!("input cb {} frames", num_frames);
102106
let buffer_left = producer_left.lock().unwrap();
103107
let buffer_right = producer_right.lock().unwrap();
@@ -116,6 +120,7 @@ fn main() -> Result<(), coreaudio::Error> {
116120
let Args {
117121
num_frames, data, ..
118122
} = args;
123+
// Print the number of frames the callback requests.
119124
println!("output cb {} frames", num_frames);
120125
let buffer_left = consumer_left.lock().unwrap();
121126
let buffer_right = consumer_right.lock().unwrap();

examples/sine.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ fn main() -> Result<(), coreaudio::Error> {
4141
// Construct an Output audio unit that delivers audio to the default output device.
4242
let mut audio_unit = AudioUnit::new(IOType::DefaultOutput)?;
4343

44+
// Read the input format. This is counterintuitive, but it's the format used when sending
45+
// audio data to the AudioUnit representing the output device. This is separate from the
46+
// format the AudioUnit later uses to send the data to the hardware device.
4447
let stream_format = audio_unit.input_stream_format()?;
4548
println!("{:#?}", &stream_format);
4649

examples/sine_advanced.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ fn main() -> Result<(), coreaudio::Error> {
136136
let Args {
137137
num_frames, data, ..
138138
} = args;
139+
// Print the number of frames the callback requests.
140+
// Included to aid understanding, don't use println and other things
141+
// that may block for an unknown amount of time inside the callback
142+
// of a real application.
139143
println!("frames: {}", num_frames);
140144
for i in 0..num_frames {
141145
let sample_l = samples_l.next().unwrap();

0 commit comments

Comments
 (0)