From 7461acf6236c0af8d6fcebe9d4ffca3458d14d1f Mon Sep 17 00:00:00 2001 From: Julien Tregoat Date: Sun, 10 Jan 2021 19:12:36 -0500 Subject: [PATCH] finish i32 support --- examples/wasm-beep/src/lib.rs | 1 + src/host/asio/stream.rs | 12 ++++++------ src/host/oboe/mod.rs | 4 ++++ src/host/wasapi/device.rs | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/examples/wasm-beep/src/lib.rs b/examples/wasm-beep/src/lib.rs index 72dc81cc0..576dce1a4 100644 --- a/examples/wasm-beep/src/lib.rs +++ b/examples/wasm-beep/src/lib.rs @@ -36,6 +36,7 @@ pub fn beep() -> Handle { Handle(match config.sample_format() { cpal::SampleFormat::F32 => run::(&device, &config.into()), + cpal::SampleFormat::I32 => run::(&device, &config.into()), cpal::SampleFormat::I16 => run::(&device, &config.into()), cpal::SampleFormat::U16 => run::(&device, &config.into()), }) diff --git a/src/host/asio/stream.rs b/src/host/asio/stream.rs index 9035045a5..c539c41fd 100644 --- a/src/host/asio/stream.rs +++ b/src/host/asio/stream.rs @@ -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::( &mut data_callback, &mut interleaved, @@ -191,7 +191,7 @@ impl Device { from_le, ); } - (&sys::AsioSampleType::ASIOSTInt32MSB, SampleFormat::I16) => { + (&sys::AsioSampleType::ASIOSTInt32MSB, SampleFormat::I32) => { process_input_callback::( &mut data_callback, &mut interleaved, @@ -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::( + (SampleFormat::I32, &sys::AsioSampleType::ASIOSTInt32LSB) => { + process_output_callback::( &mut data_callback, &mut interleaved, silence, @@ -415,8 +415,8 @@ impl Device { to_le, ); } - (SampleFormat::I16, &sys::AsioSampleType::ASIOSTInt32MSB) => { - process_output_callback::( + (SampleFormat::I32, &sys::AsioSampleType::ASIOSTInt32MSB) => { + process_output_callback::( &mut data_callback, &mut interleaved, silence, diff --git a/src/host/oboe/mod.rs b/src/host/oboe/mod.rs index 4e245cdb0..de0eb2e0d 100644 --- a/src/host/oboe/mod.rs +++ b/src/host/oboe/mod.rs @@ -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()), } } diff --git a/src/host/wasapi/device.rs b/src/host/wasapi/device.rs index be9de5d9a..78154d8de 100644 --- a/src/host/wasapi/device.rs +++ b/src/host/wasapi/device.rs @@ -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,