mozilla / cubeb-coreaudio-rs

The audio backend of Firefox on Mac OS X.
ISC License
25 stars 10 forks source link

take care of `clippy::non_send_fields_in_send_ty` #142

Open ChunMinChang opened 2 years ago

ChunMinChang commented 2 years ago

We have two clippy::non_send_fields_in_send_ty warnings that should be take care of carefully.

https://github.com/mozilla/cubeb-coreaudio-rs/blob/5ada876e8b73246b9bb0b5855f9143a0a9848467/src/backend/mod.rs#L2263

warning: this implementation is unsound, as some fields in `AudioUnitContext` are `!Send`
    --> src/backend/mod.rs:2263:1
     |
2263 | unsafe impl Send for AudioUnitContext {}
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
     = note: `#[warn(clippy::non_send_fields_in_send_ty)]` on by default
note: the type of field `serial_queue` is `!Send`
    --> src/backend/mod.rs:1882:5
     |
1882 |     serial_queue: Queue,
     |     ^^^^^^^^^^^^^^^^^^^
     = help: use a thread-safe type that implements `Send`
note: the type of field `devices` is `!Send`
    --> src/backend/mod.rs:1884:5
     |
1884 |     devices: Mutex<SharedDevices>,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     = help: use a thread-safe type that implements `Send`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty

https://github.com/mozilla/cubeb-coreaudio-rs/blob/5ada876e8b73246b9bb0b5855f9143a0a9848467/src/backend/mod.rs#L3632

warning: this implementation is unsound, as some fields in `AudioUnitStream<'ctx>` are `!Send`
    --> src/backend/mod.rs:3632:1
     |
3632 | unsafe impl<'ctx> Send for AudioUnitStream<'ctx> {}
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     |
note: the type of field `queue` is `!Send`
    --> src/backend/mod.rs:3135:5
     |
3135 |     queue: Queue,
     |     ^^^^^^^^^^^^
     = help: use a thread-safe type that implements `Send`
note: the type of field `core_stream_data` is `!Send`
    --> src/backend/mod.rs:3164:5
     |
3164 |     core_stream_data: CoreStreamData<'ctx>,
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
     = help: use a thread-safe type that implements `Send`
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#non_send_fields_in_send_ty

See more here: https://rust-lang.github.io/rust-clippy/master/#non_send_fields_in_send_ty

I temporarily allow this for now since I cannot find serious bugs related to this. But it's better to take care of the threading issue more carefully.