diff --git a/.github/workflows/cpal.yml b/.github/workflows/cpal.yml index eaf606e..c39eeef 100644 --- a/.github/workflows/cpal.yml +++ b/.github/workflows/cpal.yml @@ -313,3 +313,17 @@ jobs: - name: Build iphonesimulator feedback example run: cd examples/ios-feedback && xcodebuild -scheme cpal-ios-example -configuration Debug -derivedDataPath build -sdk iphonesimulator + wasm-beep-build: + # this only confirms that the Rust source builds + # and checks to prevent regressions like #721. + # + # It does not test the javascript/web integration + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Target + run: rustup target add wasm32-unknown-unknown + - name: Cargo Build + working-directory: ./examples/wasm-beep + run: cargo build --target wasm32-unknown-unknown + diff --git a/examples/wasm-beep/src/lib.rs b/examples/wasm-beep/src/lib.rs index 0308650..301329d 100644 --- a/examples/wasm-beep/src/lib.rs +++ b/examples/wasm-beep/src/lib.rs @@ -38,12 +38,13 @@ pub fn beep() -> Handle { cpal::SampleFormat::F32 => run::(&device, &config.into()), cpal::SampleFormat::I16 => run::(&device, &config.into()), cpal::SampleFormat::U16 => run::(&device, &config.into()), + _ => panic!("unsupported sample format"), }) } fn run(device: &cpal::Device, config: &cpal::StreamConfig) -> Stream where - T: cpal::Sample, + T: cpal::Sample + cpal::SizedSample + cpal::FromSample, { let sample_rate = config.sample_rate.0 as f32; let channels = config.channels as usize; @@ -71,10 +72,11 @@ where fn write_data(output: &mut [T], channels: usize, next_sample: &mut dyn FnMut() -> f32) where - T: cpal::Sample, + T: cpal::Sample + cpal::FromSample, { for frame in output.chunks_mut(channels) { - let value: T = cpal::Sample::from::(&next_sample()); + let sample = next_sample(); + let value = T::from_sample::(sample); for sample in frame.iter_mut() { *sample = value; }