Skip to content

support AudioFormat::PCM_I32, impl Send for AudioStream #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ndk/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ pub enum AudioFormat {
/// <a href="https://developer.android.com/reference/android/media/AudioTrack#write(float[], int, int, int)"><code>AudioTrack#write(float[], int, int, int)</code></a>.
#[doc(alias = "AAUDIO_FORMAT_PCM_FLOAT")]
PCM_Float = ffi::AAUDIO_FORMAT_PCM_FLOAT as ffi::aaudio_format_t,
/// This format uses 32-bit integer PCM.
/// Typically used in high-resolution audio processing.
/// The maximum range of the data is -2_147_483_648 to 2_147_483_647
#[cfg(feature = "api-level-31")]
#[doc(alias = "AAUDIO_FORMAT_PCM_I32")]
PCM_I32 = ffi::AAUDIO_FORMAT_PCM_I32 as ffi::aaudio_format_t,

#[doc(hidden)]
#[num_enum(catch_all)]
Expand Down Expand Up @@ -989,6 +995,10 @@ pub struct AudioStream {
error_callback: Option<AudioStreamErrorCallback>,
}

// AAudioStream is safe to be send, but not sync.
// See https://developer.android.com/ndk/guides/audio/aaudio/aaudio
unsafe impl Send for AudioStream {}

impl fmt::Debug for AudioStream {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("AAudioStream")
Expand Down
Loading