cpal icon indicating copy to clipboard operation
cpal copied to clipboard

Compilation failure on `wasm32-unknown-emscripten`: `platform_impl` is defined multiple times and type mismatch in `into_abi`

Open tomast1337 opened this issue 9 months ago • 2 comments

When compiling a Rust project using cpal for wasm32-unknown-emscripten, the build fails due to multiple errors:

  1. Duplicate module definition (E0428):

    error[E0428]: the name `platform_impl` is defined multiple times
    --> cpal-0.15.3/src/platform/mod.rs:640:1
    622 | mod platform_impl {
    | ----------------- previous definition of the module `platform_impl` here
    ...
    640 | mod platform_impl {
    | ^^^^^^^^^^^^^^^^^ `platform_impl` redefined here
    

    It seems like platform_impl is being defined twice, likely due to conditional compilation issues.

  2. Type mismatch (E0308) in into_abi function:

    error[E0308]: mismatched types
    --> cpal-0.15.3/src/lib.rs:248:9
    247 | fn into_abi(self) -> Self::Abi {
    |                      --------- expected `Option<u32>` because of return type
    248 | match self {
    249 | Self::Default => None,
    250 | Self::Fixed(fc) => Some(fc),
    251 | }
    252 | .into_abi()
    | ___________________^ expected `Option<u32>`, found `f64`
    

    The into_abi() function appears to be returning a f64, whereas the expected type is Option<u32>.


Steps to Reproduce:

  1. Create a Rust project with cpal = "0.15.3" in Cargo.toml.

    cargo new --bin cpal_test
    cd cpal_test
    cargo add cpal --version 0.15.3
    
  2. Compile using:

    cargo build --release --target=wasm32-unknown-emscripten
    
  3. Observe the errors.

tomast1337 avatar Mar 22 '25 14:03 tomast1337

#960 I run into this issue, but not sure how to contribute to this repository.

kokosha avatar Mar 24 '25 16:03 kokosha

@mitchmindtree hello, how are you? can you provide us some instruction on what is the planned host API for default platform_impl for wasm32_unknown_emscripten?

kokosha avatar Mar 25 '25 14:03 kokosha