Skip to content

Commit

Permalink
core: Add clear function to (Raw)SampleBuffer.
Browse files Browse the repository at this point in the history
Addresses #126.
  • Loading branch information
pdeljanov committed May 29, 2022
1 parent 2a73af4 commit 10e8a2d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions symphonia-core/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,11 @@ impl<S: Sample> SampleBuffer<S> {
self.buf.len()
}

/// Clears all written samples.
pub fn clear(&mut self) {
self.n_written = 0;
}

/// Copies all audio data from the source `AudioBufferRef` in planar channel order into the
/// `SampleBuffer`. The two buffers must be equivalent.
pub fn copy_planar_ref(&mut self, src: AudioBufferRef)
Expand Down Expand Up @@ -1005,6 +1010,11 @@ impl<S: Sample + RawSample> RawSampleBuffer<S> {
self.buf.len()
}

/// Clears all written samples.
pub fn clear(&mut self) {
self.n_written = 0;
}

/// Gets an immutable slice to the bytes of the sample's written in the `RawSampleBuffer`.
pub fn as_bytes(&self) -> &[u8] {
// Get a slice to the written raw samples in the buffer, and convert from &[RawType] to
Expand Down

0 comments on commit 10e8a2d

Please sign in to comment.