Skip to content

Commit

Permalink
tune API
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Jan 3, 2024
1 parent 0353f95 commit 52d1973
Show file tree
Hide file tree
Showing 28 changed files with 76 additions and 75 deletions.
2 changes: 1 addition & 1 deletion cidre/src/am/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ extern "C" {
device: &Device,
service_name: &cf::String,
ssl: *mut c_void,
service: &mut Option<arc::R<ServiceConnection>>,
service: *mut Option<arc::R<ServiceConnection>>,
) -> Error;

fn AMDeviceCopyValueWithError(
Expand Down
4 changes: 2 additions & 2 deletions cidre/src/am/device/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl Notification {
minimum_interface_speed: Speed,
connection_type: InterfaceConnectionType,
context: *mut T,
ref_out: &mut Option<arc::R<Notification>>,
ref_out: *mut Option<arc::R<Notification>>,
) -> Error {
AMDeviceNotificationSubscribe(
transmute(callback),
Expand Down Expand Up @@ -292,7 +292,7 @@ extern "C" {
minimum_interface_speed: Speed,
connection_type: InterfaceConnectionType,
context: *mut c_void,
ref_out: &mut Option<arc::R<Notification>>,
ref_out: *mut Option<arc::R<Notification>>,
) -> Error;

fn AMDeviceNotificationUnsubscribe(notification: &Notification) -> Error;
Expand Down
2 changes: 1 addition & 1 deletion cidre/src/am/device/installation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,6 @@ extern "C" {
fn AMDeviceLookupApplications(
device: &Device,
options: &cf::Dictionary,
info: &mut Option<arc::R<cf::Dictionary>>,
info: *mut Option<arc::R<cf::Dictionary>>,
) -> Error;
}
4 changes: 2 additions & 2 deletions cidre/src/at/audio/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ extern "C" {

fn AudioComponentCopyName(
in_component: &Component,
out_name: &mut Option<arc::R<cf::String>>,
out_name: *mut Option<arc::R<cf::String>>,
) -> os::Status;

fn AudioComponentGetDescription(component: &Component, out_desc: &mut Desc) -> os::Status;
Expand All @@ -222,7 +222,7 @@ extern "C" {

fn AudioComponentInstanceNew(
component: &Component,
out_instance: &mut Option<&'static mut ComponentInstance>,
out_instance: *mut Option<&'static mut ComponentInstance>,
) -> os::Status;

fn AudioComponentInstanceDispose(instance: &mut ComponentInstance) -> os::Status;
Expand Down
4 changes: 2 additions & 2 deletions cidre/src/at/audio/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ impl ConverterRef {
pub unsafe fn new(
src_format: &audio::StreamBasicDesc,
dst_format: &audio::StreamBasicDesc,
out_audio_converer: &mut Option<Self>,
out_audio_converer: *mut Option<Self>,
) -> os::Status {
AudioConverterNew(src_format, dst_format, out_audio_converer)
}
Expand Down Expand Up @@ -798,7 +798,7 @@ extern "C" {
fn AudioConverterNew(
in_source_format: &audio::StreamBasicDesc,
in_destination_format: &audio::StreamBasicDesc,
out_audio_converer: &mut Option<ConverterRef>,
out_audio_converer: *mut Option<ConverterRef>,
) -> os::Status;

fn AudioConverterReset(converter: &Converter) -> os::Status;
Expand Down
4 changes: 2 additions & 2 deletions cidre/src/at/audio/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ extern "C" {
in_file_type: FileTypeID,
in_format: &audio::StreamBasicDesc,
in_flags: Flags,
out_audio_file: &mut Option<FileID>,
out_audio_file: *mut Option<FileID>,
) -> os::Status;

fn AudioFileClose(file: *const OpaqueFileID) -> os::Status;
Expand All @@ -672,7 +672,7 @@ extern "C" {
file_url: &cf::Url,
permissions: Permissions,
file_type_hint: FileTypeID,
out_audio_file: &mut Option<FileID>,
out_audio_file: *mut Option<FileID>,
) -> os::Status;

fn AudioFileGetPropertyInfo(
Expand Down
2 changes: 1 addition & 1 deletion cidre/src/av/asset/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ impl arc::A<Reader> {
pub fn init_with_assert_err<'ar>(
self,
asset: &av::Asset,
error: &mut Option<&'ar ns::Error>,
error: *mut Option<&'ar ns::Error>,
) -> Option<arc::R<Reader>>;
}

Expand Down
2 changes: 1 addition & 1 deletion cidre/src/av/asset/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl arc::A<Writer> {
self,
url: &ns::Url,
file_type: &av::FileType,
error: &mut Option<&'ar ns::Error>,
error: *mut Option<&'ar ns::Error>,
) -> Option<arc::R<Writer>>;

#[objc::msg_send(initWithContentType:)]
Expand Down
2 changes: 1 addition & 1 deletion cidre/src/av/audio/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl Converter {
pub unsafe fn convert_to_buffer_err_with_input_from_block(
&self,
output_buffer: &mut av::AudioBuf,
error: &mut Option<&cf::Error>,
error: *mut Option<&cf::Error>,
block: *mut c_void,
) -> OutputStatus;

Expand Down
13 changes: 7 additions & 6 deletions cidre/src/av/audio/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl Engine {
pub fn prepare(&mut self);

#[objc::msg_send(startAndReturnError:)]
pub fn start_and_return_err<'ar>(&self, error: &mut Option<&'ar ns::Error>) -> bool;
pub unsafe fn start_and_return_err<'ar>(&self, error: *mut Option<&'ar ns::Error>) -> bool;

#[inline]
pub fn start<'ar>(&mut self) -> Result<(), &'ar ns::Error> {
Expand Down Expand Up @@ -227,12 +227,12 @@ impl Engine {
/// 2. Removes any taps previously installed on the input and output nodes.
/// 3. Maintains all the engine connections as is.
#[objc::msg_send(enableManualRenderingMode:format:maximumFrameCount:error:)]
pub fn enable_manual_rendering_mode_err<'ar>(
pub unsafe fn enable_manual_rendering_mode_err<'ar>(
&mut self,
mode: ManualRenderingMode,
format: &av::AudioFormat,
max_frame_count: av::AudioFrameCount,
error: &mut Option<&'ar ns::Error>,
error: *mut Option<&'ar ns::Error>,
);

#[inline]
Expand All @@ -243,11 +243,12 @@ impl Engine {
max_frame_count: av::AudioFrameCount,
) -> Result<(), &'ar ns::Error> {
let mut error = None;
self.enable_manual_rendering_mode_err(mode, format, max_frame_count, &mut error);
unsafe { self.enable_manual_rendering_mode_err(mode, format, max_frame_count, &mut error) };
if let Some(err) = error {
return Err(err);
Err(err)
} else {
Ok(())
}
Ok(())
}

#[objc::msg_send(disableManualRenderingMode)]
Expand Down
2 changes: 1 addition & 1 deletion cidre/src/av/capture/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ impl Device {
}

#[objc::msg_send(lockForConfiguration:)]
pub unsafe fn lock_for_config(&mut self, error: &mut Option<arc::R<ns::Error>>) -> bool;
pub unsafe fn lock_for_config(&mut self, error: *mut Option<arc::R<ns::Error>>) -> bool;

#[objc::msg_send(unlockForConfiguration)]
pub unsafe fn unlock_for_config(&mut self);
Expand Down
8 changes: 4 additions & 4 deletions cidre/src/cm/block_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ impl BlockBuf {
offset_to_data: usize,
data_length: usize,
flags: Flags,
block_buf_out: &mut Option<arc::R<BlockBuf>>,
block_buf_out: *mut Option<arc::R<BlockBuf>>,
) -> os::Status {
CMBlockBufferCreateWithBufferReference(
structure_allocator,
Expand Down Expand Up @@ -322,7 +322,7 @@ extern "C" {
structure_allocator: Option<&cf::Allocator>,
sub_block_capacity: u32,
flags: Flags,
block_buffer_out: &mut Option<arc::R<BlockBuf>>,
block_buffer_out: *mut Option<arc::R<BlockBuf>>,
) -> os::Status;

fn CMBlockBufferCreateWithMemoryBlock(
Expand All @@ -334,7 +334,7 @@ extern "C" {
offset_to_data: usize,
data_length: usize,
flags: Flags,
block_buffer_out: &mut Option<arc::R<BlockBuf>>,
block_buffer_out: *mut Option<arc::R<BlockBuf>>,
) -> os::Status;

fn CMBlockBufferGetDataLength(the_buffer: &BlockBuf) -> usize;
Expand All @@ -355,7 +355,7 @@ extern "C" {
offset_to_data: usize,
data_length: usize,
flags: Flags,
block_buffer_out: &mut Option<arc::R<BlockBuf>>,
block_buffer_out: *mut Option<arc::R<BlockBuf>>,
) -> os::Status;

fn CMBlockBufferAssureBlockMemory(buffer: &mut BlockBuf) -> os::Status;
Expand Down
18 changes: 9 additions & 9 deletions cidre/src/cm/format_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ impl FormatDesc {
media_type: MediaType,
media_sub_type: FourCharCode,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description_out: &mut Option<arc::R<FormatDesc>>,
format_description_out: *mut Option<arc::R<FormatDesc>>,
allocator: Option<&cf::Allocator>,
) -> os::Status {
unsafe {
Expand Down Expand Up @@ -308,7 +308,7 @@ impl VideoFormatDesc {
width: i32,
height: i32,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description_out: &mut Option<arc::R<VideoFormatDesc>>,
format_description_out: *mut Option<arc::R<VideoFormatDesc>>,
allocator: Option<&Allocator>,
) -> os::Status {
unsafe {
Expand Down Expand Up @@ -565,7 +565,7 @@ impl AudioFormatDesc {
magic_cookie_size: usize,
magic_cookie: Option<&c_void>,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description_out: &mut Option<arc::R<Self>>,
format_description_out: *mut Option<arc::R<Self>>,
allocator: Option<&cf::Allocator>,
) -> os::Status {
unsafe {
Expand Down Expand Up @@ -905,7 +905,7 @@ extern "C" {
width: i32,
height: i32,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description_out: &mut Option<arc::R<VideoFormatDesc>>,
format_description_out: *mut Option<arc::R<VideoFormatDesc>>,
) -> os::Status;

fn CMVideoFormatDescriptionGetDimensions(video_desc: &VideoFormatDesc) -> VideoDimensions;
Expand Down Expand Up @@ -936,7 +936,7 @@ extern "C" {
magic_cookie_size: usize,
magic_cookie: Option<&c_void>,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description_out: &mut Option<arc::R<AudioFormatDesc>>,
format_description_out: *mut Option<arc::R<AudioFormatDesc>>,
) -> os::Status;

#[cfg(feature = "cat")]
Expand All @@ -949,13 +949,13 @@ extern "C" {
media_type: MediaType,
media_sub_type: FourCharCode,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description_out: &mut Option<arc::R<FormatDesc>>,
format_description_out: *mut Option<arc::R<FormatDesc>>,
) -> os::Status;

fn CMVideoFormatDescriptionCreateForImageBuffer(
allocator: Option<&cf::Allocator>,
image_buffer: &cv::ImageBuf,
format_description: &mut Option<arc::R<FormatDesc>>,
format_description: *mut Option<arc::R<FormatDesc>>,
) -> os::Status;

fn CMVideoFormatDescriptionCreateFromH264ParameterSets(
Expand All @@ -964,7 +964,7 @@ extern "C" {
parameter_set_pointers: *const *const u8,
parameter_set_sizes: *const usize,
nal_unit_header_length: i32,
format_description: &mut Option<arc::R<FormatDesc>>,
format_description: *mut Option<arc::R<FormatDesc>>,
) -> os::Status;

fn CMVideoFormatDescriptionCreateFromHEVCParameterSets(
Expand All @@ -974,7 +974,7 @@ extern "C" {
parameter_set_sizes: *const usize,
nal_unit_header_length: i32,
extensions: Option<&cf::DictionaryOf<FormatDescExtKey, cf::Type>>,
format_description: &mut Option<arc::R<FormatDesc>>,
format_description: *mut Option<arc::R<FormatDesc>>,
) -> os::Status;

fn CMVideoFormatDescriptionGetH264ParameterSetAtIndex(
Expand Down
12 changes: 6 additions & 6 deletions cidre/src/cm/format_description_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,15 +329,15 @@ extern "C" {
video_format_description: &cm::VideoFormatDesc,
string_encoding: cf::StringEncoding,
flavor: Option<&ImageDescFlavor>,
block_buffer_out: &mut Option<arc::R<cm::BlockBuf>>,
block_buffer_out: *mut Option<arc::R<cm::BlockBuf>>,
) -> os::Status;

fn CMVideoFormatDescriptionCreateFromBigEndianImageDescriptionBlockBuffer(
allocator: Option<&cf::Allocator>,
image_description_block_buffer: &cm::BlockBuf,
string_encoding: cf::StringEncoding,
flavor: Option<&cm::ImageDescFlavor>,
format_description_out: &mut Option<arc::R<cm::VideoFormatDesc>>,
format_description_out: *mut Option<arc::R<cm::VideoFormatDesc>>,
) -> os::Status;

fn CMVideoFormatDescriptionCreateFromBigEndianImageDescriptionData(
Expand All @@ -346,7 +346,7 @@ extern "C" {
size: usize,
string_encoding: cf::StringEncoding,
flavor: Option<&cm::ImageDescFlavor>,
format_description_out: &mut Option<arc::R<cm::VideoFormatDesc>>,
format_description_out: *mut Option<arc::R<cm::VideoFormatDesc>>,
) -> os::Status;

fn CMSwapBigEndianImageDescriptionToHost(
Expand All @@ -373,21 +373,21 @@ extern "C" {
allocator: Option<&cf::Allocator>,
audio_format_description: &cm::AudioFormatDesc,
flavor: Option<&SoundDescFlavor>,
block_buffer_out: &mut Option<arc::R<cm::BlockBuf>>,
block_buffer_out: *mut Option<arc::R<cm::BlockBuf>>,
) -> os::Status;

fn CMAudioFormatDescriptionCreateFromBigEndianSoundDescriptionData(
allocator: Option<&cf::Allocator>,
sound_description_data: *const u8,
size: usize,
flavor: Option<&SoundDescFlavor>,
format_description_out: &mut Option<arc::R<cm::AudioFormatDesc>>,
format_description_out: *mut Option<arc::R<cm::AudioFormatDesc>>,
) -> os::Status;

fn CMAudioFormatDescriptionCreateFromBigEndianSoundDescriptionBlockBuffer(
allocator: Option<&cf::Allocator>,
block_buffer: &cm::BlockBuf,
flavor: Option<&SoundDescFlavor>,
format_description_out: &mut Option<arc::R<cm::AudioFormatDesc>>,
format_description_out: *mut Option<arc::R<cm::AudioFormatDesc>>,
) -> os::Status;
}
8 changes: 4 additions & 4 deletions cidre/src/cm/sample_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl SampleBuf {
sample_timing_array: *const SampleTimingInfo,
num_sample_size_entries: cm::ItemCount,
sample_size_array: *const usize,
sample_buffer_out: &mut Option<arc::R<SampleBuf>>,
sample_buffer_out: *mut Option<arc::R<SampleBuf>>,
) -> os::Status {
CMSampleBufferCreate(
allocator,
Expand Down Expand Up @@ -561,7 +561,7 @@ extern "C" {
sample_timing_array: *const SampleTimingInfo,
num_sample_size_entries: cm::ItemCount,
sample_size_array: *const usize,
sample_buffer_out: &mut Option<arc::R<SampleBuf>>,
sample_buffer_out: *mut Option<arc::R<SampleBuf>>,
) -> crate::os::Status;

#[cfg(feature = "cv")]
Expand All @@ -573,7 +573,7 @@ extern "C" {
make_data_ready_refcon: *const c_void,
format_description: &cm::VideoFormatDesc,
sample_timing: &SampleTimingInfo,
sample_buffer_out: &mut Option<arc::R<SampleBuf>>,
sample_buffer_out: *mut Option<arc::R<SampleBuf>>,
) -> crate::os::Status;

fn CMSampleBufferDataIsReady(sbuf: &SampleBuf) -> bool;
Expand Down Expand Up @@ -632,7 +632,7 @@ extern "C" {
block_buffer_structure_allocator: Option<&cf::Allocator>,
block_buffer_allocator: Option<&cf::Allocator>,
flags: Flags,
block_buffer_out: &mut Option<arc::R<cm::BlockBuf>>,
block_buffer_out: *mut Option<arc::R<cm::BlockBuf>>,
) -> os::Status;

fn CMSampleBufferGetNumSamples(sbuf: &SampleBuf) -> cf::Index;
Expand Down
2 changes: 1 addition & 1 deletion cidre/src/cm/simple_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extern "C" {
fn CMSimpleQueueCreate(
allocator: Option<&cf::Allocator>,
capacity: i32,
queue_out: &mut Option<arc::R<SimpleQueue>>,
queue_out: *mut Option<arc::R<SimpleQueue>>,
) -> os::Status;

fn CMSimpleQueueGetCount(queue: &SimpleQueue) -> i32;
Expand Down
4 changes: 2 additions & 2 deletions cidre/src/cm/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl Clock {
#[inline]
pub unsafe fn audio_clock_create_in(
allocator: Option<&cf::Allocator>,
clock_out: &mut Option<arc::R<Clock>>,
clock_out: *mut Option<arc::R<Clock>>,
) -> os::Status {
CMAudioClockCreate(allocator, clock_out)
}
Expand Down Expand Up @@ -68,7 +68,7 @@ extern "C" {
fn CMClockGetHostTimeClock() -> &'static Clock;
fn CMAudioClockCreate(
allocator: Option<&cf::Allocator>,
clock_out: &mut Option<arc::R<Clock>>,
clock_out: *mut Option<arc::R<Clock>>,
) -> os::Status;

fn CMClockGetTime(clock: &Clock) -> cm::Time;
Expand Down
Loading

0 comments on commit 52d1973

Please sign in to comment.