From 179c0125377dab2b08ebb775233ba529c1de9830 Mon Sep 17 00:00:00 2001 From: Yury Date: Fri, 29 Nov 2024 19:43:20 +0300 Subject: [PATCH] tune av api --- cidre/benches/interleave.rs | 4 ++-- cidre/src/av/audio/buffer.rs | 18 +++++++++--------- cidre/src/av/audio/engine.rs | 4 ++-- cidre/src/av/audio/player_node.rs | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/cidre/benches/interleave.rs b/cidre/benches/interleave.rs index e4ba6f41..172b0e77 100644 --- a/cidre/benches/interleave.rs +++ b/cidre/benches/interleave.rs @@ -54,10 +54,10 @@ pub fn criterion_benchmark(c: &mut Criterion) { let mut pcm_b = av::AudioPcmBuf::with_format(&to_fmt, N as u32).unwrap(); pcm_a - .set_frame_length(N as u32) + .set_frame_len(N as u32) .expect("Failed to set frame length on buf a"); pcm_b - .set_frame_length(N as u32) + .set_frame_len(N as u32) .expect("Failed to set frame length on buf b"); let converter = av::AudioConverter::with_formats(&from_fmt, &to_fmt).unwrap(); diff --git a/cidre/src/av/audio/buffer.rs b/cidre/src/av/audio/buffer.rs index 357d2790..319a06ca 100644 --- a/cidre/src/av/audio/buffer.rs +++ b/cidre/src/av/audio/buffer.rs @@ -75,13 +75,13 @@ impl PcmBuf { /// and vice versa. Note that in the case of deinterleaved formats, mDataByteSize will refers /// the size of one channel's worth of audio samples. #[objc::msg_send(frameLength)] - pub fn frame_length(&self) -> FrameCount; + pub fn frame_len(&self) -> FrameCount; #[objc::msg_send(setFrameLength:)] - pub fn set_frame_length_throws<'ear>(&mut self, value: FrameCount); + pub fn set_frame_len_throws<'ear>(&mut self, value: FrameCount); - pub fn set_frame_length<'ear>(&mut self, value: FrameCount) -> ns::ExResult<'ear> { - ns::try_catch(|| self.set_frame_length_throws(value)) + pub fn set_frame_len<'ear>(&mut self, value: FrameCount) -> ns::ExResult<'ear> { + ns::try_catch(|| self.set_frame_len_throws(value)) } /// The buffer's number of interleaved channels. @@ -145,7 +145,7 @@ fn pcm_slice_at(buf: &PcmBuf, ptr: *const *const T, index: usize) -> Option<& return None; } - let len = buf.frame_length() as usize; + let len = buf.frame_len() as usize; let stride = buf.stride() as usize; if stride > 1 { // if stride is not 1 it is interleaved, single buf @@ -165,7 +165,7 @@ fn pcm_slice_at_mut(buf: &mut PcmBuf, ptr: *const *mut T, index: usize) -> Op return None; } - let len = buf.frame_length() as usize; + let len = buf.frame_len() as usize; let stride = buf.stride() as usize; if stride > 1 { // interleaved, single buf @@ -286,7 +286,7 @@ mod tests { .unwrap(); let cap = 1024; let mut buf = av::AudioPcmBuf::with_format(&format, cap).unwrap(); - buf.set_frame_length(cap).unwrap(); + buf.set_frame_len(cap).unwrap(); let data = buf.data_f32(); let (n, cap) = if format.is_interleaved() { (1, channel_count * cap) @@ -308,8 +308,8 @@ mod tests { .unwrap(); let cap = 1024; let mut buf = av::AudioPcmBuf::with_format(&format, cap).unwrap(); - let _err = buf.set_frame_length(1025).expect_err("Should fail"); - buf.set_frame_length(1024) + let _err = buf.set_frame_len(1025).expect_err("Should fail"); + buf.set_frame_len(1024) .expect("Failed to set max cap frame len"); } } diff --git a/cidre/src/av/audio/engine.rs b/cidre/src/av/audio/engine.rs index 9fc96db1..32d42c81 100644 --- a/cidre/src/av/audio/engine.rs +++ b/cidre/src/av/audio/engine.rs @@ -347,7 +347,7 @@ mod tests { let mut pcm_buf = av::audio::PcmBuf::with_format(&format, 1024).unwrap(); - pcm_buf.set_frame_length(1024).unwrap(); + pcm_buf.set_frame_len(1024).unwrap(); engine.start().expect("Failed to start engine"); assert!(engine.is_running()); @@ -369,7 +369,7 @@ mod tests { let status = engine.render_offline(1024, &mut pcm_buf).unwrap(); assert_eq!(status, av::audio::EngineManualRenderingStatus::Success); - assert_eq!(pcm_buf.frame_length(), 1024); + assert_eq!(pcm_buf.frame_len(), 1024); assert_eq!(engine.manual_rendering_sample_time(), 1024); } } diff --git a/cidre/src/av/audio/player_node.rs b/cidre/src/av/audio/player_node.rs index 64bc0e3d..be8fbc9e 100644 --- a/cidre/src/av/audio/player_node.rs +++ b/cidre/src/av/audio/player_node.rs @@ -37,7 +37,7 @@ define_obj_type!( ); impl PlayerNode { - /// Schedule playing samples from an [`av::AudioPcmBuf`]. + /// Schedule playing samples from an [`av::AudioPCMBuf`]. /// /// Schedules the buffer to be played following any previously scheduled commands. #[objc::msg_send(scheduleBuffer:completionHandler:)]