Skip to content

Commit

Permalink
tune av api
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Nov 29, 2024
1 parent 5f7d821 commit 179c012
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cidre/benches/interleave.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
18 changes: 9 additions & 9 deletions cidre/src/av/audio/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -145,7 +145,7 @@ fn pcm_slice_at<T>(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
Expand All @@ -165,7 +165,7 @@ fn pcm_slice_at_mut<T>(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
Expand Down Expand Up @@ -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)
Expand All @@ -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");
}
}
4 changes: 2 additions & 2 deletions cidre/src/av/audio/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion cidre/src/av/audio/player_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:)]
Expand Down

0 comments on commit 179c012

Please # to comment.