Skip to content

Commit

Permalink
Follow clippy's advice
Browse files Browse the repository at this point in the history
  • Loading branch information
irh committed Jan 9, 2024
1 parent 6ba7f78 commit c6dd64a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
10 changes: 5 additions & 5 deletions symphonia-format-caf/src/chunks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ impl Chunk {
/// The first chunk read will be the AudioDescription chunk. Once it's been read, the caller
/// should pass it in to subsequent read calls.
pub fn read(
mut reader: &mut MediaSourceStream,
reader: &mut MediaSourceStream,
audio_description: &Option<AudioDescription>,
) -> Result<Option<Self>> {
let chunk_type = reader.read_quad_bytes()?;
let chunk_size = reader.read_be_i64()?;

let result = match &chunk_type {
b"desc" => Chunk::AudioDescription(AudioDescription::read(&mut reader)?),
b"data" => Chunk::AudioData(AudioData::read(&mut reader, chunk_size)?),
b"chan" => Chunk::ChannelLayout(ChannelLayout::read(&mut reader)?),
b"pakt" => Chunk::PacketTable(PacketTable::read(&mut reader, audio_description)?),
b"desc" => Chunk::AudioDescription(AudioDescription::read(reader)?),
b"data" => Chunk::AudioData(AudioData::read(reader, chunk_size)?),
b"chan" => Chunk::ChannelLayout(ChannelLayout::read(reader)?),
b"pakt" => Chunk::PacketTable(PacketTable::read(reader, audio_description)?),
b"kuki" => Chunk::MagicCookie(reader.read_boxed_slice_exact(chunk_size as usize)?),
b"free" => {
if chunk_size < 0 {
Expand Down
22 changes: 8 additions & 14 deletions symphonia-format-caf/src/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,10 @@ impl FormatReader for CafReader {
*current_packet_index += 1;
let buffer = self.reader.read_boxed_slice(packet.size as usize)?;
Ok(Packet::new_from_boxed_slice(0, packet.start_frame, packet.frames, buffer))
} else if *current_packet_index == packets.len() {
end_of_stream_error()
} else {
if *current_packet_index == packets.len() {
end_of_stream_error()
} else {
decode_error("Invalid packet index")
}
decode_error("Invalid packet index")
}
}
PacketInfo::Unknown => decode_error("Missing packet info"),
Expand Down Expand Up @@ -306,11 +304,8 @@ impl CafReader {
self.data_start_pos = data.start_pos;
self.data_len = data.data_len;
if let Some(data_len) = self.data_len {
match &self.packet_info {
PacketInfo::Uncompressed { bytes_per_frame } => {
codec_params.with_n_frames(data_len / *bytes_per_frame as u64);
}
_ => {}
if let PacketInfo::Uncompressed { bytes_per_frame } = &self.packet_info {
codec_params.with_n_frames(data_len / *bytes_per_frame as u64);
}
}
}
Expand All @@ -324,13 +319,12 @@ impl CafReader {
info!("couldn't convert the channel layout into a channel bitmap");
}
}
Some(PacketTable(table)) => match &mut self.packet_info {
PacketInfo::Compressed { ref mut packets, .. } => {
Some(PacketTable(table)) => {
if let PacketInfo::Compressed { ref mut packets, .. } = &mut self.packet_info {
codec_params.with_n_frames(table.valid_frames as u64);
*packets = table.packets;
}
_ => {}
},
}
Some(MagicCookie(data)) => {
codec_params.with_extra_data(data);
}
Expand Down

0 comments on commit c6dd64a

Please sign in to comment.