Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

flac: Allow different sample rate between frames #287

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions symphonia-bundle-flac/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ impl FlacDecoder {

let header = read_frame_header(&mut reader, sync)?;

// Update the sample rate for this frame.
if let Some(sample_rate) = header.sample_rate {
self.buf.spec_mut().rate = sample_rate;
}

// Use the bits per sample and sample rate as stated in the frame header, falling back to
// the stream information if provided. If neither are available, return an error.
let bits_per_sample = if let Some(bps) = header.bits_per_sample {
Expand Down
7 changes: 0 additions & 7 deletions symphonia-bundle-flac/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,13 +527,6 @@ fn strict_frame_header_check(
header: &FrameHeader,
last_header: Option<&FrameHeader>,
) -> bool {
// Sample rate is fixed for the stream.
if let Some(sample_rate) = header.sample_rate {
if sample_rate != stream_info.sample_rate {
return false;
}
}

// Bits per sample is fixed for the stream.
if let Some(bps) = header.bits_per_sample {
if bps != stream_info.bits_per_sample {
Expand Down
5 changes: 5 additions & 0 deletions symphonia-core/src/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ impl<S: Sample> AudioBuffer<S> {
&self.spec
}

/// Gets a mutable signal specification for the buffer.
pub fn spec_mut(&mut self) -> &mut SignalSpec {
&mut self.spec
}

/// Gets the total capacity of the buffer. The capacity is the maximum number of audio frames
/// a buffer can store.
pub fn capacity(&self) -> usize {
Expand Down