Skip to content

Commit

Permalink
Support more audio output formats
Browse files Browse the repository at this point in the history
  • Loading branch information
kelpsyberry committed Jan 20, 2024
1 parent b029fe4 commit 0fbca8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
3 changes: 2 additions & 1 deletion core/src/audio/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,9 @@ impl Channel {
self.check_total_size();
}

// TODO: Makes Clippy crash right now?
// #[allow(clippy::unused_self)]
#[inline]
#[allow(clippy::unused_self)]
fn keep_last_sample(&mut self) {

Check warning on line 343 in core/src/audio/channel.rs

View workflow job for this annotation

GitHub Actions / Run clippy (ubuntu-latest, no default features)

unused `self` argument

warning: unused `self` argument --> core/src/audio/channel.rs:343:25 | 343 | fn keep_last_sample(&mut self) { | ^^^^^^^^^ | = help: consider refactoring to an associated function = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_self note: the lint level is defined here --> core/src/lib.rs:11:9 | 11 | #![warn(clippy::pedantic)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(clippy::unused_self)]` implied by `#[warn(clippy::pedantic)]`

Check warning on line 343 in core/src/audio/channel.rs

View workflow job for this annotation

GitHub Actions / Run clippy (macos-latest, no default features)

unused `self` argument

warning: unused `self` argument --> core/src/audio/channel.rs:343:25 | 343 | fn keep_last_sample(&mut self) { | ^^^^^^^^^ | = help: consider refactoring to an associated function = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unused_self note: the lint level is defined here --> core/src/lib.rs:11:9 | 11 | #![warn(clippy::pedantic)] | ^^^^^^^^^^^^^^^^ = note: `#[warn(clippy::unused_self)]` implied by `#[warn(clippy::pedantic)]`
#[cfg(feature = "xq-audio")]
self.hist.copy_within(1.., 0);
Expand Down
40 changes: 22 additions & 18 deletions frontend/desktop/src/audio/output/cpal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,25 +78,29 @@ impl OutputStream {
};

let err_callback = |err| panic!("Error in default audio output device stream: {err}");

macro_rules! build_output_stream {
($t: ty) => {
output_device.build_output_stream(
&supported_output_config.config(),
move |data: &mut [$t], _| output_data.fill(data),
err_callback,
None,
)
};
}

let stream = match supported_output_config.sample_format() {
SampleFormat::U16 => output_device.build_output_stream(
&supported_output_config.config(),
move |data: &mut [u16], _| output_data.fill(data),
err_callback,
None,
),
SampleFormat::I16 => output_device.build_output_stream(
&supported_output_config.config(),
move |data: &mut [i16], _| output_data.fill(data),
err_callback,
None,
),
SampleFormat::F32 => output_device.build_output_stream(
&supported_output_config.config(),
move |data: &mut [f32], _| output_data.fill(data),
err_callback,
None,
),
SampleFormat::U8 => build_output_stream!(u8),
SampleFormat::I8 => build_output_stream!(i8),
SampleFormat::U16 => build_output_stream!(u16),
SampleFormat::I16 => build_output_stream!(i16),
SampleFormat::U32 => build_output_stream!(u32),
SampleFormat::I32 => build_output_stream!(i32),
SampleFormat::U64 => build_output_stream!(u64),
SampleFormat::I64 => build_output_stream!(i64),
SampleFormat::F32 => build_output_stream!(f32),
SampleFormat::F64 => build_output_stream!(f64),
_ => panic!("Unsupported audio output sample format"),
}
.ok()?;
Expand Down

0 comments on commit 0fbca8a

Please sign in to comment.