-
Notifications
You must be signed in to change notification settings - Fork 64
Parse codec specific descriptor to retrieve audio sample rate #39
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
Conversation
This is for #30. |
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.
Some style comments. Otherwise looks fine.
(*info).sample_rate = rate; | ||
}, | ||
_ => {}, | ||
} |
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.
match
is good to show handling of all branches, or when yielding a value for assignment. For something like this if let
is shorter, since the _ => {}
clause is equivalent to an omitted empty else
clause.
// An ESDS value overrides the track sample rate.
if let Some(rate) = v.audio_sample_rate {
(*info)sample_rate = rate;
}
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.
Thanks for suggestion. Fixed.
return Err(Error::Unsupported("fail to parse ES descriptor")); | ||
} | ||
|
||
let esds_extend = try!(esds.read_u8()); | ||
let mut esds_end: u64 = 0; |
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.
Rather than turning off the warning with #[allow(unused_assignments)]
, you can avoid it with an if
expression like a ternary in C. I'm not sure this is actually easier to read, but avoiding the mut
is more natural in rust, I think.
let esds_extend = try!(esds.read_u8());
// extension tag starts from 0x80.
let esds_end = if esds_extend >= 0x80 {
// skip remaining extension.
try!(skip(esds, 2));
esds.position() + try!(esds.read_u8()) as u64
} else {
esds.position() + esds_extend as u64
};
try!(skip(esds, 2));
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.
Fixed.
if dcds != DECODER_CONFIG_TAG { | ||
return Err(Error::Unsupported("fail to parse decoder config descriptor")); | ||
if esds_end > esds.position() { | ||
next_tag = try!(esds.read_u8()); |
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.
Since these uses of next_tag
start with a fresh assignment within a block, please drop the mut
keyword from the outer declaration and use a fresh let
here and below. Rust will not warn about the shadowing, and using a local in each block reduces the amount of code which must be understood at once.
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.
Fixed.
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.
Thanks!
No description provided.