Browse Source

feat: make Wave Send + Sync

pull/177/head
Natasha England-Elbro 8 months ago
parent
commit
fbfb574a56
No known key found for this signature in database
GPG Key ID: 46F323AE9236FD6A
  1. 1
      ctru-rs/Cargo.toml
  2. 12
      ctru-rs/src/services/ndsp/wave.rs

1
ctru-rs/Cargo.toml

@ -26,6 +26,7 @@ libc = "0.2.121"
bitflags = "2.3.3" bitflags = "2.3.3"
macaddr = "1.0.1" macaddr = "1.0.1"
widestring = "1.0.2" widestring = "1.0.2"
static_assertions = "1.1.0"
[build-dependencies] [build-dependencies]
toml = "0.5" toml = "0.5"

12
ctru-rs/src/services/ndsp/wave.rs

@ -2,6 +2,8 @@
//! //!
//! This modules has all methods and structs required to work with audio waves meant to be played via the [`ndsp`](crate::services::ndsp) service. //! This modules has all methods and structs required to work with audio waves meant to be played via the [`ndsp`](crate::services::ndsp) service.
use static_assertions::assert_impl_all;
use super::{AudioFormat, Error}; use super::{AudioFormat, Error};
use crate::linear::LinearAllocator; use crate::linear::LinearAllocator;
@ -222,3 +224,13 @@ impl Drop for Wave {
} }
} }
} }
// Safety: The 2 members we have to watch for are `adpcm_data` and `next`
// we access neither of them directly in the wave API (at least currently) but
// `next` at least _is_ used by the ndsp service internally. Given we do not
// touch `next` ourselves and never should this is not an issue, and as long as
// `adpcm_data` is not touched it should also be fine
unsafe impl Send for Wave {}
unsafe impl Sync for Wave {}
assert_impl_all!(Wave: Send, Sync);

Loading…
Cancel
Save