Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
manglemix committed May 8, 2024
1 parent 02341f9 commit df8c25c
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions lunabotics/lunabot/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@ static SINK: OnceLock<Box<[Sink]>> = OnceLock::new();

pub fn init_buzz() {
let mut sinks = vec![];
for device in cpal::default_host().output_devices().unwrap() {
let (stream, stream_handle) =
OutputStream::try_from_device(&device).expect("Failed to open audio stream");
std::mem::forget(stream);
let sink = Sink::try_new(&stream_handle).unwrap();
let source = SineWave::new(300.0);
sink.append(source);
sink.pause();
sinks.push(sink);
log::info!("Audio device: {}", device.name().unwrap());
}
let (stream, stream_handle) =
OutputStream::try_default().expect("Failed to open audio stream");
std::mem::forget(stream);
let sink = Sink::try_new(&stream_handle).unwrap();
let source = SineWave::new(300.0);
sink.append(source);
sink.pause();
sinks.push(sink);
let Ok(()) = SINK.set(sinks.into_boxed_slice()) else {
unreachable!();
};
Expand Down

0 comments on commit df8c25c

Please sign in to comment.