pub struct SyncDecoder { /* private fields */ }Expand description
A decoder with synchronization. This will use a spinlock to synchronize access to the decoder on each function call. The decoder may have multiple readers or one writer. Cloning this decoder will simply return another reference to the same decoder.
Implementations§
Source§impl SyncDecoder
impl SyncDecoder
Sourcepub fn from_file<P: AsRef<Path>>(
file: P,
config: Option<&DecoderConfig>,
) -> Result<Self, Error>
pub fn from_file<P: AsRef<Path>>( file: P, config: Option<&DecoderConfig>, ) -> Result<Self, Error>
Creates a SyncDecoder from a file. This will fail with an InvalidFile error if the path is
not valid utf-8.
pub fn from_memory<M: Into<Vec<u8>>>( data: M, config: Option<&DecoderConfig>, ) -> Result<Self, Error>
pub fn from_read<T: 'static + SeekRead>( reader: T, config: Option<&DecoderConfig>, ) -> Result<Self, Error>
pub fn from_boxed_read( reader: Box<dyn SeekRead>, config: Option<&DecoderConfig>, ) -> Result<Self, Error>
Sourcepub fn read_pcm_frames(&self, output: &mut FramesMut<'_>) -> u64
pub fn read_pcm_frames(&self, output: &mut FramesMut<'_>) -> u64
This will block until the lock for the inner decoder is acquired before calling
read_pcm_frames.
Sourcepub fn try_read_pcm_frames(&self, output: &mut FramesMut<'_>) -> u64
pub fn try_read_pcm_frames(&self, output: &mut FramesMut<'_>) -> u64
This will immediately return with 0 if the inner decoder is currently locked, if it is not this will acquire the lock and return the number of frames written.
pub fn seek_to_pcm_frame(&self, frame_index: u64) -> Result<(), Error>
pub fn length_in_pcm_frames(&self) -> u64
pub fn output_format(&self) -> Format
pub fn output_channels(&self) -> u32
pub fn output_sample_rate(&self) -> u32
pub fn write(&self) -> RwLockWriteGuard<'_, RawDecoder>
pub fn read(&self) -> RwLockReadGuard<'_, RawDecoder>
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, RawDecoder>>
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, RawDecoder>>
Trait Implementations§
Source§impl Clone for SyncDecoder
impl Clone for SyncDecoder
Source§fn clone(&self) -> SyncDecoder
fn clone(&self) -> SyncDecoder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Drop for SyncDecoder
impl Drop for SyncDecoder
impl Send for SyncDecoder
impl Sync for SyncDecoder
Auto Trait Implementations§
impl Freeze for SyncDecoder
impl !RefUnwindSafe for SyncDecoder
impl Unpin for SyncDecoder
impl !UnwindSafe for SyncDecoder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more