diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index d1a044a..1b4b9ec 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -66,13 +66,14 @@ jobs: uses: android-actions/setup-android@v2 - name: Setup Android NDK env: - NDK_VERSION: 21.3.6528147 + NDK_VERSION: 21.4.7075529 TRIPLE: x86_64-linux-android run: | - rm -rf $ANDROID_SDK_ROOT/ndk-bundle - sdkmanager --sdk_root=$ANDROID_SDK_ROOT "ndk;$NDK_VERSION" | grep -v = || true - ln -s $ANDROID_SDK_ROOT/ndk/$NDK_VERSION $ANDROID_SDK_ROOT/ndk-bundle - echo "$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;$NDK_VERSION" --channel=3 | grep -v = || true + echo "$ANDROID_SDK_ROOT/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + for var in ANDROID_NDK ANDROID_NDK_HOME ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do + echo "$var=$ANDROID_SDK_ROOT/ndk/$NDK_VERSION" >> $GITHUB_ENV + done TRIPLE_ENV=$(echo $TRIPLE | tr '-' '_') echo "CC_${TRIPLE_ENV}=${TRIPLE}21-clang" >> $GITHUB_ENV echo "CXX_${TRIPLE_ENV}=${TRIPLE}21-clang++" >> $GITHUB_ENV @@ -124,12 +125,13 @@ jobs: uses: android-actions/setup-android@v2 - name: Setup Android NDK env: - NDK_VERSION: 21.3.6528147 + NDK_VERSION: 21.4.7075529 run: | - rm -rf $ANDROID_SDK_ROOT/ndk-bundle - sdkmanager --sdk_root=$ANDROID_SDK_ROOT "ndk;$NDK_VERSION" | grep -v = || true - ln -s $ANDROID_SDK_ROOT/ndk/$NDK_VERSION $ANDROID_SDK_ROOT/ndk-bundle - echo "$ANDROID_SDK_ROOT/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + sdkmanager --sdk_root=$ANDROID_SDK_ROOT --install "ndk;$NDK_VERSION" --channel=3 | grep -v = || true + echo "$ANDROID_SDK_ROOT/ndk/$NDK_VERSION/toolchains/llvm/prebuilt/linux-x86_64/bin" >> $GITHUB_PATH + for var in ANDROID_NDK ANDROID_NDK_HOME ANDROID_NDK_LATEST_HOME ANDROID_NDK_ROOT; do + echo "$var=$ANDROID_SDK_ROOT/ndk/$NDK_VERSION" >> $GITHUB_ENV + done - name: Setup Rust ${{ matrix.rust }} [${{ matrix.target }}] uses: actions-rs/toolchain@v1 with: @@ -242,6 +244,10 @@ jobs: path: ~/.cargo/bin/cargo-apk key: ${{ runner.os }}-cargo-apk - uses: Swatinem/rust-cache@v1 + - name: Create signing key + run: | + echo ${{ secrets.APK_SIGN_KEY_DATA }} | base64 -d > demo/release.keystore + sed -i 's/keystore_password = "android"/keystore_password = "${{ secrets.APK_SIGN_KEY_SECRET }}"/' demo/Cargo.toml - name: Build demo apk uses: actions-rs/cargo@v1 with: diff --git a/Cargo.toml b/Cargo.toml index bdf8526..9e857cf 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] @@ -66,5 +66,5 @@ 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" } +#winit = { git = "https://github.com/rust-windowing/winit" } +#glutin = { git = "https://github.com/katyo/glutin", branch = "android-support" } diff --git a/demo/Cargo.toml b/demo/Cargo.toml index dd1f8a3..150a553 100644 --- a/demo/Cargo.toml +++ b/demo/Cargo.toml @@ -22,7 +22,7 @@ optional = true version = "0.1.0" [dependencies.ndk-glue] -version = "0.6.0" +version = "0.7.0" features = ["logger"] [dependencies.android_logger] @@ -32,7 +32,7 @@ version = "0.10" version = "0.4" [dependencies.glutin] -version = "0.24" +version = "0.29.1" [features] default = ["audio"] @@ -75,3 +75,7 @@ name = "android.permission.WRITE_EXTERNAL_STORAGE" [[package.metadata.android.permission]] name = "android.permission.RECORD_AUDIO" + +[package.metadata.android.signing.release] +path = "release.keystore" +keystore_password = "android" diff --git a/src/audio_stream.rs b/src/audio_stream.rs index a11def3..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/Cargo.toml b/sys/Cargo.toml index 80c0d66..a21ef89 100644 --- a/sys/Cargo.toml +++ b/sys/Cargo.toml @@ -23,7 +23,7 @@ version = "1.0" features = ["parallel"] [build-dependencies.bindgen] -version = "0.59" +version = "0.60" optional = true [features] diff --git a/sys/build.rs b/sys/build.rs index 111dc22..c26f08d 100644 --- a/sys/build.rs +++ b/sys/build.rs @@ -164,6 +164,7 @@ impl Builder { .allowlist_function("oboe::getSdkVersion") .blocklist_type("std::.*_ptr.*") .blocklist_type("oboe::ManagedStream") + .blocklist_function("oboe::AudioStreamBuilder_openStream") .blocklist_function("oboe::AudioStreamBuilder_openStream1") .blocklist_function("oboe::AudioStreamBuilder_openManagedStream") .blocklist_function("oboe::AudioStreamBuilder_setPackageName") diff --git a/sys/oboe-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(); } 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 7f864db..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)] @@ -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;