diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d1a044a..1b4b9ec 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -66,13 +66,14 @@ jobs: uses: android-actions/setup-android@v2 - name: Setup Android NDK env: - NDK_VERSION: 21.3.6528147 + NDK_VERSION: 21.4.7075529 TRIPLE: x86_64-linux-android run: | - rm -rf $ANDROID_SDK_ROOT/ndk-bundle - sdkmanager --sdk_root=$ANDROID_SDK_ROOT "ndk;$NDK_VERSION" | grep -v = || true - ln -s $ANDROID_SDK_ROOT/ndk/$NDK_VERSION $ANDROID_SDK_ROOT/ndk-bundle - echo "$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;$NDK_VERSION" --channel=3 | grep -v = || true + echo "$ANDROID_SDK_ROOT/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + for var in ANDROID_NDK ANDROID_NDK_HOME ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do + echo "$var=$ANDROID_SDK_ROOT/ndk/$NDK_VERSION" >> $GITHUB_ENV + done TRIPLE_ENV=$(echo $TRIPLE | tr '-' '_') echo "CC_${TRIPLE_ENV}=${TRIPLE}21-clang" >> $GITHUB_ENV echo "CXX_${TRIPLE_ENV}=${TRIPLE}21-clang++" >> $GITHUB_ENV @@ -124,12 +125,13 @@ jobs: uses: android-actions/setup-android@v2 - name: Setup Android NDK env: - NDK_VERSION: 21.3.6528147 + NDK_VERSION: 21.4.7075529 run: | - rm -rf $ANDROID_SDK_ROOT/ndk-bundle - sdkmanager --sdk_root=$ANDROID_SDK_ROOT "ndk;$NDK_VERSION" | grep -v = || true - ln -s $ANDROID_SDK_ROOT/ndk/$NDK_VERSION $ANDROID_SDK_ROOT/ndk-bundle - echo "$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;$NDK_VERSION" --channel=3 | grep -v = || true + echo "$ANDROID_SDK_ROOT/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + for var in ANDROID_NDK ANDROID_NDK_HOME ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do + echo "$var=$ANDROID_SDK_ROOT/ndk/$NDK_VERSION" >> $GITHUB_ENV + done - name: Setup Rust ${{ matrix.rust }} [${{ matrix.target }}] uses: actions-rs/toolchain@v1 with: @@ -242,6 +244,10 @@ jobs: path: ~/.cargo/bin/cargo-apk key: ${{ runner.os }}-cargo-apk - uses: Swatinem/rust-cache@v1 + - name: Create signing key + run: | + echo ${{ secrets.APK_SIGN_KEY_DATA }} | base64 -d > demo/release.keystore + sed -i 's/keystore_password = "android"/keystore_password = "${{ secrets.APK_SIGN_KEY_SECRET }}"/' demo/Cargo.toml - name: Build demo apk uses: actions-rs/cargo@v1 with: diff --git a/Cargo.toml b/Cargo.toml index bdf8526..f87642e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ version = "0.4.5" path = "sys" [dependencies.ndk] -version = "0.6" +version = "0.7" optional = true [dependencies.ndk-context] @@ -64,7 +64,3 @@ codegen-units = 1 panic = 'unwind' incremental = false overflow-checks = false - -[patch.crates-io] -winit = { git = "https://github.com/rust-windowing/winit" } -glutin = { git = "https://github.com/katyo/glutin", branch = "android-support" } diff --git a/demo/Cargo.toml b/demo/Cargo.toml index dd1f8a3..a683e0b 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -22,7 +22,7 @@ optional = true version = "0.1.0" [dependencies.ndk-glue] -version = "0.6.0" +version = "0.7.0" features = ["logger"] [dependencies.android_logger] @@ -32,7 +32,7 @@ version = "0.10" version = "0.4" [dependencies.glutin] -version = "0.24" +version = "0.29" [features] default = ["audio"] @@ -75,3 +75,7 @@ name = "android.permission.WRITE_EXTERNAL_STORAGE" [[package.metadata.android.permission]] name = "android.permission.RECORD_AUDIO" + +[package.metadata.android.signing.release] +path = "release.keystore" +keystore_password = "android" diff --git a/src/audio_stream.rs b/src/audio_stream.rs index a11def3..bcdfd97 100644 --- a/src/audio_stream.rs +++ b/src/audio_stream.rs @@ -10,10 +10,9 @@ use std::{ }; use super::{ - audio_stream_base_fmt, wrap_result, wrap_status, AudioApi, AudioCallbackWrapper, - AudioStreamBase, FrameTimestamp, Input, IsFrameType, Output, RawAudioInputStream, - RawAudioOutputStream, RawAudioStream, RawAudioStreamBase, Result, Status, StreamState, - NANOS_PER_MILLISECOND, + audio_stream_base_fmt, wrap_result, wrap_status, AudioApi, AudioStreamBase, FrameTimestamp, + Input, IsFrameType, Output, RawAudioInputStream, RawAudioOutputStream, RawAudioStream, + RawAudioStreamBase, Result, Status, StreamState, NANOS_PER_MILLISECOND, }; /** @@ -411,9 +410,7 @@ impl AudioStream for T { } fn close(&mut self) -> Status { - wrap_status(unsafe { - ffi::oboe_AudioStream_close(self._raw_stream_mut() as *mut _ as *mut c_void) - }) + wrap_status(unsafe { ffi::oboe_AudioStream_close1(self._raw_stream_mut()) }) } fn start_with_timeout(&mut self, timeout_nanoseconds: i64) -> Status { @@ -537,24 +534,30 @@ pub(crate) fn audio_stream_fmt( '\n'.fmt(f) } -#[repr(transparent)] -struct AudioStreamHandle(*mut ffi::oboe_AudioStream); +struct AudioStreamHandle(*mut ffi::oboe_AudioStream, *mut c_void); -impl From<*mut ffi::oboe_AudioStream> for AudioStreamHandle { - fn from(raw: *mut ffi::oboe_AudioStream) -> Self { - Self(raw) +impl AudioStreamHandle { + fn new(raw: *mut ffi::oboe_AudioStream, shared_ptr: *mut c_void) -> Self { + Self(raw, shared_ptr) } -} -impl Default for AudioStreamHandle { - fn default() -> Self { - Self(null_mut()) + /// SAFETY: `self.0` and `self.1` must be valid pointers. + pub(crate) unsafe fn delete(&mut self) { + assert!(!self.0.is_null()); + assert!(!self.1.is_null()); + + // The error callback could be holding a shared_ptr, so don't delete AudioStream + // directly, but only its shared_ptr. + ffi::oboe_AudioStream_deleteShared(self.1); + + self.0 = null_mut(); + self.1 = null_mut(); } } -impl Drop for AudioStreamHandle { - fn drop(&mut self) { - unsafe { ffi::oboe_AudioStream_delete(self.0) } +impl Default for AudioStreamHandle { + fn default() -> Self { + Self(null_mut(), null_mut()) } } @@ -625,10 +628,7 @@ impl<'s> RawAudioOutputStream for AudioStreamRef<'s, Output> {} */ pub struct AudioStreamAsync { raw: AudioStreamHandle, - - // Needed to keep callback alive - #[allow(dead_code)] - callback: AudioCallbackWrapper, + _phantom: PhantomData<(D, F)>, } impl fmt::Debug for AudioStreamAsync { @@ -638,13 +638,25 @@ impl fmt::Debug for AudioStreamAsync { } impl AudioStreamAsync { - pub(crate) fn wrap_raw( + // SAFETY: `raw` and `shared_ptr` must be valid. + pub(crate) unsafe fn wrap_raw( raw: *mut ffi::oboe_AudioStream, - callback: AudioCallbackWrapper, + shared_ptr: *mut c_void, ) -> Self { Self { - raw: raw.into(), - callback, + raw: AudioStreamHandle(raw, shared_ptr), + _phantom: PhantomData, + } + } +} + +impl Drop for AudioStreamAsync { + fn drop(&mut self) { + // SAFETY: As long as the conditions on Self::wrap_raw are guaranteed on the creation of + // self, this is safe. + unsafe { + let _ = self.close(); + self.raw.delete(); } } } @@ -688,14 +700,29 @@ impl fmt::Debug for AudioStreamSync { } impl AudioStreamSync { - pub(crate) fn wrap_raw(raw: *mut ffi::oboe_AudioStream) -> Self { + // SAFETY: `raw`, `shared_ptr` must be valid, because they will be deleted on drop. + pub(crate) unsafe fn wrap_raw( + raw: *mut ffi::oboe_AudioStream, + shared_ptr: *mut c_void, + ) -> Self { Self { - raw: raw.into(), + raw: AudioStreamHandle::new(raw, shared_ptr), _phantom: PhantomData, } } } +impl Drop for AudioStreamSync { + fn drop(&mut self) { + // SAFETY: As long as the conditions on Self::wrap_raw are guaranteed on the creation of + // self, this is safe. + unsafe { + let _ = self.close(); + self.raw.delete(); + } + } +} + impl RawAudioStreamBase for AudioStreamSync { fn _raw_base(&self) -> &ffi::oboe_AudioStreamBase { unsafe { &*ffi::oboe_AudioStream_getBase(self.raw.0) } diff --git a/src/audio_stream_builder.rs b/src/audio_stream_builder.rs index 7f443ec..28ef734 100644 --- a/src/audio_stream_builder.rs +++ b/src/audio_stream_builder.rs @@ -1,22 +1,24 @@ use num_traits::FromPrimitive; use oboe_sys as ffi; use std::{ + ffi::c_void, fmt, marker::PhantomData, - mem::MaybeUninit, + mem::{ManuallyDrop, MaybeUninit}, ops::{Deref, DerefMut}, }; +use crate::{set_input_callback, set_output_callback}; + use super::{ - audio_stream_base_fmt, wrap_status, AudioApi, AudioCallbackWrapper, AudioInputCallback, - AudioOutputCallback, AudioStreamAsync, AudioStreamSync, ContentType, Input, InputPreset, - IsChannelCount, IsDirection, IsFormat, IsFrameType, Mono, Output, PerformanceMode, - RawAudioStreamBase, Result, SampleRateConversionQuality, SessionId, SharingMode, Stereo, - Unspecified, Usage, + audio_stream_base_fmt, wrap_status, AudioApi, AudioInputCallback, AudioOutputCallback, + AudioStreamAsync, AudioStreamSync, ContentType, Input, InputPreset, IsChannelCount, + IsDirection, IsFormat, IsFrameType, Mono, Output, PerformanceMode, RawAudioStreamBase, Result, + SampleRateConversionQuality, SessionId, SharingMode, Stereo, Unspecified, Usage, }; #[repr(transparent)] -struct AudioStreamBuilderHandle(*mut ffi::oboe_AudioStreamBuilder); +pub(crate) struct AudioStreamBuilderHandle(*mut ffi::oboe_AudioStreamBuilder); impl Default for AudioStreamBuilderHandle { fn default() -> Self { @@ -49,10 +51,19 @@ impl DerefMut for AudioStreamBuilderHandle { */ #[repr(transparent)] pub struct AudioStreamBuilder { - raw: AudioStreamBuilderHandle, + raw: ManuallyDrop, _phantom: PhantomData<(D, C, T)>, } +impl Drop for AudioStreamBuilder { + fn drop(&mut self) { + // SAFETY: self.raw is only drop here, or taken in Self::destructs, which don't drop self. + unsafe { + ManuallyDrop::drop(&mut self.raw); + } + } +} + impl fmt::Debug for AudioStreamBuilder { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { audio_stream_base_fmt(self, f) @@ -81,16 +92,10 @@ impl Default for AudioStreamBuilder { } } -impl From> for AudioStreamBuilderHandle { - fn from(builder: AudioStreamBuilder) -> Self { - builder.raw - } -} - impl AudioStreamBuilder { fn convert(self) -> AudioStreamBuilder { AudioStreamBuilder { - raw: self.into(), + raw: ManuallyDrop::new(self.destructs()), _phantom: PhantomData, } } @@ -222,7 +227,7 @@ impl AudioStreamBuilder { * returns true. Otherwise __OpenSL ES__ will be used. */ pub fn get_audio_api(&self) -> AudioApi { - FromPrimitive::from_i32(unsafe { ffi::oboe_AudioStreamBuilder_getAudioApi(&*self.raw) }) + FromPrimitive::from_i32(unsafe { ffi::oboe_AudioStreamBuilder_getAudioApi(&**self.raw) }) .unwrap() } @@ -237,7 +242,7 @@ impl AudioStreamBuilder { * If the caller requests AAudio and it is supported then AAudio will be used. */ pub fn set_audio_api(mut self, audio_api: AudioApi) -> Self { - unsafe { ffi::oboe_AudioStreamBuilder_setAudioApi(&mut *self.raw, audio_api as i32) } + unsafe { ffi::oboe_AudioStreamBuilder_setAudioApi(&mut **self.raw, audio_api as i32) } self } @@ -444,6 +449,16 @@ impl AudioStreamBuilder { (audio_api == AudioApi::AAudio && Self::is_aaudio_supported()) || (audio_api == AudioApi::Unspecified && Self::is_aaudio_recommended()) } + + /// Descontructs self into its handle, without calling drop. + fn destructs(mut self) -> AudioStreamBuilderHandle { + // Safety: the std::mem::forget prevents `raw` from being dropped by Self::drop. + let raw = unsafe { ManuallyDrop::take(&mut self.raw) }; + + std::mem::forget(self); + + raw + } } impl AudioStreamBuilder { @@ -452,12 +467,23 @@ impl AudioStreamBuilder */ pub fn open_stream(self) -> Result> { let mut stream = MaybeUninit::<*mut ffi::oboe_AudioStream>::uninit(); - let Self { mut raw, .. } = self; - - wrap_status(unsafe { - ffi::oboe_AudioStreamBuilder_openStream(&mut *raw, stream.as_mut_ptr()) + let mut shared_ptr = MaybeUninit::<*mut c_void>::uninit(); + let mut raw = self.destructs(); + + let stream = wrap_status(unsafe { + ffi::oboe_AudioStreamBuilder_openStreamShared( + &mut *raw, + stream.as_mut_ptr(), + shared_ptr.as_mut_ptr(), + ) }) - .map(|_| AudioStreamSync::wrap_raw(unsafe { stream.assume_init() })) + .map(|_| unsafe { + AudioStreamSync::wrap_raw(stream.assume_init(), shared_ptr.assume_init()) + }); + + drop(raw); + + stream } } @@ -485,14 +511,10 @@ impl AudioStreamBuilder { F: AudioInputCallback, (T, C): IsFrameType, { - let mut callback = AudioCallbackWrapper::::wrap(stream_callback); - let Self { mut raw, .. } = self; - unsafe { - ffi::oboe_AudioStreamBuilder_setCallback(&mut *raw, callback.raw_callback()); - } + let mut raw = self.destructs(); + set_input_callback(&mut raw, stream_callback); AudioStreamBuilderAsync { - raw, - callback, + raw: ManuallyDrop::new(raw), _phantom: PhantomData, } } @@ -522,14 +544,10 @@ impl AudioStreamBuilder { F: AudioOutputCallback, (T, C): IsFrameType, { - let mut callback = AudioCallbackWrapper::::wrap(stream_callback); - let Self { mut raw, .. } = self; - unsafe { - ffi::oboe_AudioStreamBuilder_setCallback(&mut *raw, callback.raw_callback()); - } + let mut raw = self.destructs(); + set_output_callback(&mut raw, stream_callback); AudioStreamBuilderAsync { - raw, - callback, + raw: ManuallyDrop::new(raw), _phantom: PhantomData, } } @@ -539,11 +557,19 @@ impl AudioStreamBuilder { * Factory for an audio stream. */ pub struct AudioStreamBuilderAsync { - raw: AudioStreamBuilderHandle, - callback: AudioCallbackWrapper, + raw: ManuallyDrop, _phantom: PhantomData<(D, F)>, } +impl Drop for AudioStreamBuilderAsync { + fn drop(&mut self) { + // SAFETY: self.raw is only droped here, or taken in Self::destructs, which don't drop self. + unsafe { + ManuallyDrop::drop(&mut self.raw); + } + } +} + impl fmt::Debug for AudioStreamBuilderAsync { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { audio_stream_base_fmt(self, f) @@ -560,20 +586,41 @@ impl RawAudioStreamBase for AudioStreamBuilderAsync { } } +impl AudioStreamBuilderAsync { + /// Descontructs self into its handle without calling drop. + fn destructs(mut self) -> AudioStreamBuilderHandle { + // Safety: the std::mem::forget prevents `raw` from being dropped by Self::drop. + let raw = unsafe { ManuallyDrop::take(&mut self.raw) }; + + std::mem::forget(self); + + raw + } +} + impl AudioStreamBuilderAsync { /** * Create and open an asynchronous (callback-driven) input stream based on the current settings. */ pub fn open_stream(self) -> Result> { let mut stream = MaybeUninit::<*mut ffi::oboe_AudioStream>::uninit(); - let Self { - mut raw, callback, .. - } = self; - - wrap_status(unsafe { - ffi::oboe_AudioStreamBuilder_openStream(&mut *raw, stream.as_mut_ptr()) + let mut shared_ptr = MaybeUninit::<*mut c_void>::uninit(); + let mut raw = self.destructs(); + + let stream = wrap_status(unsafe { + ffi::oboe_AudioStreamBuilder_openStreamShared( + &mut *raw, + stream.as_mut_ptr(), + shared_ptr.as_mut_ptr(), + ) }) - .map(|_| AudioStreamAsync::wrap_raw(unsafe { stream.assume_init() }, callback)) + .map(|_| unsafe { + AudioStreamAsync::wrap_raw(stream.assume_init(), shared_ptr.assume_init()) + }); + + drop(raw); + + stream } } @@ -583,13 +630,22 @@ impl AudioStreamBuilderAsync { */ pub fn open_stream(self) -> Result> { let mut stream = MaybeUninit::<*mut ffi::oboe_AudioStream>::uninit(); - let Self { - mut raw, callback, .. - } = self; - - wrap_status(unsafe { - ffi::oboe_AudioStreamBuilder_openStream(&mut *raw, stream.as_mut_ptr()) + let mut shared_ptr = MaybeUninit::<*mut c_void>::uninit(); + let mut raw = self.destructs(); + + let stream = wrap_status(unsafe { + ffi::oboe_AudioStreamBuilder_openStreamShared( + &mut *raw, + stream.as_mut_ptr(), + shared_ptr.as_mut_ptr(), + ) }) - .map(|_| AudioStreamAsync::wrap_raw(unsafe { stream.assume_init() }, callback)) + .map(|_| unsafe { + AudioStreamAsync::wrap_raw(stream.assume_init(), shared_ptr.assume_init()) + }); + + drop(raw); + + stream } } diff --git a/src/audio_stream_callback.rs b/src/audio_stream_callback.rs index a9b099b..25795ef 100644 --- a/src/audio_stream_callback.rs +++ b/src/audio_stream_callback.rs @@ -1,7 +1,5 @@ use std::{ ffi::c_void, - marker::PhantomData, - ops::{Deref, DerefMut}, slice::{from_raw_parts, from_raw_parts_mut}, }; @@ -10,8 +8,8 @@ use oboe_sys as ffi; use num_traits::FromPrimitive; use super::{ - AudioInputStreamSafe, AudioOutputStreamSafe, AudioStreamRef, DataCallbackResult, Error, Input, - IsFrameType, Output, + AudioInputStreamSafe, AudioOutputStreamSafe, AudioStreamBuilderHandle, AudioStreamRef, + DataCallbackResult, Error, IsFrameType, }; /** @@ -208,95 +206,50 @@ pub trait AudioOutputCallback { ) -> DataCallbackResult; } -#[repr(transparent)] -struct AudioStreamCallbackWrapperHandle(*mut ffi::oboe_AudioStreamCallbackWrapper); - -impl AudioStreamCallbackWrapperHandle { - fn new( - audio_ready: ffi::oboe_AudioReadyHandler, - before_close: ffi::oboe_ErrorCloseHandler, - after_close: ffi::oboe_ErrorCloseHandler, - ) -> Self { - Self(unsafe { - ffi::oboe_AudioStreamCallbackWrapper_new(audio_ready, before_close, after_close) - }) - } -} - -impl Drop for AudioStreamCallbackWrapperHandle { - fn drop(&mut self) { - unsafe { ffi::oboe_AudioStreamCallbackWrapper_delete(self.0) } - } -} - -impl Deref for AudioStreamCallbackWrapperHandle { - type Target = ffi::oboe_AudioStreamCallbackWrapper; - - fn deref(&self) -> &Self::Target { - unsafe { &(*self.0) } - } -} - -impl DerefMut for AudioStreamCallbackWrapperHandle { - fn deref_mut(&mut self) -> &mut Self::Target { - unsafe { &mut (*self.0) } - } -} - -pub(crate) struct AudioCallbackWrapper { - raw: AudioStreamCallbackWrapperHandle, - callback: Box, - _phantom: PhantomData, -} - -impl AudioCallbackWrapper { - pub(crate) fn raw_callback(&mut self) -> &mut ffi::oboe_AudioStreamCallbackWrapper { - &mut *self.raw +pub(crate) fn set_input_callback( + builder: &mut AudioStreamBuilderHandle, + callback: T, +) { + let callback = Box::into_raw(Box::new(callback)); + + // SAFETY: `callback` has the same type as the first argument of each function, and each + // function follows the C ABI. + unsafe { + ffi::oboe_AudioStreamBuilder_setCallback( + &mut **builder as *mut ffi::oboe_AudioStreamBuilder, + callback.cast(), + Some(drop_context::), + Some(on_audio_ready_input_wrapper::), + Some(on_error_before_close_input_wrapper::), + Some(on_error_after_close_input_wrapper::), + ); } } -impl AudioCallbackWrapper -where - T: AudioInputCallback, -{ - pub(crate) fn wrap(callback: T) -> Self { - let callback = Box::new(callback); - let mut wrapper = Self { - raw: AudioStreamCallbackWrapperHandle::new( - Some(on_audio_ready_input_wrapper::), - Some(on_error_before_close_input_wrapper::), - Some(on_error_after_close_input_wrapper::), - ), - callback, - _phantom: PhantomData, - }; - unsafe { - (*wrapper.raw).setContext(&mut (*wrapper.callback) as *mut _ as *mut c_void); - } - wrapper +pub(crate) fn set_output_callback( + builder: &mut AudioStreamBuilderHandle, + callback: T, +) { + let callback = Box::new(callback); + let callback = Box::into_raw(callback); + + // SAFETY: `callback` has the same type as the first argument of each function, and each + // function follows the C ABI. + unsafe { + ffi::oboe_AudioStreamBuilder_setCallback( + &mut **builder as *mut ffi::oboe_AudioStreamBuilder, + callback.cast(), + Some(drop_context::), + Some(on_audio_ready_output_wrapper::), + Some(on_error_before_close_output_wrapper::), + Some(on_error_after_close_output_wrapper::), + ); } } -impl AudioCallbackWrapper -where - T: AudioOutputCallback, -{ - pub(crate) fn wrap(callback: T) -> Self { - let callback = Box::new(callback); - let mut wrapper = Self { - raw: AudioStreamCallbackWrapperHandle::new( - Some(on_audio_ready_output_wrapper::), - Some(on_error_before_close_output_wrapper::), - Some(on_error_after_close_output_wrapper::), - ), - callback, - _phantom: PhantomData, - }; - unsafe { - (*wrapper.raw).setContext(&mut (*wrapper.callback) as *mut _ as *mut c_void); - } - wrapper - } +unsafe extern "C" fn drop_context(context: *mut c_void) { + let context = Box::from_raw(context as *mut T); + drop(context); } unsafe extern "C" fn on_error_before_close_input_wrapper( diff --git a/sys/Cargo.toml b/sys/Cargo.toml index 80c0d66..a21ef89 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -23,7 +23,7 @@ version = "1.0" features = ["parallel"] [build-dependencies.bindgen] -version = "0.59" +version = "0.60" optional = true [features] diff --git a/sys/build.rs b/sys/build.rs index 111dc22..c26f08d 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -164,6 +164,7 @@ impl Builder { .allowlist_function("oboe::getSdkVersion") .blocklist_type("std::.*_ptr.*") .blocklist_type("oboe::ManagedStream") + .blocklist_function("oboe::AudioStreamBuilder_openStream") .blocklist_function("oboe::AudioStreamBuilder_openStream1") .blocklist_function("oboe::AudioStreamBuilder_openManagedStream") .blocklist_function("oboe::AudioStreamBuilder_setPackageName") diff --git a/sys/oboe b/sys/oboe index 855ea84..8740d0f 160000 --- a/sys/oboe +++ b/sys/oboe @@ -1 +1 @@ -Subproject commit 855ea841a93bf304065e5152909983b1b85ffabb +Subproject commit 8740d0fc321a55489dbbf6067298201b7d2e106d diff --git a/sys/oboe-ext/include/oboe/OboeExt.h b/sys/oboe-ext/include/oboe/OboeExt.h index c89160c..e3d8c92 100644 --- a/sys/oboe-ext/include/oboe/OboeExt.h +++ b/sys/oboe-ext/include/oboe/OboeExt.h @@ -4,6 +4,8 @@ #include "oboe/Oboe.h" namespace oboe { + typedef void (*DropContextHandler)(void *context); + typedef DataCallbackResult (*AudioReadyHandler)(void *context, AudioStream *oboeStream, void *audioData, @@ -13,13 +15,16 @@ namespace oboe { AudioStream *oboeStream, Result error); - class AudioStreamCallbackWrapper: public AudioStreamCallback { + class AudioStreamCallbackWrapper + : public AudioStreamDataCallback, public AudioStreamErrorCallback { public: - AudioStreamCallbackWrapper(const AudioReadyHandler audio_ready, + AudioStreamCallbackWrapper(void *context, + const DropContextHandler drop_context, + const AudioReadyHandler audio_ready, const ErrorCloseHandler before_close, const ErrorCloseHandler after_close); - void setContext(void *context); + ~AudioStreamCallbackWrapper(); DataCallbackResult onAudioReady(AudioStream *oboeStream, void *audioData, @@ -33,35 +38,32 @@ namespace oboe { private: void *_context; + const DropContextHandler _drop_context; const AudioReadyHandler _audio_ready; const ErrorCloseHandler _before_close; const ErrorCloseHandler _after_close; }; - /*void AudioStreamCallbackWrapper_init(AudioStreamCallbackWrapper *callback, - const AudioReadyHandler audio_ready, - const ErrorCloseHandler before_close, - const ErrorCloseHandler after_close); - void AudioStreamCallbackWrapper_drop(AudioStreamCallbackWrapper *callback);*/ - - AudioStreamCallbackWrapper * - AudioStreamCallbackWrapper_new(const AudioReadyHandler audio_ready, - const ErrorCloseHandler before_close, - const ErrorCloseHandler after_close); - void AudioStreamCallbackWrapper_delete(AudioStreamCallbackWrapper *callback); - - //void AudioStreamBuilder_init(AudioStreamBuilder *builder); - //void AudioStreamBuilder_drop(AudioStreamBuilder *builder); AudioStreamBuilder *AudioStreamBuilder_new(); void AudioStreamBuilder_delete(AudioStreamBuilder *builder); void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, - AudioStreamCallbackWrapper *callback); + void *context, + const DropContextHandler drop_context, + const AudioReadyHandler audio_ready, + const ErrorCloseHandler before_close, + const ErrorCloseHandler after_close); + AudioApi AudioStreamBuilder_getAudioApi(const AudioStreamBuilder *builder); void AudioStreamBuilder_setAudioApi(AudioStreamBuilder *builder, AudioApi api); AudioStreamBase* AudioStreamBuilder_getBase(AudioStreamBuilder *builder); - + Result AudioStreamBuilder_openStreamShared(AudioStreamBuilder *builder, + AudioStream **stream, + void **shared_ptr); + void AudioStream_delete(AudioStream *oboeStream); + void AudioStream_deleteShared(void *shared_ptr); Result AudioStream_open(AudioStream *oboeStream); + Result AudioStream_close(AudioStream *oboeStream); Result AudioStream_requestStart(AudioStream *oboeStream); Result AudioStream_requestPause(AudioStream *oboeStream); Result AudioStream_requestFlush(AudioStream *oboeStream); diff --git a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp index 283409f..40baca9 100644 --- a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp @@ -25,12 +25,35 @@ namespace oboe { builder->setAudioApi(api); } + /// Takes ownership of context (drop_context will be called to free it). void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, - AudioStreamCallbackWrapper *callback) { - builder->setCallback(callback); + void *context, + const DropContextHandler drop_context, + const AudioReadyHandler audio_ready, + const ErrorCloseHandler before_close, + const ErrorCloseHandler after_close) { + auto s = std::make_shared( + context, + drop_context, + audio_ready, + before_close, + after_close); + + builder->setDataCallback(s); + builder->setErrorCallback(s); } AudioStreamBase* AudioStreamBuilder_getBase(AudioStreamBuilder *builder) { return static_cast(builder); } + + Result AudioStreamBuilder_openStreamShared(AudioStreamBuilder *builder, + AudioStream **stream, + void **shared_ptr) { + std::shared_ptr *s = new std::shared_ptr(); + Result res = builder->openStream(*s); + *stream = s->get(); + *shared_ptr = (void *)s; + return res; + } } diff --git a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp index 7cbb7b2..9c9bf35 100644 --- a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp @@ -4,17 +4,20 @@ namespace oboe { AudioStreamCallbackWrapper:: - AudioStreamCallbackWrapper(const AudioReadyHandler audio_ready, + AudioStreamCallbackWrapper(void *context, + const DropContextHandler drop_context, + const AudioReadyHandler audio_ready, const ErrorCloseHandler before_close, const ErrorCloseHandler after_close): - AudioStreamCallback(), - _context(nullptr), + _context(context), + _drop_context(drop_context), _audio_ready(audio_ready), _before_close(before_close), _after_close(after_close) {} - void AudioStreamCallbackWrapper::setContext(void *context) { - _context = context; + AudioStreamCallbackWrapper + ::~AudioStreamCallbackWrapper() { + _drop_context(_context); } DataCallbackResult AudioStreamCallbackWrapper:: @@ -35,30 +38,4 @@ namespace oboe { Result error) { _after_close(_context, oboeStream, error); } - - /*void AudioStreamCallbackWrapper_init(AudioStreamCallbackWrapper *callback, - const AudioReadyHandler audio_ready, - const ErrorCloseHandler before_close, - const ErrorCloseHandler after_close) { - new (callback) AudioStreamCallbackWrapper(audio_ready, - before_close, - after_close); - } - - void AudioStreamCallbackWrapper_drop(AudioStreamCallbackWrapper *callback) { - callback->~AudioStreamCallbackWrapper(); - }*/ - - AudioStreamCallbackWrapper * - AudioStreamCallbackWrapper_new(const AudioReadyHandler audio_ready, - const ErrorCloseHandler before_close, - const ErrorCloseHandler after_close) { - return new AudioStreamCallbackWrapper(audio_ready, - before_close, - after_close); - } - - void AudioStreamCallbackWrapper_delete(AudioStreamCallbackWrapper *callback) { - delete callback; - } } diff --git a/sys/oboe-ext/src/AudioStreamWrapper.cpp b/sys/oboe-ext/src/AudioStreamWrapper.cpp index 8380ac6..e4e011b 100644 --- a/sys/oboe-ext/src/AudioStreamWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamWrapper.cpp @@ -1,14 +1,19 @@ #include "oboe/OboeExt.h" namespace oboe { - void AudioStream_delete(AudioStream *oboeStream) { - delete oboeStream; + void AudioStream_deleteShared(void *shared_ptr) { + std::shared_ptr *s = (std::shared_ptr *)shared_ptr; + delete s; } Result AudioStream_open(AudioStream *oboeStream) { return oboeStream->open(); } + Result AudioStream_close(AudioStream *oboeStream) { + return oboeStream->close(); + } + Result AudioStream_requestStart(AudioStream *oboeStream) { return oboeStream->requestStart(); } diff --git a/sys/src/bindings_aarch64.rs b/sys/src/bindings_aarch64.rs index 7f864db..5956176 100644 --- a/sys/src/bindings_aarch64.rs +++ b/sys/src/bindings_aarch64.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.59.2 */ +/* automatically generated by rust-bindgen 0.60.1 */ pub type std_string = [u64; 3usize]; pub type __uint8_t = ::std::os::raw::c_uchar; @@ -120,8 +120,11 @@ pub type oboe_PerformanceMode = i32; #[doc = " Try to use AAudio. If not available then use OpenSL ES."] pub const oboe_AudioApi_Unspecified: oboe_AudioApi = 0; #[doc = " Use OpenSL ES."] +#[doc = " Note that OpenSL ES is deprecated in Android 13, API 30 and above."] pub const oboe_AudioApi_OpenSLES: oboe_AudioApi = 1; #[doc = " Try to use AAudio. Fail if unavailable."] +#[doc = " AAudio was first supported in Android 8, API 26 and above."] +#[doc = " It is only recommended for API 27 and above."] pub const oboe_AudioApi_AAudio: oboe_AudioApi = 2; #[doc = " The underlying audio API used by the audio stream."] pub type oboe_AudioApi = i32; @@ -130,14 +133,11 @@ pub const oboe_SampleRateConversionQuality_None: oboe_SampleRateConversionQualit #[doc = " Fastest conversion but may not sound great."] #[doc = " This may be implemented using bilinear interpolation."] pub const oboe_SampleRateConversionQuality_Fastest: oboe_SampleRateConversionQuality = 1; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Low quality conversion with 8 taps."] pub const oboe_SampleRateConversionQuality_Low: oboe_SampleRateConversionQuality = 2; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Medium quality conversion with 16 taps."] pub const oboe_SampleRateConversionQuality_Medium: oboe_SampleRateConversionQuality = 3; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " High quality conversion with 32 taps."] pub const oboe_SampleRateConversionQuality_High: oboe_SampleRateConversionQuality = 4; #[doc = " Highest quality conversion, which may be expensive in terms of CPU."] pub const oboe_SampleRateConversionQuality_Best: oboe_SampleRateConversionQuality = 5; @@ -251,6 +251,66 @@ pub const oboe_ChannelCount_Stereo: oboe_ChannelCount = 2; #[doc = " rather than `builder.setChannelCount(2)`"] #[doc = ""] pub type oboe_ChannelCount = i32; +pub const oboe_ChannelMask_Unspecified: oboe_ChannelMask = 0; +pub const oboe_ChannelMask_FrontLeft: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_FrontRight: oboe_ChannelMask = 2; +pub const oboe_ChannelMask_FrontCenter: oboe_ChannelMask = 4; +pub const oboe_ChannelMask_LowFrequency: oboe_ChannelMask = 8; +pub const oboe_ChannelMask_BackLeft: oboe_ChannelMask = 16; +pub const oboe_ChannelMask_BackRight: oboe_ChannelMask = 32; +pub const oboe_ChannelMask_FrontLeftOfCenter: oboe_ChannelMask = 64; +pub const oboe_ChannelMask_FrontRightOfCenter: oboe_ChannelMask = 128; +pub const oboe_ChannelMask_BackCenter: oboe_ChannelMask = 256; +pub const oboe_ChannelMask_SideLeft: oboe_ChannelMask = 512; +pub const oboe_ChannelMask_SideRight: oboe_ChannelMask = 1024; +pub const oboe_ChannelMask_TopCenter: oboe_ChannelMask = 2048; +pub const oboe_ChannelMask_TopFrontLeft: oboe_ChannelMask = 4096; +pub const oboe_ChannelMask_TopFrontCenter: oboe_ChannelMask = 8192; +pub const oboe_ChannelMask_TopFrontRight: oboe_ChannelMask = 16384; +pub const oboe_ChannelMask_TopBackLeft: oboe_ChannelMask = 32768; +pub const oboe_ChannelMask_TopBackCenter: oboe_ChannelMask = 65536; +pub const oboe_ChannelMask_TopBackRight: oboe_ChannelMask = 131072; +pub const oboe_ChannelMask_TopSideLeft: oboe_ChannelMask = 262144; +pub const oboe_ChannelMask_TopSideRight: oboe_ChannelMask = 524288; +pub const oboe_ChannelMask_BottomFrontLeft: oboe_ChannelMask = 1048576; +pub const oboe_ChannelMask_BottomFrontCenter: oboe_ChannelMask = 2097152; +pub const oboe_ChannelMask_BottomFrontRight: oboe_ChannelMask = 4194304; +pub const oboe_ChannelMask_LowFrequency2: oboe_ChannelMask = 8388608; +pub const oboe_ChannelMask_FrontWideLeft: oboe_ChannelMask = 16777216; +pub const oboe_ChannelMask_FrontWideRight: oboe_ChannelMask = 33554432; +pub const oboe_ChannelMask_Mono: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_Stereo: oboe_ChannelMask = 3; +pub const oboe_ChannelMask_CM2Point1: oboe_ChannelMask = 11; +pub const oboe_ChannelMask_Tri: oboe_ChannelMask = 7; +pub const oboe_ChannelMask_TriBack: oboe_ChannelMask = 259; +pub const oboe_ChannelMask_CM3Point1: oboe_ChannelMask = 15; +pub const oboe_ChannelMask_CM2Point0Point2: oboe_ChannelMask = 786435; +pub const oboe_ChannelMask_CM2Point1Point2: oboe_ChannelMask = 786443; +pub const oboe_ChannelMask_CM3Point0Point2: oboe_ChannelMask = 786439; +pub const oboe_ChannelMask_CM3Point1Point2: oboe_ChannelMask = 786447; +pub const oboe_ChannelMask_Quad: oboe_ChannelMask = 51; +pub const oboe_ChannelMask_QuadSide: oboe_ChannelMask = 1539; +pub const oboe_ChannelMask_Surround: oboe_ChannelMask = 263; +pub const oboe_ChannelMask_Penta: oboe_ChannelMask = 55; +pub const oboe_ChannelMask_CM5Point1: oboe_ChannelMask = 63; +pub const oboe_ChannelMask_CM5Point1Side: oboe_ChannelMask = 1551; +pub const oboe_ChannelMask_CM6Point1: oboe_ChannelMask = 319; +pub const oboe_ChannelMask_CM7Point1: oboe_ChannelMask = 1599; +pub const oboe_ChannelMask_CM5Point1Point2: oboe_ChannelMask = 786495; +pub const oboe_ChannelMask_CM5Point1Point4: oboe_ChannelMask = 184383; +pub const oboe_ChannelMask_CM7Point1Point2: oboe_ChannelMask = 788031; +pub const oboe_ChannelMask_CM7Point1Point4: oboe_ChannelMask = 185919; +pub const oboe_ChannelMask_CM9Point1Point4: oboe_ChannelMask = 50517567; +pub const oboe_ChannelMask_CM9Point1Point6: oboe_ChannelMask = 51303999; +pub const oboe_ChannelMask_FrontBack: oboe_ChannelMask = 260; +#[doc = " The channel mask of the audio stream. The underlying type is `uint32_t`."] +#[doc = " Use of this enum is convenient."] +#[doc = ""] +#[doc = " ChannelMask::Unspecified means this is not specified."] +#[doc = " The rest of the enums are channel position masks."] +#[doc = " Use the combinations of the channel position masks defined below instead of"] +#[doc = " using those values directly."] +pub type oboe_ChannelMask = u32; #[doc = " On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and"] #[doc = " framesPerBurst are not known by the native code."] #[doc = " On API 17+ these values should be obtained from the AudioManager using this code:"] @@ -319,26 +379,40 @@ fn bindgen_test_layout_oboe_FrameTimestamp() { 8usize, concat!("Alignment of ", stringify!(oboe_FrameTimestamp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).position as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(position) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timestamp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(timestamp) - ) - ); + fn test_field_position() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).position) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(position) + ) + ); + } + test_field_position(); + fn test_field_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(timestamp) + ) + ); + } + test_field_timestamp(); } #[doc = " A ResultWithValue can store both the result of an operation (either OK or an error) and a value."] #[doc = ""] @@ -396,6 +470,10 @@ pub struct oboe_AudioStreamErrorCallback__bindgen_vtable(::std::os::raw::c_void) #[doc = " being alerted when a stream has an error or is disconnected"] #[doc = " using `onError*` methods."] #[doc = ""] +#[doc = " Note: This callback is only fired when an AudioStreamCallback is set."] +#[doc = " If you use AudioStream::write() you have to evaluate the return codes of"] +#[doc = " AudioStream::write() to notice errors in the stream."] +#[doc = ""] #[doc = " It is used with AudioStreamBuilder::setErrorCallback()."] #[repr(C)] #[derive(Debug)] @@ -450,13 +528,14 @@ fn bindgen_test_layout_oboe_AudioStreamCallback() { pub struct oboe_AudioStreamBase__bindgen_vtable(::std::os::raw::c_void); #[doc = " Base class containing parameters for audio streams and builders."] #[repr(C)] -#[derive(Debug)] pub struct oboe_AudioStreamBase { pub vtable_: *const oboe_AudioStreamBase__bindgen_vtable, #[doc = " The callback which will be fired when new data is ready to be read/written."] pub mDataCallback: *mut oboe_AudioStreamDataCallback, + pub mSharedDataCallback: [u64; 2usize], #[doc = " The callback which will be fired when an error or a disconnect occurs."] pub mErrorCallback: *mut oboe_AudioStreamErrorCallback, + pub mSharedErrorCallback: [u64; 2usize], #[doc = " Number of audio frames which will be requested in each callback"] pub mFramesPerCallback: i32, #[doc = " Stream channel count"] @@ -469,6 +548,8 @@ pub struct oboe_AudioStreamBase { pub mBufferCapacityInFrames: i32, #[doc = " Stream buffer size specified as a number of audio frames"] pub mBufferSizeInFrames: i32, + #[doc = " Stream channel mask. Only active on Android 32+"] + pub mChannelMask: oboe_ChannelMask, #[doc = " Stream sharing mode"] pub mSharingMode: oboe_SharingMode, #[doc = " Format of audio frames"] @@ -498,7 +579,7 @@ pub struct oboe_AudioStreamBase { fn bindgen_test_layout_oboe_AudioStreamBase() { assert_eq!( ::std::mem::size_of::(), - 136usize, + 176usize, concat!("Size of: ", stringify!(oboe_AudioStreamBase)) ); assert_eq!( @@ -506,266 +587,437 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { 8usize, concat!("Alignment of ", stringify!(oboe_AudioStreamBase)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mDataCallback as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDataCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mErrorCallback as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mErrorCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFramesPerCallback as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFramesPerCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelCount as *const _ as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRate as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDeviceId as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDeviceId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferCapacityInFrames as *const _ - as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferCapacityInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferSizeInFrames as *const _ - as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferSizeInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSharingMode as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSharingMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mFormat as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormat) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDirection as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDirection) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPerformanceMode as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPerformanceMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mUsage as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mUsage) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mContentType as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mContentType) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mInputPreset as *const _ as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mInputPreset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mSessionId as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSessionId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPackageName as *const _ as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPackageName) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mAttributionTag as *const _ as usize - }, - 104usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mAttributionTag) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelConversionAllowed as *const _ - as usize - }, - 128usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFormatConversionAllowed as *const _ - as usize - }, - 129usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormatConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRateConversionQuality - as *const _ as usize - }, - 132usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRateConversionQuality) - ) - ); + fn test_field_mDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDataCallback) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDataCallback) + ) + ); + } + test_field_mDataCallback(); + fn test_field_mSharedDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedDataCallback) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedDataCallback) + ) + ); + } + test_field_mSharedDataCallback(); + fn test_field_mErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mErrorCallback) + ) + ); + } + test_field_mErrorCallback(); + fn test_field_mSharedErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedErrorCallback) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedErrorCallback) + ) + ); + } + test_field_mSharedErrorCallback(); + fn test_field_mFramesPerCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFramesPerCallback) + ) + ); + } + test_field_mFramesPerCallback(); + fn test_field_mChannelCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelCount) + ) + ); + } + test_field_mChannelCount(); + fn test_field_mSampleRate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRate) + ) + ); + } + test_field_mSampleRate(); + fn test_field_mDeviceId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDeviceId) + ) + ); + } + test_field_mDeviceId(); + fn test_field_mBufferCapacityInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferCapacityInFrames) + ) + ); + } + test_field_mBufferCapacityInFrames(); + fn test_field_mBufferSizeInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + fn test_field_mChannelMask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelMask) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelMask) + ) + ); + } + test_field_mChannelMask(); + fn test_field_mSharingMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharingMode) + ) + ); + } + test_field_mSharingMode(); + fn test_field_mFormat() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormat) + ) + ); + } + test_field_mFormat(); + fn test_field_mDirection() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize + }, + 92usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDirection) + ) + ); + } + test_field_mDirection(); + fn test_field_mPerformanceMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPerformanceMode) + ) + ); + } + test_field_mPerformanceMode(); + fn test_field_mUsage() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mUsage) + ) + ); + } + test_field_mUsage(); + fn test_field_mContentType() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mContentType) + ) + ); + } + test_field_mContentType(); + fn test_field_mInputPreset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize + }, + 108usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mInputPreset) + ) + ); + } + test_field_mInputPreset(); + fn test_field_mSessionId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSessionId) + ) + ); + } + test_field_mSessionId(); + fn test_field_mPackageName() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPackageName) + ) + ); + } + test_field_mPackageName(); + fn test_field_mAttributionTag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize + }, + 144usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mAttributionTag) + ) + ); + } + test_field_mAttributionTag(); + fn test_field_mChannelConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize + }, + 168usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelConversionAllowed) + ) + ); + } + test_field_mChannelConversionAllowed(); + fn test_field_mFormatConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize + }, + 169usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormatConversionAllowed) + ) + ); + } + test_field_mFormatConversionAllowed(); + fn test_field_mSampleRateConversionQuality() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize + }, + 172usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); +} +extern "C" { + #[doc = " Return the version of the SDK that is currently running."] + #[doc = ""] + #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] + #[doc = " If the version number cannot be determined then this will return -1."] + #[doc = ""] + #[doc = " @return version number or -1"] + #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] + pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; } #[doc = " Factory class for an audio Stream."] #[repr(C)] #[repr(align(8))] #[derive(Debug, Copy, Clone)] pub struct oboe_AudioStreamBuilder { - pub _bindgen_opaque_blob: [u64; 18usize], + pub _bindgen_opaque_blob: [u64; 23usize], } #[test] fn bindgen_test_layout_oboe_AudioStreamBuilder() { assert_eq!( ::std::mem::size_of::(), - 144usize, + 184usize, concat!("Size of: ", stringify!(oboe_AudioStreamBuilder)) ); assert_eq!( @@ -793,21 +1045,6 @@ extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder19isAAudioRecommendedEv"] pub fn oboe_AudioStreamBuilder_isAAudioRecommended() -> bool; } -extern "C" { - #[doc = " Create and open a stream object based on the current settings."] - #[doc = ""] - #[doc = " The caller owns the pointer to the AudioStream object"] - #[doc = " and must delete it when finished."] - #[doc = ""] - #[doc = " @deprecated Use openStream(std::shared_ptr &stream) instead."] - #[doc = " @param stream pointer to a variable to receive the stream address"] - #[doc = " @return OBOE_OK if successful or a negative error code"] - #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder10openStreamEPPNS_11AudioStreamE"] - pub fn oboe_AudioStreamBuilder_openStream( - this: *mut oboe_AudioStreamBuilder, - stream: *mut *mut oboe_AudioStream, - ) -> oboe_Result; -} impl oboe_AudioStreamBuilder { #[inline] pub unsafe fn isAAudioSupported() -> bool { @@ -817,23 +1054,18 @@ impl oboe_AudioStreamBuilder { pub unsafe fn isAAudioRecommended() -> bool { oboe_AudioStreamBuilder_isAAudioRecommended() } - #[inline] - pub unsafe fn openStream(&mut self, stream: *mut *mut oboe_AudioStream) -> oboe_Result { - oboe_AudioStreamBuilder_openStream(self, stream) - } } #[doc = " Base class for Oboe C++ audio stream."] #[repr(C)] #[repr(align(8))] -#[derive(Debug, Copy, Clone)] pub struct oboe_AudioStream { - pub _bindgen_opaque_blob: [u64; 28usize], + pub _bindgen_opaque_blob: [u64; 34usize], } #[test] fn bindgen_test_layout_oboe_AudioStream() { assert_eq!( ::std::mem::size_of::(), - 224usize, + 272usize, concat!("Size of: ", stringify!(oboe_AudioStream)) ); assert_eq!( @@ -886,6 +1118,12 @@ extern "C" { numFrames: ::std::os::raw::c_int, ) -> oboe_DataCallbackResult; } +extern "C" { + #[doc = " This should only be called as a stream is being opened."] + #[doc = " Otherwise we might override setDelayBeforeCloseMillis()."] + #[link_name = "\u{1}_ZN4oboe11AudioStream38calculateDefaultDelayBeforeCloseMillisEv"] + pub fn oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(this: *mut oboe_AudioStream); +} extern "C" { #[doc = " Construct an `AudioStream` using the given `AudioStreamBuilder`"] #[doc = ""] @@ -922,6 +1160,10 @@ impl oboe_AudioStream { oboe_AudioStream_fireDataCallback(self, audioData, numFrames) } #[inline] + pub unsafe fn calculateDefaultDelayBeforeCloseMillis(&mut self) { + oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(self) + } + #[inline] pub unsafe fn new(builder: *const oboe_AudioStreamBuilder) -> Self { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStream_AudioStream(__bindgen_tmp.as_mut_ptr(), builder); @@ -996,6 +1238,11 @@ extern "C" { #[doc = " The time is based on the implementation's best effort, using whatever knowledge is available"] #[doc = " to the system, but cannot account for any delay unknown to the implementation."] #[doc = ""] + #[doc = " Note that due to issues in Android before R, we recommend NOT calling"] + #[doc = " this method from a data callback. See this tech note for more details."] + #[doc = " https://github.com/google/oboe/blob/main/docs/notes/rlsbuffer.md"] + #[doc = ""] + #[doc = " See"] #[doc = " @param clockId the type of clock to use e.g. CLOCK_MONOTONIC"] #[doc = " @return a FrameTimestamp containing the position and time at which a particular audio frame"] #[doc = " entered or left the audio processing pipeline, or an error if the operation failed."] @@ -1018,6 +1265,7 @@ extern "C" { timeoutNanoseconds: i64, ) -> oboe_Result; } +pub const oboe_AudioStream_kMinDelayBeforeCloseMillis: ::std::os::raw::c_int = 10; #[doc = " This struct is a stateless functor which closes an AudioStream prior to its deletion."] #[doc = " This means it can be used to safely delete a smart pointer referring to an open stream."] #[repr(C)] @@ -1151,16 +1399,6 @@ impl oboe_LatencyTuner { } pub const oboe_LatencyTuner_kIdleCount: i32 = 8; pub const oboe_LatencyTuner_kDefaultNumBursts: i32 = 2; -extern "C" { - #[doc = " Return the version of the SDK that is currently running."] - #[doc = ""] - #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] - #[doc = " If the version number cannot be determined then this will return -1."] - #[doc = ""] - #[doc = " @return version number or -1"] - #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] - pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; -} #[doc = " Oboe versioning object"] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1171,15 +1409,15 @@ pub struct oboe_Version { pub const oboe_Version_Major: u8 = 1; #[doc = " This is incremented when we add backwards compatible functionality. Or set to zero when MAJOR is"] #[doc = " incremented."] -pub const oboe_Version_Minor: u8 = 6; +pub const oboe_Version_Minor: u8 = 7; #[doc = " This is incremented when we make backwards compatible bug fixes. Or set to zero when MINOR is"] #[doc = " incremented."] -pub const oboe_Version_Patch: u16 = 1; +pub const oboe_Version_Patch: u16 = 0; #[doc = " Version string in the form MAJOR.MINOR.PATCH."] -pub const oboe_Version_Text: &[u8; 6usize] = b"1.6.1\0"; +pub const oboe_Version_Text: &[u8; 6usize] = b"1.7.0\0"; #[doc = " Integer representation of the current Oboe library version. This will always increase when the"] #[doc = " version number changes so can be compared using integer comparison."] -pub const oboe_Version_Number: u32 = 17170433; +pub const oboe_Version_Number: u32 = 17235968; #[test] fn bindgen_test_layout_oboe_Version() { assert_eq!( @@ -1214,54 +1452,74 @@ fn bindgen_test_layout_oboe_StabilizedCallback() { 8usize, concat!("Alignment of ", stringify!(oboe_StabilizedCallback)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mCallback as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFrameCount as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mFrameCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mEpochTimeNanos as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mEpochTimeNanos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mOpsPerNano as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mOpsPerNano) - ) - ); + fn test_field_mCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mCallback) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mCallback) + ) + ); + } + test_field_mCallback(); + fn test_field_mFrameCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFrameCount) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mFrameCount) + ) + ); + } + test_field_mFrameCount(); + fn test_field_mEpochTimeNanos() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mEpochTimeNanos) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mEpochTimeNanos) + ) + ); + } + test_field_mEpochTimeNanos(); + fn test_field_mOpsPerNano() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mOpsPerNano) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mOpsPerNano) + ) + ); + } + test_field_mOpsPerNano(); } extern "C" { #[link_name = "\u{1}_ZN4oboe18StabilizedCallbackC1EPNS_19AudioStreamCallbackE"] @@ -1287,6 +1545,8 @@ extern "C" { numFrames: i32, ) -> oboe_DataCallbackResult; } +pub type oboe_DropContextHandler = + ::std::option::Option; pub type oboe_AudioReadyHandler = ::std::option::Option< unsafe extern "C" fn( context: *mut ::std::os::raw::c_void, @@ -1305,8 +1565,10 @@ pub type oboe_ErrorCloseHandler = ::std::option::Option< #[repr(C)] #[derive(Debug)] pub struct oboe_AudioStreamCallbackWrapper { - pub _base: oboe_AudioStreamCallback, + pub _base: oboe_AudioStreamDataCallback, + pub _base_1: oboe_AudioStreamErrorCallback, pub _context: *mut ::std::os::raw::c_void, + pub _drop_context: oboe_DropContextHandler, pub _audio_ready: oboe_AudioReadyHandler, pub _before_close: oboe_ErrorCloseHandler, pub _after_close: oboe_ErrorCloseHandler, @@ -1315,7 +1577,7 @@ pub struct oboe_AudioStreamCallbackWrapper { fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { assert_eq!( ::std::mem::size_of::(), - 48usize, + 56usize, concat!("Size of: ", stringify!(oboe_AudioStreamCallbackWrapper)) ); assert_eq!( @@ -1323,82 +1585,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 8usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._context as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._audio_ready as *const _ - as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._before_close as *const _ - as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._after_close as *const _ - as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] - pub fn oboe_AudioStreamCallbackWrapper_setContext( - this: *mut oboe_AudioStreamCallbackWrapper, - context: *mut ::std::os::raw::c_void, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPFNS_18DataCallbackResultEPvPNS_11AudioStreamES2_iEPFvS2_S4_NS_6ResultEES9_"] + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPvPFvS1_EPFNS_18DataCallbackResultES1_PNS_11AudioStreamES1_iEPFvS1_S6_NS_6ResultEESB_"] pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( this: *mut oboe_AudioStreamCallbackWrapper, + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, ); } impl oboe_AudioStreamCallbackWrapper { - #[inline] - pub unsafe fn setContext(&mut self, context: *mut ::std::os::raw::c_void) { - oboe_AudioStreamCallbackWrapper_setContext(self, context) - } #[inline] pub unsafe fn new( + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, @@ -1406,6 +1609,8 @@ impl oboe_AudioStreamCallbackWrapper { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( __bindgen_tmp.as_mut_ptr(), + context, + drop_context, audio_ready, before_close, after_close, @@ -1413,6 +1618,12 @@ impl oboe_AudioStreamCallbackWrapper { __bindgen_tmp.assume_init() } } +extern "C" { + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperD1Ev"] + pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper_destructor( + this: *mut oboe_AudioStreamCallbackWrapper, + ); +} extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper12onAudioReadyEPNS_11AudioStreamEPvi"] pub fn oboe_AudioStreamCallbackWrapper_onAudioReady( @@ -1438,18 +1649,6 @@ extern "C" { error: oboe_Result, ); } -extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamCallbackWrapper_newEPFNS_18DataCallbackResultEPvPNS_11AudioStreamES1_iEPFvS1_S3_NS_6ResultEES8_"] - pub fn oboe_AudioStreamCallbackWrapper_new( - audio_ready: oboe_AudioReadyHandler, - before_close: oboe_ErrorCloseHandler, - after_close: oboe_ErrorCloseHandler, - ) -> *mut oboe_AudioStreamCallbackWrapper; -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPNS_26AudioStreamCallbackWrapperE"] - pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut oboe_AudioStreamCallbackWrapper); -} extern "C" { #[link_name = "\u{1}_ZN4oboe22AudioStreamBuilder_newEv"] pub fn oboe_AudioStreamBuilder_new() -> *mut oboe_AudioStreamBuilder; @@ -1459,10 +1658,14 @@ extern "C" { pub fn oboe_AudioStreamBuilder_delete(builder: *mut oboe_AudioStreamBuilder); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPNS_26AudioStreamCallbackWrapperE"] + #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPvPFvS2_EPFNS_18DataCallbackResultES2_PNS_11AudioStreamES2_iEPFvS2_S7_NS_6ResultEESC_"] pub fn oboe_AudioStreamBuilder_setCallback( builder: *mut oboe_AudioStreamBuilder, - callback: *mut oboe_AudioStreamCallbackWrapper, + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, + audio_ready: oboe_AudioReadyHandler, + before_close: oboe_ErrorCloseHandler, + after_close: oboe_ErrorCloseHandler, ); } extern "C" { @@ -1484,14 +1687,30 @@ extern "C" { builder: *mut oboe_AudioStreamBuilder, ) -> *mut oboe_AudioStreamBase; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe35AudioStreamBuilder_openStreamSharedEPNS_18AudioStreamBuilderEPPNS_11AudioStreamEPPv"] + pub fn oboe_AudioStreamBuilder_openStreamShared( + builder: *mut oboe_AudioStreamBuilder, + stream: *mut *mut oboe_AudioStream, + shared_ptr: *mut *mut ::std::os::raw::c_void, + ) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStream_deleteEPNS_11AudioStreamE"] pub fn oboe_AudioStream_delete(oboeStream: *mut oboe_AudioStream); } +extern "C" { + #[link_name = "\u{1}_ZN4oboe24AudioStream_deleteSharedEPv"] + pub fn oboe_AudioStream_deleteShared(shared_ptr: *mut ::std::os::raw::c_void); +} extern "C" { #[link_name = "\u{1}_ZN4oboe16AudioStream_openEPNS_11AudioStreamE"] pub fn oboe_AudioStream_open(oboeStream: *mut oboe_AudioStream) -> oboe_Result; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe17AudioStream_closeEPNS_11AudioStreamE"] + pub fn oboe_AudioStream_close1(oboeStream: *mut oboe_AudioStream) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe24AudioStream_requestStartEPNS_11AudioStreamE"] pub fn oboe_AudioStream_requestStart(oboeStream: *mut oboe_AudioStream) -> oboe_Result; diff --git a/sys/src/bindings_armv7.rs b/sys/src/bindings_armv7.rs index 142c265..6fa5763 100644 --- a/sys/src/bindings_armv7.rs +++ b/sys/src/bindings_armv7.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.59.2 */ +/* automatically generated by rust-bindgen 0.60.1 */ pub type std_string = [u32; 3usize]; pub type __uint8_t = ::std::os::raw::c_uchar; @@ -120,8 +120,11 @@ pub type oboe_PerformanceMode = i32; #[doc = " Try to use AAudio. If not available then use OpenSL ES."] pub const oboe_AudioApi_Unspecified: oboe_AudioApi = 0; #[doc = " Use OpenSL ES."] +#[doc = " Note that OpenSL ES is deprecated in Android 13, API 30 and above."] pub const oboe_AudioApi_OpenSLES: oboe_AudioApi = 1; #[doc = " Try to use AAudio. Fail if unavailable."] +#[doc = " AAudio was first supported in Android 8, API 26 and above."] +#[doc = " It is only recommended for API 27 and above."] pub const oboe_AudioApi_AAudio: oboe_AudioApi = 2; #[doc = " The underlying audio API used by the audio stream."] pub type oboe_AudioApi = i32; @@ -130,14 +133,11 @@ pub const oboe_SampleRateConversionQuality_None: oboe_SampleRateConversionQualit #[doc = " Fastest conversion but may not sound great."] #[doc = " This may be implemented using bilinear interpolation."] pub const oboe_SampleRateConversionQuality_Fastest: oboe_SampleRateConversionQuality = 1; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Low quality conversion with 8 taps."] pub const oboe_SampleRateConversionQuality_Low: oboe_SampleRateConversionQuality = 2; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Medium quality conversion with 16 taps."] pub const oboe_SampleRateConversionQuality_Medium: oboe_SampleRateConversionQuality = 3; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " High quality conversion with 32 taps."] pub const oboe_SampleRateConversionQuality_High: oboe_SampleRateConversionQuality = 4; #[doc = " Highest quality conversion, which may be expensive in terms of CPU."] pub const oboe_SampleRateConversionQuality_Best: oboe_SampleRateConversionQuality = 5; @@ -251,6 +251,66 @@ pub const oboe_ChannelCount_Stereo: oboe_ChannelCount = 2; #[doc = " rather than `builder.setChannelCount(2)`"] #[doc = ""] pub type oboe_ChannelCount = i32; +pub const oboe_ChannelMask_Unspecified: oboe_ChannelMask = 0; +pub const oboe_ChannelMask_FrontLeft: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_FrontRight: oboe_ChannelMask = 2; +pub const oboe_ChannelMask_FrontCenter: oboe_ChannelMask = 4; +pub const oboe_ChannelMask_LowFrequency: oboe_ChannelMask = 8; +pub const oboe_ChannelMask_BackLeft: oboe_ChannelMask = 16; +pub const oboe_ChannelMask_BackRight: oboe_ChannelMask = 32; +pub const oboe_ChannelMask_FrontLeftOfCenter: oboe_ChannelMask = 64; +pub const oboe_ChannelMask_FrontRightOfCenter: oboe_ChannelMask = 128; +pub const oboe_ChannelMask_BackCenter: oboe_ChannelMask = 256; +pub const oboe_ChannelMask_SideLeft: oboe_ChannelMask = 512; +pub const oboe_ChannelMask_SideRight: oboe_ChannelMask = 1024; +pub const oboe_ChannelMask_TopCenter: oboe_ChannelMask = 2048; +pub const oboe_ChannelMask_TopFrontLeft: oboe_ChannelMask = 4096; +pub const oboe_ChannelMask_TopFrontCenter: oboe_ChannelMask = 8192; +pub const oboe_ChannelMask_TopFrontRight: oboe_ChannelMask = 16384; +pub const oboe_ChannelMask_TopBackLeft: oboe_ChannelMask = 32768; +pub const oboe_ChannelMask_TopBackCenter: oboe_ChannelMask = 65536; +pub const oboe_ChannelMask_TopBackRight: oboe_ChannelMask = 131072; +pub const oboe_ChannelMask_TopSideLeft: oboe_ChannelMask = 262144; +pub const oboe_ChannelMask_TopSideRight: oboe_ChannelMask = 524288; +pub const oboe_ChannelMask_BottomFrontLeft: oboe_ChannelMask = 1048576; +pub const oboe_ChannelMask_BottomFrontCenter: oboe_ChannelMask = 2097152; +pub const oboe_ChannelMask_BottomFrontRight: oboe_ChannelMask = 4194304; +pub const oboe_ChannelMask_LowFrequency2: oboe_ChannelMask = 8388608; +pub const oboe_ChannelMask_FrontWideLeft: oboe_ChannelMask = 16777216; +pub const oboe_ChannelMask_FrontWideRight: oboe_ChannelMask = 33554432; +pub const oboe_ChannelMask_Mono: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_Stereo: oboe_ChannelMask = 3; +pub const oboe_ChannelMask_CM2Point1: oboe_ChannelMask = 11; +pub const oboe_ChannelMask_Tri: oboe_ChannelMask = 7; +pub const oboe_ChannelMask_TriBack: oboe_ChannelMask = 259; +pub const oboe_ChannelMask_CM3Point1: oboe_ChannelMask = 15; +pub const oboe_ChannelMask_CM2Point0Point2: oboe_ChannelMask = 786435; +pub const oboe_ChannelMask_CM2Point1Point2: oboe_ChannelMask = 786443; +pub const oboe_ChannelMask_CM3Point0Point2: oboe_ChannelMask = 786439; +pub const oboe_ChannelMask_CM3Point1Point2: oboe_ChannelMask = 786447; +pub const oboe_ChannelMask_Quad: oboe_ChannelMask = 51; +pub const oboe_ChannelMask_QuadSide: oboe_ChannelMask = 1539; +pub const oboe_ChannelMask_Surround: oboe_ChannelMask = 263; +pub const oboe_ChannelMask_Penta: oboe_ChannelMask = 55; +pub const oboe_ChannelMask_CM5Point1: oboe_ChannelMask = 63; +pub const oboe_ChannelMask_CM5Point1Side: oboe_ChannelMask = 1551; +pub const oboe_ChannelMask_CM6Point1: oboe_ChannelMask = 319; +pub const oboe_ChannelMask_CM7Point1: oboe_ChannelMask = 1599; +pub const oboe_ChannelMask_CM5Point1Point2: oboe_ChannelMask = 786495; +pub const oboe_ChannelMask_CM5Point1Point4: oboe_ChannelMask = 184383; +pub const oboe_ChannelMask_CM7Point1Point2: oboe_ChannelMask = 788031; +pub const oboe_ChannelMask_CM7Point1Point4: oboe_ChannelMask = 185919; +pub const oboe_ChannelMask_CM9Point1Point4: oboe_ChannelMask = 50517567; +pub const oboe_ChannelMask_CM9Point1Point6: oboe_ChannelMask = 51303999; +pub const oboe_ChannelMask_FrontBack: oboe_ChannelMask = 260; +#[doc = " The channel mask of the audio stream. The underlying type is `uint32_t`."] +#[doc = " Use of this enum is convenient."] +#[doc = ""] +#[doc = " ChannelMask::Unspecified means this is not specified."] +#[doc = " The rest of the enums are channel position masks."] +#[doc = " Use the combinations of the channel position masks defined below instead of"] +#[doc = " using those values directly."] +pub type oboe_ChannelMask = u32; #[doc = " On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and"] #[doc = " framesPerBurst are not known by the native code."] #[doc = " On API 17+ these values should be obtained from the AudioManager using this code:"] @@ -319,26 +379,40 @@ fn bindgen_test_layout_oboe_FrameTimestamp() { 8usize, concat!("Alignment of ", stringify!(oboe_FrameTimestamp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).position as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(position) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timestamp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(timestamp) - ) - ); + fn test_field_position() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).position) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(position) + ) + ); + } + test_field_position(); + fn test_field_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(timestamp) + ) + ); + } + test_field_timestamp(); } #[doc = " A ResultWithValue can store both the result of an operation (either OK or an error) and a value."] #[doc = ""] @@ -396,6 +470,10 @@ pub struct oboe_AudioStreamErrorCallback__bindgen_vtable(::std::os::raw::c_void) #[doc = " being alerted when a stream has an error or is disconnected"] #[doc = " using `onError*` methods."] #[doc = ""] +#[doc = " Note: This callback is only fired when an AudioStreamCallback is set."] +#[doc = " If you use AudioStream::write() you have to evaluate the return codes of"] +#[doc = " AudioStream::write() to notice errors in the stream."] +#[doc = ""] #[doc = " It is used with AudioStreamBuilder::setErrorCallback()."] #[repr(C)] #[derive(Debug)] @@ -450,13 +528,14 @@ fn bindgen_test_layout_oboe_AudioStreamCallback() { pub struct oboe_AudioStreamBase__bindgen_vtable(::std::os::raw::c_void); #[doc = " Base class containing parameters for audio streams and builders."] #[repr(C)] -#[derive(Debug)] pub struct oboe_AudioStreamBase { pub vtable_: *const oboe_AudioStreamBase__bindgen_vtable, #[doc = " The callback which will be fired when new data is ready to be read/written."] pub mDataCallback: *mut oboe_AudioStreamDataCallback, + pub mSharedDataCallback: [u32; 2usize], #[doc = " The callback which will be fired when an error or a disconnect occurs."] pub mErrorCallback: *mut oboe_AudioStreamErrorCallback, + pub mSharedErrorCallback: [u32; 2usize], #[doc = " Number of audio frames which will be requested in each callback"] pub mFramesPerCallback: i32, #[doc = " Stream channel count"] @@ -469,6 +548,8 @@ pub struct oboe_AudioStreamBase { pub mBufferCapacityInFrames: i32, #[doc = " Stream buffer size specified as a number of audio frames"] pub mBufferSizeInFrames: i32, + #[doc = " Stream channel mask. Only active on Android 32+"] + pub mChannelMask: oboe_ChannelMask, #[doc = " Stream sharing mode"] pub mSharingMode: oboe_SharingMode, #[doc = " Format of audio frames"] @@ -498,7 +579,7 @@ pub struct oboe_AudioStreamBase { fn bindgen_test_layout_oboe_AudioStreamBase() { assert_eq!( ::std::mem::size_of::(), - 100usize, + 120usize, concat!("Size of: ", stringify!(oboe_AudioStreamBase)) ); assert_eq!( @@ -506,266 +587,437 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { 4usize, concat!("Alignment of ", stringify!(oboe_AudioStreamBase)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mDataCallback as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDataCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mErrorCallback as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mErrorCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFramesPerCallback as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFramesPerCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelCount as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRate as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDeviceId as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDeviceId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferCapacityInFrames as *const _ - as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferCapacityInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferSizeInFrames as *const _ - as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferSizeInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSharingMode as *const _ as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSharingMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mFormat as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormat) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDirection as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDirection) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPerformanceMode as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPerformanceMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mUsage as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mUsage) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mContentType as *const _ as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mContentType) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mInputPreset as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mInputPreset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mSessionId as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSessionId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPackageName as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPackageName) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mAttributionTag as *const _ as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mAttributionTag) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelConversionAllowed as *const _ - as usize - }, - 92usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFormatConversionAllowed as *const _ - as usize - }, - 93usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormatConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRateConversionQuality - as *const _ as usize - }, - 96usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRateConversionQuality) - ) - ); + fn test_field_mDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDataCallback) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDataCallback) + ) + ); + } + test_field_mDataCallback(); + fn test_field_mSharedDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedDataCallback) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedDataCallback) + ) + ); + } + test_field_mSharedDataCallback(); + fn test_field_mErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mErrorCallback) + ) + ); + } + test_field_mErrorCallback(); + fn test_field_mSharedErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedErrorCallback) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedErrorCallback) + ) + ); + } + test_field_mSharedErrorCallback(); + fn test_field_mFramesPerCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFramesPerCallback) + ) + ); + } + test_field_mFramesPerCallback(); + fn test_field_mChannelCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelCount) + ) + ); + } + test_field_mChannelCount(); + fn test_field_mSampleRate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRate) + ) + ); + } + test_field_mSampleRate(); + fn test_field_mDeviceId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDeviceId) + ) + ); + } + test_field_mDeviceId(); + fn test_field_mBufferCapacityInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferCapacityInFrames) + ) + ); + } + test_field_mBufferCapacityInFrames(); + fn test_field_mBufferSizeInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + fn test_field_mChannelMask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelMask) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelMask) + ) + ); + } + test_field_mChannelMask(); + fn test_field_mSharingMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharingMode) + ) + ); + } + test_field_mSharingMode(); + fn test_field_mFormat() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormat) + ) + ); + } + test_field_mFormat(); + fn test_field_mDirection() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDirection) + ) + ); + } + test_field_mDirection(); + fn test_field_mPerformanceMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPerformanceMode) + ) + ); + } + test_field_mPerformanceMode(); + fn test_field_mUsage() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mUsage) + ) + ); + } + test_field_mUsage(); + fn test_field_mContentType() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mContentType) + ) + ); + } + test_field_mContentType(); + fn test_field_mInputPreset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mInputPreset) + ) + ); + } + test_field_mInputPreset(); + fn test_field_mSessionId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSessionId) + ) + ); + } + test_field_mSessionId(); + fn test_field_mPackageName() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPackageName) + ) + ); + } + test_field_mPackageName(); + fn test_field_mAttributionTag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mAttributionTag) + ) + ); + } + test_field_mAttributionTag(); + fn test_field_mChannelConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelConversionAllowed) + ) + ); + } + test_field_mChannelConversionAllowed(); + fn test_field_mFormatConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize + }, + 113usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormatConversionAllowed) + ) + ); + } + test_field_mFormatConversionAllowed(); + fn test_field_mSampleRateConversionQuality() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize + }, + 116usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); +} +extern "C" { + #[doc = " Return the version of the SDK that is currently running."] + #[doc = ""] + #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] + #[doc = " If the version number cannot be determined then this will return -1."] + #[doc = ""] + #[doc = " @return version number or -1"] + #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] + pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; } #[doc = " Factory class for an audio Stream."] #[repr(C)] #[repr(align(4))] #[derive(Debug, Copy, Clone)] pub struct oboe_AudioStreamBuilder { - pub _bindgen_opaque_blob: [u32; 26usize], + pub _bindgen_opaque_blob: [u32; 31usize], } #[test] fn bindgen_test_layout_oboe_AudioStreamBuilder() { assert_eq!( ::std::mem::size_of::(), - 104usize, + 124usize, concat!("Size of: ", stringify!(oboe_AudioStreamBuilder)) ); assert_eq!( @@ -793,21 +1045,6 @@ extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder19isAAudioRecommendedEv"] pub fn oboe_AudioStreamBuilder_isAAudioRecommended() -> bool; } -extern "C" { - #[doc = " Create and open a stream object based on the current settings."] - #[doc = ""] - #[doc = " The caller owns the pointer to the AudioStream object"] - #[doc = " and must delete it when finished."] - #[doc = ""] - #[doc = " @deprecated Use openStream(std::shared_ptr &stream) instead."] - #[doc = " @param stream pointer to a variable to receive the stream address"] - #[doc = " @return OBOE_OK if successful or a negative error code"] - #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder10openStreamEPPNS_11AudioStreamE"] - pub fn oboe_AudioStreamBuilder_openStream( - this: *mut oboe_AudioStreamBuilder, - stream: *mut *mut oboe_AudioStream, - ) -> oboe_Result; -} impl oboe_AudioStreamBuilder { #[inline] pub unsafe fn isAAudioSupported() -> bool { @@ -817,23 +1054,19 @@ impl oboe_AudioStreamBuilder { pub unsafe fn isAAudioRecommended() -> bool { oboe_AudioStreamBuilder_isAAudioRecommended() } - #[inline] - pub unsafe fn openStream(&mut self, stream: *mut *mut oboe_AudioStream) -> oboe_Result { - oboe_AudioStreamBuilder_openStream(self, stream) - } } #[doc = " Base class for Oboe C++ audio stream."] #[repr(C)] #[repr(align(8))] #[derive(Debug, Copy, Clone)] pub struct oboe_AudioStream { - pub _bindgen_opaque_blob: [u64; 19usize], + pub _bindgen_opaque_blob: [u64; 21usize], } #[test] fn bindgen_test_layout_oboe_AudioStream() { assert_eq!( ::std::mem::size_of::(), - 152usize, + 168usize, concat!("Size of: ", stringify!(oboe_AudioStream)) ); assert_eq!( @@ -886,6 +1119,12 @@ extern "C" { numFrames: ::std::os::raw::c_int, ) -> oboe_DataCallbackResult; } +extern "C" { + #[doc = " This should only be called as a stream is being opened."] + #[doc = " Otherwise we might override setDelayBeforeCloseMillis()."] + #[link_name = "\u{1}_ZN4oboe11AudioStream38calculateDefaultDelayBeforeCloseMillisEv"] + pub fn oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(this: *mut oboe_AudioStream); +} extern "C" { #[doc = " Construct an `AudioStream` using the given `AudioStreamBuilder`"] #[doc = ""] @@ -922,6 +1161,10 @@ impl oboe_AudioStream { oboe_AudioStream_fireDataCallback(self, audioData, numFrames) } #[inline] + pub unsafe fn calculateDefaultDelayBeforeCloseMillis(&mut self) { + oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(self) + } + #[inline] pub unsafe fn new(builder: *const oboe_AudioStreamBuilder) -> Self { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStream_AudioStream(__bindgen_tmp.as_mut_ptr(), builder); @@ -996,6 +1239,11 @@ extern "C" { #[doc = " The time is based on the implementation's best effort, using whatever knowledge is available"] #[doc = " to the system, but cannot account for any delay unknown to the implementation."] #[doc = ""] + #[doc = " Note that due to issues in Android before R, we recommend NOT calling"] + #[doc = " this method from a data callback. See this tech note for more details."] + #[doc = " https://github.com/google/oboe/blob/main/docs/notes/rlsbuffer.md"] + #[doc = ""] + #[doc = " See"] #[doc = " @param clockId the type of clock to use e.g. CLOCK_MONOTONIC"] #[doc = " @return a FrameTimestamp containing the position and time at which a particular audio frame"] #[doc = " entered or left the audio processing pipeline, or an error if the operation failed."] @@ -1018,6 +1266,7 @@ extern "C" { timeoutNanoseconds: i64, ) -> oboe_Result; } +pub const oboe_AudioStream_kMinDelayBeforeCloseMillis: ::std::os::raw::c_int = 10; #[doc = " This struct is a stateless functor which closes an AudioStream prior to its deletion."] #[doc = " This means it can be used to safely delete a smart pointer referring to an open stream."] #[repr(C)] @@ -1151,16 +1400,6 @@ impl oboe_LatencyTuner { } pub const oboe_LatencyTuner_kIdleCount: i32 = 8; pub const oboe_LatencyTuner_kDefaultNumBursts: i32 = 2; -extern "C" { - #[doc = " Return the version of the SDK that is currently running."] - #[doc = ""] - #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] - #[doc = " If the version number cannot be determined then this will return -1."] - #[doc = ""] - #[doc = " @return version number or -1"] - #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] - pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; -} #[doc = " Oboe versioning object"] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1171,15 +1410,15 @@ pub struct oboe_Version { pub const oboe_Version_Major: u8 = 1; #[doc = " This is incremented when we add backwards compatible functionality. Or set to zero when MAJOR is"] #[doc = " incremented."] -pub const oboe_Version_Minor: u8 = 6; +pub const oboe_Version_Minor: u8 = 7; #[doc = " This is incremented when we make backwards compatible bug fixes. Or set to zero when MINOR is"] #[doc = " incremented."] -pub const oboe_Version_Patch: u16 = 1; +pub const oboe_Version_Patch: u16 = 0; #[doc = " Version string in the form MAJOR.MINOR.PATCH."] -pub const oboe_Version_Text: &[u8; 6usize] = b"1.6.1\0"; +pub const oboe_Version_Text: &[u8; 6usize] = b"1.7.0\0"; #[doc = " Integer representation of the current Oboe library version. This will always increase when the"] #[doc = " version number changes so can be compared using integer comparison."] -pub const oboe_Version_Number: u32 = 17170433; +pub const oboe_Version_Number: u32 = 17235968; #[test] fn bindgen_test_layout_oboe_Version() { assert_eq!( @@ -1214,54 +1453,74 @@ fn bindgen_test_layout_oboe_StabilizedCallback() { 8usize, concat!("Alignment of ", stringify!(oboe_StabilizedCallback)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mCallback as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFrameCount as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mFrameCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mEpochTimeNanos as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mEpochTimeNanos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mOpsPerNano as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mOpsPerNano) - ) - ); + fn test_field_mCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mCallback) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mCallback) + ) + ); + } + test_field_mCallback(); + fn test_field_mFrameCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFrameCount) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mFrameCount) + ) + ); + } + test_field_mFrameCount(); + fn test_field_mEpochTimeNanos() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mEpochTimeNanos) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mEpochTimeNanos) + ) + ); + } + test_field_mEpochTimeNanos(); + fn test_field_mOpsPerNano() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mOpsPerNano) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mOpsPerNano) + ) + ); + } + test_field_mOpsPerNano(); } extern "C" { #[link_name = "\u{1}_ZN4oboe18StabilizedCallbackC1EPNS_19AudioStreamCallbackE"] @@ -1287,6 +1546,8 @@ extern "C" { numFrames: i32, ) -> oboe_DataCallbackResult; } +pub type oboe_DropContextHandler = + ::std::option::Option; pub type oboe_AudioReadyHandler = ::std::option::Option< unsafe extern "C" fn( context: *mut ::std::os::raw::c_void, @@ -1305,8 +1566,10 @@ pub type oboe_ErrorCloseHandler = ::std::option::Option< #[repr(C)] #[derive(Debug)] pub struct oboe_AudioStreamCallbackWrapper { - pub _base: oboe_AudioStreamCallback, + pub _base: oboe_AudioStreamDataCallback, + pub _base_1: oboe_AudioStreamErrorCallback, pub _context: *mut ::std::os::raw::c_void, + pub _drop_context: oboe_DropContextHandler, pub _audio_ready: oboe_AudioReadyHandler, pub _before_close: oboe_ErrorCloseHandler, pub _after_close: oboe_ErrorCloseHandler, @@ -1315,7 +1578,7 @@ pub struct oboe_AudioStreamCallbackWrapper { fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { assert_eq!( ::std::mem::size_of::(), - 24usize, + 28usize, concat!("Size of: ", stringify!(oboe_AudioStreamCallbackWrapper)) ); assert_eq!( @@ -1323,82 +1586,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 4usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._context as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._audio_ready as *const _ - as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._before_close as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._after_close as *const _ - as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] - pub fn oboe_AudioStreamCallbackWrapper_setContext( - this: *mut oboe_AudioStreamCallbackWrapper, - context: *mut ::std::os::raw::c_void, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPFNS_18DataCallbackResultEPvPNS_11AudioStreamES2_iEPFvS2_S4_NS_6ResultEES9_"] + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPvPFvS1_EPFNS_18DataCallbackResultES1_PNS_11AudioStreamES1_iEPFvS1_S6_NS_6ResultEESB_"] pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( this: *mut oboe_AudioStreamCallbackWrapper, + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, ); } impl oboe_AudioStreamCallbackWrapper { - #[inline] - pub unsafe fn setContext(&mut self, context: *mut ::std::os::raw::c_void) { - oboe_AudioStreamCallbackWrapper_setContext(self, context) - } #[inline] pub unsafe fn new( + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, @@ -1406,6 +1610,8 @@ impl oboe_AudioStreamCallbackWrapper { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( __bindgen_tmp.as_mut_ptr(), + context, + drop_context, audio_ready, before_close, after_close, @@ -1413,6 +1619,12 @@ impl oboe_AudioStreamCallbackWrapper { __bindgen_tmp.assume_init() } } +extern "C" { + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperD1Ev"] + pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper_destructor( + this: *mut oboe_AudioStreamCallbackWrapper, + ); +} extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper12onAudioReadyEPNS_11AudioStreamEPvi"] pub fn oboe_AudioStreamCallbackWrapper_onAudioReady( @@ -1439,16 +1651,8 @@ extern "C" { ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamCallbackWrapper_newEPFNS_18DataCallbackResultEPvPNS_11AudioStreamES1_iEPFvS1_S3_NS_6ResultEES8_"] - pub fn oboe_AudioStreamCallbackWrapper_new( - audio_ready: oboe_AudioReadyHandler, - before_close: oboe_ErrorCloseHandler, - after_close: oboe_ErrorCloseHandler, - ) -> *mut oboe_AudioStreamCallbackWrapper; -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPNS_26AudioStreamCallbackWrapperE"] - pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut oboe_AudioStreamCallbackWrapper); + #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPv"] + pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut ::std::os::raw::c_void); } extern "C" { #[link_name = "\u{1}_ZN4oboe22AudioStreamBuilder_newEv"] @@ -1459,11 +1663,15 @@ extern "C" { pub fn oboe_AudioStreamBuilder_delete(builder: *mut oboe_AudioStreamBuilder); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPNS_26AudioStreamCallbackWrapperE"] + #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPvPFvS2_EPFNS_18DataCallbackResultES2_PNS_11AudioStreamES2_iEPFvS2_S7_NS_6ResultEESC_"] pub fn oboe_AudioStreamBuilder_setCallback( builder: *mut oboe_AudioStreamBuilder, - callback: *mut oboe_AudioStreamCallbackWrapper, - ); + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, + audio_ready: oboe_AudioReadyHandler, + before_close: oboe_ErrorCloseHandler, + after_close: oboe_ErrorCloseHandler, + ) -> *mut ::std::os::raw::c_void; } extern "C" { #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_getAudioApiEPKNS_18AudioStreamBuilderE"] @@ -1484,14 +1692,30 @@ extern "C" { builder: *mut oboe_AudioStreamBuilder, ) -> *mut oboe_AudioStreamBase; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe35AudioStreamBuilder_openStreamSharedEPNS_18AudioStreamBuilderEPPNS_11AudioStreamEPPv"] + pub fn oboe_AudioStreamBuilder_openStreamShared( + builder: *mut oboe_AudioStreamBuilder, + stream: *mut *mut oboe_AudioStream, + shared_ptr: *mut *mut ::std::os::raw::c_void, + ) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStream_deleteEPNS_11AudioStreamE"] pub fn oboe_AudioStream_delete(oboeStream: *mut oboe_AudioStream); } +extern "C" { + #[link_name = "\u{1}_ZN4oboe24AudioStream_deleteSharedEPv"] + pub fn oboe_AudioStream_deleteShared(shared_ptr: *mut ::std::os::raw::c_void); +} extern "C" { #[link_name = "\u{1}_ZN4oboe16AudioStream_openEPNS_11AudioStreamE"] pub fn oboe_AudioStream_open(oboeStream: *mut oboe_AudioStream) -> oboe_Result; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe17AudioStream_closeEPNS_11AudioStreamE"] + pub fn oboe_AudioStream_close1(oboeStream: *mut oboe_AudioStream) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe24AudioStream_requestStartEPNS_11AudioStreamE"] pub fn oboe_AudioStream_requestStart(oboeStream: *mut oboe_AudioStream) -> oboe_Result; diff --git a/sys/src/bindings_i686.rs b/sys/src/bindings_i686.rs index 5238181..b00cd80 100644 --- a/sys/src/bindings_i686.rs +++ b/sys/src/bindings_i686.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.59.2 */ +/* automatically generated by rust-bindgen 0.60.1 */ pub type std_string = [u32; 3usize]; pub type __uint8_t = ::std::os::raw::c_uchar; @@ -120,8 +120,11 @@ pub type oboe_PerformanceMode = i32; #[doc = " Try to use AAudio. If not available then use OpenSL ES."] pub const oboe_AudioApi_Unspecified: oboe_AudioApi = 0; #[doc = " Use OpenSL ES."] +#[doc = " Note that OpenSL ES is deprecated in Android 13, API 30 and above."] pub const oboe_AudioApi_OpenSLES: oboe_AudioApi = 1; #[doc = " Try to use AAudio. Fail if unavailable."] +#[doc = " AAudio was first supported in Android 8, API 26 and above."] +#[doc = " It is only recommended for API 27 and above."] pub const oboe_AudioApi_AAudio: oboe_AudioApi = 2; #[doc = " The underlying audio API used by the audio stream."] pub type oboe_AudioApi = i32; @@ -130,14 +133,11 @@ pub const oboe_SampleRateConversionQuality_None: oboe_SampleRateConversionQualit #[doc = " Fastest conversion but may not sound great."] #[doc = " This may be implemented using bilinear interpolation."] pub const oboe_SampleRateConversionQuality_Fastest: oboe_SampleRateConversionQuality = 1; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Low quality conversion with 8 taps."] pub const oboe_SampleRateConversionQuality_Low: oboe_SampleRateConversionQuality = 2; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Medium quality conversion with 16 taps."] pub const oboe_SampleRateConversionQuality_Medium: oboe_SampleRateConversionQuality = 3; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " High quality conversion with 32 taps."] pub const oboe_SampleRateConversionQuality_High: oboe_SampleRateConversionQuality = 4; #[doc = " Highest quality conversion, which may be expensive in terms of CPU."] pub const oboe_SampleRateConversionQuality_Best: oboe_SampleRateConversionQuality = 5; @@ -251,6 +251,66 @@ pub const oboe_ChannelCount_Stereo: oboe_ChannelCount = 2; #[doc = " rather than `builder.setChannelCount(2)`"] #[doc = ""] pub type oboe_ChannelCount = i32; +pub const oboe_ChannelMask_Unspecified: oboe_ChannelMask = 0; +pub const oboe_ChannelMask_FrontLeft: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_FrontRight: oboe_ChannelMask = 2; +pub const oboe_ChannelMask_FrontCenter: oboe_ChannelMask = 4; +pub const oboe_ChannelMask_LowFrequency: oboe_ChannelMask = 8; +pub const oboe_ChannelMask_BackLeft: oboe_ChannelMask = 16; +pub const oboe_ChannelMask_BackRight: oboe_ChannelMask = 32; +pub const oboe_ChannelMask_FrontLeftOfCenter: oboe_ChannelMask = 64; +pub const oboe_ChannelMask_FrontRightOfCenter: oboe_ChannelMask = 128; +pub const oboe_ChannelMask_BackCenter: oboe_ChannelMask = 256; +pub const oboe_ChannelMask_SideLeft: oboe_ChannelMask = 512; +pub const oboe_ChannelMask_SideRight: oboe_ChannelMask = 1024; +pub const oboe_ChannelMask_TopCenter: oboe_ChannelMask = 2048; +pub const oboe_ChannelMask_TopFrontLeft: oboe_ChannelMask = 4096; +pub const oboe_ChannelMask_TopFrontCenter: oboe_ChannelMask = 8192; +pub const oboe_ChannelMask_TopFrontRight: oboe_ChannelMask = 16384; +pub const oboe_ChannelMask_TopBackLeft: oboe_ChannelMask = 32768; +pub const oboe_ChannelMask_TopBackCenter: oboe_ChannelMask = 65536; +pub const oboe_ChannelMask_TopBackRight: oboe_ChannelMask = 131072; +pub const oboe_ChannelMask_TopSideLeft: oboe_ChannelMask = 262144; +pub const oboe_ChannelMask_TopSideRight: oboe_ChannelMask = 524288; +pub const oboe_ChannelMask_BottomFrontLeft: oboe_ChannelMask = 1048576; +pub const oboe_ChannelMask_BottomFrontCenter: oboe_ChannelMask = 2097152; +pub const oboe_ChannelMask_BottomFrontRight: oboe_ChannelMask = 4194304; +pub const oboe_ChannelMask_LowFrequency2: oboe_ChannelMask = 8388608; +pub const oboe_ChannelMask_FrontWideLeft: oboe_ChannelMask = 16777216; +pub const oboe_ChannelMask_FrontWideRight: oboe_ChannelMask = 33554432; +pub const oboe_ChannelMask_Mono: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_Stereo: oboe_ChannelMask = 3; +pub const oboe_ChannelMask_CM2Point1: oboe_ChannelMask = 11; +pub const oboe_ChannelMask_Tri: oboe_ChannelMask = 7; +pub const oboe_ChannelMask_TriBack: oboe_ChannelMask = 259; +pub const oboe_ChannelMask_CM3Point1: oboe_ChannelMask = 15; +pub const oboe_ChannelMask_CM2Point0Point2: oboe_ChannelMask = 786435; +pub const oboe_ChannelMask_CM2Point1Point2: oboe_ChannelMask = 786443; +pub const oboe_ChannelMask_CM3Point0Point2: oboe_ChannelMask = 786439; +pub const oboe_ChannelMask_CM3Point1Point2: oboe_ChannelMask = 786447; +pub const oboe_ChannelMask_Quad: oboe_ChannelMask = 51; +pub const oboe_ChannelMask_QuadSide: oboe_ChannelMask = 1539; +pub const oboe_ChannelMask_Surround: oboe_ChannelMask = 263; +pub const oboe_ChannelMask_Penta: oboe_ChannelMask = 55; +pub const oboe_ChannelMask_CM5Point1: oboe_ChannelMask = 63; +pub const oboe_ChannelMask_CM5Point1Side: oboe_ChannelMask = 1551; +pub const oboe_ChannelMask_CM6Point1: oboe_ChannelMask = 319; +pub const oboe_ChannelMask_CM7Point1: oboe_ChannelMask = 1599; +pub const oboe_ChannelMask_CM5Point1Point2: oboe_ChannelMask = 786495; +pub const oboe_ChannelMask_CM5Point1Point4: oboe_ChannelMask = 184383; +pub const oboe_ChannelMask_CM7Point1Point2: oboe_ChannelMask = 788031; +pub const oboe_ChannelMask_CM7Point1Point4: oboe_ChannelMask = 185919; +pub const oboe_ChannelMask_CM9Point1Point4: oboe_ChannelMask = 50517567; +pub const oboe_ChannelMask_CM9Point1Point6: oboe_ChannelMask = 51303999; +pub const oboe_ChannelMask_FrontBack: oboe_ChannelMask = 260; +#[doc = " The channel mask of the audio stream. The underlying type is `uint32_t`."] +#[doc = " Use of this enum is convenient."] +#[doc = ""] +#[doc = " ChannelMask::Unspecified means this is not specified."] +#[doc = " The rest of the enums are channel position masks."] +#[doc = " Use the combinations of the channel position masks defined below instead of"] +#[doc = " using those values directly."] +pub type oboe_ChannelMask = u32; #[doc = " On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and"] #[doc = " framesPerBurst are not known by the native code."] #[doc = " On API 17+ these values should be obtained from the AudioManager using this code:"] @@ -319,26 +379,40 @@ fn bindgen_test_layout_oboe_FrameTimestamp() { 4usize, concat!("Alignment of ", stringify!(oboe_FrameTimestamp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).position as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(position) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timestamp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(timestamp) - ) - ); + fn test_field_position() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).position) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(position) + ) + ); + } + test_field_position(); + fn test_field_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(timestamp) + ) + ); + } + test_field_timestamp(); } #[doc = " A ResultWithValue can store both the result of an operation (either OK or an error) and a value."] #[doc = ""] @@ -396,6 +470,10 @@ pub struct oboe_AudioStreamErrorCallback__bindgen_vtable(::std::os::raw::c_void) #[doc = " being alerted when a stream has an error or is disconnected"] #[doc = " using `onError*` methods."] #[doc = ""] +#[doc = " Note: This callback is only fired when an AudioStreamCallback is set."] +#[doc = " If you use AudioStream::write() you have to evaluate the return codes of"] +#[doc = " AudioStream::write() to notice errors in the stream."] +#[doc = ""] #[doc = " It is used with AudioStreamBuilder::setErrorCallback()."] #[repr(C)] #[derive(Debug)] @@ -450,13 +528,14 @@ fn bindgen_test_layout_oboe_AudioStreamCallback() { pub struct oboe_AudioStreamBase__bindgen_vtable(::std::os::raw::c_void); #[doc = " Base class containing parameters for audio streams and builders."] #[repr(C)] -#[derive(Debug)] pub struct oboe_AudioStreamBase { pub vtable_: *const oboe_AudioStreamBase__bindgen_vtable, #[doc = " The callback which will be fired when new data is ready to be read/written."] pub mDataCallback: *mut oboe_AudioStreamDataCallback, + pub mSharedDataCallback: [u32; 2usize], #[doc = " The callback which will be fired when an error or a disconnect occurs."] pub mErrorCallback: *mut oboe_AudioStreamErrorCallback, + pub mSharedErrorCallback: [u32; 2usize], #[doc = " Number of audio frames which will be requested in each callback"] pub mFramesPerCallback: i32, #[doc = " Stream channel count"] @@ -469,6 +548,8 @@ pub struct oboe_AudioStreamBase { pub mBufferCapacityInFrames: i32, #[doc = " Stream buffer size specified as a number of audio frames"] pub mBufferSizeInFrames: i32, + #[doc = " Stream channel mask. Only active on Android 32+"] + pub mChannelMask: oboe_ChannelMask, #[doc = " Stream sharing mode"] pub mSharingMode: oboe_SharingMode, #[doc = " Format of audio frames"] @@ -498,7 +579,7 @@ pub struct oboe_AudioStreamBase { fn bindgen_test_layout_oboe_AudioStreamBase() { assert_eq!( ::std::mem::size_of::(), - 100usize, + 120usize, concat!("Size of: ", stringify!(oboe_AudioStreamBase)) ); assert_eq!( @@ -506,266 +587,437 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { 4usize, concat!("Alignment of ", stringify!(oboe_AudioStreamBase)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mDataCallback as *const _ as usize - }, - 4usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDataCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mErrorCallback as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mErrorCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFramesPerCallback as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFramesPerCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelCount as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRate as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDeviceId as *const _ as usize }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDeviceId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferCapacityInFrames as *const _ - as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferCapacityInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferSizeInFrames as *const _ - as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferSizeInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSharingMode as *const _ as usize - }, - 36usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSharingMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mFormat as *const _ as usize }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormat) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDirection as *const _ as usize }, - 44usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDirection) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPerformanceMode as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPerformanceMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mUsage as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mUsage) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mContentType as *const _ as usize - }, - 56usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mContentType) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mInputPreset as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mInputPreset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mSessionId as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSessionId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPackageName as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPackageName) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mAttributionTag as *const _ as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mAttributionTag) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelConversionAllowed as *const _ - as usize - }, - 92usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFormatConversionAllowed as *const _ - as usize - }, - 93usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormatConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRateConversionQuality - as *const _ as usize - }, - 96usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRateConversionQuality) - ) - ); + fn test_field_mDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDataCallback) as usize - ptr as usize + }, + 4usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDataCallback) + ) + ); + } + test_field_mDataCallback(); + fn test_field_mSharedDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedDataCallback) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedDataCallback) + ) + ); + } + test_field_mSharedDataCallback(); + fn test_field_mErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mErrorCallback) + ) + ); + } + test_field_mErrorCallback(); + fn test_field_mSharedErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedErrorCallback) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedErrorCallback) + ) + ); + } + test_field_mSharedErrorCallback(); + fn test_field_mFramesPerCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFramesPerCallback) + ) + ); + } + test_field_mFramesPerCallback(); + fn test_field_mChannelCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelCount) + ) + ); + } + test_field_mChannelCount(); + fn test_field_mSampleRate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize + }, + 36usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRate) + ) + ); + } + test_field_mSampleRate(); + fn test_field_mDeviceId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDeviceId) + ) + ); + } + test_field_mDeviceId(); + fn test_field_mBufferCapacityInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferCapacityInFrames) + ) + ); + } + test_field_mBufferCapacityInFrames(); + fn test_field_mBufferSizeInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize + }, + 48usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + fn test_field_mChannelMask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelMask) as usize - ptr as usize + }, + 52usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelMask) + ) + ); + } + test_field_mChannelMask(); + fn test_field_mSharingMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharingMode) + ) + ); + } + test_field_mSharingMode(); + fn test_field_mFormat() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormat) + ) + ); + } + test_field_mFormat(); + fn test_field_mDirection() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDirection) + ) + ); + } + test_field_mDirection(); + fn test_field_mPerformanceMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPerformanceMode) + ) + ); + } + test_field_mPerformanceMode(); + fn test_field_mUsage() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mUsage) + ) + ); + } + test_field_mUsage(); + fn test_field_mContentType() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mContentType) + ) + ); + } + test_field_mContentType(); + fn test_field_mInputPreset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mInputPreset) + ) + ); + } + test_field_mInputPreset(); + fn test_field_mSessionId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSessionId) + ) + ); + } + test_field_mSessionId(); + fn test_field_mPackageName() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPackageName) + ) + ); + } + test_field_mPackageName(); + fn test_field_mAttributionTag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mAttributionTag) + ) + ); + } + test_field_mAttributionTag(); + fn test_field_mChannelConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelConversionAllowed) + ) + ); + } + test_field_mChannelConversionAllowed(); + fn test_field_mFormatConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize + }, + 113usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormatConversionAllowed) + ) + ); + } + test_field_mFormatConversionAllowed(); + fn test_field_mSampleRateConversionQuality() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize + }, + 116usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); +} +extern "C" { + #[doc = " Return the version of the SDK that is currently running."] + #[doc = ""] + #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] + #[doc = " If the version number cannot be determined then this will return -1."] + #[doc = ""] + #[doc = " @return version number or -1"] + #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] + pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; } #[doc = " Factory class for an audio Stream."] #[repr(C)] #[repr(align(4))] #[derive(Debug, Copy, Clone)] pub struct oboe_AudioStreamBuilder { - pub _bindgen_opaque_blob: [u32; 26usize], + pub _bindgen_opaque_blob: [u32; 31usize], } #[test] fn bindgen_test_layout_oboe_AudioStreamBuilder() { assert_eq!( ::std::mem::size_of::(), - 104usize, + 124usize, concat!("Size of: ", stringify!(oboe_AudioStreamBuilder)) ); assert_eq!( @@ -793,21 +1045,6 @@ extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder19isAAudioRecommendedEv"] pub fn oboe_AudioStreamBuilder_isAAudioRecommended() -> bool; } -extern "C" { - #[doc = " Create and open a stream object based on the current settings."] - #[doc = ""] - #[doc = " The caller owns the pointer to the AudioStream object"] - #[doc = " and must delete it when finished."] - #[doc = ""] - #[doc = " @deprecated Use openStream(std::shared_ptr &stream) instead."] - #[doc = " @param stream pointer to a variable to receive the stream address"] - #[doc = " @return OBOE_OK if successful or a negative error code"] - #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder10openStreamEPPNS_11AudioStreamE"] - pub fn oboe_AudioStreamBuilder_openStream( - this: *mut oboe_AudioStreamBuilder, - stream: *mut *mut oboe_AudioStream, - ) -> oboe_Result; -} impl oboe_AudioStreamBuilder { #[inline] pub unsafe fn isAAudioSupported() -> bool { @@ -817,23 +1054,19 @@ impl oboe_AudioStreamBuilder { pub unsafe fn isAAudioRecommended() -> bool { oboe_AudioStreamBuilder_isAAudioRecommended() } - #[inline] - pub unsafe fn openStream(&mut self, stream: *mut *mut oboe_AudioStream) -> oboe_Result { - oboe_AudioStreamBuilder_openStream(self, stream) - } } #[doc = " Base class for Oboe C++ audio stream."] #[repr(C)] #[repr(align(8))] #[derive(Debug, Copy, Clone)] pub struct oboe_AudioStream { - pub _bindgen_opaque_blob: [u64; 19usize], + pub _bindgen_opaque_blob: [u64; 21usize], } #[test] fn bindgen_test_layout_oboe_AudioStream() { assert_eq!( ::std::mem::size_of::(), - 152usize, + 168usize, concat!("Size of: ", stringify!(oboe_AudioStream)) ); assert_eq!( @@ -886,6 +1119,12 @@ extern "C" { numFrames: ::std::os::raw::c_int, ) -> oboe_DataCallbackResult; } +extern "C" { + #[doc = " This should only be called as a stream is being opened."] + #[doc = " Otherwise we might override setDelayBeforeCloseMillis()."] + #[link_name = "\u{1}_ZN4oboe11AudioStream38calculateDefaultDelayBeforeCloseMillisEv"] + pub fn oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(this: *mut oboe_AudioStream); +} extern "C" { #[doc = " Construct an `AudioStream` using the given `AudioStreamBuilder`"] #[doc = ""] @@ -922,6 +1161,10 @@ impl oboe_AudioStream { oboe_AudioStream_fireDataCallback(self, audioData, numFrames) } #[inline] + pub unsafe fn calculateDefaultDelayBeforeCloseMillis(&mut self) { + oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(self) + } + #[inline] pub unsafe fn new(builder: *const oboe_AudioStreamBuilder) -> Self { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStream_AudioStream(__bindgen_tmp.as_mut_ptr(), builder); @@ -996,6 +1239,11 @@ extern "C" { #[doc = " The time is based on the implementation's best effort, using whatever knowledge is available"] #[doc = " to the system, but cannot account for any delay unknown to the implementation."] #[doc = ""] + #[doc = " Note that due to issues in Android before R, we recommend NOT calling"] + #[doc = " this method from a data callback. See this tech note for more details."] + #[doc = " https://github.com/google/oboe/blob/main/docs/notes/rlsbuffer.md"] + #[doc = ""] + #[doc = " See"] #[doc = " @param clockId the type of clock to use e.g. CLOCK_MONOTONIC"] #[doc = " @return a FrameTimestamp containing the position and time at which a particular audio frame"] #[doc = " entered or left the audio processing pipeline, or an error if the operation failed."] @@ -1018,6 +1266,7 @@ extern "C" { timeoutNanoseconds: i64, ) -> oboe_Result; } +pub const oboe_AudioStream_kMinDelayBeforeCloseMillis: ::std::os::raw::c_int = 10; #[doc = " This struct is a stateless functor which closes an AudioStream prior to its deletion."] #[doc = " This means it can be used to safely delete a smart pointer referring to an open stream."] #[repr(C)] @@ -1151,16 +1400,6 @@ impl oboe_LatencyTuner { } pub const oboe_LatencyTuner_kIdleCount: i32 = 8; pub const oboe_LatencyTuner_kDefaultNumBursts: i32 = 2; -extern "C" { - #[doc = " Return the version of the SDK that is currently running."] - #[doc = ""] - #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] - #[doc = " If the version number cannot be determined then this will return -1."] - #[doc = ""] - #[doc = " @return version number or -1"] - #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] - pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; -} #[doc = " Oboe versioning object"] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1171,15 +1410,15 @@ pub struct oboe_Version { pub const oboe_Version_Major: u8 = 1; #[doc = " This is incremented when we add backwards compatible functionality. Or set to zero when MAJOR is"] #[doc = " incremented."] -pub const oboe_Version_Minor: u8 = 6; +pub const oboe_Version_Minor: u8 = 7; #[doc = " This is incremented when we make backwards compatible bug fixes. Or set to zero when MINOR is"] #[doc = " incremented."] -pub const oboe_Version_Patch: u16 = 1; +pub const oboe_Version_Patch: u16 = 0; #[doc = " Version string in the form MAJOR.MINOR.PATCH."] -pub const oboe_Version_Text: &[u8; 6usize] = b"1.6.1\0"; +pub const oboe_Version_Text: &[u8; 6usize] = b"1.7.0\0"; #[doc = " Integer representation of the current Oboe library version. This will always increase when the"] #[doc = " version number changes so can be compared using integer comparison."] -pub const oboe_Version_Number: u32 = 17170433; +pub const oboe_Version_Number: u32 = 17235968; #[test] fn bindgen_test_layout_oboe_Version() { assert_eq!( @@ -1214,54 +1453,74 @@ fn bindgen_test_layout_oboe_StabilizedCallback() { 4usize, concat!("Alignment of ", stringify!(oboe_StabilizedCallback)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mCallback as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFrameCount as *const _ as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mFrameCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mEpochTimeNanos as *const _ as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mEpochTimeNanos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mOpsPerNano as *const _ as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mOpsPerNano) - ) - ); + fn test_field_mCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mCallback) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mCallback) + ) + ); + } + test_field_mCallback(); + fn test_field_mFrameCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFrameCount) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mFrameCount) + ) + ); + } + test_field_mFrameCount(); + fn test_field_mEpochTimeNanos() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mEpochTimeNanos) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mEpochTimeNanos) + ) + ); + } + test_field_mEpochTimeNanos(); + fn test_field_mOpsPerNano() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mOpsPerNano) as usize - ptr as usize + }, + 28usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mOpsPerNano) + ) + ); + } + test_field_mOpsPerNano(); } extern "C" { #[link_name = "\u{1}_ZN4oboe18StabilizedCallbackC1EPNS_19AudioStreamCallbackE"] @@ -1287,6 +1546,8 @@ extern "C" { numFrames: i32, ) -> oboe_DataCallbackResult; } +pub type oboe_DropContextHandler = + ::std::option::Option; pub type oboe_AudioReadyHandler = ::std::option::Option< unsafe extern "C" fn( context: *mut ::std::os::raw::c_void, @@ -1305,8 +1566,10 @@ pub type oboe_ErrorCloseHandler = ::std::option::Option< #[repr(C)] #[derive(Debug)] pub struct oboe_AudioStreamCallbackWrapper { - pub _base: oboe_AudioStreamCallback, + pub _base: oboe_AudioStreamDataCallback, + pub _base_1: oboe_AudioStreamErrorCallback, pub _context: *mut ::std::os::raw::c_void, + pub _drop_context: oboe_DropContextHandler, pub _audio_ready: oboe_AudioReadyHandler, pub _before_close: oboe_ErrorCloseHandler, pub _after_close: oboe_ErrorCloseHandler, @@ -1315,7 +1578,7 @@ pub struct oboe_AudioStreamCallbackWrapper { fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { assert_eq!( ::std::mem::size_of::(), - 24usize, + 28usize, concat!("Size of: ", stringify!(oboe_AudioStreamCallbackWrapper)) ); assert_eq!( @@ -1323,82 +1586,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 4usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._context as *const _ - as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._audio_ready as *const _ - as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._before_close as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._after_close as *const _ - as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] - pub fn oboe_AudioStreamCallbackWrapper_setContext( - this: *mut oboe_AudioStreamCallbackWrapper, - context: *mut ::std::os::raw::c_void, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPFNS_18DataCallbackResultEPvPNS_11AudioStreamES2_iEPFvS2_S4_NS_6ResultEES9_"] + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPvPFvS1_EPFNS_18DataCallbackResultES1_PNS_11AudioStreamES1_iEPFvS1_S6_NS_6ResultEESB_"] pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( this: *mut oboe_AudioStreamCallbackWrapper, + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, ); } impl oboe_AudioStreamCallbackWrapper { - #[inline] - pub unsafe fn setContext(&mut self, context: *mut ::std::os::raw::c_void) { - oboe_AudioStreamCallbackWrapper_setContext(self, context) - } #[inline] pub unsafe fn new( + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, @@ -1406,6 +1610,8 @@ impl oboe_AudioStreamCallbackWrapper { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( __bindgen_tmp.as_mut_ptr(), + context, + drop_context, audio_ready, before_close, after_close, @@ -1413,6 +1619,12 @@ impl oboe_AudioStreamCallbackWrapper { __bindgen_tmp.assume_init() } } +extern "C" { + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperD1Ev"] + pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper_destructor( + this: *mut oboe_AudioStreamCallbackWrapper, + ); +} extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper12onAudioReadyEPNS_11AudioStreamEPvi"] pub fn oboe_AudioStreamCallbackWrapper_onAudioReady( @@ -1439,16 +1651,8 @@ extern "C" { ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamCallbackWrapper_newEPFNS_18DataCallbackResultEPvPNS_11AudioStreamES1_iEPFvS1_S3_NS_6ResultEES8_"] - pub fn oboe_AudioStreamCallbackWrapper_new( - audio_ready: oboe_AudioReadyHandler, - before_close: oboe_ErrorCloseHandler, - after_close: oboe_ErrorCloseHandler, - ) -> *mut oboe_AudioStreamCallbackWrapper; -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPNS_26AudioStreamCallbackWrapperE"] - pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut oboe_AudioStreamCallbackWrapper); + #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPv"] + pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut ::std::os::raw::c_void); } extern "C" { #[link_name = "\u{1}_ZN4oboe22AudioStreamBuilder_newEv"] @@ -1459,11 +1663,15 @@ extern "C" { pub fn oboe_AudioStreamBuilder_delete(builder: *mut oboe_AudioStreamBuilder); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPNS_26AudioStreamCallbackWrapperE"] + #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPvPFvS2_EPFNS_18DataCallbackResultES2_PNS_11AudioStreamES2_iEPFvS2_S7_NS_6ResultEESC_"] pub fn oboe_AudioStreamBuilder_setCallback( builder: *mut oboe_AudioStreamBuilder, - callback: *mut oboe_AudioStreamCallbackWrapper, - ); + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, + audio_ready: oboe_AudioReadyHandler, + before_close: oboe_ErrorCloseHandler, + after_close: oboe_ErrorCloseHandler, + ) -> *mut ::std::os::raw::c_void; } extern "C" { #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_getAudioApiEPKNS_18AudioStreamBuilderE"] @@ -1484,14 +1692,30 @@ extern "C" { builder: *mut oboe_AudioStreamBuilder, ) -> *mut oboe_AudioStreamBase; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe35AudioStreamBuilder_openStreamSharedEPNS_18AudioStreamBuilderEPPNS_11AudioStreamEPPv"] + pub fn oboe_AudioStreamBuilder_openStreamShared( + builder: *mut oboe_AudioStreamBuilder, + stream: *mut *mut oboe_AudioStream, + shared_ptr: *mut *mut ::std::os::raw::c_void, + ) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStream_deleteEPNS_11AudioStreamE"] pub fn oboe_AudioStream_delete(oboeStream: *mut oboe_AudioStream); } +extern "C" { + #[link_name = "\u{1}_ZN4oboe24AudioStream_deleteSharedEPv"] + pub fn oboe_AudioStream_deleteShared(shared_ptr: *mut ::std::os::raw::c_void); +} extern "C" { #[link_name = "\u{1}_ZN4oboe16AudioStream_openEPNS_11AudioStreamE"] pub fn oboe_AudioStream_open(oboeStream: *mut oboe_AudioStream) -> oboe_Result; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe17AudioStream_closeEPNS_11AudioStreamE"] + pub fn oboe_AudioStream_close1(oboeStream: *mut oboe_AudioStream) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe24AudioStream_requestStartEPNS_11AudioStreamE"] pub fn oboe_AudioStream_requestStart(oboeStream: *mut oboe_AudioStream) -> oboe_Result; diff --git a/sys/src/bindings_x86_64.rs b/sys/src/bindings_x86_64.rs index 7f864db..b97c0f2 100644 --- a/sys/src/bindings_x86_64.rs +++ b/sys/src/bindings_x86_64.rs @@ -1,4 +1,4 @@ -/* automatically generated by rust-bindgen 0.59.2 */ +/* automatically generated by rust-bindgen 0.60.1 */ pub type std_string = [u64; 3usize]; pub type __uint8_t = ::std::os::raw::c_uchar; @@ -120,8 +120,11 @@ pub type oboe_PerformanceMode = i32; #[doc = " Try to use AAudio. If not available then use OpenSL ES."] pub const oboe_AudioApi_Unspecified: oboe_AudioApi = 0; #[doc = " Use OpenSL ES."] +#[doc = " Note that OpenSL ES is deprecated in Android 13, API 30 and above."] pub const oboe_AudioApi_OpenSLES: oboe_AudioApi = 1; #[doc = " Try to use AAudio. Fail if unavailable."] +#[doc = " AAudio was first supported in Android 8, API 26 and above."] +#[doc = " It is only recommended for API 27 and above."] pub const oboe_AudioApi_AAudio: oboe_AudioApi = 2; #[doc = " The underlying audio API used by the audio stream."] pub type oboe_AudioApi = i32; @@ -130,14 +133,11 @@ pub const oboe_SampleRateConversionQuality_None: oboe_SampleRateConversionQualit #[doc = " Fastest conversion but may not sound great."] #[doc = " This may be implemented using bilinear interpolation."] pub const oboe_SampleRateConversionQuality_Fastest: oboe_SampleRateConversionQuality = 1; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Low quality conversion with 8 taps."] pub const oboe_SampleRateConversionQuality_Low: oboe_SampleRateConversionQuality = 2; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " Medium quality conversion with 16 taps."] pub const oboe_SampleRateConversionQuality_Medium: oboe_SampleRateConversionQuality = 3; -#[doc = " Fastest conversion but may not sound great."] -#[doc = " This may be implemented using bilinear interpolation."] +#[doc = " High quality conversion with 32 taps."] pub const oboe_SampleRateConversionQuality_High: oboe_SampleRateConversionQuality = 4; #[doc = " Highest quality conversion, which may be expensive in terms of CPU."] pub const oboe_SampleRateConversionQuality_Best: oboe_SampleRateConversionQuality = 5; @@ -251,6 +251,66 @@ pub const oboe_ChannelCount_Stereo: oboe_ChannelCount = 2; #[doc = " rather than `builder.setChannelCount(2)`"] #[doc = ""] pub type oboe_ChannelCount = i32; +pub const oboe_ChannelMask_Unspecified: oboe_ChannelMask = 0; +pub const oboe_ChannelMask_FrontLeft: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_FrontRight: oboe_ChannelMask = 2; +pub const oboe_ChannelMask_FrontCenter: oboe_ChannelMask = 4; +pub const oboe_ChannelMask_LowFrequency: oboe_ChannelMask = 8; +pub const oboe_ChannelMask_BackLeft: oboe_ChannelMask = 16; +pub const oboe_ChannelMask_BackRight: oboe_ChannelMask = 32; +pub const oboe_ChannelMask_FrontLeftOfCenter: oboe_ChannelMask = 64; +pub const oboe_ChannelMask_FrontRightOfCenter: oboe_ChannelMask = 128; +pub const oboe_ChannelMask_BackCenter: oboe_ChannelMask = 256; +pub const oboe_ChannelMask_SideLeft: oboe_ChannelMask = 512; +pub const oboe_ChannelMask_SideRight: oboe_ChannelMask = 1024; +pub const oboe_ChannelMask_TopCenter: oboe_ChannelMask = 2048; +pub const oboe_ChannelMask_TopFrontLeft: oboe_ChannelMask = 4096; +pub const oboe_ChannelMask_TopFrontCenter: oboe_ChannelMask = 8192; +pub const oboe_ChannelMask_TopFrontRight: oboe_ChannelMask = 16384; +pub const oboe_ChannelMask_TopBackLeft: oboe_ChannelMask = 32768; +pub const oboe_ChannelMask_TopBackCenter: oboe_ChannelMask = 65536; +pub const oboe_ChannelMask_TopBackRight: oboe_ChannelMask = 131072; +pub const oboe_ChannelMask_TopSideLeft: oboe_ChannelMask = 262144; +pub const oboe_ChannelMask_TopSideRight: oboe_ChannelMask = 524288; +pub const oboe_ChannelMask_BottomFrontLeft: oboe_ChannelMask = 1048576; +pub const oboe_ChannelMask_BottomFrontCenter: oboe_ChannelMask = 2097152; +pub const oboe_ChannelMask_BottomFrontRight: oboe_ChannelMask = 4194304; +pub const oboe_ChannelMask_LowFrequency2: oboe_ChannelMask = 8388608; +pub const oboe_ChannelMask_FrontWideLeft: oboe_ChannelMask = 16777216; +pub const oboe_ChannelMask_FrontWideRight: oboe_ChannelMask = 33554432; +pub const oboe_ChannelMask_Mono: oboe_ChannelMask = 1; +pub const oboe_ChannelMask_Stereo: oboe_ChannelMask = 3; +pub const oboe_ChannelMask_CM2Point1: oboe_ChannelMask = 11; +pub const oboe_ChannelMask_Tri: oboe_ChannelMask = 7; +pub const oboe_ChannelMask_TriBack: oboe_ChannelMask = 259; +pub const oboe_ChannelMask_CM3Point1: oboe_ChannelMask = 15; +pub const oboe_ChannelMask_CM2Point0Point2: oboe_ChannelMask = 786435; +pub const oboe_ChannelMask_CM2Point1Point2: oboe_ChannelMask = 786443; +pub const oboe_ChannelMask_CM3Point0Point2: oboe_ChannelMask = 786439; +pub const oboe_ChannelMask_CM3Point1Point2: oboe_ChannelMask = 786447; +pub const oboe_ChannelMask_Quad: oboe_ChannelMask = 51; +pub const oboe_ChannelMask_QuadSide: oboe_ChannelMask = 1539; +pub const oboe_ChannelMask_Surround: oboe_ChannelMask = 263; +pub const oboe_ChannelMask_Penta: oboe_ChannelMask = 55; +pub const oboe_ChannelMask_CM5Point1: oboe_ChannelMask = 63; +pub const oboe_ChannelMask_CM5Point1Side: oboe_ChannelMask = 1551; +pub const oboe_ChannelMask_CM6Point1: oboe_ChannelMask = 319; +pub const oboe_ChannelMask_CM7Point1: oboe_ChannelMask = 1599; +pub const oboe_ChannelMask_CM5Point1Point2: oboe_ChannelMask = 786495; +pub const oboe_ChannelMask_CM5Point1Point4: oboe_ChannelMask = 184383; +pub const oboe_ChannelMask_CM7Point1Point2: oboe_ChannelMask = 788031; +pub const oboe_ChannelMask_CM7Point1Point4: oboe_ChannelMask = 185919; +pub const oboe_ChannelMask_CM9Point1Point4: oboe_ChannelMask = 50517567; +pub const oboe_ChannelMask_CM9Point1Point6: oboe_ChannelMask = 51303999; +pub const oboe_ChannelMask_FrontBack: oboe_ChannelMask = 260; +#[doc = " The channel mask of the audio stream. The underlying type is `uint32_t`."] +#[doc = " Use of this enum is convenient."] +#[doc = ""] +#[doc = " ChannelMask::Unspecified means this is not specified."] +#[doc = " The rest of the enums are channel position masks."] +#[doc = " Use the combinations of the channel position masks defined below instead of"] +#[doc = " using those values directly."] +pub type oboe_ChannelMask = u32; #[doc = " On API 16 to 26 OpenSL ES will be used. When using OpenSL ES the optimal values for sampleRate and"] #[doc = " framesPerBurst are not known by the native code."] #[doc = " On API 17+ these values should be obtained from the AudioManager using this code:"] @@ -319,26 +379,40 @@ fn bindgen_test_layout_oboe_FrameTimestamp() { 8usize, concat!("Alignment of ", stringify!(oboe_FrameTimestamp)) ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).position as *const _ as usize }, - 0usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(position) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).timestamp as *const _ as usize }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_FrameTimestamp), - "::", - stringify!(timestamp) - ) - ); + fn test_field_position() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).position) as usize - ptr as usize + }, + 0usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(position) + ) + ); + } + test_field_position(); + fn test_field_timestamp() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).timestamp) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_FrameTimestamp), + "::", + stringify!(timestamp) + ) + ); + } + test_field_timestamp(); } #[doc = " A ResultWithValue can store both the result of an operation (either OK or an error) and a value."] #[doc = ""] @@ -396,6 +470,10 @@ pub struct oboe_AudioStreamErrorCallback__bindgen_vtable(::std::os::raw::c_void) #[doc = " being alerted when a stream has an error or is disconnected"] #[doc = " using `onError*` methods."] #[doc = ""] +#[doc = " Note: This callback is only fired when an AudioStreamCallback is set."] +#[doc = " If you use AudioStream::write() you have to evaluate the return codes of"] +#[doc = " AudioStream::write() to notice errors in the stream."] +#[doc = ""] #[doc = " It is used with AudioStreamBuilder::setErrorCallback()."] #[repr(C)] #[derive(Debug)] @@ -450,13 +528,14 @@ fn bindgen_test_layout_oboe_AudioStreamCallback() { pub struct oboe_AudioStreamBase__bindgen_vtable(::std::os::raw::c_void); #[doc = " Base class containing parameters for audio streams and builders."] #[repr(C)] -#[derive(Debug)] pub struct oboe_AudioStreamBase { pub vtable_: *const oboe_AudioStreamBase__bindgen_vtable, #[doc = " The callback which will be fired when new data is ready to be read/written."] pub mDataCallback: *mut oboe_AudioStreamDataCallback, + pub mSharedDataCallback: [u64; 2usize], #[doc = " The callback which will be fired when an error or a disconnect occurs."] pub mErrorCallback: *mut oboe_AudioStreamErrorCallback, + pub mSharedErrorCallback: [u64; 2usize], #[doc = " Number of audio frames which will be requested in each callback"] pub mFramesPerCallback: i32, #[doc = " Stream channel count"] @@ -469,6 +548,8 @@ pub struct oboe_AudioStreamBase { pub mBufferCapacityInFrames: i32, #[doc = " Stream buffer size specified as a number of audio frames"] pub mBufferSizeInFrames: i32, + #[doc = " Stream channel mask. Only active on Android 32+"] + pub mChannelMask: oboe_ChannelMask, #[doc = " Stream sharing mode"] pub mSharingMode: oboe_SharingMode, #[doc = " Format of audio frames"] @@ -498,7 +579,7 @@ pub struct oboe_AudioStreamBase { fn bindgen_test_layout_oboe_AudioStreamBase() { assert_eq!( ::std::mem::size_of::(), - 136usize, + 176usize, concat!("Size of: ", stringify!(oboe_AudioStreamBase)) ); assert_eq!( @@ -506,266 +587,437 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { 8usize, concat!("Alignment of ", stringify!(oboe_AudioStreamBase)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mDataCallback as *const _ as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDataCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mErrorCallback as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mErrorCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFramesPerCallback as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFramesPerCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelCount as *const _ as usize - }, - 28usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRate as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRate) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDeviceId as *const _ as usize }, - 36usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDeviceId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferCapacityInFrames as *const _ - as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferCapacityInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mBufferSizeInFrames as *const _ - as usize - }, - 44usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mBufferSizeInFrames) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSharingMode as *const _ as usize - }, - 48usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSharingMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mFormat as *const _ as usize }, - 52usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormat) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mDirection as *const _ as usize }, - 56usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mDirection) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPerformanceMode as *const _ as usize - }, - 60usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPerformanceMode) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mUsage as *const _ as usize }, - 64usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mUsage) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mContentType as *const _ as usize - }, - 68usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mContentType) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mInputPreset as *const _ as usize - }, - 72usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mInputPreset) - ) - ); - assert_eq!( - unsafe { &(*(::std::ptr::null::())).mSessionId as *const _ as usize }, - 76usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSessionId) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mPackageName as *const _ as usize - }, - 80usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mPackageName) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mAttributionTag as *const _ as usize - }, - 104usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mAttributionTag) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mChannelConversionAllowed as *const _ - as usize - }, - 128usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mChannelConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFormatConversionAllowed as *const _ - as usize - }, - 129usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mFormatConversionAllowed) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mSampleRateConversionQuality - as *const _ as usize - }, - 132usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamBase), - "::", - stringify!(mSampleRateConversionQuality) - ) - ); + fn test_field_mDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDataCallback) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDataCallback) + ) + ); + } + test_field_mDataCallback(); + fn test_field_mSharedDataCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedDataCallback) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedDataCallback) + ) + ); + } + test_field_mSharedDataCallback(); + fn test_field_mErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mErrorCallback) + ) + ); + } + test_field_mErrorCallback(); + fn test_field_mSharedErrorCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharedErrorCallback) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharedErrorCallback) + ) + ); + } + test_field_mSharedErrorCallback(); + fn test_field_mFramesPerCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize + }, + 56usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFramesPerCallback) + ) + ); + } + test_field_mFramesPerCallback(); + fn test_field_mChannelCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize + }, + 60usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelCount) + ) + ); + } + test_field_mChannelCount(); + fn test_field_mSampleRate() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize + }, + 64usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRate) + ) + ); + } + test_field_mSampleRate(); + fn test_field_mDeviceId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize + }, + 68usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDeviceId) + ) + ); + } + test_field_mDeviceId(); + fn test_field_mBufferCapacityInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize + }, + 72usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferCapacityInFrames) + ) + ); + } + test_field_mBufferCapacityInFrames(); + fn test_field_mBufferSizeInFrames() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize + }, + 76usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + fn test_field_mChannelMask() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelMask) as usize - ptr as usize + }, + 80usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelMask) + ) + ); + } + test_field_mChannelMask(); + fn test_field_mSharingMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize + }, + 84usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSharingMode) + ) + ); + } + test_field_mSharingMode(); + fn test_field_mFormat() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize + }, + 88usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormat) + ) + ); + } + test_field_mFormat(); + fn test_field_mDirection() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize + }, + 92usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mDirection) + ) + ); + } + test_field_mDirection(); + fn test_field_mPerformanceMode() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPerformanceMode) + ) + ); + } + test_field_mPerformanceMode(); + fn test_field_mUsage() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize + }, + 100usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mUsage) + ) + ); + } + test_field_mUsage(); + fn test_field_mContentType() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize + }, + 104usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mContentType) + ) + ); + } + test_field_mContentType(); + fn test_field_mInputPreset() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize + }, + 108usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mInputPreset) + ) + ); + } + test_field_mInputPreset(); + fn test_field_mSessionId() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize + }, + 112usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSessionId) + ) + ); + } + test_field_mSessionId(); + fn test_field_mPackageName() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize + }, + 120usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mPackageName) + ) + ); + } + test_field_mPackageName(); + fn test_field_mAttributionTag() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize + }, + 144usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mAttributionTag) + ) + ); + } + test_field_mAttributionTag(); + fn test_field_mChannelConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize + }, + 168usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mChannelConversionAllowed) + ) + ); + } + test_field_mChannelConversionAllowed(); + fn test_field_mFormatConversionAllowed() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize + }, + 169usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mFormatConversionAllowed) + ) + ); + } + test_field_mFormatConversionAllowed(); + fn test_field_mSampleRateConversionQuality() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize + }, + 172usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); +} +extern "C" { + #[doc = " Return the version of the SDK that is currently running."] + #[doc = ""] + #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] + #[doc = " If the version number cannot be determined then this will return -1."] + #[doc = ""] + #[doc = " @return version number or -1"] + #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] + pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; } #[doc = " Factory class for an audio Stream."] #[repr(C)] #[repr(align(8))] #[derive(Debug, Copy, Clone)] pub struct oboe_AudioStreamBuilder { - pub _bindgen_opaque_blob: [u64; 18usize], + pub _bindgen_opaque_blob: [u64; 23usize], } #[test] fn bindgen_test_layout_oboe_AudioStreamBuilder() { assert_eq!( ::std::mem::size_of::(), - 144usize, + 184usize, concat!("Size of: ", stringify!(oboe_AudioStreamBuilder)) ); assert_eq!( @@ -793,21 +1045,6 @@ extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder19isAAudioRecommendedEv"] pub fn oboe_AudioStreamBuilder_isAAudioRecommended() -> bool; } -extern "C" { - #[doc = " Create and open a stream object based on the current settings."] - #[doc = ""] - #[doc = " The caller owns the pointer to the AudioStream object"] - #[doc = " and must delete it when finished."] - #[doc = ""] - #[doc = " @deprecated Use openStream(std::shared_ptr &stream) instead."] - #[doc = " @param stream pointer to a variable to receive the stream address"] - #[doc = " @return OBOE_OK if successful or a negative error code"] - #[link_name = "\u{1}_ZN4oboe18AudioStreamBuilder10openStreamEPPNS_11AudioStreamE"] - pub fn oboe_AudioStreamBuilder_openStream( - this: *mut oboe_AudioStreamBuilder, - stream: *mut *mut oboe_AudioStream, - ) -> oboe_Result; -} impl oboe_AudioStreamBuilder { #[inline] pub unsafe fn isAAudioSupported() -> bool { @@ -817,23 +1054,18 @@ impl oboe_AudioStreamBuilder { pub unsafe fn isAAudioRecommended() -> bool { oboe_AudioStreamBuilder_isAAudioRecommended() } - #[inline] - pub unsafe fn openStream(&mut self, stream: *mut *mut oboe_AudioStream) -> oboe_Result { - oboe_AudioStreamBuilder_openStream(self, stream) - } } #[doc = " Base class for Oboe C++ audio stream."] #[repr(C)] #[repr(align(8))] -#[derive(Debug, Copy, Clone)] pub struct oboe_AudioStream { - pub _bindgen_opaque_blob: [u64; 28usize], + pub _bindgen_opaque_blob: [u64; 34usize], } #[test] fn bindgen_test_layout_oboe_AudioStream() { assert_eq!( ::std::mem::size_of::(), - 224usize, + 272usize, concat!("Size of: ", stringify!(oboe_AudioStream)) ); assert_eq!( @@ -886,6 +1118,12 @@ extern "C" { numFrames: ::std::os::raw::c_int, ) -> oboe_DataCallbackResult; } +extern "C" { + #[doc = " This should only be called as a stream is being opened."] + #[doc = " Otherwise we might override setDelayBeforeCloseMillis()."] + #[link_name = "\u{1}_ZN4oboe11AudioStream38calculateDefaultDelayBeforeCloseMillisEv"] + pub fn oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(this: *mut oboe_AudioStream); +} extern "C" { #[doc = " Construct an `AudioStream` using the given `AudioStreamBuilder`"] #[doc = ""] @@ -922,6 +1160,10 @@ impl oboe_AudioStream { oboe_AudioStream_fireDataCallback(self, audioData, numFrames) } #[inline] + pub unsafe fn calculateDefaultDelayBeforeCloseMillis(&mut self) { + oboe_AudioStream_calculateDefaultDelayBeforeCloseMillis(self) + } + #[inline] pub unsafe fn new(builder: *const oboe_AudioStreamBuilder) -> Self { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStream_AudioStream(__bindgen_tmp.as_mut_ptr(), builder); @@ -996,6 +1238,11 @@ extern "C" { #[doc = " The time is based on the implementation's best effort, using whatever knowledge is available"] #[doc = " to the system, but cannot account for any delay unknown to the implementation."] #[doc = ""] + #[doc = " Note that due to issues in Android before R, we recommend NOT calling"] + #[doc = " this method from a data callback. See this tech note for more details."] + #[doc = " https://github.com/google/oboe/blob/main/docs/notes/rlsbuffer.md"] + #[doc = ""] + #[doc = " See"] #[doc = " @param clockId the type of clock to use e.g. CLOCK_MONOTONIC"] #[doc = " @return a FrameTimestamp containing the position and time at which a particular audio frame"] #[doc = " entered or left the audio processing pipeline, or an error if the operation failed."] @@ -1018,6 +1265,7 @@ extern "C" { timeoutNanoseconds: i64, ) -> oboe_Result; } +pub const oboe_AudioStream_kMinDelayBeforeCloseMillis: ::std::os::raw::c_int = 10; #[doc = " This struct is a stateless functor which closes an AudioStream prior to its deletion."] #[doc = " This means it can be used to safely delete a smart pointer referring to an open stream."] #[repr(C)] @@ -1151,16 +1399,6 @@ impl oboe_LatencyTuner { } pub const oboe_LatencyTuner_kIdleCount: i32 = 8; pub const oboe_LatencyTuner_kDefaultNumBursts: i32 = 2; -extern "C" { - #[doc = " Return the version of the SDK that is currently running."] - #[doc = ""] - #[doc = " For example, on Android, this would return 27 for Oreo 8.1."] - #[doc = " If the version number cannot be determined then this will return -1."] - #[doc = ""] - #[doc = " @return version number or -1"] - #[link_name = "\u{1}_ZN4oboe13getSdkVersionEv"] - pub fn oboe_getSdkVersion() -> ::std::os::raw::c_int; -} #[doc = " Oboe versioning object"] #[repr(C)] #[derive(Debug, Copy, Clone)] @@ -1171,15 +1409,15 @@ pub struct oboe_Version { pub const oboe_Version_Major: u8 = 1; #[doc = " This is incremented when we add backwards compatible functionality. Or set to zero when MAJOR is"] #[doc = " incremented."] -pub const oboe_Version_Minor: u8 = 6; +pub const oboe_Version_Minor: u8 = 7; #[doc = " This is incremented when we make backwards compatible bug fixes. Or set to zero when MINOR is"] #[doc = " incremented."] -pub const oboe_Version_Patch: u16 = 1; +pub const oboe_Version_Patch: u16 = 0; #[doc = " Version string in the form MAJOR.MINOR.PATCH."] -pub const oboe_Version_Text: &[u8; 6usize] = b"1.6.1\0"; +pub const oboe_Version_Text: &[u8; 6usize] = b"1.7.0\0"; #[doc = " Integer representation of the current Oboe library version. This will always increase when the"] #[doc = " version number changes so can be compared using integer comparison."] -pub const oboe_Version_Number: u32 = 17170433; +pub const oboe_Version_Number: u32 = 17235968; #[test] fn bindgen_test_layout_oboe_Version() { assert_eq!( @@ -1214,54 +1452,74 @@ fn bindgen_test_layout_oboe_StabilizedCallback() { 8usize, concat!("Alignment of ", stringify!(oboe_StabilizedCallback)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mCallback as *const _ as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mCallback) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mFrameCount as *const _ as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mFrameCount) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mEpochTimeNanos as *const _ as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mEpochTimeNanos) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::())).mOpsPerNano as *const _ as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_StabilizedCallback), - "::", - stringify!(mOpsPerNano) - ) - ); + fn test_field_mCallback() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mCallback) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mCallback) + ) + ); + } + test_field_mCallback(); + fn test_field_mFrameCount() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mFrameCount) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mFrameCount) + ) + ); + } + test_field_mFrameCount(); + fn test_field_mEpochTimeNanos() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mEpochTimeNanos) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mEpochTimeNanos) + ) + ); + } + test_field_mEpochTimeNanos(); + fn test_field_mOpsPerNano() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr).mOpsPerNano) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_StabilizedCallback), + "::", + stringify!(mOpsPerNano) + ) + ); + } + test_field_mOpsPerNano(); } extern "C" { #[link_name = "\u{1}_ZN4oboe18StabilizedCallbackC1EPNS_19AudioStreamCallbackE"] @@ -1287,6 +1545,8 @@ extern "C" { numFrames: i32, ) -> oboe_DataCallbackResult; } +pub type oboe_DropContextHandler = + ::std::option::Option; pub type oboe_AudioReadyHandler = ::std::option::Option< unsafe extern "C" fn( context: *mut ::std::os::raw::c_void, @@ -1305,8 +1565,10 @@ pub type oboe_ErrorCloseHandler = ::std::option::Option< #[repr(C)] #[derive(Debug)] pub struct oboe_AudioStreamCallbackWrapper { - pub _base: oboe_AudioStreamCallback, + pub _base: oboe_AudioStreamDataCallback, + pub _base_1: oboe_AudioStreamErrorCallback, pub _context: *mut ::std::os::raw::c_void, + pub _drop_context: oboe_DropContextHandler, pub _audio_ready: oboe_AudioReadyHandler, pub _before_close: oboe_ErrorCloseHandler, pub _after_close: oboe_ErrorCloseHandler, @@ -1315,7 +1577,7 @@ pub struct oboe_AudioStreamCallbackWrapper { fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { assert_eq!( ::std::mem::size_of::(), - 48usize, + 56usize, concat!("Size of: ", stringify!(oboe_AudioStreamCallbackWrapper)) ); assert_eq!( @@ -1323,82 +1585,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 8usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._context as *const _ - as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._audio_ready as *const _ - as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._before_close as *const _ - as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - assert_eq!( - unsafe { - &(*(::std::ptr::null::()))._after_close as *const _ - as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] - pub fn oboe_AudioStreamCallbackWrapper_setContext( - this: *mut oboe_AudioStreamCallbackWrapper, - context: *mut ::std::os::raw::c_void, - ); -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPFNS_18DataCallbackResultEPvPNS_11AudioStreamES2_iEPFvS2_S4_NS_6ResultEES9_"] + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperC1EPvPFvS1_EPFNS_18DataCallbackResultES1_PNS_11AudioStreamES1_iEPFvS1_S6_NS_6ResultEESB_"] pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( this: *mut oboe_AudioStreamCallbackWrapper, + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, ); } impl oboe_AudioStreamCallbackWrapper { - #[inline] - pub unsafe fn setContext(&mut self, context: *mut ::std::os::raw::c_void) { - oboe_AudioStreamCallbackWrapper_setContext(self, context) - } #[inline] pub unsafe fn new( + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, audio_ready: oboe_AudioReadyHandler, before_close: oboe_ErrorCloseHandler, after_close: oboe_ErrorCloseHandler, @@ -1406,6 +1609,8 @@ impl oboe_AudioStreamCallbackWrapper { let mut __bindgen_tmp = ::std::mem::MaybeUninit::uninit(); oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper( __bindgen_tmp.as_mut_ptr(), + context, + drop_context, audio_ready, before_close, after_close, @@ -1413,6 +1618,12 @@ impl oboe_AudioStreamCallbackWrapper { __bindgen_tmp.assume_init() } } +extern "C" { + #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapperD1Ev"] + pub fn oboe_AudioStreamCallbackWrapper_AudioStreamCallbackWrapper_destructor( + this: *mut oboe_AudioStreamCallbackWrapper, + ); +} extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper12onAudioReadyEPNS_11AudioStreamEPvi"] pub fn oboe_AudioStreamCallbackWrapper_onAudioReady( @@ -1439,16 +1650,8 @@ extern "C" { ); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamCallbackWrapper_newEPFNS_18DataCallbackResultEPvPNS_11AudioStreamES1_iEPFvS1_S3_NS_6ResultEES8_"] - pub fn oboe_AudioStreamCallbackWrapper_new( - audio_ready: oboe_AudioReadyHandler, - before_close: oboe_ErrorCloseHandler, - after_close: oboe_ErrorCloseHandler, - ) -> *mut oboe_AudioStreamCallbackWrapper; -} -extern "C" { - #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPNS_26AudioStreamCallbackWrapperE"] - pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut oboe_AudioStreamCallbackWrapper); + #[link_name = "\u{1}_ZN4oboe33AudioStreamCallbackWrapper_deleteEPv"] + pub fn oboe_AudioStreamCallbackWrapper_delete(callback: *mut ::std::os::raw::c_void); } extern "C" { #[link_name = "\u{1}_ZN4oboe22AudioStreamBuilder_newEv"] @@ -1459,11 +1662,15 @@ extern "C" { pub fn oboe_AudioStreamBuilder_delete(builder: *mut oboe_AudioStreamBuilder); } extern "C" { - #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPNS_26AudioStreamCallbackWrapperE"] + #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_setCallbackEPNS_18AudioStreamBuilderEPvPFvS2_EPFNS_18DataCallbackResultES2_PNS_11AudioStreamES2_iEPFvS2_S7_NS_6ResultEESC_"] pub fn oboe_AudioStreamBuilder_setCallback( builder: *mut oboe_AudioStreamBuilder, - callback: *mut oboe_AudioStreamCallbackWrapper, - ); + context: *mut ::std::os::raw::c_void, + drop_context: oboe_DropContextHandler, + audio_ready: oboe_AudioReadyHandler, + before_close: oboe_ErrorCloseHandler, + after_close: oboe_ErrorCloseHandler, + ) -> *mut ::std::os::raw::c_void; } extern "C" { #[link_name = "\u{1}_ZN4oboe30AudioStreamBuilder_getAudioApiEPKNS_18AudioStreamBuilderE"] @@ -1484,14 +1691,30 @@ extern "C" { builder: *mut oboe_AudioStreamBuilder, ) -> *mut oboe_AudioStreamBase; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe35AudioStreamBuilder_openStreamSharedEPNS_18AudioStreamBuilderEPPNS_11AudioStreamEPPv"] + pub fn oboe_AudioStreamBuilder_openStreamShared( + builder: *mut oboe_AudioStreamBuilder, + stream: *mut *mut oboe_AudioStream, + shared_ptr: *mut *mut ::std::os::raw::c_void, + ) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe18AudioStream_deleteEPNS_11AudioStreamE"] pub fn oboe_AudioStream_delete(oboeStream: *mut oboe_AudioStream); } +extern "C" { + #[link_name = "\u{1}_ZN4oboe24AudioStream_deleteSharedEPv"] + pub fn oboe_AudioStream_deleteShared(shared_ptr: *mut ::std::os::raw::c_void); +} extern "C" { #[link_name = "\u{1}_ZN4oboe16AudioStream_openEPNS_11AudioStreamE"] pub fn oboe_AudioStream_open(oboeStream: *mut oboe_AudioStream) -> oboe_Result; } +extern "C" { + #[link_name = "\u{1}_ZN4oboe17AudioStream_closeEPNS_11AudioStreamE"] + pub fn oboe_AudioStream_close1(oboeStream: *mut oboe_AudioStream) -> oboe_Result; +} extern "C" { #[link_name = "\u{1}_ZN4oboe24AudioStream_requestStartEPNS_11AudioStreamE"] pub fn oboe_AudioStream_requestStart(oboeStream: *mut oboe_AudioStream) -> oboe_Result;