Skip to content

Commit

Permalink
finish i32 support
Browse files Browse the repository at this point in the history
  • Loading branch information
julientregoat committed Jan 11, 2021
1 parent cf0295f commit 7461acf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
1 change: 1 addition & 0 deletions examples/wasm-beep/src/lib.rs
Expand Up @@ -36,6 +36,7 @@ pub fn beep() -> Handle {

Handle(match config.sample_format() {
cpal::SampleFormat::F32 => run::<f32>(&device, &config.into()),
cpal::SampleFormat::I32 => run::<i32>(&device, &config.into()),
cpal::SampleFormat::I16 => run::<i16>(&device, &config.into()),
cpal::SampleFormat::U16 => run::<u16>(&device, &config.into()),
})
Expand Down
12 changes: 6 additions & 6 deletions src/host/asio/stream.rs
Expand Up @@ -181,7 +181,7 @@ impl Device {
// TODO: Add support for the following sample formats to CPAL and simplify the
// `process_output_callback` function above by removing the unnecessary sample
// conversion function.
(&sys::AsioSampleType::ASIOSTInt32LSB, SampleFormat::I16) => {
(&sys::AsioSampleType::ASIOSTInt32LSB, SampleFormat::I32) => {
process_input_callback::<i32, i16, _, _>(
&mut data_callback,
&mut interleaved,
Expand All @@ -191,7 +191,7 @@ impl Device {
from_le,
);
}
(&sys::AsioSampleType::ASIOSTInt32MSB, SampleFormat::I16) => {
(&sys::AsioSampleType::ASIOSTInt32MSB, SampleFormat::I32) => {
process_input_callback::<i32, i16, _, _>(
&mut data_callback,
&mut interleaved,
Expand Down Expand Up @@ -404,8 +404,8 @@ impl Device {
// TODO: Add support for the following sample formats to CPAL and simplify the
// `process_output_callback` function above by removing the unnecessary sample
// conversion function.
(SampleFormat::I16, &sys::AsioSampleType::ASIOSTInt32LSB) => {
process_output_callback::<i16, i32, _, _>(
(SampleFormat::I32, &sys::AsioSampleType::ASIOSTInt32LSB) => {
process_output_callback::<i32, i32, _, _>(
&mut data_callback,
&mut interleaved,
silence,
Expand All @@ -415,8 +415,8 @@ impl Device {
to_le,
);
}
(SampleFormat::I16, &sys::AsioSampleType::ASIOSTInt32MSB) => {
process_output_callback::<i16, i32, _, _>(
(SampleFormat::I32, &sys::AsioSampleType::ASIOSTInt32MSB) => {
process_output_callback::<i32, i32, _, _>(
&mut data_callback,
&mut interleaved,
silence,
Expand Down
4 changes: 4 additions & 0 deletions src/host/oboe/mod.rs
Expand Up @@ -397,6 +397,10 @@ impl DeviceTrait for Device {
description: "U16 format is not supported on Android.".to_owned(),
}
.into()),
SampleFormat::I32 => Err(BackendSpecificError {
description: "I32 format is not supported on Android.".to_owned(),
}
.into()),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/host/wasapi/device.rs
Expand Up @@ -300,7 +300,7 @@ unsafe fn format_from_waveformatex_ptr(
a.Data1 == b.Data1 && a.Data2 == b.Data2 && a.Data3 == b.Data3 && a.Data4 == b.Data4
}
let sample_format = match (
(*waveformatex_ptr).wBitsPerSample,
(*waveformatex_ptr).wBitsPerSample, // 8 or 16 for integers, 32 for floats
(*waveformatex_ptr).wFormatTag,
) {
(16, mmreg::WAVE_FORMAT_PCM) => SampleFormat::I16,
Expand Down

0 comments on commit 7461acf

Please sign in to comment.