Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub use mp3lame_sys as ffi;

use alloc::vec::Vec;
use core::mem::{self, MaybeUninit};
use core::num::NonZeroU32;
use core::ptr::{self, NonNull};
use core::{cmp, fmt};

Expand Down Expand Up @@ -384,7 +385,34 @@ impl Builder {
}

#[inline]
///Sets sample rate.
///Sets output sample rate.
Comment thread
ginnyTheCat marked this conversation as resolved.
///
///The default `None` allows LAME to pick the best value.
///
///Returns whether the requested value is supported.
Comment thread
ginnyTheCat marked this conversation as resolved.
Outdated
pub fn set_output_sample_rate(&mut self, rate: Option<NonZeroU32>) -> Result<(), BuildError> {
let rate = rate.map_or(0, NonZeroU32::get).try_into().unwrap_or(libc::c_int::MAX);

let res = unsafe {
ffi::lame_set_out_samplerate(self.ptr(), rate)
};

BuildError::from_c_int(res)
}

#[inline]
///Sets output sample rate using the builder pattern.
///
///The default `None` allows LAME to pick the best value.
///
///Returns whether the requested value is supported.
pub fn with_output_sample_rate(mut self, rate: Option<NonZeroU32>) -> Result<Self, BuildError> {
self.set_output_sample_rate(rate)?;
Ok(self)
}

#[inline]
///Sets input sample rate.
///
///Defaults to 44_100.
///
Expand All @@ -398,7 +426,7 @@ impl Builder {
}

#[inline]
///Sets sample rate using the builder pattern.
///Sets input sample rate using the builder pattern.
///
///Defaults to 44_100.
///
Expand Down
Loading