From 36c0e8aa65e0c9f6efb08f4dcfd1c6df43c2c8c2 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Fri, 26 Aug 2022 17:42:52 -0300 Subject: [PATCH 01/15] Fix some unsoundess and crash issues This mainly fix issue #41, that causes crashes when a `AudioStream` was drop. That happen because the `AudioStream` was not closed on Drop, but was deleted, causing a use-after-free by the not closed `onDataCallback` thread. Also, the method `AudioStreamBuilder::open_stream` was using the deprecated method `openStream(AudioStream*)`, that do not allow deleting the `AudioStream` safely. Replaced it by `openStream(shared_ptr)`. The deprecated function allowed a use-after-free by the `onErrorCallback` thread. Also, as noted by issue #45, the bindings for `AudioStream::close()` was wrongly bound to the concrete implementation of the base class, instead of calling the virtual method. Also note that currently there is no safe way to delete the `onErrorCallback` of a `AudioStream` in oboe (see https://github.com/google/oboe/issues/1610), so instead the current implementation leaks the callback on drop. Also, remove some unsound `Drop` implementations and replace them by explicit unsafe delete methods. --- src/audio_stream.rs | 80 +++++++--- src/audio_stream_builder.rs | 147 +++++++++++++----- src/audio_stream_callback.rs | 27 ++-- sys/build.rs | 1 + sys/oboe-ext/include/oboe/OboeExt.h | 7 +- .../src/AudioStreamBuilderWrapper.cpp | 10 ++ sys/oboe-ext/src/AudioStreamWrapper.cpp | 9 +- 7 files changed, 209 insertions(+), 72 deletions(-) diff --git a/src/audio_stream.rs b/src/audio_stream.rs index a11def3..3e2b933 100644 --- a/src/audio_stream.rs +++ b/src/audio_stream.rs @@ -411,9 +411,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 +535,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,9 +629,6 @@ impl<'s> RawAudioOutputStream for AudioStreamRef<'s, Output> {} */ pub struct AudioStreamAsync { raw: AudioStreamHandle, - - // Needed to keep callback alive - #[allow(dead_code)] callback: AudioCallbackWrapper, } @@ -638,17 +639,37 @@ impl fmt::Debug for AudioStreamAsync { } impl AudioStreamAsync { - pub(crate) fn wrap_raw( + // SAFETY: `raw`, `shared_ptr` and `callback` must be valid. + pub(crate) unsafe fn wrap_raw( raw: *mut ffi::oboe_AudioStream, + shared_ptr: *mut c_void, callback: AudioCallbackWrapper, ) -> Self { Self { - raw: raw.into(), + raw: AudioStreamHandle(raw, shared_ptr), callback, } } } +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 { + self.close(); + self.raw.delete(); + + // NOTE: Currently there is no safe way to delete the AudioStreamCallback, so we are + // leaking it here. + // see https://github.com/google/oboe/issues/1610 and https://github.com/google/oboe/issues/1603 + + // replace this by `self.callback.delete()` when a fix upstream appear. + let _ = &self.callback; + } + } +} + impl RawAudioStreamBase for AudioStreamAsync { fn _raw_base(&self) -> &ffi::oboe_AudioStreamBase { unsafe { &*ffi::oboe_AudioStream_getBase(self.raw.0) } @@ -688,14 +709,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 { + 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..3e972c3 100644 --- a/src/audio_stream_builder.rs +++ b/src/audio_stream_builder.rs @@ -1,9 +1,10 @@ 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}, }; @@ -49,10 +50,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 +91,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 +226,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 +241,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 +448,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 +466,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 } } @@ -486,13 +511,13 @@ impl AudioStreamBuilder { (T, C): IsFrameType, { let mut callback = AudioCallbackWrapper::::wrap(stream_callback); - let Self { mut raw, .. } = self; + let mut raw = self.destructs(); unsafe { ffi::oboe_AudioStreamBuilder_setCallback(&mut *raw, callback.raw_callback()); } AudioStreamBuilderAsync { - raw, - callback, + raw: ManuallyDrop::new(raw), + callback: ManuallyDrop::new(callback), _phantom: PhantomData, } } @@ -523,13 +548,13 @@ impl AudioStreamBuilder { (T, C): IsFrameType, { let mut callback = AudioCallbackWrapper::::wrap(stream_callback); - let Self { mut raw, .. } = self; + let mut raw = self.destructs(); unsafe { ffi::oboe_AudioStreamBuilder_setCallback(&mut *raw, callback.raw_callback()); } AudioStreamBuilderAsync { - raw, - callback, + raw: ManuallyDrop::new(raw), + callback: ManuallyDrop::new(callback), _phantom: PhantomData, } } @@ -539,11 +564,25 @@ impl AudioStreamBuilder { * Factory for an audio stream. */ pub struct AudioStreamBuilderAsync { - raw: AudioStreamBuilderHandle, - callback: AudioCallbackWrapper, + raw: ManuallyDrop, + callback: ManuallyDrop>, _phantom: PhantomData<(D, F)>, } +impl Drop for AudioStreamBuilderAsync { + fn drop(&mut self) { + // SAFETY: the stream has not yet been open (Self::drop is not called after open_stream), + // so there is no data thread or error thread using this callback yet. + unsafe { + self.callback.delete(); + } + // 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 AudioStreamBuilderAsync { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { audio_stream_base_fmt(self, f) @@ -560,20 +599,43 @@ impl RawAudioStreamBase for AudioStreamBuilderAsync { } } +impl AudioStreamBuilderAsync { + /// Descontructs self into its handle and audio callback, without calling drop. + fn destructs(mut self) -> (AudioStreamBuilderHandle, AudioCallbackWrapper) { + // Safety: the std::mem::forget prevents `raw` and `callback` from being dropped by + // Self::drop. + let raw = unsafe { ManuallyDrop::take(&mut self.raw) }; + let callback = unsafe { ManuallyDrop::take(&mut self.callback) }; + + std::mem::forget(self); + + (raw, callback) + } +} + 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, callback) = 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(), callback) + }); + + drop(raw); + + stream } } @@ -583,13 +645,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, callback) = 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(), callback) + }); + + drop(raw); + + stream } } diff --git a/src/audio_stream_callback.rs b/src/audio_stream_callback.rs index a9b099b..a9a3223 100644 --- a/src/audio_stream_callback.rs +++ b/src/audio_stream_callback.rs @@ -1,6 +1,7 @@ use std::{ ffi::c_void, marker::PhantomData, + mem::ManuallyDrop, ops::{Deref, DerefMut}, slice::{from_raw_parts, from_raw_parts_mut}, }; @@ -221,11 +222,10 @@ impl AudioStreamCallbackWrapperHandle { 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) } + /// SAFFETY: `self.0` must be a valid pointer. + pub(crate) unsafe fn delete(&mut self) { + ffi::oboe_AudioStreamCallbackWrapper_delete(self.0) } } @@ -245,7 +245,7 @@ impl DerefMut for AudioStreamCallbackWrapperHandle { pub(crate) struct AudioCallbackWrapper { raw: AudioStreamCallbackWrapperHandle, - callback: Box, + callback: ManuallyDrop>, _phantom: PhantomData, } @@ -253,6 +253,15 @@ impl AudioCallbackWrapper { pub(crate) fn raw_callback(&mut self) -> &mut ffi::oboe_AudioStreamCallbackWrapper { &mut *self.raw } + + /// SAFETY: `self.raw` and `self.callback` should be valid. Calling this twice results in a + /// double free. The AudioStream that owns this callback must not have being open. If the + /// AudioStream was open, there is currently no safe way of calling this function. + /// (see https://github.com/google/oboe/issues/1610) + pub(crate) unsafe fn delete(&mut self) { + self.raw.delete(); + ManuallyDrop::drop(&mut self.callback); + } } impl AudioCallbackWrapper @@ -267,11 +276,11 @@ where Some(on_error_before_close_input_wrapper::), Some(on_error_after_close_input_wrapper::), ), - callback, + callback: ManuallyDrop::new(callback), _phantom: PhantomData, }; unsafe { - (*wrapper.raw).setContext(&mut (*wrapper.callback) as *mut _ as *mut c_void); + (*wrapper.raw).setContext(&mut (**wrapper.callback) as *mut T as *mut c_void); } wrapper } @@ -289,11 +298,11 @@ where Some(on_error_before_close_output_wrapper::), Some(on_error_after_close_output_wrapper::), ), - callback, + callback: ManuallyDrop::new(callback), _phantom: PhantomData, }; unsafe { - (*wrapper.raw).setContext(&mut (*wrapper.callback) as *mut _ as *mut c_void); + (*wrapper.raw).setContext(&mut (**wrapper.callback) as *mut T as *mut c_void); } wrapper } 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-ext/include/oboe/OboeExt.h b/sys/oboe-ext/include/oboe/OboeExt.h index c89160c..be91241 100644 --- a/sys/oboe-ext/include/oboe/OboeExt.h +++ b/sys/oboe-ext/include/oboe/OboeExt.h @@ -59,9 +59,14 @@ namespace oboe { 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..23625b6 100644 --- a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp @@ -33,4 +33,14 @@ namespace oboe { 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/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(); } From 1dad28349bd1fab72404b8fcdf8b9485e0dfc5d8 Mon Sep 17 00:00:00 2001 From: K Date: Wed, 31 Aug 2022 22:41:55 +0500 Subject: [PATCH 02/15] Update bindings for x86_64 --- sys/src/bindings_x86_64.rs | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/sys/src/bindings_x86_64.rs b/sys/src/bindings_x86_64.rs index 7f864db..d773a12 100644 --- a/sys/src/bindings_x86_64.rs +++ b/sys/src/bindings_x86_64.rs @@ -793,21 +793,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,10 +802,6 @@ 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)] @@ -1484,14 +1465,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; From 4dbf88fdacd9718377a7b07a4faf9823f375ef9f Mon Sep 17 00:00:00 2001 From: K Date: Thu, 1 Sep 2022 09:12:13 +0500 Subject: [PATCH 03/15] CI: Update NDK version to 21.4.7075529 (LTS) --- .github/workflows/rust.yml | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d1a044a..fe79560 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: From 06759f587842be7222739caeda65a06e9da06858 Mon Sep 17 00:00:00 2001 From: K Date: Thu, 1 Sep 2022 09:16:59 +0500 Subject: [PATCH 04/15] Update bindgen to 0.60 --- sys/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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] From 7f2fbc21e34b1d25f55c2f901b72a7dd5c6383a9 Mon Sep 17 00:00:00 2001 From: katyo Date: Thu, 1 Sep 2022 05:29:20 +0000 Subject: [PATCH 05/15] Updated bindings --- sys/src/bindings_aarch64.rs | 931 +++++++++++++++++++++--------------- sys/src/bindings_armv7.rs | 931 +++++++++++++++++++++--------------- sys/src/bindings_i686.rs | 931 +++++++++++++++++++++--------------- sys/src/bindings_x86_64.rs | 896 ++++++++++++++++++++-------------- 4 files changed, 2160 insertions(+), 1529 deletions(-) diff --git a/sys/src/bindings_aarch64.rs b/sys/src/bindings_aarch64.rs index 7f864db..0f247dc 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; @@ -319,26 +319,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 = ""] @@ -506,253 +520,363 @@ 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_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_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 + }, + 24usize, + 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 + }, + 28usize, + 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 + }, + 32usize, + 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 + }, + 36usize, + 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 + }, + 40usize, + 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 + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + 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 + }, + 48usize, + 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 + }, + 52usize, + 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 + }, + 56usize, + 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 + }, + 60usize, + 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 + }, + 64usize, + 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 + }, + 68usize, + 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 + }, + 72usize, + 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 + }, + 76usize, + 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 + }, + 80usize, + 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 + }, + 104usize, + 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 + }, + 128usize, + 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 + }, + 129usize, + 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 + }, + 132usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); } #[doc = " Factory class for an audio Stream."] #[repr(C)] @@ -793,21 +917,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,10 +926,6 @@ 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)] @@ -1214,54 +1319,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"] @@ -1323,58 +1448,74 @@ 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) - ) - ); + fn test_field__context() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_context) + ) + ); + } + test_field__context(); + fn test_field__audio_ready() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_audio_ready) + ) + ); + } + test_field__audio_ready(); + fn test_field__before_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_before_close) + ) + ); + } + test_field__before_close(); + fn test_field__after_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_after_close) + ) + ); + } + test_field__after_close(); } extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] @@ -1484,14 +1625,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..7caaff3 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; @@ -319,26 +319,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 = ""] @@ -506,253 +520,363 @@ 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_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 + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mErrorCallback) + ) + ); + } + test_field_mErrorCallback(); + 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 + }, + 12usize, + 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 + }, + 16usize, + 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 + }, + 20usize, + 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 + }, + 24usize, + 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 + }, + 28usize, + 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 + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + 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 + }, + 36usize, + 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 + }, + 40usize, + 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 + }, + 44usize, + 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 + }, + 48usize, + 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 + }, + 52usize, + 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 + }, + 56usize, + 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 + }, + 60usize, + 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 + }, + 64usize, + 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 + }, + 68usize, + 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 + }, + 80usize, + 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 + }, + 92usize, + 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 + }, + 93usize, + 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 + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); } #[doc = " Factory class for an audio Stream."] #[repr(C)] @@ -793,21 +917,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,10 +926,6 @@ 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)] @@ -1214,54 +1319,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"] @@ -1323,58 +1448,74 @@ 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) - ) - ); + fn test_field__context() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_context) + ) + ); + } + test_field__context(); + fn test_field__audio_ready() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_audio_ready) + ) + ); + } + test_field__audio_ready(); + fn test_field__before_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_before_close) + ) + ); + } + test_field__before_close(); + fn test_field__after_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_after_close) + ) + ); + } + test_field__after_close(); } extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] @@ -1484,14 +1625,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..ac819fd 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; @@ -319,26 +319,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 = ""] @@ -506,253 +520,363 @@ 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_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 + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mErrorCallback) + ) + ); + } + test_field_mErrorCallback(); + 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 + }, + 12usize, + 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 + }, + 16usize, + 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 + }, + 20usize, + 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 + }, + 24usize, + 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 + }, + 28usize, + 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 + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + 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 + }, + 36usize, + 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 + }, + 40usize, + 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 + }, + 44usize, + 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 + }, + 48usize, + 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 + }, + 52usize, + 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 + }, + 56usize, + 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 + }, + 60usize, + 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 + }, + 64usize, + 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 + }, + 68usize, + 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 + }, + 80usize, + 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 + }, + 92usize, + 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 + }, + 93usize, + 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 + }, + 96usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); } #[doc = " Factory class for an audio Stream."] #[repr(C)] @@ -793,21 +917,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,10 +926,6 @@ 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)] @@ -1214,54 +1319,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"] @@ -1323,58 +1448,74 @@ 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) - ) - ); + fn test_field__context() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize + }, + 8usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_context) + ) + ); + } + test_field__context(); + fn test_field__audio_ready() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize + }, + 12usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_audio_ready) + ) + ); + } + test_field__audio_ready(); + fn test_field__before_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_before_close) + ) + ); + } + test_field__before_close(); + fn test_field__after_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize + }, + 20usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_after_close) + ) + ); + } + test_field__after_close(); } extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] @@ -1484,14 +1625,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 d773a12..0f247dc 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; @@ -319,26 +319,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 = ""] @@ -506,253 +520,363 @@ 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_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_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 + }, + 24usize, + 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 + }, + 28usize, + 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 + }, + 32usize, + 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 + }, + 36usize, + 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 + }, + 40usize, + 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 + }, + 44usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mBufferSizeInFrames) + ) + ); + } + test_field_mBufferSizeInFrames(); + 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 + }, + 48usize, + 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 + }, + 52usize, + 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 + }, + 56usize, + 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 + }, + 60usize, + 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 + }, + 64usize, + 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 + }, + 68usize, + 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 + }, + 72usize, + 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 + }, + 76usize, + 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 + }, + 80usize, + 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 + }, + 104usize, + 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 + }, + 128usize, + 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 + }, + 129usize, + 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 + }, + 132usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamBase), + "::", + stringify!(mSampleRateConversionQuality) + ) + ); + } + test_field_mSampleRateConversionQuality(); } #[doc = " Factory class for an audio Stream."] #[repr(C)] @@ -1195,54 +1319,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"] @@ -1304,58 +1448,74 @@ 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) - ) - ); + fn test_field__context() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize + }, + 16usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_context) + ) + ); + } + test_field__context(); + fn test_field__audio_ready() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize + }, + 24usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_audio_ready) + ) + ); + } + test_field__audio_ready(); + fn test_field__before_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize + }, + 32usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_before_close) + ) + ); + } + test_field__before_close(); + fn test_field__after_close() { + assert_eq!( + unsafe { + let uninit = ::std::mem::MaybeUninit::::uninit(); + let ptr = uninit.as_ptr(); + ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize + }, + 40usize, + concat!( + "Offset of field: ", + stringify!(oboe_AudioStreamCallbackWrapper), + "::", + stringify!(_after_close) + ) + ); + } + test_field__after_close(); } extern "C" { #[link_name = "\u{1}_ZN4oboe26AudioStreamCallbackWrapper10setContextEPv"] From 1fe1e24fd884507aa4d49fffd67a4342ad63e897 Mon Sep 17 00:00:00 2001 From: K Date: Thu, 1 Sep 2022 11:25:53 +0500 Subject: [PATCH 06/15] Add missing apk signing key for demo --- .github/workflows/rust.yml | 4 ++++ demo/Cargo.toml | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index fe79560..1b4b9ec 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -244,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/demo/Cargo.toml b/demo/Cargo.toml index dd1f8a3..e9efd3b 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -32,7 +32,7 @@ version = "0.10" version = "0.4" [dependencies.glutin] -version = "0.24" +version = "0.28" [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" From 6259786cbf600f10bd25fdade0583246937d41e3 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Sat, 27 Aug 2022 12:26:43 -0300 Subject: [PATCH 07/15] fix warning for unused result --- src/audio_stream.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio_stream.rs b/src/audio_stream.rs index 3e2b933..4fc632d 100644 --- a/src/audio_stream.rs +++ b/src/audio_stream.rs @@ -657,7 +657,7 @@ impl Drop for AudioStreamAsync { // SAFETY: As long as the conditions on Self::wrap_raw are guaranteed on the creation of // self, this is safe. unsafe { - self.close(); + let _ = self.close(); self.raw.delete(); // NOTE: Currently there is no safe way to delete the AudioStreamCallback, so we are @@ -726,7 +726,7 @@ impl Drop for AudioStreamSync { // SAFETY: As long as the conditions on Self::wrap_raw are guaranteed on the creation of // self, this is safe. unsafe { - self.close(); + let _ = self.close(); self.raw.delete(); } } From 6367d3b4f1d2356c62846952b5e5eb3054684674 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Wed, 11 Jan 2023 19:08:59 -0300 Subject: [PATCH 08/15] update ndk to 0.7 This allows updating glutin to 0.29, making the oboe-demo work on Android without using a patched version of glutin. Could have updated to 0.30, but that would imply in fixing breaking changes. --- Cargo.toml | 6 +----- demo/Cargo.toml | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) 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 e9efd3b..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.28" +version = "0.29" [features] default = ["audio"] From d3732322821cbfab86a56b1cf85db320a13768b2 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 12:05:19 -0300 Subject: [PATCH 09/15] Updated oboe library to 1.7.0 --- sys/oboe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From e853223bbb2b9d77c42d3252c53ed775eb78ce90 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 13:36:35 -0300 Subject: [PATCH 10/15] Updated bindings --- sys/src/bindings_aarch64.rs | 227 ++++++++++++++++++++++++++++-------- sys/src/bindings_armv7.rs | 226 +++++++++++++++++++++++++++-------- sys/src/bindings_i686.rs | 226 +++++++++++++++++++++++++++-------- sys/src/bindings_x86_64.rs | 227 ++++++++++++++++++++++++++++-------- 4 files changed, 720 insertions(+), 186 deletions(-) diff --git a/sys/src/bindings_aarch64.rs b/sys/src/bindings_aarch64.rs index 0f247dc..a5bae01 100644 --- a/sys/src/bindings_aarch64.rs +++ b/sys/src/bindings_aarch64.rs @@ -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:"] @@ -410,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)] @@ -464,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"] @@ -483,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"] @@ -512,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!( @@ -537,6 +604,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -544,7 +628,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize }, - 16usize, + 32usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -554,6 +638,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -561,7 +662,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize }, - 24usize, + 56usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -578,7 +679,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize }, - 28usize, + 60usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -595,7 +696,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize }, - 32usize, + 64usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -612,7 +713,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize }, - 36usize, + 68usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -629,7 +730,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize }, - 40usize, + 72usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -646,7 +747,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize }, - 44usize, + 76usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -656,6 +757,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -663,7 +781,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize }, - 48usize, + 84usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -680,7 +798,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize }, - 52usize, + 88usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -697,7 +815,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize }, - 56usize, + 92usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -714,7 +832,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize }, - 60usize, + 96usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -731,7 +849,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize }, - 64usize, + 100usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -748,7 +866,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize }, - 68usize, + 104usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -765,7 +883,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize }, - 72usize, + 108usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -782,7 +900,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize }, - 76usize, + 112usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -799,7 +917,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize }, - 80usize, + 120usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -816,7 +934,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize }, - 104usize, + 144usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -833,7 +951,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize }, - 128usize, + 168usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -850,7 +968,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize }, - 129usize, + 169usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -867,7 +985,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize }, - 132usize, + 172usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -878,18 +996,28 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { } 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!( @@ -930,15 +1058,14 @@ impl oboe_AudioStreamBuilder { #[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!( @@ -991,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 = ""] @@ -1027,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); @@ -1101,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."] @@ -1123,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)] @@ -1256,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)] @@ -1276,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!( diff --git a/sys/src/bindings_armv7.rs b/sys/src/bindings_armv7.rs index 7caaff3..8f6a0bb 100644 --- a/sys/src/bindings_armv7.rs +++ b/sys/src/bindings_armv7.rs @@ -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:"] @@ -410,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)] @@ -464,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"] @@ -483,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"] @@ -512,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!( @@ -537,6 +604,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -544,7 +628,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize }, - 8usize, + 16usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -554,6 +638,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -561,7 +662,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize }, - 12usize, + 28usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -578,7 +679,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize }, - 16usize, + 32usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -595,7 +696,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize }, - 20usize, + 36usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -612,7 +713,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize }, - 24usize, + 40usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -629,7 +730,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize }, - 28usize, + 44usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -646,7 +747,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize }, - 32usize, + 48usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -656,6 +757,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -663,7 +781,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize }, - 36usize, + 56usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -680,7 +798,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize }, - 40usize, + 60usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -697,7 +815,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize }, - 44usize, + 64usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -714,7 +832,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize }, - 48usize, + 68usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -731,7 +849,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize }, - 52usize, + 72usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -748,7 +866,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize }, - 56usize, + 76usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -765,7 +883,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize }, - 60usize, + 80usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -782,7 +900,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize }, - 64usize, + 84usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -799,7 +917,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize }, - 68usize, + 88usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -816,7 +934,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize }, - 80usize, + 100usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -833,7 +951,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize }, - 92usize, + 112usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -850,7 +968,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize }, - 93usize, + 113usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -867,7 +985,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize }, - 96usize, + 116usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -878,18 +996,28 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { } 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!( @@ -932,13 +1060,13 @@ impl oboe_AudioStreamBuilder { #[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!( @@ -991,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 = ""] @@ -1027,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); @@ -1101,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."] @@ -1123,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)] @@ -1256,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)] @@ -1276,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!( diff --git a/sys/src/bindings_i686.rs b/sys/src/bindings_i686.rs index ac819fd..28b3712 100644 --- a/sys/src/bindings_i686.rs +++ b/sys/src/bindings_i686.rs @@ -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:"] @@ -410,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)] @@ -464,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"] @@ -483,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"] @@ -512,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!( @@ -537,6 +604,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -544,7 +628,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize }, - 8usize, + 16usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -554,6 +638,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -561,7 +662,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize }, - 12usize, + 28usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -578,7 +679,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize }, - 16usize, + 32usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -595,7 +696,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize }, - 20usize, + 36usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -612,7 +713,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize }, - 24usize, + 40usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -629,7 +730,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize }, - 28usize, + 44usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -646,7 +747,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize }, - 32usize, + 48usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -656,6 +757,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -663,7 +781,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize }, - 36usize, + 56usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -680,7 +798,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize }, - 40usize, + 60usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -697,7 +815,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize }, - 44usize, + 64usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -714,7 +832,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize }, - 48usize, + 68usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -731,7 +849,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize }, - 52usize, + 72usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -748,7 +866,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize }, - 56usize, + 76usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -765,7 +883,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize }, - 60usize, + 80usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -782,7 +900,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize }, - 64usize, + 84usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -799,7 +917,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize }, - 68usize, + 88usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -816,7 +934,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize }, - 80usize, + 100usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -833,7 +951,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize }, - 92usize, + 112usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -850,7 +968,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize }, - 93usize, + 113usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -867,7 +985,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize }, - 96usize, + 116usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -878,18 +996,28 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { } 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!( @@ -932,13 +1060,13 @@ impl oboe_AudioStreamBuilder { #[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!( @@ -991,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 = ""] @@ -1027,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); @@ -1101,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."] @@ -1123,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)] @@ -1256,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)] @@ -1276,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!( diff --git a/sys/src/bindings_x86_64.rs b/sys/src/bindings_x86_64.rs index 0f247dc..a5bae01 100644 --- a/sys/src/bindings_x86_64.rs +++ b/sys/src/bindings_x86_64.rs @@ -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:"] @@ -410,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)] @@ -464,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"] @@ -483,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"] @@ -512,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!( @@ -537,6 +604,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -544,7 +628,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mErrorCallback) as usize - ptr as usize }, - 16usize, + 32usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -554,6 +638,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -561,7 +662,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFramesPerCallback) as usize - ptr as usize }, - 24usize, + 56usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -578,7 +679,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelCount) as usize - ptr as usize }, - 28usize, + 60usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -595,7 +696,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRate) as usize - ptr as usize }, - 32usize, + 64usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -612,7 +713,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDeviceId) as usize - ptr as usize }, - 36usize, + 68usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -629,7 +730,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferCapacityInFrames) as usize - ptr as usize }, - 40usize, + 72usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -646,7 +747,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mBufferSizeInFrames) as usize - ptr as usize }, - 44usize, + 76usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -656,6 +757,23 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { ); } 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 { @@ -663,7 +781,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSharingMode) as usize - ptr as usize }, - 48usize, + 84usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -680,7 +798,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormat) as usize - ptr as usize }, - 52usize, + 88usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -697,7 +815,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mDirection) as usize - ptr as usize }, - 56usize, + 92usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -714,7 +832,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPerformanceMode) as usize - ptr as usize }, - 60usize, + 96usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -731,7 +849,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mUsage) as usize - ptr as usize }, - 64usize, + 100usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -748,7 +866,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mContentType) as usize - ptr as usize }, - 68usize, + 104usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -765,7 +883,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mInputPreset) as usize - ptr as usize }, - 72usize, + 108usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -782,7 +900,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSessionId) as usize - ptr as usize }, - 76usize, + 112usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -799,7 +917,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mPackageName) as usize - ptr as usize }, - 80usize, + 120usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -816,7 +934,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mAttributionTag) as usize - ptr as usize }, - 104usize, + 144usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -833,7 +951,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mChannelConversionAllowed) as usize - ptr as usize }, - 128usize, + 168usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -850,7 +968,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mFormatConversionAllowed) as usize - ptr as usize }, - 129usize, + 169usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -867,7 +985,7 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { let ptr = uninit.as_ptr(); ::std::ptr::addr_of!((*ptr).mSampleRateConversionQuality) as usize - ptr as usize }, - 132usize, + 172usize, concat!( "Offset of field: ", stringify!(oboe_AudioStreamBase), @@ -878,18 +996,28 @@ fn bindgen_test_layout_oboe_AudioStreamBase() { } 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!( @@ -930,15 +1058,14 @@ impl oboe_AudioStreamBuilder { #[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!( @@ -991,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 = ""] @@ -1027,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); @@ -1101,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."] @@ -1123,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)] @@ -1256,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)] @@ -1276,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!( From 5882266cda5c7b649815f3d378a805b52fa688dc Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 15:38:23 -0300 Subject: [PATCH 11/15] Stop using deprecated AudioStreamCallback This class were already deprecated in oboe 1.5.0, and was splitted in AudioStreamErrorCallback and AudioStreamDataCallback. Removing the use of this class is one step in using the methods setErrorCallback and setDataCallback introduced in the last version, that will allow fixing the workaround were the callback is leaked. --- sys/oboe-ext/include/oboe/OboeExt.h | 3 ++- sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp | 3 ++- sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp | 1 - 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sys/oboe-ext/include/oboe/OboeExt.h b/sys/oboe-ext/include/oboe/OboeExt.h index be91241..e2c0052 100644 --- a/sys/oboe-ext/include/oboe/OboeExt.h +++ b/sys/oboe-ext/include/oboe/OboeExt.h @@ -13,7 +13,8 @@ namespace oboe { AudioStream *oboeStream, Result error); - class AudioStreamCallbackWrapper: public AudioStreamCallback { + class AudioStreamCallbackWrapper + : public AudioStreamDataCallback, public AudioStreamErrorCallback { public: AudioStreamCallbackWrapper(const AudioReadyHandler audio_ready, const ErrorCloseHandler before_close, diff --git a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp index 23625b6..584dc75 100644 --- a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp @@ -27,7 +27,8 @@ namespace oboe { void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, AudioStreamCallbackWrapper *callback) { - builder->setCallback(callback); + builder->setDataCallback(callback); + builder->setErrorCallback(callback); } AudioStreamBase* AudioStreamBuilder_getBase(AudioStreamBuilder *builder) { diff --git a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp index 7cbb7b2..d905048 100644 --- a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp @@ -7,7 +7,6 @@ namespace oboe { AudioStreamCallbackWrapper(const AudioReadyHandler audio_ready, const ErrorCloseHandler before_close, const ErrorCloseHandler after_close): - AudioStreamCallback(), _context(nullptr), _audio_ready(audio_ready), _before_close(before_close), From 50894ec1ed76c9596c37474fda0e1aa5a86666a3 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 19:00:59 -0300 Subject: [PATCH 12/15] Remove commented out code --- sys/oboe-ext/include/oboe/OboeExt.h | 2 -- sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp | 13 ------------- 2 files changed, 15 deletions(-) diff --git a/sys/oboe-ext/include/oboe/OboeExt.h b/sys/oboe-ext/include/oboe/OboeExt.h index e2c0052..9f5eeae 100644 --- a/sys/oboe-ext/include/oboe/OboeExt.h +++ b/sys/oboe-ext/include/oboe/OboeExt.h @@ -51,8 +51,6 @@ namespace oboe { 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, diff --git a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp index d905048..0a9c5b6 100644 --- a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp @@ -35,19 +35,6 @@ namespace oboe { _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, From d9d5313357958bad18a244f71efbd573492f93fe Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 19:53:49 -0300 Subject: [PATCH 13/15] Use new API for setting the AudioStreamCallback The previous API for setErrorCallback didn't allow soundly deleting the errorCallback, which led oboe-rs to leak the callback. The new API receives holds a shared_ptr, fixing the issue. --- src/audio_stream.rs | 7 - src/audio_stream_builder.rs | 21 +-- src/audio_stream_callback.rs | 116 +++++++---------- sys/oboe-ext/include/oboe/OboeExt.h | 28 ++-- .../src/AudioStreamBuilderWrapper.cpp | 23 +++- .../src/AudioStreamCallbackWrapper.cpp | 26 ++-- sys/src/bindings_aarch64.rs | 123 ++++-------------- 7 files changed, 124 insertions(+), 220 deletions(-) diff --git a/src/audio_stream.rs b/src/audio_stream.rs index 4fc632d..d9e3bf8 100644 --- a/src/audio_stream.rs +++ b/src/audio_stream.rs @@ -659,13 +659,6 @@ impl Drop for AudioStreamAsync { unsafe { let _ = self.close(); self.raw.delete(); - - // NOTE: Currently there is no safe way to delete the AudioStreamCallback, so we are - // leaking it here. - // see https://github.com/google/oboe/issues/1610 and https://github.com/google/oboe/issues/1603 - - // replace this by `self.callback.delete()` when a fix upstream appear. - let _ = &self.callback; } } } diff --git a/src/audio_stream_builder.rs b/src/audio_stream_builder.rs index 3e972c3..fadb950 100644 --- a/src/audio_stream_builder.rs +++ b/src/audio_stream_builder.rs @@ -17,7 +17,7 @@ use super::{ }; #[repr(transparent)] -struct AudioStreamBuilderHandle(*mut ffi::oboe_AudioStreamBuilder); +pub(crate) struct AudioStreamBuilderHandle(*mut ffi::oboe_AudioStreamBuilder); impl Default for AudioStreamBuilderHandle { fn default() -> Self { @@ -510,11 +510,8 @@ impl AudioStreamBuilder { F: AudioInputCallback, (T, C): IsFrameType, { - let mut callback = AudioCallbackWrapper::::wrap(stream_callback); let mut raw = self.destructs(); - unsafe { - ffi::oboe_AudioStreamBuilder_setCallback(&mut *raw, callback.raw_callback()); - } + let callback = AudioCallbackWrapper::::set_callback(&mut raw, stream_callback); AudioStreamBuilderAsync { raw: ManuallyDrop::new(raw), callback: ManuallyDrop::new(callback), @@ -547,11 +544,8 @@ impl AudioStreamBuilder { F: AudioOutputCallback, (T, C): IsFrameType, { - let mut callback = AudioCallbackWrapper::::wrap(stream_callback); let mut raw = self.destructs(); - unsafe { - ffi::oboe_AudioStreamBuilder_setCallback(&mut *raw, callback.raw_callback()); - } + let callback = AudioCallbackWrapper::::set_callback(&mut raw, stream_callback); AudioStreamBuilderAsync { raw: ManuallyDrop::new(raw), callback: ManuallyDrop::new(callback), @@ -571,13 +565,10 @@ pub struct AudioStreamBuilderAsync { impl Drop for AudioStreamBuilderAsync { fn drop(&mut self) { - // SAFETY: the stream has not yet been open (Self::drop is not called after open_stream), - // so there is no data thread or error thread using this callback yet. - unsafe { - self.callback.delete(); - } - // SAFETY: self.raw is only drop here, or taken in Self::destructs, which don't drop self. + // SAFETY: raw and callback are only droped here, or taken in Self::destructs, which don't + // drop self. unsafe { + ManuallyDrop::drop(&mut self.callback); ManuallyDrop::drop(&mut self.raw); } } diff --git a/src/audio_stream_callback.rs b/src/audio_stream_callback.rs index a9a3223..ccc0694 100644 --- a/src/audio_stream_callback.rs +++ b/src/audio_stream_callback.rs @@ -1,8 +1,6 @@ use std::{ ffi::c_void, marker::PhantomData, - mem::ManuallyDrop, - ops::{Deref, DerefMut}, slice::{from_raw_parts, from_raw_parts_mut}, }; @@ -11,8 +9,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, Input, IsFrameType, Output, }; /** @@ -209,58 +207,18 @@ 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) - }) - } - - /// SAFFETY: `self.0` must be a valid pointer. - pub(crate) unsafe fn delete(&mut self) { - 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: ManuallyDrop>, - _phantom: PhantomData, + raw: *mut c_void, + _phantom: PhantomData<(D, T)>, } -impl AudioCallbackWrapper { - pub(crate) fn raw_callback(&mut self) -> &mut ffi::oboe_AudioStreamCallbackWrapper { - &mut *self.raw - } - - /// SAFETY: `self.raw` and `self.callback` should be valid. Calling this twice results in a - /// double free. The AudioStream that owns this callback must not have being open. If the - /// AudioStream was open, there is currently no safe way of calling this function. - /// (see https://github.com/google/oboe/issues/1610) - pub(crate) unsafe fn delete(&mut self) { - self.raw.delete(); - ManuallyDrop::drop(&mut self.callback); +impl Drop for AudioCallbackWrapper { + fn drop(&mut self) { + // SAFETY: As long as `self` was created at AudioCallbackwrapper::set_callback, self.raw is + // a valid pointer, and this call is safe. + unsafe { + ffi::oboe_AudioStreamCallbackWrapper_delete(self.raw); + } } } @@ -268,20 +226,26 @@ impl AudioCallbackWrapper where T: AudioInputCallback, { - pub(crate) fn wrap(callback: T) -> Self { - let callback = Box::new(callback); - let mut wrapper = Self { - raw: AudioStreamCallbackWrapperHandle::new( + pub(crate) fn set_callback(builder: &mut AudioStreamBuilderHandle, callback: T) -> Self { + 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. + let raw = 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::), - ), - callback: ManuallyDrop::new(callback), + ) + }; + + let wrapper = Self { + raw, _phantom: PhantomData, }; - unsafe { - (*wrapper.raw).setContext(&mut (**wrapper.callback) as *mut T as *mut c_void); - } wrapper } } @@ -290,24 +254,36 @@ impl AudioCallbackWrapper where T: AudioOutputCallback, { - pub(crate) fn wrap(callback: T) -> Self { + pub(crate) fn set_callback(builder: &mut AudioStreamBuilderHandle, callback: T) -> Self { let callback = Box::new(callback); - let mut wrapper = Self { - raw: AudioStreamCallbackWrapperHandle::new( + 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. + let raw = 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::), - ), - callback: ManuallyDrop::new(callback), + ) + }; + + let wrapper = Self { + raw, _phantom: PhantomData, }; - unsafe { - (*wrapper.raw).setContext(&mut (**wrapper.callback) as *mut T 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( context: *mut c_void, audio_stream: *mut ffi::oboe_AudioStream, diff --git a/sys/oboe-ext/include/oboe/OboeExt.h b/sys/oboe-ext/include/oboe/OboeExt.h index 9f5eeae..8a7a872 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, @@ -16,11 +18,13 @@ namespace oboe { 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, @@ -34,27 +38,23 @@ 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, + void AudioStreamCallbackWrapper_delete(void *callback); + + AudioStreamBuilder *AudioStreamBuilder_new(); + void AudioStreamBuilder_delete(AudioStreamBuilder *builder); + void* AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, + void *context, + const DropContextHandler drop_context, 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); - - AudioStreamBuilder *AudioStreamBuilder_new(); - void AudioStreamBuilder_delete(AudioStreamBuilder *builder); - void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, - AudioStreamCallbackWrapper *callback); AudioApi AudioStreamBuilder_getAudioApi(const AudioStreamBuilder *builder); void AudioStreamBuilder_setAudioApi(AudioStreamBuilder *builder, AudioApi api); AudioStreamBase* AudioStreamBuilder_getBase(AudioStreamBuilder *builder); diff --git a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp index 584dc75..3abbeaf 100644 --- a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp @@ -25,10 +25,25 @@ namespace oboe { builder->setAudioApi(api); } - void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, - AudioStreamCallbackWrapper *callback) { - builder->setDataCallback(callback); - builder->setErrorCallback(callback); + /// Returns a pointer to a shared_ptr that must be deleted with + /// AudioStreamCallbackWrapper_delete. + void* AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, + void *context, + const DropContextHandler drop_context, + const AudioReadyHandler audio_ready, + const ErrorCloseHandler before_close, + const ErrorCloseHandler after_close) { + auto *s = new std::shared_ptr( + new AudioStreamCallbackWrapper( + context, + drop_context, + audio_ready, + before_close, + after_close)); + builder->setDataCallback(*s); + builder->setErrorCallback(*s); + + return (void*) s; } AudioStreamBase* AudioStreamBuilder_getBase(AudioStreamBuilder *builder) { diff --git a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp index 0a9c5b6..25bed3a 100644 --- a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp @@ -4,16 +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): - _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,16 +39,8 @@ namespace oboe { _after_close(_context, oboeStream, error); } - 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; + void AudioStreamCallbackWrapper_delete(void *callback) { + std::shared_ptr *s = (std::shared_ptr *)callback; + delete s; } } diff --git a/sys/src/bindings_aarch64.rs b/sys/src/bindings_aarch64.rs index a5bae01..b97c0f2 100644 --- a/sys/src/bindings_aarch64.rs +++ b/sys/src/bindings_aarch64.rs @@ -1545,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, @@ -1563,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, @@ -1573,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!( @@ -1581,98 +1585,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 8usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - fn test_field__context() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - } - test_field__context(); - fn test_field__audio_ready() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - } - test_field__audio_ready(); - fn test_field__before_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - } - test_field__before_close(); - fn test_field__after_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); - } - test_field__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, @@ -1680,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, @@ -1687,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( @@ -1713,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"] @@ -1733,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"] From ce797bc1fe4ccf797442eda6a1f9b5e8f063bc7f Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 21:35:34 -0300 Subject: [PATCH 14/15] Stop holding the audio callback in Rust side Before, the code in Rust side were resposible of freeing the callback. But now that oboe's API receives a shared_ptr, that does automatic memory management, we no longer need to hold the callback in the Rust side. --- src/audio_stream.rs | 14 +-- src/audio_stream_builder.rs | 40 +++---- src/audio_stream_callback.rs | 104 ++++++------------ sys/oboe-ext/include/oboe/OboeExt.h | 14 +-- .../src/AudioStreamBuilderWrapper.cpp | 25 ++--- .../src/AudioStreamCallbackWrapper.cpp | 5 - sys/src/bindings_aarch64.rs | 6 +- 7 files changed, 77 insertions(+), 131 deletions(-) diff --git a/src/audio_stream.rs b/src/audio_stream.rs index d9e3bf8..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, }; /** @@ -629,7 +628,7 @@ impl<'s> RawAudioOutputStream for AudioStreamRef<'s, Output> {} */ pub struct AudioStreamAsync { raw: AudioStreamHandle, - callback: AudioCallbackWrapper, + _phantom: PhantomData<(D, F)>, } impl fmt::Debug for AudioStreamAsync { @@ -639,15 +638,14 @@ impl fmt::Debug for AudioStreamAsync { } impl AudioStreamAsync { - // SAFETY: `raw`, `shared_ptr` and `callback` must be valid. + // SAFETY: `raw` and `shared_ptr` must be valid. pub(crate) unsafe fn wrap_raw( raw: *mut ffi::oboe_AudioStream, shared_ptr: *mut c_void, - callback: AudioCallbackWrapper, ) -> Self { Self { raw: AudioStreamHandle(raw, shared_ptr), - callback, + _phantom: PhantomData, } } } diff --git a/src/audio_stream_builder.rs b/src/audio_stream_builder.rs index fadb950..28ef734 100644 --- a/src/audio_stream_builder.rs +++ b/src/audio_stream_builder.rs @@ -8,12 +8,13 @@ use std::{ 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)] @@ -511,10 +512,9 @@ impl AudioStreamBuilder { (T, C): IsFrameType, { let mut raw = self.destructs(); - let callback = AudioCallbackWrapper::::set_callback(&mut raw, stream_callback); + set_input_callback(&mut raw, stream_callback); AudioStreamBuilderAsync { raw: ManuallyDrop::new(raw), - callback: ManuallyDrop::new(callback), _phantom: PhantomData, } } @@ -545,10 +545,9 @@ impl AudioStreamBuilder { (T, C): IsFrameType, { let mut raw = self.destructs(); - let callback = AudioCallbackWrapper::::set_callback(&mut raw, stream_callback); + set_output_callback(&mut raw, stream_callback); AudioStreamBuilderAsync { raw: ManuallyDrop::new(raw), - callback: ManuallyDrop::new(callback), _phantom: PhantomData, } } @@ -559,16 +558,13 @@ impl AudioStreamBuilder { */ pub struct AudioStreamBuilderAsync { raw: ManuallyDrop, - callback: ManuallyDrop>, _phantom: PhantomData<(D, F)>, } impl Drop for AudioStreamBuilderAsync { fn drop(&mut self) { - // SAFETY: raw and callback are only droped here, or taken in Self::destructs, which don't - // drop self. + // SAFETY: self.raw is only droped here, or taken in Self::destructs, which don't drop self. unsafe { - ManuallyDrop::drop(&mut self.callback); ManuallyDrop::drop(&mut self.raw); } } @@ -591,16 +587,14 @@ impl RawAudioStreamBase for AudioStreamBuilderAsync { } impl AudioStreamBuilderAsync { - /// Descontructs self into its handle and audio callback, without calling drop. - fn destructs(mut self) -> (AudioStreamBuilderHandle, AudioCallbackWrapper) { - // Safety: the std::mem::forget prevents `raw` and `callback` from being dropped by - // Self::drop. + /// 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) }; - let callback = unsafe { ManuallyDrop::take(&mut self.callback) }; std::mem::forget(self); - (raw, callback) + raw } } @@ -611,7 +605,7 @@ impl AudioStreamBuilderAsync { pub fn open_stream(self) -> Result> { let mut stream = MaybeUninit::<*mut ffi::oboe_AudioStream>::uninit(); let mut shared_ptr = MaybeUninit::<*mut c_void>::uninit(); - let (mut raw, callback) = self.destructs(); + let mut raw = self.destructs(); let stream = wrap_status(unsafe { ffi::oboe_AudioStreamBuilder_openStreamShared( @@ -621,7 +615,7 @@ impl AudioStreamBuilderAsync { ) }) .map(|_| unsafe { - AudioStreamAsync::wrap_raw(stream.assume_init(), shared_ptr.assume_init(), callback) + AudioStreamAsync::wrap_raw(stream.assume_init(), shared_ptr.assume_init()) }); drop(raw); @@ -637,7 +631,7 @@ impl AudioStreamBuilderAsync { pub fn open_stream(self) -> Result> { let mut stream = MaybeUninit::<*mut ffi::oboe_AudioStream>::uninit(); let mut shared_ptr = MaybeUninit::<*mut c_void>::uninit(); - let (mut raw, callback) = self.destructs(); + let mut raw = self.destructs(); let stream = wrap_status(unsafe { ffi::oboe_AudioStreamBuilder_openStreamShared( @@ -647,7 +641,7 @@ impl AudioStreamBuilderAsync { ) }) .map(|_| unsafe { - AudioStreamAsync::wrap_raw(stream.assume_init(), shared_ptr.assume_init(), callback) + AudioStreamAsync::wrap_raw(stream.assume_init(), shared_ptr.assume_init()) }); drop(raw); diff --git a/src/audio_stream_callback.rs b/src/audio_stream_callback.rs index ccc0694..25795ef 100644 --- a/src/audio_stream_callback.rs +++ b/src/audio_stream_callback.rs @@ -1,6 +1,5 @@ use std::{ ffi::c_void, - marker::PhantomData, slice::{from_raw_parts, from_raw_parts_mut}, }; @@ -10,7 +9,7 @@ use num_traits::FromPrimitive; use super::{ AudioInputStreamSafe, AudioOutputStreamSafe, AudioStreamBuilderHandle, AudioStreamRef, - DataCallbackResult, Error, Input, IsFrameType, Output, + DataCallbackResult, Error, IsFrameType, }; /** @@ -207,75 +206,44 @@ pub trait AudioOutputCallback { ) -> DataCallbackResult; } -pub(crate) struct AudioCallbackWrapper { - raw: *mut c_void, - _phantom: PhantomData<(D, T)>, -} - -impl Drop for AudioCallbackWrapper { - fn drop(&mut self) { - // SAFETY: As long as `self` was created at AudioCallbackwrapper::set_callback, self.raw is - // a valid pointer, and this call is safe. - unsafe { - ffi::oboe_AudioStreamCallbackWrapper_delete(self.raw); - } - } -} - -impl AudioCallbackWrapper -where - T: AudioInputCallback, -{ - pub(crate) fn set_callback(builder: &mut AudioStreamBuilderHandle, callback: T) -> Self { - 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. - let raw = 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::), - ) - }; - - let wrapper = Self { - raw, - _phantom: PhantomData, - }; - wrapper +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: AudioOutputCallback, -{ - pub(crate) fn set_callback(builder: &mut AudioStreamBuilderHandle, callback: T) -> Self { - 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. - let raw = 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::), - ) - }; - - let wrapper = Self { - raw, - _phantom: PhantomData, - }; - 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::), + ); } } diff --git a/sys/oboe-ext/include/oboe/OboeExt.h b/sys/oboe-ext/include/oboe/OboeExt.h index 8a7a872..e3d8c92 100644 --- a/sys/oboe-ext/include/oboe/OboeExt.h +++ b/sys/oboe-ext/include/oboe/OboeExt.h @@ -44,16 +44,14 @@ namespace oboe { const ErrorCloseHandler _after_close; }; - void AudioStreamCallbackWrapper_delete(void *callback); - AudioStreamBuilder *AudioStreamBuilder_new(); void AudioStreamBuilder_delete(AudioStreamBuilder *builder); - void* AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, - void *context, - const DropContextHandler drop_context, - const AudioReadyHandler audio_ready, - const ErrorCloseHandler before_close, - const ErrorCloseHandler after_close); + void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, + 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); diff --git a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp index 3abbeaf..40baca9 100644 --- a/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamBuilderWrapper.cpp @@ -25,25 +25,22 @@ namespace oboe { builder->setAudioApi(api); } - /// Returns a pointer to a shared_ptr that must be deleted with - /// AudioStreamCallbackWrapper_delete. - void* AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, + /// Takes ownership of context (drop_context will be called to free it). + void AudioStreamBuilder_setCallback(AudioStreamBuilder *builder, void *context, const DropContextHandler drop_context, const AudioReadyHandler audio_ready, const ErrorCloseHandler before_close, const ErrorCloseHandler after_close) { - auto *s = new std::shared_ptr( - new AudioStreamCallbackWrapper( - context, - drop_context, - audio_ready, - before_close, - after_close)); - builder->setDataCallback(*s); - builder->setErrorCallback(*s); - - return (void*) s; + 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) { diff --git a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp index 25bed3a..9c9bf35 100644 --- a/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp +++ b/sys/oboe-ext/src/AudioStreamCallbackWrapper.cpp @@ -38,9 +38,4 @@ namespace oboe { Result error) { _after_close(_context, oboeStream, error); } - - void AudioStreamCallbackWrapper_delete(void *callback) { - std::shared_ptr *s = (std::shared_ptr *)callback; - delete s; - } } diff --git a/sys/src/bindings_aarch64.rs b/sys/src/bindings_aarch64.rs index b97c0f2..5956176 100644 --- a/sys/src/bindings_aarch64.rs +++ b/sys/src/bindings_aarch64.rs @@ -1649,10 +1649,6 @@ extern "C" { error: oboe_Result, ); } -extern "C" { - #[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"] pub fn oboe_AudioStreamBuilder_new() -> *mut oboe_AudioStreamBuilder; @@ -1670,7 +1666,7 @@ extern "C" { 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"] From fea00f609ec11b64272900a1fad47898521d44e0 Mon Sep 17 00:00:00 2001 From: Rodrigo Batista de Moraes Date: Thu, 12 Jan 2023 21:45:11 -0300 Subject: [PATCH 15/15] Update bindings --- sys/src/bindings_armv7.rs | 123 +++++++++---------------------------- sys/src/bindings_i686.rs | 123 +++++++++---------------------------- sys/src/bindings_x86_64.rs | 123 +++++++++---------------------------- 3 files changed, 84 insertions(+), 285 deletions(-) diff --git a/sys/src/bindings_armv7.rs b/sys/src/bindings_armv7.rs index 8f6a0bb..6fa5763 100644 --- a/sys/src/bindings_armv7.rs +++ b/sys/src/bindings_armv7.rs @@ -1546,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, @@ -1564,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, @@ -1574,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!( @@ -1582,98 +1586,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 4usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - fn test_field__context() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - } - test_field__context(); - fn test_field__audio_ready() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - } - test_field__audio_ready(); - fn test_field__before_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - } - test_field__before_close(); - fn test_field__after_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); - } - test_field__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, @@ -1681,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, @@ -1688,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( @@ -1714,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"] @@ -1734,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"] diff --git a/sys/src/bindings_i686.rs b/sys/src/bindings_i686.rs index 28b3712..b00cd80 100644 --- a/sys/src/bindings_i686.rs +++ b/sys/src/bindings_i686.rs @@ -1546,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, @@ -1564,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, @@ -1574,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!( @@ -1582,98 +1586,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 4usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - fn test_field__context() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize - }, - 8usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - } - test_field__context(); - fn test_field__audio_ready() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize - }, - 12usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - } - test_field__audio_ready(); - fn test_field__before_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - } - test_field__before_close(); - fn test_field__after_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize - }, - 20usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); - } - test_field__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, @@ -1681,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, @@ -1688,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( @@ -1714,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"] @@ -1734,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"] diff --git a/sys/src/bindings_x86_64.rs b/sys/src/bindings_x86_64.rs index a5bae01..b97c0f2 100644 --- a/sys/src/bindings_x86_64.rs +++ b/sys/src/bindings_x86_64.rs @@ -1545,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, @@ -1563,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, @@ -1573,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!( @@ -1581,98 +1585,23 @@ fn bindgen_test_layout_oboe_AudioStreamCallbackWrapper() { 8usize, concat!("Alignment of ", stringify!(oboe_AudioStreamCallbackWrapper)) ); - fn test_field__context() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._context) as usize - ptr as usize - }, - 16usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_context) - ) - ); - } - test_field__context(); - fn test_field__audio_ready() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._audio_ready) as usize - ptr as usize - }, - 24usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_audio_ready) - ) - ); - } - test_field__audio_ready(); - fn test_field__before_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._before_close) as usize - ptr as usize - }, - 32usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_before_close) - ) - ); - } - test_field__before_close(); - fn test_field__after_close() { - assert_eq!( - unsafe { - let uninit = ::std::mem::MaybeUninit::::uninit(); - let ptr = uninit.as_ptr(); - ::std::ptr::addr_of!((*ptr)._after_close) as usize - ptr as usize - }, - 40usize, - concat!( - "Offset of field: ", - stringify!(oboe_AudioStreamCallbackWrapper), - "::", - stringify!(_after_close) - ) - ); - } - test_field__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, @@ -1680,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, @@ -1687,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( @@ -1713,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"] @@ -1733,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"]