-
Notifications
You must be signed in to change notification settings - Fork 28
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
Store sample rate of block #35
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -406,15 +406,18 @@ pub struct Block { | |||
block_size: u32, | ||||
/// The number of channels in the block. | ||||
channels: u32, | ||||
/// The sample rate of this block. | ||||
sample_rate: u32, | ||||
/// The decoded samples, the channels stored consecutively. | ||||
buffer: Vec<i32>, | ||||
} | ||||
|
||||
impl Block { | ||||
fn new(time: u64, bs: u32, buffer: Vec<i32>) -> Block { | ||||
fn new(time: u64, bs: u32, sr: u32, buffer: Vec<i32>) -> Block { | ||||
Block { | ||||
first_sample_number: time, | ||||
block_size: bs, | ||||
sample_rate: sr, | ||||
channels: buffer.len() as u32 / bs, | ||||
buffer: buffer, | ||||
} | ||||
|
@@ -426,6 +429,7 @@ impl Block { | |||
first_sample_number: 0, | ||||
block_size: 0, | ||||
channels: 0, | ||||
sample_rate: 0, | ||||
buffer: Vec::with_capacity(0), | ||||
} | ||||
} | ||||
|
@@ -504,6 +508,12 @@ impl Block { | |||
return self.buffer; | ||||
} | ||||
|
||||
/// Returns the sample rate of this block. | ||||
#[inline(always)] | ||||
pub fn sample_rate(&self) -> u32 { | ||||
self.sample_rate | ||||
} | ||||
|
||||
/// Returns an iterator that produces left and right channel samples. | ||||
/// | ||||
/// This iterator can be more efficient than requesting a sample directly, | ||||
|
@@ -773,7 +783,7 @@ impl<R: ReadBytes> FrameReader<R> { | |||
BlockTime::SampleNumber(snr) => snr, | ||||
}; | ||||
|
||||
let block = Block::new(time, header.block_size as u32, buffer); | ||||
let block = Block::new(time, header.block_size as u32, header.sample_rate.unwrap_or_default(), buffer); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Line 193 in 20fd6a7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't seem like streaminfo is available from this function's scope? |
||||
|
||||
Ok(Some(block)) | ||||
} | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.